| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164 |
- /*
- * LayerSlider
- *
- * (c) 2011-2014 George Krupa, John Gera & Kreatura Media
- *
- * Plugin web: http://kreaturamedia.com/
- * licenses: http://codecanyon.net/licenses/
- */
- function lsShowNotice(lsobj,issue,ver){
- var el;
- if( typeof lsobj == 'string' ){
- el = jQuery('#'+lsobj);
- }else if( typeof lsobj == 'object' ){
- el = lsobj;
- }
- var errorTitle, errorText;
- switch(issue){
- case 'jquery':
- errorTitle = 'multiple jQuery issue';
- errorText = 'It looks like that another plugin or your theme loads an extra copy of the jQuery library causing problems for LayerSlider to show your sliders. <strong>Please navigate on your WordPress admin area to the main page of LayerSlider and enable the "Put JS includes to body" option within the Troubleshooting & Advanced Settings box.</strong>';
- break;
- case 'oldjquery':
- errorTitle = 'old jQuery issue';
- errorText = 'It looks like you are using an old version ('+ver+') of the jQuery library. LayerSlider requires at least version 1.7.0 or newer. Please update jQuery to 1.10.x or higher. Important: Please do not use the jQuery Updater plugin on WordPress and do not update to 2.x version of jQuery because it is not compatible with older browsers like IE 7 & 8. <a href="http://support.kreaturamedia.com/faq/4/layerslider-for-wordpress/#group-13&entry-60">You can read more about updating jQuery by clicking here.</a>';
- break;
- }
- el.addClass('ls-error');
- el.append('<p class="ls-exclam">!</p>');
- el.append('<p class="ls-error-title">LayerSlider: '+errorTitle+'</p>');
- el.append('<p class="ls-error-text">'+errorText+'</p>');
- }
- (function($) {
- $.fn.layerSlider = function( options ){
- // IMPROVEMENT v4.1.0 Checking jQuery version
- // IMPROVEMENT v4.1.3 Changed required version from 1.7.2 to 1.7.0
- var reqVer = '1.7.0';
- var curVer = $.fn.jquery;
- var el = $(this);
- var checkVersions = function(v1,v2){
- var v1parts = v1.split('.');
- var v2parts = v2.split('.');
- for (var i = 0; i < v1parts.length; ++i) {
- if (v2parts.length == i) {
- return false;
- }
- if(parseInt(v1parts[i]) == parseInt(v2parts[i])){
- continue;
- }else if (parseInt(v1parts[i]) > parseInt(v2parts[i])){
- return false;
- }else{
- return true;
- }
- }
- if (v1parts.length != v2parts.length) {
- return true;
- }
- return true;
- };
- if( !checkVersions('1.8.0',curVer) ){
- el.addClass('ls-norotate');
- }
- // Initializing if jQuery version is greater than 1.7.0
- if( !checkVersions(reqVer,curVer) ){
- lsShowNotice( el, 'oldjquery', curVer );
- }else{
- if( (typeof(options)).match('object|undefined') ){
- return this.each(function(i){
- new layerSlider(this, options);
- });
- }else{
- if( options === 'data' ){
- var lsData = $(this).data('LayerSlider').g;
- if( lsData ){
- return lsData;
- }
- // NEW FEATURES v5.2.0 option to get userInitData & defaultInitData
- }else if( options === 'userInitData' ){
- var lsInitData = $(this).data('LayerSlider').o;
- if( lsInitData ){
- return lsInitData;
- }
- }else if( options === 'defaultInitData' ){
- var lsInitData = $(this).data('LayerSlider').defaults;
- if( lsInitData ){
- return lsInitData;
- }
- }else{
- return this.each(function(i){
- // Control functions: prev, next, start, stop & change
- var lsData = $(this).data('LayerSlider');
- if( lsData ){
- if( !lsData.g.isAnimating && !lsData.g.isLoading ){
- if( typeof options == 'number' ){
- if( options > 0 && options < lsData.g.layersNum + 1 && options != lsData.g.curLayerIndex ){
- lsData.change(options);
- }
- }else{
- switch(options){
- case 'prev':
- lsData.o.cbPrev(lsData.g);
- lsData.prev('clicked');
- break;
- case 'next':
- lsData.o.cbNext(lsData.g);
- lsData.next('clicked');
- break;
- case 'start':
- if( !lsData.g.autoSlideshow ){
- lsData.o.cbStart(lsData.g);
- lsData.g.originalAutoSlideshow = true;
- lsData.start();
- }
- break;
- }
- }
- }
- // if( options === 'debug' ){
- // lsData.d.show();
- // }
- if( options === 'redraw' ){
- lsData.resize();
- }
- if( ( lsData.g.autoSlideshow || ( !lsData.g.autoSlideshow && lsData.g.originalAutoSlideshow ) ) && options == 'stop' ){
- lsData.o.cbStop(lsData.g);
- lsData.g.originalAutoSlideshow = false;
- lsData.g.curLayer.find('iframe[src*="youtube.com"], iframe[src*="youtu.be"], iframe[src*="player.vimeo"]').each(function(){
- // Clearing videoTimeouts
- clearTimeout( $(this).data( 'videoTimer') );
- });
- lsData.stop();
- }
- if( options == 'forceStop'){
- lsData.forcestop();
- }
- }
- });
- }
- }
- }
- };
- // LayerSlider methods
- var layerSlider = function(el, options) {
- var ls = this;
- ls.$el = $(el).addClass('ls-container');
- ls.$el.data('LayerSlider', ls);
- ls.load = function(){
- // Setting options (user settings) and global (not modificable) parameters
- ls.defaults = layerSlider.options;
- ls.o = $.extend({},ls.defaults, options);
- ls.g = $.extend({},layerSlider.global);
- ls.lt = $.extend({},layerSlider.layerTransitions );
- ls.st = $.extend({},layerSlider.slideTransitions );
- ls.g.enableCSS3 = $(el).hasClass('ls-norotate') ? false : true;
- // NEW FEATURE v5.2.0 saving original HTML Markup
- ls.g.originalMarkup = $(el).html();
- if( ls.g.ie78 ){
- ls.o.lazyLoad = false;
- }
- // WP parameters
- if( ls.o.autoPauseSlideshow === 'enabled' ){
- ls.o.autoPauseSlideshow = true;
- }
- if( ls.o.autoPauseSlideshow === 'disabled' ){
- ls.o.autoPauseSlideshow = false;
- }
- // If layerslider.transitions.js is loaded...
- if( typeof layerSliderTransitions !== 'undefined' ){
- ls.t = $.extend({},layerSliderTransitions);
- }
- // If custom transitions are loaded...
- if( typeof layerSliderCustomTransitions !== 'undefined' ){
- ls.ct = $.extend({},layerSliderCustomTransitions);
- }
- // NEW IMPROVEMENT v3.6 forbid to call the init code more than once on the same element
- if( !ls.g.initialized ){
- ls.g.initialized = true;
- // Added debug mode v3.5
- // ls.debug();
- if( $('html').find('meta[content*="WordPress"]').length ){
- ls.g.wpVersion = $('html').find('meta[content*="WordPress"]').attr('content').split('WordPress')[1];
- }
- if( $('html').find('script[src*="layerslider"]').length ){
- if( $('html').find('script[src*="layerslider"]').attr('src').indexOf('?') != -1 ){
- ls.g.lswpVersion = $('html').find('script[src*="layerslider"]').attr('src').split('?')[1].split('=')[1];
- }
- }
- // Debug mode controls
- // ls.d.aT('LayerSlider controls');
- // ls.d.aU('<a href="#">prev</a> | <a href="#">next</a> | <a href="#">start</a> | <a href="#">stop</a> | <a href="#">force stop</a>');
- // ls.d.history.find('a').each(function(){
- // $(this).click(function(e){
- // e.preventDefault();
- // $(el).layerSlider($(this).text());
- // });
- // });
- // ls.d.aT('LayerSlider version information');
- // ls.d.aU('JS version: <strong>' + ls.g.version + '</strong>');
- // if(ls.g.lswpVersion){
- // ls.d.aL('WP version: <strong>' + ls.g.lswpVersion + '</strong>');
- // }
- // if(ls.g.wpVersion){
- // ls.d.aL('WordPress version: <strong>' + ls.g.wpVersion + '</strong>');
- // }
- // ls.d.aL('jQuery version: <strong>' + $().jquery + '</strong>');
- // if( $(el).attr('id') ){
- // ls.d.aT('LayerSlider container');
- // ls.d.aU('#'+$(el).attr('id'));
- // }
- // NEW LOAD METHOD v3.5
- // FIXED v4.0 If the selected skin is already loaded, calling the ls.init() function immediately
- if( !ls.o.skin || ls.o.skin == '' || !ls.o.skinsPath || ls.o.skinsPath == '' ){
- // ls.d.aT('Loading without skin. Possibilities: mistyped skin and / or skinsPath.');
- ls.init();
- }else{
- // ls.d.aT('Trying to load with skin: '+ls.o.skin, true);
- // Applying skin
- $(el).addClass('ls-'+ls.o.skin);
- var skinStyle = ls.o.skinsPath+ls.o.skin+'/skin.css';
- cssContainer = $('head');
- if( !$('head').length ){
- cssContainer = $('body');
- }
- if( $('link[href="'+skinStyle+'"]').length ){
- // ls.d.aU('Skin "'+ls.o.skin+'" is already loaded.');
- curSkin = $('link[href="'+skinStyle+'"]');
- if( !ls.g.loaded ){
- ls.g.loaded = true;
- // IMPROVEMENT v4.5.0 Added delay because of caching bugs
- ls.g.t1 = setTimeout(function(){
- ls.init();
- },150);
- }
- }else{
- if (document.createStyleSheet){
- document.createStyleSheet(skinStyle);
- var curSkin = $('link[href="'+skinStyle+'"]');
- }else{
- var curSkin = $('<link rel="stylesheet" href="'+skinStyle+'" type="text/css" />').appendTo( cssContainer );
- }
- }
- // curSkin.load(); function for most of the browsers.
- curSkin.load(function(){
- if( !ls.g.loaded ){
- // ls.d.aU('curSkin.load(); fired');
- ls.g.loaded = true;
- // IMPROVEMENT v4.5.0 Added delay because of caching bugs
- ls.g.t2 = setTimeout(function(){
- ls.init();
- },150);
- }
- });
- // $(window).load(); function for older webkit ( < v536 ).
- $(window).load(function(){
- if( !ls.g.loaded ){
- // ls.d.aU('$(window).load(); fired');
- ls.g.loaded = true;
- // IMPROVEMENT v4.5.0 Added delay because of caching bugs
- ls.g.t3 = setTimeout(function(){
- ls.init();
- },150);
- }
- });
- // Fallback: if $(window).load(); not fired in 2 secs after $(document).ready(),
- // curSkin.load(); not fired at all or the name of the skin and / or the skinsPath
- // mistyped, we must call the init function manually.
- ls.g.t4 = setTimeout( function(){
- if( !ls.g.loaded ){
- // ls.d.aT('Fallback mode: Neither curSkin.load(); or $(window).load(); were fired');
- ls.g.loaded = true;
- ls.init();
- }
- }, 1000);
- }
- }
- };
- ls.init = function(){
- // NEW FEATURE v5.5.0 Appending the slider element into the element specified in appendTo
- $(el).prependTo( $( ls.o.appendTo ) );
- // IMPROVEMENT v4.0.1 Trying to add special ID to <body> or <html> (required to overwrite WordPresss global styles)
- if( !$('html').attr('id') ){
- $('html').attr('id','ls-global');
- }else if( !$('body').attr('id') ){
- $('body').attr('id','ls-global');
- }
- // NEW FEATURES v5.5.0 Hiding the slider on mobile devices, smaller resolutions
- // or changing it to a static but responsive image
- if( ls.g.isMobile() === true && ls.o.hideOnMobile === true ){
- $(el).addClass('ls-forcehide');
- $(el).closest('.ls-wp-fullwidth-container').addClass('ls-forcehide');
- }
- var showHide = function(){
- if( ls.o.hideOnMobile === true && ls.g.isMobile() === true ){
- $(el).addClass('ls-forcehide');
- $(el).closest('.ls-wp-fullwidth-container').addClass('ls-forcehide');
- ls.o.autoStart = false;
- }else{
- if( $(window).width() < ls.o.hideUnder || $(window).width() > ls.o.hideOver ){
- $(el).addClass('ls-forcehide');
- $(el).closest('.ls-wp-fullwidth-container').addClass('ls-forcehide');
- }else{
- $(el).removeClass('ls-forcehide');
- $(el).closest('.ls-wp-fullwidth-container').removeClass('ls-forcehide');
- }
- }
- };
- $(window).resize( function(){
- showHide();
- });
- showHide();
- // NEW FEATURE v1.7 making the slider responsive
- ls.g.sliderWidth = function(){
- return $(el).width();
- }
- ls.g.sliderHeight = function(){
- return $(el).height();
- }
- // Compatibility mode v5.0.0
- // .ls-layer -> .ls-slide
- // .ls-s -> .ls-l
- $(el).find('.ls-layer').removeClass('ls-layer').addClass('ls-slide');
- $(el).find('.ls-slide > *[class*="ls-s"]').each(function(){
- var oldDistanceNum = $(this).attr('class').split('ls-s')[1].split(' ')[0];
- $(this).removeClass('ls-s'+oldDistanceNum).addClass('ls-l'+oldDistanceNum);
- });
- if( ls.o.firstLayer ){
- ls.o.firstSlide = ls.o.firstLayer;
- }
- if( ls.o.animateFirstLayer === false ){
- ls.o.animateFirstSlide = false;
- }
- // REPLACED FEATURE v2.0 If there is only ONE layer, instead of duplicating it, turning off slideshow and loops, hiding all controls, etc.
- if( $(el).find('.ls-slide').length == 1 ){
- ls.o.autoStart = false;
- ls.o.navPrevNext = false;
- ls.o.navStartStop = false;
- ls.o.navButtons = false;
- ls.o.loops = 0;
- ls.o.forceLoopNum = false;
- ls.o.autoPauseSlideshow = true;
- ls.o.firstSlide = 1;
- ls.o.thumbnailNavigation = 'disabled';
- }
- // IMPROVEMENT v5.2.0 the original width of a full width slider should be always 100% even if the user forgot to set that value
- // BUGFIX v5.3.0 An additional check required (with the original improvement full-width sliders with "normal" responsiveness couldn't be created)
- if( $(el).parent().hasClass('ls-wp-fullwidth-helper') && ls.o.responsiveUnder !== 0 ){
- $(el)[0].style.width = '100%';
- }
- // NEW FEATURE v3.0 added "normal" responsive mode with image and font resizing
- // NEW FEATURE v3.5 responsiveUnder
- if( ls.o.width ){
- ls.g.sliderOriginalWidthRU = ls.g.sliderOriginalWidth = '' + ls.o.width;
- }else{
- ls.g.sliderOriginalWidthRU = ls.g.sliderOriginalWidth = $(el)[0].style.width;
- }
- if( ls.o.height ){
- ls.g.sliderOriginalHeight = '' + ls.o.height;
- }else{
- ls.g.sliderOriginalHeight = $(el)[0].style.height;
- }
- if( ls.g.sliderOriginalWidth.indexOf('%') == -1 && ls.g.sliderOriginalWidth.indexOf('px') == -1 ){
- ls.g.sliderOriginalWidth += 'px';
- }
- if( ls.g.sliderOriginalHeight.indexOf('%') == -1 && ls.g.sliderOriginalHeight.indexOf('px') == -1 ){
- ls.g.sliderOriginalHeight += 'px';
- }
- if( ls.o.responsive && ls.g.sliderOriginalWidth.indexOf('px') != -1 && ls.g.sliderOriginalHeight.indexOf('px') != -1 ){
- ls.g.responsiveMode = true;
- }else{
- ls.g.responsiveMode = false;
- }
- // NEW FEATURE v5.5.0 We must overwrite some user settings if fullScreen mode is enabled
- if( ls.o.fullScreen === true ){
- ls.o.responsiveUnder = 0;
- ls.g.responsiveMode = true;
- if( ls.g.sliderOriginalWidth.indexOf('%') != -1 ){
- ls.g.sliderOriginalWidth = parseInt( ls.g.sliderOriginalWidth) + 'px';
- }
- if( ls.g.sliderOriginalHeight.indexOf('%') != -1 ){
- ls.g.sliderOriginalHeight = parseInt( ls.g.sliderOriginalHeight) + 'px';
- }
- }
- // IMPROVEMENT v3.0 preventing WordPress to wrap your sublayers in <code> or <p> elements
- $(el).find('*[class*="ls-l"], *[class*="ls-bg"]').each(function(){
- if( !$(this).parent().hasClass('ls-slide') ){
- $(this).insertBefore( $(this).parent() );
- }
- });
- $(el).find('.ls-slide').each(function(){
- $(this).children(':not([class*="ls-"])').each(function(){
- $(this).remove();
- });
- var hd = $('<div>').addClass('ls-gpuhack');
- if( $(this).find('.ls-bg').length ){
- hd.insertAfter( $(this).find('.ls-bg').eq('0') );
- }else{
- hd.prependTo( $(this) );
- }
- });
- $(el).find('.ls-slide, *[class*="ls-l"]').each(function(){
- if( $(this).data('ls') || $(this).attr('rel') || $(this).attr('style') ){
- if( $(this).data('ls') ){
- var params = $(this).data('ls').toLowerCase().split(';');
- }else if( $(this).attr('rel') && $(this).attr('rel').indexOf(':') != -1 && $(this).attr('rel').indexOf(';') != -1 ){
- var params = $(this).attr('rel').toLowerCase().split(';');
- }else{
- var params = $(this).attr('style').toLowerCase().split(';');
- }
- for(x=0;x<params.length;x++){
- param = params[x].split(':');
- if( param[0].indexOf('easing') != -1 ){
- param[1] = ls.ieEasing( param[1] );
- }
- var p2 = '';
- if( param[2] ){
- p2 = ':'+$.trim(param[2]);
- }
- if( param[0] != ' ' && param[0] != '' ){
- $(this).data( $.trim(param[0]), $.trim(param[1]) + p2 );
- }
- }
- }
- // NEW FEATURE v5.2.0 Starts the slider only if it is in the viewport
- if( ls.o.startInViewport === true && ls.o.autoStart === true ){
- ls.o.autoStart = false;
- ls.g.originalAutoStart = true;
- }
- // NEW FEATURE v1.7 and v3.0 making the slider responsive - we have to use style.left instead of jQuery's .css('left') function!
- var sl = $(this);
- sl.data( 'originalLeft', sl[0].style.left );
- sl.data( 'originalTop', sl[0].style.top );
- if( $(this).is('a') && $(this).children().length > 0 ){
- sl = $(this).children();
- }
- var _w = sl.width();
- var _h = sl.height();
- if( sl[0].style.width && sl[0].style.width.indexOf('%') != -1 ){
- _w = sl[0].style.width;
- }
- if( sl[0].style.height && sl[0].style.height.indexOf('%') != -1 ){
- _h = sl[0].style.height;
- }
- sl.data( 'originalWidth', _w );
- sl.data( 'originalHeight', _h );
- sl.data( 'originalPaddingLeft', sl.css('padding-left') );
- sl.data( 'originalPaddingRight', sl.css('padding-right') );
- sl.data( 'originalPaddingTop', sl.css('padding-top') );
- sl.data( 'originalPaddingBottom', sl.css('padding-bottom') );
- // iOS fade bug when GPU acceleration is enabled #1
- var _o = typeof parseFloat( sl.css('opacity') ) == 'number' ? Math.round( parseFloat( sl.css('opacity') ) * 100 ) / 100 : 1;
- $(this).data( 'originalOpacity', _o );
- if( sl.css('border-left-width').indexOf('px') == -1 ){
- sl.data( 'originalBorderLeft', sl[0].style.borderLeftWidth );
- }else{
- sl.data( 'originalBorderLeft', sl.css('border-left-width') );
- }
- if( sl.css('border-right-width').indexOf('px') == -1 ){
- sl.data( 'originalBorderRight', sl[0].style.borderRightWidth );
- }else{
- sl.data( 'originalBorderRight', sl.css('border-right-width') );
- }
- if( sl.css('border-top-width').indexOf('px') == -1 ){
- sl.data( 'originalBorderTop', sl[0].style.borderTopWidth );
- }else{
- sl.data( 'originalBorderTop', sl.css('border-top-width') );
- }
- if( sl.css('border-bottom-width').indexOf('px') == -1 ){
- sl.data( 'originalBorderBottom', sl[0].style.borderBottomWidth );
- }else{
- sl.data( 'originalBorderBottom', sl.css('border-bottom-width') );
- }
- sl.data( 'originalFontSize', sl.css('font-size') );
- sl.data( 'originalLineHeight', sl.css('line-height') );
- });
- // CHANGED FEATURE v3.5 url- / deep linking layers
- if( document.location.hash ){
- for( var dl = 0; dl < $(el).find('.ls-slide').length; dl++ ){
- if( $(el).find('.ls-slide').eq(dl).data('deeplink') == document.location.hash.split('#')[1] ){
- ls.o.firstSlide = dl+1;
- }
- }
- }
- // NEW FEATURE v2.0 linkTo
- $(el).find('*[class*="ls-linkto-"]').each(function(){
- var lClasses = $(this).attr('class').split(' ');
- for( var ll=0; ll<lClasses.length; ll++ ){
- if( lClasses[ll].indexOf('ls-linkto-') != -1 ){
- var linkTo = parseInt( lClasses[ll].split('ls-linkto-')[1] );
- $(this).css({
- cursor: 'pointer'
- }).click(function(e){
- e.preventDefault();
- $(el).layerSlider( linkTo );
- });
- }
- }
- });
- // Setting variables
- ls.g.layersNum = $(el).find('.ls-slide').length;
- // NEW FEATURE v3.5 randomSlideshow
- if( ls.o.randomSlideshow && ls.g.layersNum > 2 ){
- ls.o.firstSlide == 'random';
- ls.o.twoWaySlideshow = false;
- }else{
- ls.o.randomSlideshow = false;
- }
- // NEW FEATURE v3.0 random firstSlide
- if( ls.o.firstSlide == 'random' ){
- ls.o.firstSlide = Math.floor(Math.random() * ls.g.layersNum+1);
- }
- ls.o.fisrtSlide = ls.o.fisrtSlide < ls.g.layersNum + 1 ? ls.o.fisrtSlide : 1;
- ls.o.fisrtSlide = ls.o.fisrtSlide < 1 ? 1 : ls.o.fisrtSlide;
- // NEW FEATURE v2.0 loops
- ls.g.nextLoop = 1;
- if( ls.o.animateFirstSlide ){
- ls.g.nextLoop = 0;
- }
- // NEW FEATURE v2.0 videoPreview
- // IMPROVEMENT v4.6.0 http / https support of embedded videos
- var HTTP = document.location.href.indexOf('file:') === -1 ? '' : 'http:';
- // Youtube videos
- $(el).find('iframe[src*="youtube.com"], iframe[src*="youtu.be"]').each(function(){
- // BUGFIX v4.1.0 Firefox embedded video fix
- $(this).parent().addClass('ls-video-layer');
- if( $(this).parent('[class*="ls-l"]') ){
- var iframe = $(this);
- var http = HTTP;
- // Getting thumbnail
- $.getJSON( http + '//gdata.youtube.com/feeds/api/videos/' + $(this).attr('src').split('embed/')[1].split('?')[0] + '?v=2&alt=json&callback=?', function(data) {
- iframe.data( 'videoDuration', parseInt(data['entry']['media$group']['yt$duration']['seconds']) * 1000 );
- });
- var vpContainer = $('<div>').addClass('ls-vpcontainer').appendTo( $(this).parent() );
- // if( ls.o.lazyLoad ){
- // $('<img>').appendTo( vpContainer ).addClass('ls-videopreview').attr('alt', 'Play video').data('src', http + '//img.youtube.com/vi/' + $(this).attr('src').split('embed/')[1].split('?')[0] + '/' + ls.o.youtubePreview );
- // }else{
- $('<img>').appendTo( vpContainer ).addClass('ls-videopreview').attr('alt', 'Play video').attr('src', http + '//img.youtube.com/vi/' + $(this).attr('src').split('embed/')[1].split('?')[0] + '/' + ls.o.youtubePreview );
- // }
- $('<div>').appendTo( vpContainer ).addClass('ls-playvideo');
- $(this).parent().css({
- width : $(this).width(),
- height : $(this).height()
- }).click(function(){
- // IMPROVEMENT v5.2.0 if video playing is in progress, video layers with auto play will skip showuntil feature
- if( $(this).data('showuntil') > 0 && $(this).data('showUntilTimer') ){
- clearTimeout( $(this).data('showUntilTimer') );
- }
- ls.g.isAnimating = true;
- if( ls.g.paused ){
- if( ls.o.autoPauseSlideshow != false ){
- ls.g.paused = false;
- }
- ls.g.originalAutoSlideshow = true;
- }else{
- ls.g.originalAutoSlideshow = ls.g.autoSlideshow;
- }
- if( ls.o.autoPauseSlideshow != false ){
- ls.stop();
- }
- ls.g.pausedByVideo = true;
- http = $(this).find('iframe').data('videoSrc').indexOf('http') === -1 ? HTTP : '';
- $(this).find('iframe').attr('src', http + $(this).find('iframe').data('videoSrc') );
- $(this).find('.ls-vpcontainer').delay(ls.g.v.d).fadeOut(ls.g.v.fo, function(){
- if( ls.o.autoPauseSlideshow == 'auto' && ls.g.originalAutoSlideshow == true ){
- var videoTimer = setTimeout(function() {
- ls.start();
- }, iframe.data( 'videoDuration') - ls.g.v.d );
- iframe.data( 'videoTimer', videoTimer );
- }
- ls.g.isAnimating = false;
- if( ls.g.resize == true ){
- ls.makeResponsive( ls.g.curLayer, function(){
- ls.g.resize = false;
- });
- }
- });
- });
- var sep = '&';
- if( $(this).attr('src').indexOf('?') == -1 ){
- sep = '?';
- }
- // BUGFIX v5.1.0 Fixed several issues with embedded videos (mostly under Firefox and IE)
- // fixed 'only audio but no video' bug, fixed 'unclickable video controls' bug, fixed 'hidden slider controls' bug
- var videoFix = '&wmode=opaque&html5=1';
- // BUGFIX v5.1.0 Fixed autoplay parameter
- if( $(this).attr('src').indexOf('autoplay') == -1 ){
- $(this).data( 'videoSrc', $(this).attr('src') + sep + 'autoplay=1' + videoFix );
- }else{
- $(this).data( 'videoSrc', $(this).attr('src').replace('autoplay=0','autoplay=1') + videoFix );
- }
- $(this).data( 'originalWidth', $(this).attr('width') );
- $(this).data( 'originalHeight', $(this).attr('height') );
- $(this).attr('src','');
- }
- });
- // Vimeo videos
- $(el).find('iframe[src*="player.vimeo"]').each(function(){
- // BUGFIX v4.1.0 Firefox embedded video fix
- $(this).parent().addClass('ls-video-layer');
- if( $(this).parent('[class*="ls-l"]') ){
- var iframe = $(this);
- var http = HTTP;
- // Getting thumbnail
- var vpContainer = $('<div>').addClass('ls-vpcontainer').appendTo( $(this).parent() );
- $.getJSON( http + '//vimeo.com/api/v2/video/'+ ( $(this).attr('src').split('video/')[1].split('?')[0] ) +'.json?callback=?', function(data){
- // if( ls.o.lazyLoad ){
- // $('<img>').appendTo( vpContainer ).addClass('ls-videopreview').attr('alt', 'Play video').data('src', data[0]['thumbnail_large'] );
- // }else{
- $('<img>').appendTo( vpContainer ).addClass('ls-videopreview').attr('alt', 'Play video').attr('src', data[0]['thumbnail_large'] );
- // }
- iframe.data( 'videoDuration', parseInt( data[0]['duration'] ) * 1000 );
- $('<div>').appendTo( vpContainer ).addClass('ls-playvideo');
- });
- $(this).parent().css({
- width : $(this).width(),
- height : $(this).height()
- }).click(function(){
- // IMPROVEMENT v5.2.0 if video playing is in progress, video layers with auto play will skip showuntil feature
- if( $(this).data('showuntil') > 0 && $(this).data('showUntilTimer') ){
- clearTimeout( $(this).data('showUntilTimer') );
- }
- ls.g.isAnimating = true;
- if( ls.g.paused ){
- if( ls.o.autoPauseSlideshow != false ){
- ls.g.paused = false;
- }
- ls.g.originalAutoSlideshow = true;
- }else{
- ls.g.originalAutoSlideshow = ls.g.autoSlideshow;
- }
- if( ls.o.autoPauseSlideshow != false ){
- ls.stop();
- }
- ls.g.pausedByVideo = true;
- http = $(this).find('iframe').data('videoSrc').indexOf('http') === -1 ? HTTP : '';
- $(this).find('iframe').attr('src', http + $(this).find('iframe').data('videoSrc') );
- $(this).find('.ls-vpcontainer').delay(ls.g.v.d).fadeOut(ls.g.v.fo, function(){
- if( ls.o.autoPauseSlideshow == 'auto' && ls.g.originalAutoSlideshow == true ){
- var videoTimer = setTimeout(function() {
- ls.start();
- }, iframe.data( 'videoDuration') - ls.g.v.d );
- iframe.data( 'videoTimer', videoTimer );
- }
- ls.g.isAnimating = false;
- if( ls.g.resize == true ){
- ls.makeResponsive( ls.g.curLayer, function(){
- ls.g.resize = false;
- });
- }
- });
- });
- var sep = '&';
- if( $(this).attr('src').indexOf('?') == -1 ){
- sep = '?';
- }
- // BUGFIX v5.1.0 Fixed several issues with embedded videos (mostly under Firefox and IE)
- // fixed 'only audio but no video' bug, fixed 'unclickable video controls' bug, fixed 'hidden slider controls' bug
- var videoFix = '&wmode=opaque';
- // BUGFIX v5.1.0 Fixed autoplay parameter
- if( $(this).attr('src').indexOf('autoplay') == -1 ){
- $(this).data( 'videoSrc', $(this).attr('src') + sep + 'autoplay=1' + videoFix );
- }else{
- $(this).data( 'videoSrc', $(this).attr('src').replace('autoplay=0','autoplay=1') + videoFix );
- }
- $(this).data( 'originalWidth', $(this).attr('width') );
- $(this).data( 'originalHeight', $(this).attr('height') );
- $(this).attr('src','');
- }
- });
- // NEW FEATURE v5.0.0 HTML5 Video Support
- $(el).find('video, audio').each(function(){
- // BUGFIX v5.1.0 fixed HTML5 video sizing issue (again :)
- var ow = typeof $(this).attr('width') !== 'undefined' ? $(this).attr('width') : '640';
- var oh = typeof $(this).attr('height') !== 'undefined' ? $(this).attr('height') : '' + $(this).height();
- if( ow.indexOf('%') === -1 ){
- ow = parseInt( ow );
- }
- if( oh.indexOf('%') === -1 ){
- oh = parseInt( oh );
- }
- if( ow === '100%' && ( oh === 0 || oh === '0' || oh === '100%' ) ){
- $(this).attr('height', '100%');
- oh = 'auto';
- }
- $(this).parent().addClass('ls-video-layer').css({
- width : ow,
- height : oh
- }).data({
- originalWidth : ow,
- originalHeight : oh
- });
- var curVideo = $(this);
- // BUGFIX v5.3.0 'ended' function removed from 'click' function due to multiply
- $(this).on('ended', function(){
- if( ls.o.autoPauseSlideshow === 'auto' && ls.g.originalAutoSlideshow === true ){
- ls.start();
- }
- });
- $(this).removeAttr('width').removeAttr('height').css({
- width : '100%',
- height : '100%'
- }).click(function(e){
- // BUGFIX v5.3.0 autoplay didn't work in all cases
- if( !ls.g.pausedByVideo ){
- if( this.paused ){
- e.preventDefault();
- }
- this.play();
- ls.g.isAnimating = true;
- if( ls.g.paused ){
- if( ls.o.autoPauseSlideshow !== false ){
- ls.g.paused = false;
- }
- ls.g.originalAutoSlideshow = true;
- }else{
- ls.g.originalAutoSlideshow = ls.g.autoSlideshow;
- }
- if( ls.o.autoPauseSlideshow !== false ){
- ls.stop();
- }
- ls.g.pausedByVideo = true;
- ls.g.isAnimating = false;
- if( ls.g.resize === true ){
- ls.makeResponsive( ls.g.curLayer, function(){
- ls.g.resize = false;
- });
- }
- }
- });
- });
- // NEW FEATURE v1.7 animating first layer
- if( ls.o.animateFirstSlide ){
- ls.o.firstSlide = ls.o.firstSlide - 1 === 0 ? ls.g.layersNum : ls.o.firstSlide-1;
- }
- ls.g.curLayerIndex = ls.o.firstSlide;
- ls.g.curLayer = $(el).find('.ls-slide:eq('+(ls.g.curLayerIndex-1)+')');
- // Moving all layers to .ls-inner container
- $(el).find('.ls-slide').wrapAll('<div class="ls-inner"></div>');
- // NEW FEATURE v4.5.0 Timers
- if( ls.o.showBarTimer ){
- ls.g.barTimer = $('<div>').addClass('ls-bar-timer').appendTo( $(el).find('.ls-inner') );
- }
- if( ls.o.showCircleTimer && !ls.g.ie78 ){
- ls.g.circleTimer = $('<div>').addClass('ls-circle-timer').appendTo( $(el).find('.ls-inner') );
- ls.g.circleTimer.append( $('<div class="ls-ct-left"><div class="ls-ct-rotate"><div class="ls-ct-hider"><div class="ls-ct-half"></div></div></div></div><div class="ls-ct-right"><div class="ls-ct-rotate"><div class="ls-ct-hider"><div class="ls-ct-half"></div></div></div></div><div class="ls-ct-center"></div>') );
- }
- // NEW FEATURE v4.0 Adding loading indicator into the element
- ls.g.li = $('<div>').css({
- zIndex: -1,
- display: 'none'
- }).addClass('ls-loading-container').appendTo( $(el) );
- $('<div>').addClass('ls-loading-indicator').appendTo( ls.g.li );
- // Adding styles
- if( $(el).css('position') == 'static' ){
- $(el).css('position','relative');
- }
- // IMPROVEMENT & BUGFIX v4.6.0 Fixed transparent global background issue under IE7 & IE8
- if( ls.o.globalBGImage ){
- $(el).find('.ls-inner').css({
- backgroundImage : 'url('+ls.o.globalBGImage+')'
- });
- }else{
- $(el).find('.ls-inner').css({
- backgroundColor : ls.o.globalBGColor
- });
- }
- if( ls.o.globalBGColor == 'transparent' && ls.o.globalBGImage == false ){
- $(el).find('.ls-inner').css({
- background : 'none transparent !important'
- });
- }
- // NEW FEATURES v5.0.0 Lazy-load & remove unnecessary width & height attributes from images
- $(el).find('.ls-slide img').each(function(){
- $(this).removeAttr('width').removeAttr('height');
- if( ls.o.imgPreload === true && ls.o.lazyLoad === true ){
- if( typeof $(this).data('src') !== 'string' ){
- $(this).data('src', $(this).attr('src') );
- var src = ls.o.skinsPath+'../css/blank.gif';
- $(this).attr('src',src);
- }
- }else{
- if( typeof $(this).data('src') === 'string' ){
- $(this).attr('src',$(this).data('src'));
- $(this).removeAttr('data-src');
- }
- }
- });
- // NEW FEATURE v5.0.0 Parallax layers by mousemove
- $(el).find('.ls-slide').on('mouseenter',function(e){
- ls.g.parallaxStartX = e.pageX - $(this).parent().offset().left;
- ls.g.parallaxStartY = e.pageY - $(this).parent().offset().top;
- });
- $(el).find('.ls-slide').on('mousemove',function(e){
- var mX0 = $(this).parent().offset().left + ls.g.parallaxStartX;
- var mY0 = $(this).parent().offset().top + ls.g.parallaxStartY;
- var mX = e.pageX - mX0;
- var mY = e.pageY - mY0;
- $(this).find('> *:not(.ls-bg)').each(function(){
- if( typeof $(this).data('parallaxlevel') !== 'undefined' && parseInt( $(this).data('parallaxlevel') ) !== 0 ){
- $(this).css({
- marginLeft : -mX / 100 * parseInt( $(this).data('parallaxlevel') ),
- marginTop : -mY / 100 * parseInt( $(this).data('parallaxlevel') )
- });
- }
- });
- });
- $(el).find('.ls-slide').on('mouseleave',function(){
- $(this).find('> *:not(.ls-bg)').each(function(){
- if( typeof $(this).data('parallaxlevel') !== 'undefined' && parseInt( $(this).data('parallaxlevel') ) !== 0 ){
- TweenLite.to( this, .4, {css:{
- marginLeft : 0,
- marginTop : 0
- }
- });
- }
- });
- });
- // Creating navigation
- if( ls.o.navPrevNext ){
- $('<a class="ls-nav-prev" href="#" />').click(function(e){
- e.preventDefault();
- $(el).layerSlider('prev');
- }).appendTo($(el));
- $('<a class="ls-nav-next" href="#" />').click(function(e){
- e.preventDefault();
- $(el).layerSlider('next');
- }).appendTo($(el));
- if( ls.o.hoverPrevNext ){
- $(el).find('.ls-nav-prev, .ls-nav-next').css({
- display: 'none'
- });
- $(el).hover(
- function(){
- if( !ls.g.forceHideControls ){
- if( ls.g.ie78 ){
- $(el).find('.ls-nav-prev, .ls-nav-next').css('display','block');
- }else{
- $(el).find('.ls-nav-prev, .ls-nav-next').stop(true,true).fadeIn(300);
- }
- }
- },
- function(){
- if( ls.g.ie78 ){
- $(el).find('.ls-nav-prev, .ls-nav-next').css('display','none');
- }else{
- $(el).find('.ls-nav-prev, .ls-nav-next').stop(true,true).fadeOut(300);
- }
- }
- );
- }
- }
- // Creating bottom navigation
- if( ls.o.navStartStop || ls.o.navButtons ){
- var bottomNav = $('<div class="ls-bottom-nav-wrapper" />').appendTo( $(el) );
- ls.g.bottomWrapper = bottomNav;
- if( ls.o.thumbnailNavigation == 'always' ){
- bottomNav.addClass('ls-above-thumbnails');
- }
- if( ls.o.navButtons && ls.o.thumbnailNavigation != 'always' ){
- $('<span class="ls-bottom-slidebuttons" />').appendTo( $(el).find('.ls-bottom-nav-wrapper') );
- // NEW FEATURE v3.5 thumbnailNavigation ('hover')
- if( ls.o.thumbnailNavigation == 'hover' ){
- var thumbs = $('<div class="ls-thumbnail-hover"><div class="ls-thumbnail-hover-inner"><div class="ls-thumbnail-hover-bg"></div><div class="ls-thumbnail-hover-img"><img></div><span></span></div></div>').appendTo( $(el).find('.ls-bottom-slidebuttons') );
- }
- for(x=1;x<ls.g.layersNum+1;x++){
- var btn = $('<a href="#" />').appendTo( $(el).find('.ls-bottom-slidebuttons') ).click(function(e){
- e.preventDefault();
- $(el).layerSlider( ($(this).index() + 1) );
- });
- // NEW FEATURE v3.5 thumbnailNavigation ('hover')
- if( ls.o.thumbnailNavigation == 'hover' ){
- $(el).find('.ls-thumbnail-hover, .ls-thumbnail-hover-img').css({
- width : ls.o.tnWidth,
- height : ls.o.tnHeight
- });
- var th = $(el).find('.ls-thumbnail-hover');
- var ti = th.find('img').css({
- height : ls.o.tnHeight
- });
- var thi = $(el).find('.ls-thumbnail-hover-inner').css({
- visibility : 'hidden',
- display: 'block'
- });
- btn.hover(
- function(){
- var hoverLayer = $(el).find('.ls-slide').eq( $(this).index() );
- var tnSrc;
- if( ls.o.imgPreload === true && ls.o.lazyLoad === true ){
- if( hoverLayer.find('.ls-tn').length ){
- tnSrc = hoverLayer.find('.ls-tn').data('src');
- }else if( hoverLayer.find('.ls-videopreview').length ){
- tnSrc = hoverLayer.find('.ls-videopreview').attr('src');
- }else if( hoverLayer.find('.ls-bg').length ){
- tnSrc = hoverLayer.find('.ls-bg').data('src');
- }else{
- tnSrc = ls.o.skinsPath+ls.o.skin+'/nothumb.png';
- }
- }else{
- if( hoverLayer.find('.ls-tn').length ){
- tnSrc = hoverLayer.find('.ls-tn').attr('src');
- }else if( hoverLayer.find('.ls-videopreview').length ){
- tnSrc = hoverLayer.find('.ls-videopreview').attr('src');
- }else if( hoverLayer.find('.ls-bg').length ){
- tnSrc = hoverLayer.find('.ls-bg').attr('src');
- }else{
- tnSrc = ls.o.skinsPath+ls.o.skin+'/nothumb.png';
- }
- }
- $(el).find('.ls-thumbnail-hover-img').css({
- left: parseInt( th.css('padding-left') ),
- top: parseInt( th.css('padding-top') )
- });
- ti.load(function(){
- if( $(this).width() == 0 ){
- ti.css({
- position: 'relative',
- margin: '0 auto',
- left: 'auto'
- });
- }else{
- ti.css({
- position: 'absolute',
- marginLeft : - $(this).width() / 2,
- left: '50%'
- });
- }
- }).attr( 'src', tnSrc );
- th.css({
- display: 'block'
- }).stop().animate({
- left: $(this).position().left + ( $(this).width() - th.outerWidth() ) / 2
- }, 250 );
- thi.css({
- display : 'none',
- visibility : 'visible'
- }).stop().fadeIn(250);
- },
- function(){
- thi.stop().fadeOut(250, function(){
- th.css({
- visibility : 'hidden',
- display: 'block'
- });
- });
- }
- );
- }
- }
- if( ls.o.thumbnailNavigation == 'hover' ){
- thumbs.appendTo( $(el).find('.ls-bottom-slidebuttons') );
- }
- $(el).find('.ls-bottom-slidebuttons a:eq('+(ls.o.firstSlide-1)+')').addClass('ls-nav-active');
- }
- if( ls.o.navStartStop ){
- var buttonStart = $('<a class="ls-nav-start" href="#" />').click(function(e){
- e.preventDefault();
- $(el).layerSlider('start');
- }).prependTo( $(el).find('.ls-bottom-nav-wrapper') );
- var buttonStop = $('<a class="ls-nav-stop" href="#" />').click(function(e){
- e.preventDefault();
- $(el).layerSlider('stop');
- }).appendTo( $(el).find('.ls-bottom-nav-wrapper') );
- }else if( ls.o.thumbnailNavigation != 'always' ){
- $('<span class="ls-nav-sides ls-nav-sideleft" />').prependTo( $(el).find('.ls-bottom-nav-wrapper') );
- $('<span class="ls-nav-sides ls-nav-sideright" />').appendTo( $(el).find('.ls-bottom-nav-wrapper') );
- }
- if( ls.o.hoverBottomNav && ls.o.thumbnailNavigation != 'always' ){
- bottomNav.css({
- display: 'none'
- });
- $(el).hover(
- function(){
- if( !ls.g.forceHideControls ){
- if( ls.g.ie78 ){
- bottomNav.css('display','block');
- }else{
- bottomNav.stop(true,true).fadeIn(300);
- }
- }
- },
- function(){
- if( ls.g.ie78 ){
- bottomNav.css('display','none');
- }else{
- bottomNav.stop(true,true).fadeOut(300);
- }
- }
- )
- }
- }
- // NEW FEATURE v3x.5 thumbnailNavigation ('always')
- if( ls.o.thumbnailNavigation == 'always' ){
- ls.g.thumbsWrapper = $('<div class="ls-thumbnail-wrapper"></div>').appendTo( $(el) );
- var thumbs = $('<div class="ls-thumbnail"><div class="ls-thumbnail-inner"><div class="ls-thumbnail-slide-container"><div class="ls-thumbnail-slide"></div></div></div></div>').appendTo( ls.g.thumbsWrapper );
- ls.g.thumbnails = $(el).find('.ls-thumbnail-slide-container');
- if( !('ontouchstart' in window) ){
- ls.g.thumbnails.hover(
- function(){
- $(this).addClass('ls-thumbnail-slide-hover');
- },
- function(){
- $(this).removeClass('ls-thumbnail-slide-hover');
- ls.scrollThumb();
- }
- ).mousemove(function(e){
- var mL = parseInt(e.pageX - $(this).offset().left ) / $(this).width() * ( $(this).width() - $(this).find('.ls-thumbnail-slide').width() );
- $(this).find('.ls-thumbnail-slide').stop().css({
- marginLeft : mL
- });
- });
- }else{
- ls.g.thumbnails.addClass('ls-touchscroll');
- }
- $(el).find('.ls-slide').each(function(){
- var tempIndex = $(this).index() + 1;
- var tnSrc;
- if( ls.o.imgPreload === true && ls.o.lazyLoad === true ){
- if( $(this).find('.ls-tn').length ){
- tnSrc = $(this).find('.ls-tn').data('src');
- }else if( $(this).find('.ls-videopreview').length ){
- tnSrc = $(this).find('.ls-videopreview').attr('src');
- }else if( $(this).find('.ls-bg').length ){
- tnSrc = $(this).find('.ls-bg').data('src');
- }else{
- tnSrc = ls.o.skinsPath+ls.o.skin+'/nothumb.png';
- }
- }else{
- if( $(this).find('.ls-tn').length ){
- tnSrc = $(this).find('.ls-tn').attr('src');
- }else if( $(this).find('.ls-videopreview').length ){
- tnSrc = $(this).find('.ls-videopreview').attr('src');
- }else if( $(this).find('.ls-bg').length ){
- tnSrc = $(this).find('.ls-bg').attr('src');
- }else{
- tnSrc = ls.o.skinsPath+ls.o.skin+'/nothumb.png';
- }
- }
- var thumb = $('<a href="#" class="ls-thumb-' + tempIndex + '"><img src="'+tnSrc+'"></a>');
- thumb.appendTo( $(el).find('.ls-thumbnail-slide') );
- if( !('ontouchstart' in window) ){
- thumb.hover(
- function(){
- $(this).children().stop().fadeTo(300,ls.o.tnActiveOpacity/100);
- },
- function(){
- if( !$(this).children().hasClass('ls-thumb-active') ){
- $(this).children().stop().fadeTo(300,ls.o.tnInactiveOpacity/100);
- }
- }
- );
- }
- thumb.click(function(e){
- e.preventDefault();
- $(el).layerSlider( tempIndex );
- });
- });
- if( buttonStart && buttonStop ){
- var lsBottomBelowTN = ls.g.bottomWrapper = $('<div class="ls-bottom-nav-wrapper ls-below-thumbnails"></div>').appendTo( $(el) );
- buttonStart.clone().click(function(e){
- e.preventDefault();
- $(el).layerSlider('start');
- }).appendTo( lsBottomBelowTN );
- buttonStop.clone().click(function(e){
- e.preventDefault();
- $(el).layerSlider('stop');
- }).appendTo( lsBottomBelowTN );
- }
- if( ls.o.hoverBottomNav ){
- ls.g.thumbsWrapper.css('display','none');
- if( lsBottomBelowTN ){
- ls.g.bottomWrapper = lsBottomBelowTN.css('display') == 'block' ? lsBottomBelowTN : $(el).find('.ls-above-thumbnails');
- ls.g.bottomWrapper.css('display','none');
- }
- // BUGFIXES v4.1.3 Added checking of the bottomWrapper variable
- $(el).hover(
- function(){
- $(el).addClass('ls-hover');
- if( !ls.g.forceHideControls ){
- if( ls.g.ie78 ){
- ls.g.thumbsWrapper.css('display','block');
- if( ls.g.bottomWrapper ){
- ls.g.bottomWrapper.css('display','block');
- }
- }else{
- ls.g.thumbsWrapper.stop(true,true).fadeIn(300);
- if( ls.g.bottomWrapper ){
- ls.g.bottomWrapper.stop(true,true).fadeIn(300);
- }
- }
- }
- },
- function(){
- $(el).removeClass('ls-hover');
- if( ls.g.ie78 ){
- ls.g.thumbsWrapper.css('display','none');
- if( ls.g.bottomWrapper ){
- ls.g.bottomWrapper.css('display','none');
- }
- }else{
- ls.g.thumbsWrapper.stop(true,true).fadeOut(300);
- if( ls.g.bottomWrapper ){
- ls.g.bottomWrapper.stop(true,true).fadeOut(300);
- }
- }
- }
- )
- }
- }
- // Adding shadow wrapper
- ls.g.shadow = $('<div class="ls-shadow"></div>').appendTo( $(el) );
- if( ls.g.shadow.css('display') == 'block' && !ls.g.shadow.find('img').length ){
- ls.g.showShadow = function(){
- ls.g.shadow.css({
- display: 'none',
- visibility: 'visible'
- }).fadeIn( 500, function(){
- ls.g.showShadow = false;
- });
- }
- ls.g.shadowImg = $('<img>').attr('src',ls.o.skinsPath+ls.o.skin+'/shadow.png').appendTo( ls.g.shadow );
- ls.g.shadowBtmMod = typeof parseInt( $(el).css('padding-bottom') ) == 'number' ? parseInt( $(el).css('padding-bottom') ) : 0;
- }
- ls.resizeShadow();
- // Adding keyboard navigation if turned on and if number of layers > 1
- if( ls.o.keybNav && $(el).find('.ls-slide').length > 1 ){
- $('body').bind('keydown',function(e){
- if( !ls.g.isAnimating && !ls.g.isLoading ){
- if( e.which == 37 ){
- ls.o.cbPrev(ls.g);
- ls.prev('clicked');
- }else if( e.which == 39 ){
- ls.o.cbNext(ls.g);
- ls.next('clicked');
- }
- }
- });
- }
- // Adding touch-control navigation if number of layers > 1
- if('ontouchstart' in window && $(el).find('.ls-slide').length > 1 && ls.o.touchNav ){
- $(el).find('.ls-inner').bind('touchstart', function( e ) {
- var t = e.touches ? e.touches : e.originalEvent.touches;
- if( t.length == 1 ){
- ls.g.touchStartX = ls.g.touchEndX = t[0].clientX;
- }
- });
- $(el).find('.ls-inner').bind('touchmove', function( e ) {
- var t = e.touches ? e.touches : e.originalEvent.touches;
- if( t.length == 1 ){
- ls.g.touchEndX = t[0].clientX;
- }
- if( Math.abs( ls.g.touchStartX - ls.g.touchEndX ) > 45 ){
- e.preventDefault();
- }
- });
- $(el).find('.ls-inner').bind('touchend',function( e ){
- if( Math.abs( ls.g.touchStartX - ls.g.touchEndX ) > 45 ){
- if( ls.g.touchStartX - ls.g.touchEndX > 0 ){
- ls.o.cbNext(ls.g);
- $(el).layerSlider('next');
- }else{
- ls.o.cbPrev(ls.g);
- $(el).layerSlider('prev');
- }
- }
- });
- }
- // Feature: pauseOnHover (if number of layers > 1)
- if( ls.o.pauseOnHover == true && $(el).find('.ls-slide').length > 1 ){
- // BUGFIX v1.6 stop was not working because of pause on hover
- $(el).find('.ls-inner').hover(
- function(){
- // Calling cbPause callback function
- ls.o.cbPause(ls.g);
- if( ls.g.autoSlideshow ){
- ls.g.paused = true;
- ls.stop();
- // Stopping the animation of Timers
- if( ls.g.barTimer ){
- ls.g.barTimer.stop();
- }
- if( ls.g.circleTimer ){
- if( ls.g.cttl ){
- ls.g.cttl.pause();
- }
- }
- ls.g.pausedSlideTime = new Date().getTime();
- }
- },
- function(){
- if( ls.g.paused == true ){
- ls.start();
- ls.g.paused = false;
- }
- }
- );
- }
- ls.resizeSlider();
- // NEW FEATURE v1.7 added yourLogo
- if( ls.o.yourLogo ){
- ls.g.yourLogo = $('<img>').addClass('ls-yourlogo').appendTo($(el)).attr('style', ls.o.yourLogoStyle ).css({
- visibility: 'hidden',
- display: 'bock'
- }).load(function(){
- // NEW FEATURE v3.0 added responsive yourLogo
- var logoTimeout = 0;
- if( !ls.g.yourLogo ){
- logoTimeout = 1000;
- }
- setTimeout( function(){
- ls.g.yourLogo.data( 'originalWidth', ls.g.yourLogo.width() );
- ls.g.yourLogo.data( 'originalHeight', ls.g.yourLogo.height() );
- if( ls.g.yourLogo.css('left') != 'auto' ){
- ls.g.yourLogo.data( 'originalLeft', ls.g.yourLogo[0].style.left );
- }
- if( ls.g.yourLogo.css('right') != 'auto' ){
- ls.g.yourLogo.data( 'originalRight', ls.g.yourLogo[0].style.right );
- }
- if( ls.g.yourLogo.css('top') != 'auto' ){
- ls.g.yourLogo.data( 'originalTop', ls.g.yourLogo[0].style.top );
- }
- if( ls.g.yourLogo.css('bottom') != 'auto' ){
- ls.g.yourLogo.data( 'originalBottom', ls.g.yourLogo[0].style.bottom );
- }
- // NEW FEATURES v1.8 added yourLogoLink & yourLogoTarget
- if( ls.o.yourLogoLink != false ){
- $('<a>').appendTo($(el)).attr( 'href', ls.o.yourLogoLink ).attr('target', ls.o.yourLogoTarget ).css({
- textDecoration : 'none',
- outline : 'none'
- }).append( ls.g.yourLogo );
- }
- ls.g.yourLogo.css({
- display: 'none',
- visibility: 'visible'
- });
- ls.resizeYourLogo();
- }, logoTimeout );
- }).attr( 'src', ls.o.yourLogo );
- }
- // NEW FEATURE v1.7 added window resize function for make responsive layout better
- $(window).resize(function(){
- ls.resize();
- });
- // BUGFIX v5.3.0 Responsiveness not worked in some cases while changed orientation on mobile devices
- $(window).on('orientationchange',function(){
- $(window).resize();
- });
- ls.g.showSlider = true;
- // NEW FEATURE v1.7 animating first slide
- if( ls.o.animateFirstSlide == true ){
- if( ls.o.autoStart ){
- ls.g.autoSlideshow = true;
- $(el).find('.ls-nav-start').addClass('ls-nav-start-active');
- }else{
- $(el).find('.ls-nav-stop').addClass('ls-nav-stop-active');
- }
- ls.next();
- }else if( typeof ls.g.curLayer[0] !== 'undefined' ){
- ls.imgPreload(ls.g.curLayer,function(){
- ls.g.curLayer.fadeIn(ls.o.sliderFadeInDuration, function(){
- ls.g.isLoading = false;
- $(this).addClass('ls-active');
- // NEW FEATURE v2.0 autoPlayVideos
- if( ls.o.autoPlayVideos ){
- $(this).delay( $(this).data('delayin') + 25 ).queue(function(){
- // YouTube & Vimeo videos
- $(this).find('.ls-videopreview').click();
- // HTML5 videos
- $(this).find('video, audio').each(function(){
- if( typeof $(this)[0].currentTime !== 0){
- $(this)[0].currentTime = 0;
- }
- $(this).click();
- });
- $(this).dequeue();
- });
- }
- // NEW FEATURE v3.0 showUntil sublayers
- ls.g.curLayer.find(' > *[class*="ls-l"]').each(function(){
- // Setting showUntilTimers
- var cursub = $(this);
- // IMPROVEMENT v5.2.0 video layers with auto play will skip showuntil feature
- if( ( !cursub.hasClass('ls-video-layer') || ( cursub.hasClass('ls-video-layer') && ls.o.autoPlayVideos === false ) ) && cursub.data('showuntil') > 0 ){
- // IMPROVEMENT v4.5.0 sublayerShowUntil will be called anly if necessary
- cursub.data('showUntilTimer', setTimeout(function(){
- ls.sublayerShowUntil( cursub );
- }, cursub.data('showuntil') ));
- }
- });
- });
- ls.changeThumb(ls.g.curLayerIndex)
- // If autoStart is true
- if( ls.o.autoStart ){
- ls.g.isLoading = false;
- ls.start();
- }else{
- $(el).find('.ls-nav-stop').addClass('ls-nav-stop-active');
- }
- });
- }
- // NEW FEATURE v1.7 added cbInit function
- ls.o.cbInit($(el));
- };
- ls.resize = function(){
- ls.g.resize = true;
- if( !ls.g.isAnimating ){
- ls.makeResponsive( ls.g.curLayer, function(){
- if( ls.g.ltContainer ){
- ls.g.ltContainer.empty();
- }
- ls.g.resize = false;
- });
- if( ls.g.yourLogo ){
- ls.resizeYourLogo();
- }
- }
- };
- ls.start = function(){
- if( ls.g.autoSlideshow ){
- if( ls.g.prevNext == 'prev' && ls.o.twoWaySlideshow ){
- ls.prev();
- }else{
- ls.next();
- }
- }else{
- ls.g.autoSlideshow = true;
- if( !ls.g.isAnimating && !ls.g.isLoading ){
- ls.timer();
- }
- }
- $(el).find('.ls-nav-start').addClass('ls-nav-start-active');
- $(el).find('.ls-nav-stop').removeClass('ls-nav-stop-active');
- };
- ls.timer = function(){
- if( $(el).find('.ls-active').data('ls') ){
- var sD = ls.st.slideDelay;
- }else{
- var sD = ls.o.slideDelay;
- }
- var delaytime = $(el).find('.ls-active').data('slidedelay') ? parseInt( $(el).find('.ls-active').data('slidedelay') ) : sD;
- // BUGFIX v3.0 delaytime did not work on first layer if animateFirstSlide was set to off
- // BUGFIX v3.5 delaytime did not work on all layers in standalone version after bugfix 3.0 :)
- if( !ls.o.animateFirstSlide && !$(el).find('.ls-active').data('slidedelay') ){
- var tempD = $(el).find('.ls-slide:eq('+(ls.o.firstSlide-1)+')').data('slidedelay');
- delaytime = tempD ? tempD : sD;
- }
- clearTimeout( ls.g.slideTimer );
- // NEW FEATURE v4.5.0 Timers
- if( ls.g.pausedSlideTime ){
- if( !ls.g.startSlideTime ){
- ls.g.startSlideTime = new Date().getTime();
- }
- if( ls.g.startSlideTime > ls.g.pausedSlideTime ){
- ls.g.pausedSlideTime = new Date().getTime();
- }
- if(! ls.g.curSlideTime ){
- ls.g.curSlideTime = delaytime;
- }
- ls.g.curSlideTime -= (ls.g.pausedSlideTime - ls.g.startSlideTime);
- ls.g.pausedSlideTime = false;
- ls.g.startSlideTime = new Date().getTime();
- }else{
- ls.g.curSlideTime = delaytime;
- ls.g.startSlideTime = new Date().getTime();
- }
- // BUGFIX v4.6.0 fixed Bar Timer animation on the fisrt slide if animateFirstSlide is false
- ls.g.curSlideTime = parseInt( ls.g.curSlideTime );
- ls.g.slideTimer = setTimeout(function(){
- ls.g.startSlideTime = ls.g.pausedSlideTime = ls.g.curSlideTime = false;
- ls.start();
- }, ls.g.curSlideTime );
- // Animating Timers
- if( ls.g.barTimer ){
- ls.g.barTimer.animate({
- width : ls.g.sliderWidth()
- }, ls.g.curSlideTime, 'linear', function(){
- $(this).css({
- width: 0
- });
- });
- }
- if( ls.g.circleTimer ){
- var ct1 = ls.g.circleTimer.find('.ls-ct-right .ls-ct-rotate');
- var ct2 = ls.g.circleTimer.find('.ls-ct-left .ls-ct-rotate');
- if( ls.g.circleTimer.css('display') == 'none' ){
- ct1.css({
- rotate : 0
- });
- ct2.css({
- rotate : 0
- });
- ls.g.circleTimer.fadeIn(350);
- }
- if( !ls.g.cttl ){
- ls.g.cttl = new TimelineLite();
- ls.g.cttl.add( TweenLite.fromTo(ct1[0],delaytime/2000,{
- rotation : 0
- },{
- ease : Linear.easeNone,
- rotation : 180,
- onReverseComplete : function(){
- ls.g.cttl = false;
- }
- }));
- ls.g.cttl.add( TweenLite.fromTo(ct2[0],delaytime/2000,{
- rotation : 0
- },{
- ease : Linear.easeNone,
- rotation : 180
- }));
- }else{
- ls.g.cttl.resume();
- }
- }
- };
- ls.stop = function(){
- // Stopping Timers
- ls.g.pausedSlideTime = new Date().getTime();
- if( ls.g.barTimer ){
- ls.g.barTimer.stop();
- }
- if( ls.g.circleTimer ){
- if( ls.g.cttl ){
- ls.g.cttl.pause();
- }
- }
- if( !ls.g.paused && !ls.g.originalAutoSlideshow ){
- $(el).find('.ls-nav-stop').addClass('ls-nav-stop-active');
- $(el).find('.ls-nav-start').removeClass('ls-nav-start-active');
- }
- clearTimeout( ls.g.slideTimer );
- ls.g.autoSlideshow = false;
- };
- ls.forcestop = function(){
- clearTimeout( ls.g.slideTimer );
- ls.g.autoSlideshow = false;
- clearTimeout( ls.g.t1 );
- clearTimeout( ls.g.t2 );
- clearTimeout( ls.g.t3 );
- clearTimeout( ls.g.t4 );
- clearTimeout( ls.g.t5 );
- if( ls.g.barTimer ){
- ls.g.barTimer.stop();
- }
- if( ls.g.circleTimer ){
- if( ls.g.cttl ){
- ls.g.cttl.pause();
- }
- }
- $(el).find('*').stop(true,false).dequeue();
- $(el).find('.ls-slide >').each(function(){
- if( $(this).data('tr') ){
- $(this).data('tr').pause();
- }
- });
- if( !ls.g.paused && !ls.g.originalAutoSlideshow ){
- $(el).find('.ls-nav-stop').addClass('ls-nav-stop-active');
- $(el).find('.ls-nav-start').removeClass('ls-nav-start-active');
- }
- };
- ls.restart = function(){
- $(el).find('*').stop();
- clearTimeout( ls.g.slideTimer );
- ls.change(ls.g.curLayerIndex,ls.g.prevNext);
- };
- // Because of an ie7 bug, we have to check & format the strings correctly
- ls.ieEasing = function( e ){
- // BUGFIX v1.6 and v1.8 some type of animations didn't work properly
- if( $.trim(e.toLowerCase()) == 'swing' || $.trim(e.toLowerCase()) == 'linear'){
- return e.toLowerCase();
- }else{
- return e.replace('easeinout','easeInOut').replace('easein','easeIn').replace('easeout','easeOut').replace('quad','Quad').replace('quart','Quart').replace('cubic','Cubic').replace('quint','Quint').replace('sine','Sine').replace('expo','Expo').replace('circ','Circ').replace('elastic','Elastic').replace('back','Back').replace('bounce','Bounce');
- }
- };
- // Calculating prev layer
- ls.prev = function(clicked){
- // NEW FEATURE v2.0 loops
- if( ls.g.curLayerIndex < 2 ){
- ls.g.nextLoop += 1;
- }
- if( ( ls.g.nextLoop > ls.o.loops ) && ( ls.o.loops > 0 ) && !clicked ){
- ls.g.nextLoop = 0;
- ls.stop();
- if( ls.o.forceLoopNum == false ){
- ls.o.loops = 0;
- }
- }else{
- var prev = ls.g.curLayerIndex < 2 ? ls.g.layersNum : ls.g.curLayerIndex - 1;
- ls.g.prevNext = 'prev';
- ls.change(prev,ls.g.prevNext);
- }
- };
- // Calculating next layer
- ls.next = function(clicked){
- // NEW FEATURE v2.0 loops
- if( !ls.o.randomSlideshow ){
- if( !(ls.g.curLayerIndex < ls.g.layersNum) ){
- ls.g.nextLoop += 1;
- }
- if( ( ls.g.nextLoop > ls.o.loops ) && ( ls.o.loops > 0 ) && !clicked ){
- ls.g.nextLoop = 0;
- ls.stop();
- if( ls.o.forceLoopNum == false ){
- ls.o.loops = 0;
- }
- }else{
- var next = ls.g.curLayerIndex < ls.g.layersNum ? ls.g.curLayerIndex + 1 : 1;
- ls.g.prevNext = 'next';
- ls.change(next,ls.g.prevNext);
- }
- }else if( !clicked ){
- // NEW FEATURE v3.5 randomSlideshow
- var next = ls.g.curLayerIndex;
- var calcRand = function(){
- next = Math.floor(Math.random() * ls.g.layersNum) + 1;
- if( next == ls.g.curLayerIndex ){
- calcRand();
- }else{
- ls.g.prevNext = 'next';
- ls.change(next,ls.g.prevNext);
- }
- }
- calcRand();
- }else if( clicked ){
- var next = ls.g.curLayerIndex < ls.g.layersNum ? ls.g.curLayerIndex + 1 : 1;
- ls.g.prevNext = 'next';
- ls.change(next,ls.g.prevNext);
- }
- };
- ls.change = function(num,prevnext){
- // Stopping Timers if needed
- ls.g.startSlideTime = ls.g.pausedSlideTime = ls.g.curSlideTime = false;
- // IMPROVEMENT v4.6.0 Bar Timer animation
- if( ls.g.barTimer ){
- ls.g.barTimer.stop().delay(300).animate({
- width: 0
- },450);
- }
- if( ls.g.circleTimer ){
- ls.g.circleTimer.fadeOut(500);
- if( ls.g.cttl ){
- ls.g.cttl.reverse().duration(.35);
- }
- }
- // NEW FEATURE v2.0 videoPreview & autoPlayVideos
- if( ls.g.pausedByVideo == true ){
- ls.g.pausedByVideo = false;
- ls.g.autoSlideshow = ls.g.originalAutoSlideshow;
- ls.g.curLayer.find('iframe[src*="youtube.com"], iframe[src*="youtu.be"], iframe[src*="player.vimeo"]').each(function(){
- $(this).parent().find('.ls-vpcontainer').fadeIn(ls.g.v.fi,function(){
- $(this).parent().find('iframe').attr('src','');
- });
- });
- ls.g.curLayer.find('video, audio').each(function(){
- this.pause();
- });
- }
- $(el).find('iframe[src*="youtube.com"], iframe[src*="youtu.be"], iframe[src*="player.vimeo"]').each(function(){
- // Clearing videoTimeouts
- clearTimeout( $(this).data( 'videoTimer') );
- });
- clearTimeout( ls.g.slideTimer );
- ls.g.nextLayerIndex = num;
- ls.g.nextLayer = $(el).find('.ls-slide:eq('+(ls.g.nextLayerIndex-1)+')');
- // BUGFIX v1.6 fixed wrong directions of animations if navigating by slidebuttons
- if( !prevnext ){
- if( ls.g.curLayerIndex < ls.g.nextLayerIndex ){
- ls.g.prevNext = 'next';
- }else{
- ls.g.prevNext = 'prev';
- }
- }
- // Added timeOut to wait for the fade animation of videoPreview image...
- var timeOut = 0;
- if( $(el).find('iframe[src*="youtube.com"], iframe[src*="youtu.be"], iframe[src*="player.vimeo"]').length > 0 ){
- timeOut = ls.g.v.fi;
- }
- if( typeof ls.g.nextLayer[0] !== 'undefined' ){
- ls.imgPreload(ls.g.nextLayer,function(){
- ls.animate();
- });
- }
- };
- // Preloading images
- ls.imgPreload = function(layer,callback){
- ls.g.isLoading = true;
- // Showing slider for the first time
- if( ls.g.showSlider ){
- $(el).css({
- visibility : 'visible'
- });
- }
- // If image preload is on
- if( ls.o.imgPreload ){
- var preImages = [];
- var preloaded = 0;
- // NEW FEATURE v1.8 Preloading background images of layers
- if( layer.css('background-image') != 'none' && layer.css('background-image').indexOf('url') != -1 && !layer.hasClass('ls-preloaded') && !layer.hasClass('ls-not-preloaded') ){
- var bgi = layer.css('background-image');
- bgi = bgi.match(/url\((.*)\)/)[1].replace(/"/gi, '');
- preImages[preImages.length] = [bgi, layer];
- }
- // Images inside layers
- layer.find('img:not(.ls-preloaded, .ls-not-preloaded)').each(function(){
- // NEW FEATURE v5.0.0 Lazy-load
- if( ls.o.lazyLoad === true ){
- $(this).attr('src',$(this).data('src'));
- }
- preImages[preImages.length] = [$(this).attr('src'), $(this)];
- });
- // Background images inside layers
- layer.find('*').each(function(){
- // BUGFIX v1.7 fixed preload bug with sublayers with gradient backgrounds
- if( $(this).css('background-image') != 'none' && $(this).css('background-image').indexOf('url') != -1 && !$(this).hasClass('ls-preloaded') && !$(this).hasClass('ls-not-preloaded') ){
- var bgi = $(this).css('background-image');
- bgi = bgi.match(/url\((.*)\)/)[1].replace(/"/gi, '');
- preImages[preImages.length] = [bgi, $(this)];
- }
- });
- // BUGFIX v1.7 if there are no images in a layer, calling the callback function
- if(preImages.length == 0){
- $('.ls-thumbnail-wrapper, .ls-nav-next, .ls-nav-prev, .ls-bottom-nav-wrapper').css({
- visibility : 'visible'
- });
- ls.makeResponsive(layer, callback);
- }else{
- // NEW FEATURE v4.0 Showing loading indicator
- if( ls.g.ie78 ){
- ls.g.li.css('display','block');
- }else{
- // BUGIFX v4.1.3 Adding delay to the showing of the loading indicator
- ls.g.li.delay(400).fadeIn(300);
- }
- var afterImgLoad = function(){
- // NEW FEATURE v4.0 Hiding loading indicator
- ls.g.li.stop(true,true).css({
- display: 'none'
- });
- $('.ls-thumbnail-wrapper, .ls-nav-next, .ls-nav-prev, .ls-bottom-nav-wrapper').css({
- visibility : 'visible'
- });
- // We love you so much IE... -.-
- if( navigator.userAgent.indexOf('Trident/7') !== -1 || ls.g.ie78 ){
- setTimeout(function(){
- ls.makeResponsive(layer, callback);
- },50);
- }else{
- ls.makeResponsive(layer, callback);
- }
- };
- for(x=0;x<preImages.length;x++){
- $('<img>').data('el',preImages[x]).load(function(){
- $(this).data('el')[1].addClass('ls-preloaded');
- if( ++preloaded == preImages.length ){
- afterImgLoad();
- }
- }).error(function(){
- var imgURL = $(this).data('el')[0].substring($(this).data('el')[0].lastIndexOf("/") + 1, $(this).data('el')[0].length);
- if( window.console ){
- console.log('LayerSlider error:\r\n\r\nIt seems like the URL of the image or background image "'+imgURL+'" is pointing to a wrong location and it cannot be loaded. Please check the URLs of all your images used in the slider.');
- }else{
- alert('LayerSlider error:\r\n\r\nIt seems like the URL of the image or background image "'+imgURL+'" is pointing to a wrong location and it cannot be loaded. Please check the URLs of all your images used in the slider.');
- }
- $(this).addClass('ls-not-preloaded');
- // IMPROVEMENT v5.2.0 The slider should not stop even if an image cannot be loaded
- if( ++preloaded == preImages.length ){
- afterImgLoad();
- }
- }).attr('src',preImages[x][0]);
- }
- }
- }else{
- $('.ls-thumbnail-wrapper, .ls-nav-next, .ls-nav-prev, .ls-bottom-nav-wrapper').css({
- visibility : 'visible'
- });
- ls.makeResponsive(layer, callback);
- }
- };
- // NEW FEATURE v1.7 making the slider responsive
- ls.makeResponsive = function(layer, callback ){
- layer.css({
- visibility: 'hidden',
- display: 'block'
- });
- if( ls.g.showShadow ){
- ls.g.showShadow();
- }
- ls.resizeSlider();
- if( ls.o.thumbnailNavigation == 'always' ){
- ls.resizeThumb();
- }
- layer.children().each(function(){
- var sl = $(this);
- // positioning
- var ol = sl.data('originalLeft') ? sl.data('originalLeft') : '0';
- var ot = sl.data('originalTop') ? sl.data('originalTop') : '0';
- if( sl.is('a') && sl.children().length > 0 ){
- sl.css({
- display : 'block'
- });
- sl = sl.children();
- }
- var ow = 'auto';
- var oh = 'auto';
- if( sl.data('originalWidth') ){
- if( typeof sl.data('originalWidth') == 'number' ){
- ow = parseInt( sl.data('originalWidth') ) * ls.g.ratio;
- }else if( sl.data('originalWidth').indexOf('%') != -1 ){
- ow = sl.data('originalWidth');
- }
- }
- if( sl.data('originalHeight') ){
- if( typeof sl.data('originalHeight') == 'number' ){
- oh = parseInt( sl.data('originalHeight') ) * ls.g.ratio;
- }else if( sl.data('originalHeight').indexOf('%') != -1 ){
- oh = sl.data('originalHeight');
- }
- }
- // padding
- var opl = sl.data('originalPaddingLeft') ? parseInt( sl.data('originalPaddingLeft') ) * ls.g.ratio : 0;
- var opr = sl.data('originalPaddingRight') ? parseInt( sl.data('originalPaddingRight') ) * ls.g.ratio : 0;
- var opt = sl.data('originalPaddingTop') ? parseInt( sl.data('originalPaddingTop') ) * ls.g.ratio : 0;
- var opb = sl.data('originalPaddingBottom') ? parseInt( sl.data('originalPaddingBottom') ) * ls.g.ratio : 0;
- // border
- var obl = sl.data('originalBorderLeft') ? parseInt( sl.data('originalBorderLeft') ) * ls.g.ratio : 0;
- var obr = sl.data('originalBorderRight') ? parseInt( sl.data('originalBorderRight') ) * ls.g.ratio : 0;
- var obt = sl.data('originalBorderTop') ? parseInt( sl.data('originalBorderTop') ) * ls.g.ratio : 0;
- var obb = sl.data('originalBorderBottom') ? parseInt( sl.data('originalBorderBottom') ) * ls.g.ratio : 0;
- // font
- var ofs = sl.data('originalFontSize');
- var olh = sl.data('originalLineHeight');
- // NEW FEATURE v3.0 added "normal" responsive mode with image and font resizing
- // NEW FEATURE v3.5 added responsiveUnder
- if( ls.g.responsiveMode || ls.o.responsiveUnder > 0 ){
- if( sl.is('img') && !sl.hasClass('ls-bg') && sl.attr('src') ){
- sl.css({
- width: 'auto',
- height: 'auto'
- });
- // IMPROVEMENT v4.5.0 Images can have now starting width / height
- if( ( ow == 0 || ow == 'auto' ) && typeof oh == 'number' && oh != 0 ){
- ow = ( oh / sl.height() ) * sl.width();
- }
- if( ( oh == 0 || oh == 'auto' ) && typeof ow == 'number' && ow != 0 ){
- oh = ( ow / sl.width() ) * sl.height();
- }
- if( ow == 'auto'){
- ow = sl.width() * ls.g.ratio;
- }
- if( oh == 'auto'){
- oh = sl.height() * ls.g.ratio;
- }
- sl.css({
- width : ow,
- height : oh
- });
- }
- if( !sl.is('img') ){
- sl.css({
- width : ow,
- height : oh,
- 'font-size' : parseInt(ofs) * ls.g.ratio +'px',
- 'line-height' : parseInt(olh) * ls.g.ratio + 'px'
- });
- }
- if( sl.is('div') && sl.find('iframe').data('videoSrc') ){
- var videoIframe = sl.find('iframe');
- videoIframe.attr('width', parseInt( videoIframe.data('originalWidth') ) * ls.g.ratio ).attr('height', parseInt( videoIframe.data('originalHeight') ) * ls.g.ratio );
- sl.css({
- width : parseInt( videoIframe.data('originalWidth') ) * ls.g.ratio,
- height : parseInt( videoIframe.data('originalHeight') ) * ls.g.ratio
- });
- }
- sl.css({
- padding : opt + 'px ' + opr + 'px ' + opb + 'px ' + opl + 'px ',
- borderLeftWidth : obl + 'px',
- borderRightWidth : obr + 'px',
- borderTopWidth : obt + 'px',
- borderBottomWidth : obb + 'px'
- });
- }
- // If it is NOT a bg sublayer
- if( !sl.hasClass('ls-bg') ){
- var sl2 = sl;
- if( sl.parent().is('a') ){
- sl = sl.parent();
- }
- // NEW FEATURE v3.5 sublayerContainer
- var slC = 0;
- if( ls.o.layersContainer ){
- slC = ls.o.layersContainer > 0 ? ( ls.g.sliderWidth() - ls.o.layersContainer ) / 2 : 0;
- }else if( ls.o.sublayerContainer ){
- slC = ls.o.sublayerContainer > 0 ? ( ls.g.sliderWidth() - ls.o.sublayerContainer ) / 2 : 0;
- }
- slC = slC < 0 ? 0 : slC;
- // (RE)positioning sublayer (left property)
- if( ol.indexOf('%') != -1 ){
- sl.css({
- left : ls.g.sliderWidth() / 100 * parseInt(ol) - sl2.width() / 2 - opl - obl
- });
- }else if( slC > 0 || ls.g.responsiveMode || ls.o.responsiveUnder > 0 ){
- sl.css({
- left : slC + parseInt(ol) * ls.g.ratio
- });
- }
- // (RE)positioning sublayer (top property)
- if( ot.indexOf('%') != -1 ){
- sl.css({
- top : ls.g.sliderHeight() / 100 * parseInt(ot) - sl2.height() / 2 - opt - obt
- });
- }else if( ls.g.responsiveMode || ls.o.responsiveUnder > 0 ){
- sl.css({
- top : parseInt(ot) * ls.g.ratio
- });
- }
- }else{
- var inner = $(el).find('.ls-inner');
- sl.css({
- width : 'auto',
- height : 'auto'
- });
- ow = sl.width();
- oh = sl.height();
- // IMPROVEMENT v4.5.0 Resizing smaller background images in full width mode as well to fill the whole slide
- var or = ls.g.ratio;
- if( ls.g.sliderOriginalWidth.indexOf('%') != -1 ){
- if( ls.g.sliderWidth() > ow ){
- or = ls.g.sliderWidth() / ow;
- if( ls.g.sliderHeight() > oh * or ){
- or = ls.g.sliderHeight() / oh;
- }
- }else if( ls.g.sliderHeight() > oh ){
- or = ls.g.sliderHeight() / oh;
- if( ls.g.sliderWidth() > ow * or ){
- or = ls.g.sliderWidth() / ow;
- }
- }
- }
- sl.css({
- width : ow * or,
- height : oh * or,
- marginLeft : inner.width() / 2 - ow * or / 2,
- marginTop : inner.height() / 2 - oh * or / 2
- });
- // $('#w2 span:eq(0)').html( ( inner.width() / 2 ) - Math.round( ow * or / 2 ) );
- }
- });
- layer.css({
- display: 'none',
- visibility: 'visible'
- });
- // Resizing shadow
- ls.resizeShadow();
- callback();
- $(this).dequeue();
- };
- // Resizing shadow
- ls.resizeShadow = function(){
- if( ls.g.shadowImg ){
- var resizeShadow = function(){
- if( ls.g.shadowImg.height() > 0 ){
- if( ls.g.shadowBtmMod > 0 ){
- ls.g.shadow.css({
- height: ls.g.shadowImg.height() / 2
- });
- }else{
- ls.g.shadow.css({
- height: ls.g.shadowImg.height(),
- marginTop: - ls.g.shadowImg.height() / 2
- });
- }
- }else{
- setTimeout(function(){
- resizeShadow();
- },50);
- }
- };
- resizeShadow();
- }
- };
- // Resizing the slider
- ls.resizeSlider = function(){
- if( ls.o.responsiveUnder > 0 ){
- if( $(window).width() < ls.o.responsiveUnder ){
- ls.g.responsiveMode = true;
- ls.g.sliderOriginalWidth = ls.o.responsiveUnder + 'px';
- }else{
- ls.g.responsiveMode = false;
- ls.g.sliderOriginalWidth = ls.g.sliderOriginalWidthRU;
- ls.g.ratio = 1;
- }
- }
- // BUGFIX 5.3.0 Fixed full-width resize issue
- if( $(el).closest('.ls-wp-fullwidth-container').length ){
- $(el).closest('.ls-wp-fullwidth-helper').css({
- width : $(window).width()
- });
- }
- // NEW FEATURE v3.0 added "normal" responsive mode with image and font resizing
- if( ls.g.responsiveMode ){
- var parent = $(el).parent();
- // NEW FEATURE v5.5.0 Added fullScreen mode
- if( ls.o.fullScreen === true ){
- $(el).css({
- width : '100%',
- height : $(window).height()
- });
- }else{
- // BUGFIX v4.0 there is no need to subtract the values of the left and right paddings of the container element!
- $(el).css({
- width : parent.width() - parseInt($(el).css('padding-left')) - parseInt($(el).css('padding-right'))
- });
- ls.g.ratio = $(el).width() / parseInt( ls.g.sliderOriginalWidth );
- $(el).css({
- height : ls.g.ratio * parseInt( ls.g.sliderOriginalHeight )
- });
- }
- }else{
- ls.g.ratio = 1;
- $(el).css({
- width : ls.g.sliderOriginalWidth,
- height : ls.g.sliderOriginalHeight
- });
- }
- // WP fullWidth mode (originally forceResponsive mode)
- if( $(el).closest('.ls-wp-fullwidth-container').length ){
- $(el).closest('.ls-wp-fullwidth-helper').css({
- height : $(el).outerHeight(true)
- });
- $(el).closest('.ls-wp-fullwidth-container').css({
- height : $(el).outerHeight(true)
- });
- $(el).closest('.ls-wp-fullwidth-helper').css({
- width : $(window).width(),
- left : - $(el).closest('.ls-wp-fullwidth-container').offset().left
- });
- if( ls.g.sliderOriginalWidth.indexOf('%') != -1 ){
- var percentWidth = parseInt( ls.g.sliderOriginalWidth );
- var newWidth = $('body').width() / 100 * percentWidth - ( $(el).outerWidth() - $(el).width() );
- $(el).width( newWidth );
- }
- }
- $(el).find('.ls-inner, .ls-lt-container').css({
- width : ls.g.sliderWidth(),
- height : ls.g.sliderHeight()
- });
- // BUGFIX v2.0 fixed width problem if firstSlide is not 1
- if( ls.g.curLayer && ls.g.nextLayer ){
- ls.g.curLayer.css({
- width : ls.g.sliderWidth(),
- height : ls.g.sliderHeight()
- });
- ls.g.nextLayer.css({
- width : ls.g.sliderWidth(),
- height : ls.g.sliderHeight()
- });
- }else{
- $(el).find('.ls-slide').css({
- width : ls.g.sliderWidth(),
- height : ls.g.sliderHeight()
- });
- }
- };
- // NEW FEATURE v3.0 added responsive yourLogo
- ls.resizeYourLogo = function(){
- ls.g.yourLogo.css({
- width : ls.g.yourLogo.data( 'originalWidth' ) * ls.g.ratio,
- height : ls.g.yourLogo.data( 'originalHeight' ) * ls.g.ratio
- });
- if( ls.g.ie78 ){
- ls.g.yourLogo.css('display','block');
- }else{
- ls.g.yourLogo.fadeIn(300);
- }
- var oL = oR = oT = oB = 'auto';
- if( ls.g.yourLogo.data( 'originalLeft' ) && ls.g.yourLogo.data( 'originalLeft' ).indexOf('%') != -1 ){
- oL = ls.g.sliderWidth() / 100 * parseInt( ls.g.yourLogo.data( 'originalLeft' ) ) - ls.g.yourLogo.width() / 2 + parseInt( $(el).css('padding-left') );
- }else{
- oL = parseInt( ls.g.yourLogo.data( 'originalLeft' ) ) * ls.g.ratio;
- }
- if( ls.g.yourLogo.data( 'originalRight' ) && ls.g.yourLogo.data( 'originalRight' ).indexOf('%') != -1 ){
- oR = ls.g.sliderWidth() / 100 * parseInt( ls.g.yourLogo.data( 'originalRight' ) ) - ls.g.yourLogo.width() / 2 + parseInt( $(el).css('padding-right') );
- }else{
- oR = parseInt( ls.g.yourLogo.data( 'originalRight' ) ) * ls.g.ratio;
- }
- if( ls.g.yourLogo.data( 'originalTop' ) && ls.g.yourLogo.data( 'originalTop' ).indexOf('%') != -1 ){
- oT = ls.g.sliderHeight() / 100 * parseInt( ls.g.yourLogo.data( 'originalTop' ) ) - ls.g.yourLogo.height() / 2 + parseInt( $(el).css('padding-top') );
- }else{
- oT = parseInt( ls.g.yourLogo.data( 'originalTop' ) ) * ls.g.ratio;
- }
- if( ls.g.yourLogo.data( 'originalBottom' ) && ls.g.yourLogo.data( 'originalBottom' ).indexOf('%') != -1 ){
- oB = ls.g.sliderHeight() / 100 * parseInt( ls.g.yourLogo.data( 'originalBottom' ) ) - ls.g.yourLogo.height() / 2 + parseInt( $(el).css('padding-bottom') );
- }else{
- oB = parseInt( ls.g.yourLogo.data( 'originalBottom' ) ) * ls.g.ratio;
- }
- ls.g.yourLogo.css({
- left : oL,
- right : oR,
- top : oT,
- bottom : oB
- });
- };
- // NEW FEATURE v3.5 thumbnailNavigation ('always')
- // Resizing thumbnails
- ls.resizeThumb = function(){
- ls.bottomNavSizeHelper('on');
- var sliderW = ls.g.sliderOriginalWidth.indexOf('%') == -1 ? parseInt( ls.g.sliderOriginalWidth ) : ls.g.sliderWidth();
- $(el).find('.ls-thumbnail-slide a').css({
- width : parseInt( ls.o.tnWidth * ls.g.ratio ),
- height : parseInt( ls.o.tnHeight * ls.g.ratio )
- });
- $(el).find('.ls-thumbnail-slide a:last').css({
- margin: 0
- });
- $(el).find('.ls-thumbnail-slide').css({
- height : parseInt( ls.o.tnHeight * ls.g.ratio )
- });
- var tn = $(el).find('.ls-thumbnail');
- var originalWidth = ls.o.tnContainerWidth.indexOf('%') == -1 ? parseInt( ls.o.tnContainerWidth ) : parseInt( sliderW / 100 * parseInt( ls.o.tnContainerWidth ) );
- tn.css({
- width : originalWidth * Math.floor( ls.g.ratio * 100 ) / 100
- });
- if( tn.width() > $(el).find('.ls-thumbnail-slide').width() ){
- tn.css({
- width : $(el).find('.ls-thumbnail-slide').width()
- });
- }
- ls.bottomNavSizeHelper('off');
- };
- // Changing thumbnails
- ls.changeThumb = function(index){
- var curIndex = index ? index : ls.g.nextLayerIndex;
- $(el).find('.ls-thumbnail-slide a:not(.ls-thumb-'+curIndex+')').children().each(function(){
- $(this).removeClass('ls-thumb-active').stop().fadeTo(750,ls.o.tnInactiveOpacity/100);
- });
- $(el).find('.ls-thumbnail-slide a.ls-thumb-'+curIndex).children().addClass('ls-thumb-active').stop().fadeTo(750,ls.o.tnActiveOpacity/100);
- };
- // Scrolling thumbnails
- ls.scrollThumb = function(){
- if( !$(el).find('.ls-thumbnail-slide-container').hasClass('ls-thumbnail-slide-hover') ){
- var curThumb = $(el).find('.ls-thumb-active').length ? $(el).find('.ls-thumb-active').parent() : false;
- if( curThumb ){
- var thumbCenter = curThumb.position().left + curThumb.width() / 2;
- var mL = $(el).find('.ls-thumbnail-slide-container').width() / 2 - thumbCenter;
- mL = mL < $(el).find('.ls-thumbnail-slide-container').width() - $(el).find('.ls-thumbnail-slide').width() ? $(el).find('.ls-thumbnail-slide-container').width() - $(el).find('.ls-thumbnail-slide').width() : mL;
- mL = mL > 0 ? 0 : mL;
- $(el).find('.ls-thumbnail-slide').animate({
- marginLeft : mL
- }, 600 );
- }
- }
- };
- // IMPROVEMENT v4.1.3 Changed the working of some Thumbnail and Bottom Navigation features
- ls.bottomNavSizeHelper = function(val){
- if( ls.o.hoverBottomNav && !$(el).hasClass('ls-hover') ){
- switch(val){
- case 'on':
- ls.g.thumbsWrapper.css({
- visibility: 'hidden',
- display: 'block'
- });
- break;
- case 'off':
- ls.g.thumbsWrapper.css({
- visibility: 'visible',
- display: 'none'
- });
- break;
- }
- }
- };
- // Animating layers and sublayers
- ls.animate = function(){
- /* GLOBAL (used by both old and new transitions ) */
- // Changing variables
- // BUGFIX v4.6.0 If there is only one layer, there is no need to set ls.g.isAnimating to true
- if( $(el).find('.ls-slide').length > 1 ){
- ls.g.isAnimating = true;
- }
- ls.g.isLoading = false;
- // Clearing timeouts
- clearTimeout( ls.g.slideTimer );
- clearTimeout( ls.g.changeTimer );
- ls.g.stopLayer = ls.g.curLayer;
- // Calling cbAnimStart callback function
- ls.o.cbAnimStart(ls.g);
- // NEW FEATURE v3.5 thumbnailNavigation ('always')
- if( ls.o.thumbnailNavigation == 'always' ){
- // ChangeThumb
- ls.changeThumb();
- // ScrollThumb
- if( !('ontouchstart' in window) ){
- ls.scrollThumb();
- }
- }
- // Adding .ls-animating class to next layer
- ls.g.nextLayer.addClass('ls-animating');
- /* OLD layer transitions (version 3.x) */
- // Setting position and styling of current and next layers
- var curLayerLeft = curLayerRight = curLayerTop = curLayerBottom = nextLayerLeft = nextLayerRight = nextLayerTop = nextLayerBottom = layerMarginLeft = layerMarginRight = layerMarginTop = layerMarginBottom = 'auto';
- var curLayerWidth = nextLayerWidth = ls.g.sliderWidth();
- var curLayerHeight = nextLayerHeight = ls.g.sliderHeight();
- // Calculating direction
- var prevOrNext = ls.g.prevNext == 'prev' ? ls.g.curLayer : ls.g.nextLayer;
- var chooseDirection = prevOrNext.data('slidedirection') ? prevOrNext.data('slidedirection') : ls.o.slideDirection;
- // Setting the direction of sliding
- var slideDirection = ls.g.slideDirections[ls.g.prevNext][chooseDirection];
- if( slideDirection == 'left' || slideDirection == 'right' ){
- curLayerWidth = curLayerTop = nextLayerWidth = nextLayerTop = 0;
- layerMarginTop = 0;
- }
- if( slideDirection == 'top' || slideDirection == 'bottom' ){
- curLayerHeight = curLayerLeft = nextLayerHeight = nextLayerLeft = 0;
- layerMarginLeft = 0;
- }
- switch(slideDirection){
- case 'left':
- curLayerRight = nextLayerLeft = 0;
- layerMarginLeft = -ls.g.sliderWidth();
- break;
- case 'right':
- curLayerLeft = nextLayerRight = 0;
- layerMarginLeft = ls.g.sliderWidth();
- break;
- case 'top':
- curLayerBottom = nextLayerTop = 0;
- layerMarginTop = -ls.g.sliderHeight();
- break;
- case 'bottom':
- curLayerTop = nextLayerBottom = 0;
- layerMarginTop = ls.g.sliderHeight();
- break;
- }
- // Setting start positions and styles of layers
- ls.g.curLayer.css({
- left : curLayerLeft,
- right : curLayerRight,
- top : curLayerTop,
- bottom : curLayerBottom
- });
- ls.g.nextLayer.css({
- width : nextLayerWidth,
- height : nextLayerHeight,
- left : nextLayerLeft,
- right : nextLayerRight,
- top : nextLayerTop,
- bottom : nextLayerBottom
- });
- // Creating variables for the OLD transitions of CURRENT LAYER
- // BUGFIX v1.6 fixed some wrong parameters of current layer
- // BUGFIX v1.7 fixed using of delayout of current layer
- var curDelay = ls.g.curLayer.data('delayout') ? parseInt(ls.g.curLayer.data('delayout')) : ls.o.delayOut;
- var curDuration = ls.g.curLayer.data('durationout') ? parseInt(ls.g.curLayer.data('durationout')) : ls.o.durationOut;
- var curEasing = ls.g.curLayer.data('easingout') ? ls.g.curLayer.data('easingout') : ls.o.easingOut;
- // Creating variables for the OLD transitions of NEXT LAYER
- var nextDelay = ls.g.nextLayer.data('delayin') ? parseInt(ls.g.nextLayer.data('delayin')) : ls.o.delayIn;
- var nextDuration = ls.g.nextLayer.data('durationin') ? parseInt(ls.g.nextLayer.data('durationin')) : ls.o.durationIn;
- // BUGFIX v5.2.0 duration cannot be 0
- if( nextDuration === 0 ){ nextDuration = 1 }
- var nextEasing = ls.g.nextLayer.data('easingin') ? ls.g.nextLayer.data('easingin') : ls.o.easingIn;
- var curLayer = function(){
- // BUGFIX v1.6 added an additional delaytime to current layer to fix the '1px gap' bug
- // BUGFIX v3.0 modified from curDuration / 80 to curDuration / 15
- ls.g.curLayer.delay( curDelay + curDuration / 15).animate({
- width : curLayerWidth,
- height : curLayerHeight
- }, curDuration, curEasing,function(){
- curLayerCallback();
- });
- };
- var curLayerCallback = function(){
- // Stopping current sublayer animations if needed (they are not visible at this point).
- ls.g.stopLayer.find(' > *[class*="ls-l"]').each(function(){
- if( $(this).data('tr') ){
- $(this).data('tr').kill();
- }
- $(this).css({
- filter: 'none'
- });
- });
- // Setting current layer
- ls.g.curLayer = ls.g.nextLayer;
- // IMPROVEMENT v5.2.0 added prevLayerIndex and fixing curLayerIndex (nextLayerIndex is the same as curLayerIndex because the slider doesn't know at this point which slide will be the next)
- ls.g.prevLayerIndex = ls.g.curLayerIndex;
- ls.g.curLayerIndex = ls.g.nextLayerIndex;
- ls.o.cbAnimStop(ls.g);
- // NEW FEATURE v5.0.0 Lazy-load (preloading here the images of the next layer)
- if( ls.o.imgPreload && ls.o.lazyLoad ){
- var preLayerIndex = ls.g.curLayerIndex == ls.g.layersNum ? 1 : ls.g.curLayerIndex + 1;
- $(el).find('.ls-slide').eq(preLayerIndex-1).find('img:not(.ls-preloaded)').each(function(){
- $(this).load(function(){
- $(this).addClass('ls-preloaded');
- }).error(function(){
- var imgURL = $(this).data('src').substring($(this).data('src').lastIndexOf("/") + 1, $(this).data('src').length);
- if( window.console ){
- console('LayerSlider error:\r\n\r\nIt seems like the URL of the image or background image "'+imgURL+'" is pointing to a wrong location and it cannot be loaded. Please check the URLs of all your images used in the slider.');
- }else{
- alert('LayerSlider error:\r\n\r\nIt seems like the URL of the image or background image "'+imgURL+'" is pointing to a wrong location and it cannot be loaded. Please check the URLs of all your images used in the slider.');
- }
- $(this).addClass('ls-not-preloaded');
- }).attr('src', $(this).data('src'));
- });
- }
- // Changing some css classes
- $(el).find('.ls-slide').removeClass('ls-active');
- $(el).find('.ls-slide:eq(' + ( ls.g.curLayerIndex - 1 ) + ')').addClass('ls-active').removeClass('ls-animating');
- $(el).find('.ls-bottom-slidebuttons a').removeClass('ls-nav-active');
- $(el).find('.ls-bottom-slidebuttons a:eq('+( ls.g.curLayerIndex - 1 )+')').addClass('ls-nav-active');
- // Setting timer if needed
- if( ls.g.autoSlideshow ){
- ls.timer();
- }
- // Changing variables
- ls.g.isAnimating = false;
- if( ls.g.resize == true ){
- ls.makeResponsive( ls.g.curLayer, function(){
- ls.g.resize = false;
- });
- }
- };
- var curSubLayers = function(sublayersDurationOut){
- ls.g.curLayer.find(' > *[class*="ls-l"]').each(function(){
- if( !$(this).data('transitiontype') ){
- ls.transitionType( $(this) );
- }
- // BUGFIX v5.1.0 Removing ls-videohack class before starting transition
- $(this).removeClass('ls-videohack');
- var curSubSlideDir = $(this).data('slidedirection') ? $(this).data('slidedirection') : slideDirection;
- var lml, lmt;
- switch(curSubSlideDir){
- case 'left':
- lml = -ls.g.sliderWidth();
- lmt = 0;
- break;
- case 'right':
- lml = ls.g.sliderWidth();
- lmt = 0;
- break;
- case 'top':
- lmt = -ls.g.sliderHeight();
- lml = 0;
- break;
- case 'bottom':
- lmt = ls.g.sliderHeight();
- lml = 0;
- break;
- case 'fade':
- lmt = 0;
- lml = 0;
- break;
- }
- // NEW FEATURE v1.6 added slideoutdirection to sublayers
- // NEW FEATURES 5.0.0 added axis-free transitions with offsetx and offsety properties
- if( $(this).data('transitiontype') === 'new' ){
- var curSubSlideOutDir = 'new';
- }else{
- var curSubSlideOutDir = $(this).data('slideoutdirection') ? $(this).data('slideoutdirection') : false;
- }
- switch(curSubSlideOutDir){
- case 'left':
- lml = ls.g.sliderWidth();
- lmt = 0;
- break;
- case 'right':
- lml = -ls.g.sliderWidth();
- lmt = 0;
- break;
- case 'top':
- lmt = ls.g.sliderHeight();
- lml = 0;
- break;
- case 'bottom':
- lmt = -ls.g.sliderHeight();
- lml = 0;
- break;
- case 'fade':
- lmt = 0;
- lml = 0;
- break;
- case 'new':
- if( $(this).data('offsetxout') ){
- if( $(this).data('offsetxout') === 'left' ){
- lml = ls.g.sliderWidth();
- }else if( $(this).data('offsetxout') === 'right' ){
- lml = -ls.g.sliderWidth();
- }else{
- lml = -parseInt( $(this).data('offsetxout') );
- }
- }else{
- lml = -ls.lt.offsetXOut;
- }
- if( $(this).data('offsetyout') ){
- if( $(this).data('offsetyout') === 'top' ){
- lmt = ls.g.sliderHeight();
- }else if( $(this).data('offsetyout') === 'bottom' ){
- lmt = -ls.g.sliderHeight();
- }else{
- lmt = -parseInt( $(this).data('offsetyout') );
- }
- }else{
- lmt = -ls.lt.offsetYOut;
- }
- break;
- }
- // NEW FEATURES v4.5.0 Rotating & Scaling sublayers
- // BUGFIX v4.5.5 changing the default value from 0 to 'none' (because of old jQuery, 1.7.2)
- // NEW FEATURES v5.0.0 Added SkewX, SkewY, ScaleX, ScaleY, RotateX & RotateY transitions
- var curSubRotate = curSubRotateX = curSubRotateY = curSubScale = curSubSkewX = curSubSkewY = curSubScaleX = curSubScaleY = 'none';
- // if( !ls.g.ie78 && ls.g.enableCSS3 ){
- curSubRotate = $(this).data('rotateout') ? $(this).data('rotateout') : ls.lt.rotateOut;
- curSubRotateX = $(this).data('rotatexout') ? $(this).data('rotatexout') : ls.lt.rotateXOut;
- curSubRotateY = $(this).data('rotateyout') ? $(this).data('rotateyout') : ls.lt.rotateYOut;
- curSubScale = $(this).data('scaleout') ? $(this).data('scaleout') : ls.lt.scaleOut;
- curSubSkewX = $(this).data('skewxout') ? $(this).data('skewxout') : ls.lt.skewXOut;
- curSubSkewY = $(this).data('skewyout') ? $(this).data('skewyout') : ls.lt.skewYOut;
- if( curSubScale === 1 ){
- curSubScaleX = $(this).data('scalexout') ? $(this).data('scalexout') : ls.lt.scaleXOut;
- curSubScaleY = $(this).data('scaleyout') ? $(this).data('scaleyout') : ls.lt.scaleYOut;
- }else{
- curSubScaleX = curSubScaleY = curSubScale;
- }
- var too = $(this).data('transformoriginout') ? $(this).data('transformoriginout').split(' ') : ls.lt.transformOriginOut;
- for(var t =0;t<too.length;t++){
- if( too[t].indexOf('%') === -1 && too[t].indexOf('left') !== -1 && too[t].indexOf('right') !== -1 && too[t].indexOf('top') !== -1 && too[t].indexOf('bottom') !== -1 ){
- too[t] = '' + parseInt( too[t] ) * ls.g.ratio + 'px';
- }
- }
- var curSubTransformOrigin = too.join(' ');
- var curSubPerspective = $(this).data('perspectiveout') ? $(this).data('perspectiveout') : ls.lt.perspectiveOut;
- // }
- // IMPROVEMENT v4.0 Distance (P.level): -1
- var endLeft = parseInt( $(this).css('left') );
- var endTop = parseInt( $(this).css('top') );
- var curSubPLevel = parseInt( $(this).attr('class').split('ls-l')[1] );
- var wh = $(this).outerWidth() > $(this).outerHeight() ? $(this).outerWidth() : $(this).outerHeight();
- var modX = parseInt( curSubRotate ) === 0 ? $(this).outerWidth() : wh;
- var modY = parseInt( curSubRotate ) === 0 ? $(this).outerHeight() : wh;
- if( ( curSubPLevel === -1 && curSubSlideOutDir !== 'new' ) || ( $(this).data('offsetxout') === 'left' || $(this).data('offsetxout') === 'right' ) ){
- if( lml < 0 ){
- lml = - ( ls.g.sliderWidth() - endLeft + ( curSubScaleX / 2 - .5 ) * modX + 100 );
- }else if( lml > 0 ){
- lml = endLeft + ( curSubScaleX / 2 + .5 ) * modX + 100;
- }
- }else{
- lml = lml * ls.g.ratio;
- }
- if( ( curSubPLevel === -1 && curSubSlideOutDir !== 'new' ) || ( $(this).data('offsetyout') === 'top' || $(this).data('offsetyout') === 'bottom' ) ){
- if( lmt < 0 ){
- lmt = - ( ls.g.sliderHeight() - endTop + ( curSubScaleY / 2 - .5 ) * modY + 100 );
- }else if( lmt > 0 ){
- lmt = endTop + ( curSubScaleY / 2 + .5 ) * modY + 100;
- }
- }else{
- lmt = lmt * ls.g.ratio;
- }
- if( curSubPLevel === -1 || curSubSlideOutDir === 'new' ){
- var curSubPar = 1;
- }else{
- var curSubParMod = ls.g.curLayer.data('parallaxout') ? parseInt(ls.g.curLayer.data('parallaxout')) : ls.o.parallaxOut;
- var curSubPar = curSubPLevel * curSubParMod;
- }
- if( $(this).data('transitiontype') === 'new' ){
- var deO = ls.lt.delayOut;
- var duO = ls.lt.durationOut;
- var eO = ls.lt.easingOut;
- }else{
- var deO = ls.o.delayOut;
- var duO = ls.o.durationOut;
- var eO = ls.o.easingOut;
- }
- var curSubDelay = $(this).data('delayout') ? parseInt($(this).data('delayout')) : deO;
- var curSubTime = $(this).data('durationout') ? parseInt($(this).data('durationout')) : duO;
- // BUGFIX v5.2.0 duration cannot be 0
- if( curSubTime === 0 ){ curSubTime = 1 }
- var curSubEasing = $(this).data('easingout') ? $(this).data('easingout') : eO;
- // On new layer transitions, all sublayer will be slide / fade out in 500ms without any delays
- if(sublayersDurationOut){
- curSubDelay = 0;
- curSubTime = sublayersDurationOut;
- // curSubEasing = 'easeInExpo';
- }
- // Clearing showUntilTimers
- if( $(this).data('showUntilTimer') ){
- clearTimeout( $(this).data('showUntilTimer') );
- }
- var css = {
- visibility : 'hidden'
- };
- var el = $(this);
- var transition = {
- rotation : curSubRotate,
- rotationX : curSubRotateX,
- rotationY : curSubRotateY,
- skewX : curSubSkewX,
- skewY : curSubSkewY,
- scaleX : curSubScaleX,
- scaleY : curSubScaleY,
- x : -lml * curSubPar,
- y : -lmt * curSubPar,
- delay : curSubDelay/1000,
- ease : lsConvertEasing( curSubEasing ),
- onComplete : function(){
- el.css( css );
- }
- };
- if( curSubSlideOutDir == 'fade' || ( !curSubSlideOutDir && curSubSlideDir === 'fade' ) || ( $(this).data('fadeout') !== 'false' && $(this).data('transitiontype') === 'new' ) ){
- transition['opacity'] = 0;
- css['opacity'] = $(this).data( 'originalOpacity' );
- }
- if( $(this).data('tr') ){
- $(this).data('tr').kill();
- }
- TweenLite.set( $(this)[0],{
- transformOrigin : curSubTransformOrigin,
- transformPerspective : curSubPerspective
- });
- $(this).data('tr', TweenLite.to($(this)[0],curSubTime/1000,transition) );
- // $(this).stop(true,false).delay( curSubDelay ).animate( transition, curSubTime, curSubEasing,function(){
- // $(this).css( css );
- // });
- });
- };
- var nextLayer = function(){
- ls.g.nextLayer.delay( curDelay + nextDelay ).animate({
- width : ls.g.sliderWidth(),
- height : ls.g.sliderHeight()
- }, nextDuration, nextEasing );
- };
- var nextSubLayers = function(){
- if( ls.g.totalDuration ){
- curDelay = 0;
- }
- // Needed for the Timeline
- if( typeof ls.o.cbTimeLineStart === 'function' ){
- ls.o.cbTimeLineStart(ls.g, curDelay+nextDelay );
- }
- ls.g.nextLayer.find(' > *[class*="ls-l"]').each(function(){
- // Replacing global parameters with unique if need
- // NEW FEATURES 5.0.0 added axis-free transitions with offsetx and offsety properties
- if( !$(this).data('transitiontype') ){
- ls.transitionType( $(this) );
- }
- if( $(this).data('transitiontype') === 'new' ){
- var nextSubSlideDir = 'new';
- }else{
- var nextSubSlideDir = $(this).data('slidedirection') ? $(this).data('slidedirection') : slideDirection;
- }
- var lml, lmt;
- switch(nextSubSlideDir){
- case 'left':
- lml = -ls.g.sliderWidth();
- lmt = 0;
- break;
- case 'right':
- lml = ls.g.sliderWidth();
- lmt = 0;
- break;
- case 'top':
- lmt = -ls.g.sliderHeight();
- lml = 0;
- break;
- case 'bottom':
- lmt = ls.g.sliderHeight();
- lml = 0;
- break;
- case 'fade':
- lmt = 0;
- lml = 0;
- break;
- case 'new':
- if( $(this).data('offsetxin') ){
- if( $(this).data('offsetxin') === 'left' ){
- lml = -ls.g.sliderWidth();
- }else if( $(this).data('offsetxin') === 'right' ){
- lml = ls.g.sliderWidth();
- }else{
- lml = parseInt( $(this).data('offsetxin') );
- }
- }else{
- lml = ls.lt.offsetXIn;
- }
- if( $(this).data('offsetyin') ){
- if( $(this).data('offsetyin') === 'top' ){
- lmt = -ls.g.sliderHeight();
- }else if( $(this).data('offsetyin') === 'bottom' ){
- lmt = ls.g.sliderHeight();
- }else{
- lmt = parseInt( $(this).data('offsetyin') );
- }
- }else{
- lmt = ls.lt.offsetYIn;
- }
- break;
- }
- // NEW FEATURE v4.5.0 Rotating & Scaling sublayers
- // BUGFIX v4.5.5 changing the default value from 0 to 'none' (because of old jQuery, 1.7.2)
- // NEW FEATURES v5.0.0 Added SkewX, SkewY, ScaleX, ScaleY, RotateX & RotateY transitions
- var nextSubRotate = nextSubRotateX = nextSubRotateY = nextSubScale = nextSubSkewX = nextSubSkewY = nextSubScaleX = nextSubScaleY = 'none';
- // if( !ls.g.ie78 && ls.g.enableCSS3 ){
- nextSubRotate = $(this).data('rotatein') ? $(this).data('rotatein') : ls.lt.rotateIn;
- nextSubRotateX = $(this).data('rotatexin') ? $(this).data('rotatexin') : ls.lt.rotateXIn;
- nextSubRotateY = $(this).data('rotateyin') ? $(this).data('rotateyin') : ls.lt.rotateYIn;
- nextSubScale = $(this).data('scalein') ? $(this).data('scalein') : ls.lt.scaleIn;
- nextSubSkewX = $(this).data('skewxin') ? $(this).data('skewxin') : ls.lt.skewXIn;
- nextSubSkewY = $(this).data('skewyin') ? $(this).data('skewyin') : ls.lt.skewYIn;
- if( nextSubScale === 1 ){
- nextSubScaleX = $(this).data('scalexin') ? $(this).data('scalexin') : ls.lt.scaleXIn;
- nextSubScaleY = $(this).data('scaleyin') ? $(this).data('scaleyin') : ls.lt.scaleYIn;
- }else{
- nextSubScaleX = nextSubScaleY = nextSubScale;
- }
- var toi = $(this).data('transformoriginin') ? $(this).data('transformoriginin').split(' ') : ls.lt.transformOriginIn;
- for(var t =0;t<toi.length;t++){
- if( toi[t].indexOf('%') === -1 && toi[t].indexOf('left') !== -1 && toi[t].indexOf('right') !== -1 && toi[t].indexOf('top') !== -1 && toi[t].indexOf('bottom') !== -1 ){
- toi[t] = '' + parseInt( toi[t] ) * ls.g.ratio + 'px';
- }
- }
- var nextSubTransformOrigin = toi.join(' ');
- var nextSubPerspective = $(this).data('perspectivein') ? $(this).data('perspectivein') : ls.lt.perspectiveIn;
- // }
- // IMPROVEMENT v4.0 Distance (P.level): -1
- var endLeft = parseInt( $(this).css('left') );
- var endTop = parseInt( $(this).css('top') );
- var nextSubPLevel = parseInt( $(this).attr('class').split('ls-l')[1] );
- // BUGFIX v5.0.1 Fixed the starting position of layers with percentage value of width
- if( $(this)[0].style.width.indexOf('%') !== -1 ){
- $(this).css({
- width: ls.g.sliderWidth() / 100 * parseInt( $(this)[0].style.width )
- });
- }
- var wh = $(this).outerWidth() > $(this).outerHeight() ? $(this).outerWidth() : $(this).outerHeight();
- var modX = parseInt( nextSubRotate ) === 0 ? $(this).outerWidth() : wh;
- var modY = parseInt( nextSubRotate ) === 0 ? $(this).outerHeight() : wh;
- // console.log( modX, $(this).outerWidth(), $(this).width(), $(this).height(), $(this)[0].style.width, $(this).outerHeight(), wh );
- if( ( nextSubPLevel === -1 && nextSubSlideDir !== 'new' ) || ( $(this).data('offsetxin') === 'left' || $(this).data('offsetxin') === 'right' ) ){
- if( lml < 0 ){
- lml = - ( endLeft + ( nextSubScaleX / 2 + .5 ) * modX + 100 );
- }else if( lml > 0 ){
- lml = ls.g.sliderWidth() - endLeft + ( nextSubScaleX / 2 - .5 ) * modX + 100;
- }
- }else{
- lml = lml * ls.g.ratio;
- }
- if( ( nextSubPLevel === -1 && nextSubSlideDir !== 'new' ) || ( $(this).data('offsetyin') === 'top' || $(this).data('offsetyin') === 'bottom' ) ){
- if( lmt < 0 ){
- lmt = - ( endTop + ( nextSubScaleY / 2 + .5 ) * modY + 100 );
- }else if( lmt > 0 ){
- lmt = ls.g.sliderHeight() - endTop + ( nextSubScaleY / 2 - .5 ) * modY + 100;
- }
- }else{
- lmt = lmt * ls.g.ratio;
- }
- if( nextSubPLevel === -1 || nextSubSlideDir === 'new'){
- var nextSubPar = 1;
- }else{
- var nextSubParMod = ls.g.nextLayer.data('parallaxin') ? parseInt(ls.g.nextLayer.data('parallaxin')) : ls.o.parallaxIn;
- var nextSubPar = nextSubPLevel * nextSubParMod;
- }
- if( $(this).data('transitiontype') === 'new' ){
- var deI = ls.lt.delayIn;
- var duI = ls.lt.durationIn;
- var eI = ls.lt.easingIn;
- }else{
- var deI = ls.o.delayIn;
- var duI = ls.o.durationIn;
- var eI = ls.o.easingIn;
- }
- var nextSubDelay = $(this).data('delayin') ? parseInt($(this).data('delayin')) : deI;
- var nextSubTime = $(this).data('durationin') ? parseInt($(this).data('durationin')) : duI;
- var nextSubEasing = $(this).data('easingin') ? $(this).data('easingin') : eI;
- var cursub = $(this);
- var nextSubCallback = function(){
- // BUGFIX v5.1.0 Removing transition property from video layers
- if( cursub.hasClass('ls-video-layer') ){
- cursub.addClass('ls-videohack');
- }
- // NEW FEATURE v2.0 autoPlayVideos
- if( ls.o.autoPlayVideos == true ){
- // YouTube & Vimeo videos
- cursub.find('.ls-videopreview').click();
- // HTML5 videos
- cursub.find('video, audio').each(function(){
- if( typeof $(this)[0].currentTime !== 0){
- $(this)[0].currentTime = 0;
- }
- $(this).click();
- });
- }
- // NEW FEATURE v3.0 showUntil sublayers
- // IMPROVEMENT v5.2.0 video layers with auto play will skip showuntil feature
- if( ( !cursub.hasClass('ls-video-layer') || ( cursub.hasClass('ls-video-layer') && ls.o.autoPlayVideos === false ) ) && cursub.data('showuntil') > 0 ){
- // IMPROVEMENT v4.5.0 sublayerShowUntil will be called anly if necessary
- cursub.data('showUntilTimer', setTimeout(function(){
- ls.sublayerShowUntil( cursub );
- }, cursub.data('showuntil') ));
- }
- };
- $(this).css({
- marginLeft : 0,
- marginTop : 0
- });
- var css = {
- scaleX : nextSubScaleX,
- scaleY : nextSubScaleY,
- skewX : nextSubSkewX,
- skewY : nextSubSkewY,
- rotation : nextSubRotate,
- rotationX : nextSubRotateX,
- rotationY : nextSubRotateY,
- visibility : 'visible',
- x : lml * nextSubPar,
- y : lmt * nextSubPar
- };
- var transition = {
- rotation : 0,
- rotationX : 0,
- rotationY : 0,
- skewX : 0,
- skewY : 0,
- scaleX : 1,
- scaleY : 1,
- ease : lsConvertEasing( nextSubEasing ),
- delay : nextSubDelay/1000,
- x : 0,
- y : 0,
- onComplete : function(){
- nextSubCallback();
- }
- };
- if( nextSubSlideDir.indexOf('fade') != -1 || ( $(this).data('fadein') !== 'false' && $(this).data('transitiontype') === 'new' ) ){
- css['opacity'] = 0;
- transition['opacity'] = $(this).data( 'originalOpacity' );
- }
- // $(this).css( css );
- // $(this).stop().delay( curDelay + nextDelay + nextSubDelay ).animate( transition, nextSubTime, nextSubEasing, function(){
- // if( ls.g.ie78 & $(this).data( 'originalOpacity') === 1 ){
- // $(this).get(0).style.removeAttribute('filter');
- // }
- // nextSubCallback();
- // });
- if( $(this).data('tr') ){
- $(this).data('tr').kill();
- }
- TweenLite.set( $(this)[0],{
- transformPerspective : nextSubPerspective,
- transformOrigin : nextSubTransformOrigin
- });
- $(this).data('tr', TweenLite.fromTo($(this)[0],nextSubTime/1000,css,transition) );
- });
- };
- /* NEW FEATURE v4.0 2D & 3D Layer Transitions */
- // Selecting ONE transition (random)
- // If the browser doesn't support CSS3 3D, 2D fallback mode will be used instead
- // In this case, if user didn't specify any 2D transitions, a random will be selected
- var selectTransition = function(){
- // if the browser supports CSS3 3D and user specified at least one of 3D transitions
- if( lsSupport3D( $(el) ) && ( ls.g.nextLayer.data('transition3d') || ls.g.nextLayer.data('customtransition3d') ) ){
- if( ls.g.nextLayer.data('transition3d') && ls.g.nextLayer.data('customtransition3d') ){
- var rnd = Math.floor(Math.random() * 2);
- var rndT = [['3d',ls.g.nextLayer.data('transition3d')],['custom3d',ls.g.nextLayer.data('customtransition3d')]];
- getTransitionType(rndT[rnd][0],rndT[rnd][1]);
- }else if( ls.g.nextLayer.data('transition3d') ){
- getTransitionType('3d',ls.g.nextLayer.data('transition3d'));
- }else{
- getTransitionType('custom3d',ls.g.nextLayer.data('customtransition3d'));
- }
- }else{
- if( ls.g.nextLayer.data('transition2d') && ls.g.nextLayer.data('customtransition2d') ){
- var rnd = Math.floor(Math.random() * 2);
- var rndT = [['2d',ls.g.nextLayer.data('transition2d')],['custom2d',ls.g.nextLayer.data('customtransition2d')]];
- getTransitionType(rndT[rnd][0],rndT[rnd][1]);
- }else if( ls.g.nextLayer.data('transition2d') ){
- getTransitionType('2d',ls.g.nextLayer.data('transition2d'));
- }else if( ls.g.nextLayer.data('customtransition2d') ){
- getTransitionType('custom2d',ls.g.nextLayer.data('customtransition2d'));
- }else{
- getTransitionType('2d','1');
- }
- }
- };
- // Needed by the demo page
- var selectCustomTransition = function(){
- if( lsSupport3D( $(el) ) && LSCustomTransition.indexOf('3d') != -1 ){
- getTransitionType('3d',LSCustomTransition.split(':')[1]);
- }else{
- if( LSCustomTransition.indexOf('3d') != -1){
- getTransitionType('2d','all');
- }else{
- getTransitionType('2d',LSCustomTransition.split(':')[1]);
- }
- }
- };
- // Choosing layer transition type (2d, 3d, or both)
- var getTransitionType = function(type,transitionlist){
- var tr = type.indexOf('custom') == -1 ? ls.t : ls.ct;
- var tt = '3d', lt, number;
- if( type.indexOf('2d') != -1 ){
- tt = '2d';
- }
- if( transitionlist.indexOf('last') != -1 ){
- number = tr['t'+tt].length-1;
- lt = 'last';
- }else if( transitionlist.indexOf('all') != -1){
- number = Math.floor(Math.random() * lsCountProp(tr['t'+tt]) );
- lt = 'random from all';
- }else{
- var t = transitionlist.split(',');
- var l = t.length;
- number = parseInt(t[Math.floor(Math.random() * l)])-1;
- lt = 'random from specified';
- }
- slideTransition(tt,tr['t'+tt][number]);
- // $('.test').html('Originals:<br><br>t3D: '+ls.g.nextLayer.data('transition3d')+'<br>t2D: '+ls.g.nextLayer.data('transition2d')+'<br>custom3D: '+ls.g.nextLayer.data('customtransition3d')+'<br>custom2D: '+ls.g.nextLayer.data('customtransition2d')+'<br><br>Support 3D: '+lsSupport3D( $(el) )+'<br><br>Selected transition:<br><br>Type: '+type+' ('+lt+')<br>Number in transition list: '+(number+1)+'<br>Name of the transition: '+tr['t'+tt][number]['name']);
- };
- // The slideTransition function
- var slideTransition = function(type,prop){
- var inner = $(el).find('.ls-inner');
- // sublayersDurationOut - for future usage
- var sublayersDurationOut = ls.g.curLayer.find('*[class*="ls-l"]').length > 0 ? 1000 : 0;
- // Detecting a carousel transition - Transition name must have the carousel string
- var carousel = prop.name.toLowerCase().indexOf('carousel') == -1 ? false : true;
- // Detecting a crossfade transition - Transition name must have the crossfad string
- var crossfade = prop.name.toLowerCase().indexOf('crossfad') == -1 ? false : true;
- // Calculating cols and rows
- var cols = typeof(prop.cols);
- var rows = typeof(prop.rows);
- switch( cols ){
- case 'number':
- cols = prop.cols;
- break;
- case 'string':
- cols = Math.floor( Math.random() * ( parseInt( prop.cols.split(',')[1] ) - parseInt( prop.cols.split(',')[0] ) + 1) ) + parseInt( prop.cols.split(',')[0] );
- break;
- default:
- cols = Math.floor( Math.random() * ( prop.cols[1] - prop.cols[0] + 1) ) + prop.cols[0];
- break;
- }
- switch( rows ){
- case 'number':
- rows = prop.rows;
- break;
- case 'string':
- rows = Math.floor( Math.random() * ( parseInt( prop.rows.split(',')[1] ) - parseInt( prop.rows.split(',')[0] ) + 1) ) + parseInt( prop.rows.split(',')[0] );
- break;
- default:
- rows = Math.floor( Math.random() * ( prop.rows[1] - prop.rows[0] + 1) ) + prop.rows[0];
- break;
- }
- if( ( ls.g.isMobile() == true && ls.o.optimizeForMobile == true ) || ( ls.g.ie78 && ls.o.optimizeForIE78 == true ) ){
- // Reducing cols in three steps
- if( cols >= 15 ){
- cols = 7;
- }else if( cols >= 5 ){
- cols = 4;
- }else if( cols >= 4 ){
- cols = 3;
- }else if( cols > 2 ){
- cols = 2;
- }
- // Reducing rows in three steps
- if( rows >= 15 ){
- rows = 7;
- }else if( rows >= 5 ){
- rows = 4;
- }else if( rows >= 4 ){
- rows = 3;
- }else if( rows > 2 ){
- rows = 2;
- }
- // Reducing more :)
- if( rows > 2 && cols > 2 ){
- rows = 2;
- if( cols > 4){
- cols = 4;
- }
- }
- }
- var tileWidth = $(el).find('.ls-inner').width() / cols;
- var tileHeight = $(el).find('.ls-inner').height() / rows;
- // Creating HTML markup for layer transitions
- if( !ls.g.ltContainer ){
- ls.g.ltContainer = $('<div>').addClass('ls-lt-container').addClass('ls-overflow-hidden').css({
- width : inner.width(),
- height : inner.height()
- }).prependTo( inner );
- }else{
- ls.g.ltContainer.stop(true,true).empty().css({
- display : 'block',
- width : inner.width(),
- height : inner.height()
- });
- }
- // Setting size
- var restW = inner.width() - Math.floor(tileWidth) * cols;
- var restH = inner.height() - Math.floor(tileHeight) * rows;
- var tileSequence = [];
- // IMPROVEMENT v4.1.3 Array-randomizer is now a local function
- // Randomize array function
- tileSequence.randomize = function() {
- var i = this.length, j, tempi, tempj;
- if ( i == 0 ) return false;
- while ( --i ) {
- j = Math.floor( Math.random() * ( i + 1 ) );
- tempi = this[i];
- tempj = this[j];
- this[i] = tempj;
- this[j] = tempi;
- }
- return this;
- }
- for(var ts=0; ts<cols * rows; ts++){
- tileSequence.push(ts);
- }
- // Setting the sequences of the transition
- switch( prop.tile.sequence ){
- case 'reverse':
- tileSequence.reverse();
- break;
- case 'col-forward':
- tileSequence = lsOrderArray(rows,cols,'forward');
- break;
- case 'col-reverse':
- tileSequence = lsOrderArray(rows,cols,'reverse');
- break;
- case 'random':
- tileSequence.randomize();
- break;
- }
- var curBG = ls.g.curLayer.find('.ls-bg');
- var nextBG = ls.g.nextLayer.find('.ls-bg');
- // IMPROVEMENT v4.6.0 If current and next layer both have no BG, skipping the slide transition
- if( curBG.length == 0 && nextBG.length == 0 ){
- type = '2d';
- prop = $.extend(true, {}, ls.t['t2d'][0]);
- prop.transition.duration = 1
- prop.tile.delay = 0;
- }
- if( type == '3d' ){
- ls.g.totalDuration = ((cols * rows) - 1) * prop.tile.delay;
- var stepDuration = 0;
- if( prop.before && prop.before.duration ){
- stepDuration += prop.before.duration;
- }
- if( prop.animation && prop.animation.duration ){
- stepDuration += prop.animation.duration;
- }
- if( prop.after && prop.after.duration ){
- stepDuration += prop.after.duration;
- }
- ls.g.totalDuration += stepDuration;
- var stepDelay = 0;
- if( prop.before && prop.before.delay ){
- stepDelay += prop.before.delay;
- }
- if( prop.animation && prop.animation.delay ){
- stepDelay += prop.animation.delay;
- }
- if( prop.after && prop.after.delay ){
- stepDelay += prop.after.delay;
- }
- ls.g.totalDuration += stepDelay;
- }else{
- ls.g.totalDuration = ((cols * rows) - 1) * prop.tile.delay + prop.transition.duration;
- // IMPROVEMENT v4.5.0 Creating separated containers for current and next tiles
- ls.g.curTiles = $('<div>').addClass('ls-curtiles').appendTo( ls.g.ltContainer );
- ls.g.nextTiles = $('<div>').addClass('ls-nexttiles').appendTo( ls.g.ltContainer );
- }
- var pn = ls.g.prevNext;
- // Creating cuboids for 3d or tiles for 2d transition (cols * rows)
- for(var tiles=0; tiles < cols * rows; tiles++){
- var rW = tiles%cols == 0 ? restW : 0;
- var rH = tiles > (rows-1)*cols-1 ? restH : 0;
- var tile = $('<div>').addClass('ls-lt-tile').css({
- width : Math.floor(tileWidth) + rW,
- height : Math.floor(tileHeight) + rH
- }).appendTo( ls.g.ltContainer );
- var curTile, nextTile;
- // If current transition is a 3d transition
- if( type == '3d' ){
- tile.addClass('ls-3d-container');
- var W = Math.floor(tileWidth) + rW;
- var H = Math.floor(tileHeight) + rH;
- var D;
- if( prop.animation.direction == 'horizontal' ){
- if( Math.abs(prop.animation.transition.rotateY) > 90 && prop.tile.depth != 'large' ){
- D = Math.floor( W / 7 ) + rW;
- }else{
- D = W;
- }
- }else{
- if( Math.abs(prop.animation.transition.rotateX) > 90 && prop.tile.depth != 'large' ){
- D = Math.floor( H / 7 ) + rH;
- }else{
- D = H;
- }
- }
- var W2 = W/2;
- var H2 = H/2;
- var D2 = D/2;
- // createCuboids function will append cuboids with their style settings to their container
- // BUGFIX v5.1.2 the prefixless transform must be the last property
- var createCuboids = function(c,a,w,h,tx,ty,tz,rx,ry){
- $('<div>').addClass(c).css({
- width: w,
- height: h,
- '-o-transform': 'translate3d('+tx+'px, '+ty+'px, '+tz+'px) rotateX('+rx+'deg) rotateY('+ry+'deg) rotateZ(0deg) scale3d(1, 1, 1)',
- '-ms-transform': 'translate3d('+tx+'px, '+ty+'px, '+tz+'px) rotateX('+rx+'deg) rotateY('+ry+'deg) rotateZ(0deg) scale3d(1, 1, 1)',
- '-moz-transform': 'translate3d('+tx+'px, '+ty+'px, '+tz+'px) rotateX('+rx+'deg) rotateY('+ry+'deg) rotateZ(0deg) scale3d(1, 1, 1)',
- '-webkit-transform': 'translate3d('+tx+'px, '+ty+'px, '+tz+'px) rotateX('+rx+'deg) rotateY('+ry+'deg) rotateZ(0deg) scale3d(1, 1, 1)',
- 'transform': 'translate3d('+tx+'px, '+ty+'px, '+tz+'px) rotateX('+rx+'deg) rotateY('+ry+'deg) rotateZ(0deg) scale3d(1, 1, 1)'
- }).appendTo(a);
- };
- createCuboids('ls-3d-box',tile,0,0,0,0,-D2,0,0);
- var backRotX = 0
- var topRotX = 0
- var bottomRotX = 0
- if( prop.animation.direction == 'vertical' && Math.abs(prop.animation.transition.rotateX) > 90){
- createCuboids('ls-3d-back',tile.find('.ls-3d-box'),W,H,-W2,-H2,-D2,180,0);
- }else{
- createCuboids('ls-3d-back',tile.find('.ls-3d-box'),W,H,-W2,-H2,-D2,0,180);
- }
- createCuboids('ls-3d-bottom',tile.find('.ls-3d-box'),W,D,-W2,H2-D2,0,-90,0);
- createCuboids('ls-3d-top',tile.find('.ls-3d-box'),W,D,-W2,-H2-D2,0,90,0);
- createCuboids('ls-3d-front',tile.find('.ls-3d-box'),W,H,-W2,-H2,D2,0,0);
- createCuboids('ls-3d-left',tile.find('.ls-3d-box'),D,H,-W2-D2,-H2,0,0,-90);
- createCuboids('ls-3d-right',tile.find('.ls-3d-box'),D,H,W2-D2,-H2,0,0,90);
- curTile = tile.find('.ls-3d-front');
- if( prop.animation.direction == 'horizontal' ){
- if( Math.abs(prop.animation.transition.rotateY) > 90 ){
- nextTile = tile.find('.ls-3d-back');
- }else{
- nextTile = tile.find('.ls-3d-left, .ls-3d-right');
- }
- }else{
- if( Math.abs(prop.animation.transition.rotateX) > 90 ){
- nextTile = tile.find('.ls-3d-back');
- }else{
- nextTile = tile.find('.ls-3d-top, .ls-3d-bottom');
- }
- }
- // Animating cuboids
- var curCubDelay = tileSequence[tiles] * prop.tile.delay;
- var curCub = ls.g.ltContainer.find('.ls-3d-container:eq('+tiles+') .ls-3d-box');
- var tl = new TimelineLite();
- if( prop.before && prop.before.transition ){
- prop.before.transition.delay = prop.before.transition.delay ? (prop.before.transition.delay + curCubDelay)/1000 : curCubDelay/1000;
- tl.to( curCub[0],prop.before.duration/1000,lsConvertTransition( prop.before.transition, prop.before.easing ));
- }else{
- prop.animation.transition.delay = prop.animation.transition.delay ? (prop.animation.transition.delay + curCubDelay)/1000 : curCubDelay/1000;
- }
- tl.to( curCub[0],prop.animation.duration/1000,lsConvertTransition( prop.animation.transition, prop.animation.easing ));
- if( prop.after ){
- if( !prop.after.transition ){
- prop.after.transition = {};
- }
- tl.to( curCub[0],prop.after.duration/1000,lsConvertTransition( prop.after.transition, prop.after.easing, 'after' ));
- }
- }else{
- // If current transition is a 2d transition
- var T1 = L1 = T2 = L2 = 'auto';
- var O1 = O2 = 1;
- if( prop.transition.direction == 'random' ){
- var dir = ['top','bottom','right','left'];
- var direction = dir[Math.floor(Math.random() * dir.length )];
- }else{
- var direction = prop.transition.direction;
- }
- // IMPROVEMENT v4.5.0 Reversing animation directions if slider is moving backwards
- if( prop.name.toLowerCase().indexOf('mirror') != -1 && tiles%2 == 0 ){
- if( pn == 'prev' ){
- pn = 'next';
- }else{
- pn = 'prev';
- }
- }
- if( pn == 'prev' ){
- switch( direction ){
- case 'top':
- direction = 'bottom';
- break;
- case 'bottom':
- direction = 'top';
- break;
- case 'left':
- direction = 'right';
- break;
- case 'right':
- direction = 'left';
- break;
- case 'topleft':
- direction = 'bottomright';
- break;
- case 'topright':
- direction = 'bottomleft';
- break;
- case 'bottomleft':
- direction = 'topright';
- break;
- case 'bottomright':
- direction = 'topleft';
- break;
- }
- }
- switch( direction ){
- case 'top':
- T1 = T2 = -tile.height();
- L1 = L2 = 0;
- break;
- case 'bottom':
- T1 = T2 = tile.height();
- L1 = L2 = 0;
- break;
- case 'left':
- T1 = T2 = 0;
- L1 = L2 = -tile.width();
- break;
- case 'right':
- T1 = T2 = 0;
- L1 = L2 = tile.width();
- break;
- case 'topleft':
- T1 = tile.height();
- T2 = 0;
- L1 = tile.width();
- L2 = 0;
- break;
- case 'topright':
- T1 = tile.height();
- T2 = 0;
- L1 = - tile.width();
- L2 = 0;
- break;
- case 'bottomleft':
- T1 = - tile.height();
- T2 = 0;
- L1 = tile.width();
- L2 = 0;
- break;
- case 'bottomright':
- T1 = - tile.height();
- T2 = 0;
- L1 = - tile.width();
- L2 = 0;
- break;
- }
- ls.g.scale2D = prop.transition.scale ? prop.transition.scale : 1;
- if( carousel == true && ls.g.scale2D != 1 ){
- T1 = T1 / 2;
- T2 = T2 / 2;
- L1 = L1 / 2;
- L2 = L2 / 2;
- }
- // Selecting the type of the transition
- // if( !ls.g.ie78 || ( ls.g.ie78 && !ls.o.optimizeForIE78 ) || ( ls.g.ie78 && ls.o.optimizeForIE78 == true && prop.name.toLowerCase().indexOf('crossfade') != -1 ) ){
- switch( prop.transition.type ){
- case 'fade':
- T1 = T2 = L1 = L2 = 0;
- O1 = 0;
- O2 = 1;
- break;
- case 'mixed':
- O1 = 0;
- O2 = 1;
- if( ls.g.scale2D == 1 ){
- T2 = L2 = 0;
- }
- break;
- }
- // }
- // IMPROVEMENT v4.5.0 Implemented Rotation and Scale into 2D Transitions
- if((( prop.transition.rotate || prop.transition.rotateX || prop.transition.rotateY ) || ls.g.scale2D != 1 ) && !ls.g.ie78 && prop.transition.type != 'slide' ){
- tile.css({
- overflow : 'visible'
- });
- }else{
- tile.css({
- overflow : 'hidden'
- });
- }
- if( carousel == true){
- ls.g.curTiles.css({
- overflow: 'visible'
- });
- }else{
- ls.g.curTiles.css({
- overflow: 'hidden'
- });
- }
- if( crossfade == true || prop.transition.type == 'slide' || carousel == true ){
- var tileInCur = tile.appendTo( ls.g.curTiles );
- var tileInNext = tile.clone().appendTo( ls.g.nextTiles );
- curTile = $('<div>').addClass('ls-curtile').appendTo( tileInCur );
- }else{
- var tileInNext = tile.appendTo( ls.g.nextTiles );
- }
- nextTile = $('<div>').addClass('ls-nexttile').appendTo( tileInNext ).css({
- top : -T1,
- left : -L1,
- dispay : 'block',
- opacity : O1
- });
- // Animating tiles
- var curTileDelay = tileSequence[tiles] * prop.tile.delay;
- // IMPROVEMENT v4.5.0 Implemented various types of rotations into 2D Transitions
- var r = prop.transition.rotate ? prop.transition.rotate : 0;
- var rX = prop.transition.rotateX ? prop.transition.rotateX : 0;
- var rY = prop.transition.rotateY ? prop.transition.rotateY : 0;
- // Reversing rotation degrees if slider is moving backwards
- if( pn == 'prev' ){
- r = -r;
- rX = -rX;
- rY = -rY;
- }
- TweenLite.fromTo(nextTile[0],prop.transition.duration/1000,{
- rotation : r,
- rotationX : rX,
- rotationY : rY,
- scale : ls.g.scale2D
- },{
- delay : curTileDelay / 1000,
- top : 0,
- left : 0,
- opacity : O2,
- rotation : 0,
- rotationX : 0,
- rotationY : 0,
- scale : 1,
- ease : lsConvertEasing( prop.transition.easing )
- });
- // IMPROVEMENT v5.0.0 Smart crossfading for semi-transparent PNG and different size JPG backgrounds
- if(
- crossfade == true && (
- nextBG.length < 1 || (
- nextBG.length > 0 && (
- nextBG.attr('src').toLowerCase().indexOf('png') != -1 || (
- nextBG.width() < ls.g.sliderWidth() || nextBG.height() < ls.g.sliderHeight()
- )
- )
- )
- )
- ){
- TweenLite.to(curTile[0],prop.transition.duration/1000,{
- delay : curTileDelay / 1000,
- opacity : 0,
- ease : lsConvertEasing( prop.transition.easing )
- });
- }
- if( ( prop.transition.type == 'slide' || carousel == true ) && prop.name.toLowerCase().indexOf('mirror') == -1 ){
- var r2 = 0;
- if( r != 0 ){
- r2 = -r;
- }
- TweenLite.to(curTile[0],prop.transition.duration/1000,{
- delay : curTileDelay / 1000,
- top : T2,
- left : L2,
- rotation : r2,
- scale : ls.g.scale2D,
- opacity: O1,
- ease : lsConvertEasing( prop.transition.easing )
- });
- }
- }
- // Appending the background images of current and next layers into the tiles on both of 2d & 3d transitions
- // BUGFIX v5.0.0 added Math.floor to prevent '1px bug' under Safari and Firefox
- if( curBG.length ){
- if( type == '3d' || ( type == '2d' && ( crossfade == true || prop.transition.type == 'slide' || carousel == true ) ) ){
- curTile.append($('<img>').attr('src', curBG.attr('src')).css({
- width : curBG[0].style.width,
- height : curBG[0].style.height,
- marginLeft : parseFloat(curBG.css('margin-left')) - parseFloat(tile.position().left),
- marginTop : parseFloat(curBG.css('margin-top')) - parseFloat(tile.position().top)
- }));
- }else if( ls.g.curTiles.children().length == 0 ){
- ls.g.curTiles.append($('<img>').attr('src', curBG.attr('src')).css({
- width : curBG[0].style.width,
- height : curBG[0].style.height,
- marginLeft : parseFloat(curBG.css('margin-left')),
- marginTop : parseFloat(curBG.css('margin-top'))
- }));
- }
- }
- if( nextBG.length ){
- nextTile.append( $('<img>').attr('src', nextBG.attr('src')).css({
- width : nextBG[0].style.width,
- height : nextBG[0].style.height,
- marginLeft : parseFloat(nextBG.css('margin-left')) - parseFloat(tile.position().left),
- marginTop : parseFloat(nextBG.css('margin-top')) - parseFloat(tile.position().top)
- }));
- }
- }
- // Storing current and next layer elements in a local variable (needed by setTimeout functions in some cases)
- var curLayer = ls.g.curLayer;
- var nextLayer = ls.g.nextLayer;
- // Hiding the background image of the current and next layers (immediately)
- setTimeout(function(){
- curLayer.find('.ls-bg').css({
- visibility : 'hidden'
- });
- },50);
- nextLayer.find('.ls-bg').css({
- visibility : 'hidden'
- });
- ls.g.ltContainer.removeClass('ls-overflow-hidden');
- // Sliding out the sublayers of the current layer
- // (immediately, delay out and duration out properties are not applied to the sublayers during the new layer transitions)
- curSubLayers(sublayersDurationOut);
- // BUGFIX v5.2.0 prevents background flickering in some cases
- if( sublayersDurationOut === 0 ){
- sublayersDurationOut = 10;
- }
- // Hiding current layer after its sublayers animated out
- setTimeout(function(){
- curLayer.css({
- width: 0
- });
- }, sublayersDurationOut );
- // Calculating next layer delay
- var nextLayerTimeShift = parseInt(nextLayer.data('timeshift')) ? parseInt(nextLayer.data('timeshift')) : 0;
- var nextLayerDelay = ls.g.totalDuration + nextLayerTimeShift > 0 ? ls.g.totalDuration + nextLayerTimeShift : 0;
- // Showing next layer and sliding sublayers of the next layer in after the current layer transition ended
- setTimeout(function(){
- if( ls.g.resize == true ){
- ls.g.ltContainer.empty();
- curLayer.removeClass('ls-active');
- ls.makeResponsive( nextLayer, function(){
- ls.g.resize = false;
- });
- }
- // Sliding in / fading in the sublayers of the next layer
- nextSubLayers();
- // NEW FEATURE v4.6.0 Hiding background if the next layer has png BG or has no BG
- // BUGFIX v4.6.1 Changed some properties to prevent flickering
- if( nextLayer.find('.ls-bg').length < 1 || ( nextLayer.find('.ls-bg').length > 0 && nextLayer.find('.ls-bg').attr('src').toLowerCase().indexOf('png') != -1 ) ){
- ls.g.ltContainer.delay(350).fadeOut(300,function(){
- $(this).empty().show();
- });
- }
- // Displaying the next layer (immediately)
- nextLayer.css({
- width : ls.g.sliderWidth(),
- height : ls.g.sliderHeight()
- });
- }, nextLayerDelay );
- // BUGFIX v5.0.1 Added a minimal value of ls.g.totalDuration
- // CHANGED in v5.1.0 due to a fading issue in carousel transition
- if( ls.g.totalDuration < 300 ){
- ls.g.totalDuration = 1000;
- }
- // Changing visibility to visible of the background image of the next layer and overflow to hidden of .ls-lt-container after the transition and calling callback function
- setTimeout(function(){
- ls.g.ltContainer.addClass('ls-overflow-hidden');
- nextLayer.addClass('ls-active');
- if( nextLayer.find('.ls-bg').length ){
- nextLayer.find('.ls-bg').css({
- display : 'none',
- visibility : 'visible'
- });
- if( ls.g.ie78 ){
- nextLayer.find('.ls-bg').css('display','block');
- setTimeout(function(){
- curLayerCallback();
- },500);
- }else{
- nextLayer.find('.ls-bg').fadeIn(500, function(){
- curLayerCallback();
- });
- }
- }else{
- curLayerCallback();
- }
- }, ls.g.totalDuration );
- };
- /* Selecting and running the transition */
- // NEW FEATURE v5.2.0 Starts the slider only if it is in the viewport
- var startInViewport = function(){
- ls.g.nextLayer.find(' > *[class*="ls-l"]').each(function(){
- $(this).css({
- visibility : 'hidden'
- });
- });
- ls.g.sliderTop = $(el).offset().top;
- $(window).load(function(){
- setTimeout(function(){
- ls.g.sliderTop = $(el).offset().top;
- }, 20);
- });
- var isSliderInViewport = function(){
- if( $(window).scrollTop() + $(window).height() - ( ls.g.sliderHeight() / 2 ) > ls.g.sliderTop ){
- ls.g.firstSlideAnimated = true;
- if( ls.g.originalAutoStart === true ){
- //ls.g.autoSlideshow = true;
- ls.o.autoStart = true;
- ls.start();
- }
- nextSubLayers();
- }
- }
- $(window).scroll(function(){
- if( !ls.g.firstSlideAnimated ){
- isSliderInViewport();
- }
- });
- isSliderInViewport();
- };
- var tType = ( ( ls.g.nextLayer.data('transition3d') || ls.g.nextLayer.data('transition2d') ) && ls.t ) || ( ( ls.g.nextLayer.data('customtransition3d') || ls.g.nextLayer.data('customtransition2d') ) && ls.ct ) ? 'new' : 'old';
- if( !ls.g.nextLayer.data('transitiontype') ){
- ls.transitionType( ls.g.nextLayer );
- }
- if( ls.g.nextLayer.data('transitiontype') === 'new' ){
- tType = 'new';
- }
- if( ls.o.slideTransition ){
- tType = 'forced';
- }
- if( ls.o.animateFirstSlide && !ls.g.firstSlideAnimated ){
- // BUGFIX v3.5 there is no need to animate 'current' layer if the following conditions are true
- // this fixes the sublayer animation direction bug
- if( ls.g.layersNum == 1 ){
- var curDelay = 0;
- // IMPROVEMENT v4.1.0 Calling cbAnimStop(); function if only one layer is in the slider
- ls.o.cbAnimStop(ls.g);
- }else{
- var nextLayerTimeShift = parseInt(ls.g.nextLayer.data('timeshift')) ? parseInt(ls.g.nextLayer.data('timeshift')) : 0;
- var d = tType == 'new' ? 0 : curDuration;
- ls.g.t5 = setTimeout(function(){
- curLayerCallback();
- }, d + Math.abs(nextLayerTimeShift) );
- }
- // curDelay must be 0!
- ls.g.totalDuration = true;
- // Animating SUBLAYERS of the first layer
- if( ls.o.startInViewport === true ){
- startInViewport();
- }else{
- ls.g.firstSlideAnimated = true;
- nextSubLayers();
- }
- // Displaying the first layer (immediately)
- ls.g.nextLayer.css({
- width : ls.g.sliderWidth(),
- height : ls.g.sliderHeight()
- });
- if( !ls.g.ie78 ){
- ls.g.nextLayer.find('.ls-bg').css({
- display : 'none'
- }).fadeIn(ls.o.sliderFadeInDuration);
- }
- ls.g.isLoading = false;
- }else{
- switch(tType){
- // Old transitions (sliding layers)
- case 'old':
- ls.g.totalDuration = false;
- // BUGFIX v4.5.0 Removing elements from ls-lt-container is necessary
- if( ls.g.ltContainer ){
- ls.g.ltContainer.empty();
- }
- // Animating CURRENT LAYER and its SUBLAYERS
- curLayer();
- curSubLayers();
- // Animating NEXT LAYER and its SUBLAYERS
- nextLayer();
- nextSubLayers();
- break;
- // NEW FEATURE v4.0 2D & 3D Layer Transitions
- case 'new':
- if( typeof LSCustomTransition != 'undefined' ){
- selectCustomTransition();
- }else{
- selectTransition();
- }
- break;
- case 'forced':
- slideTransition( ls.o.slideTransition.type, ls.o.slideTransition.obj );
- break;
- }
- }
- };
- ls.transitionType = function( el ){
- var ttype = el.data('ls') ||
- ( !el.data('ls') &&
- !el.data('slidedelay') &&
- !el.data('slidedirection') &&
- !el.data('slideoutdirection') &&
- !el.data('delayin') &&
- !el.data('delayout') &&
- !el.data('durationin') &&
- !el.data('durationout') &&
- !el.data('showuntil') &&
- !el.data('easingin') &&
- !el.data('easingout') &&
- !el.data('scalein') &&
- !el.data('scaleout') &&
- !el.data('rotatein') &&
- !el.data('rotateout')
- ) ? 'new' : 'old';
- el.data('transitiontype', ttype);
- };
- ls.sublayerShowUntil = function( sublayer ){
- if( !sublayer.data('transitiontype') ){
- ls.transitionType( sublayer );
- }
- // BUGFIX v5.1.0 Removing ls-videohack class before starting transition
- sublayer.removeClass('ls-videohack');
- var prevOrNext = ls.g.curLayer;
- if( ls.g.prevNext != 'prev' && ls.g.nextLayer ){
- prevOrNext = ls.g.nextLayer;
- }
- var chooseDirection = prevOrNext.data('slidedirection') ? prevOrNext.data('slidedirection') : ls.o.slideDirection;
- // Setting the direction of sliding
- var slideDirection = ls.g.slideDirections[ls.g.prevNext][chooseDirection];
- var curSubSlideDir = sublayer.data('slidedirection') ? sublayer.data('slidedirection') : slideDirection;
- var lml, lmt;
- switch(curSubSlideDir){
- case 'left':
- lml = -ls.g.sliderWidth();
- lmt = 0;
- break;
- case 'right':
- lml = ls.g.sliderWidth();
- lmt = 0;
- break;
- case 'top':
- lmt = -ls.g.sliderHeight();
- lml = 0;
- break;
- case 'bottom':
- lmt = ls.g.sliderHeight();
- lml = 0;
- break;
- case 'fade':
- lmt = 0;
- lml = 0;
- break;
- }
- // NEW FEATURE v1.6 added slideoutdirection to sublayers
- // NEW FEATURES 5.0.0 added axis-free transitions with offsetx and offsety properties
- if( sublayer.data('transitiontype') === 'new' ){
- var curSubSlideOutDir = 'new';
- }else{
- var curSubSlideOutDir = sublayer.data('slideoutdirection') ? sublayer.data('slideoutdirection') : false;
- }
- switch(curSubSlideOutDir){
- case 'left':
- lml = ls.g.sliderWidth();
- lmt = 0;
- break;
- case 'right':
- lml = -ls.g.sliderWidth();
- lmt = 0;
- break;
- case 'top':
- lmt = ls.g.sliderHeight();
- lml = 0;
- break;
- case 'bottom':
- lmt = -ls.g.sliderHeight();
- lml = 0;
- break;
- case 'fade':
- lmt = 0;
- lml = 0;
- break;
- case 'new':
- if( sublayer.data('offsetxout') ){
- if( sublayer.data('offsetxout') === 'left' ){
- lml = ls.g.sliderWidth();
- }else if( sublayer.data('offsetxout') === 'right' ){
- lml = -ls.g.sliderWidth();
- }else{
- lml = -parseInt( sublayer.data('offsetxout') );
- }
- }else{
- lml = -ls.lt.offsetXOut;
- }
- if( sublayer.data('offsetyout') ){
- if( sublayer.data('offsetyout') === 'top' ){
- lmt = ls.g.sliderHeight();
- }else if( sublayer.data('offsetyout') === 'bottom' ){
- lmt = -ls.g.sliderHeight();
- }else{
- lmt = -parseInt( sublayer.data('offsetyout') );
- }
- }else{
- lmt = -ls.lt.offsetYOut;
- }
- break;
- }
- // NEW FEATURE v4.5.0 Rotating & Scaling sublayers
- // BUGFIX v4.5.5 changing the default value from 0 to 'none' (because of old jQuery, 1.7.2)
- // NEW FEATURES v5.0.0 Added SkewX, SkewY, ScaleX, ScaleY, RotateX & RotateY transitions
- var curSubRotate = curSubRotateX = curSubRotateY = curSubScale = curSubSkewX = curSubSkewY = curSubScaleX = curSubScaleY = 'none';
- // if( !ls.g.ie78 && ls.g.enableCSS3 ){
- curSubRotate = sublayer.data('rotateout') ? sublayer.data('rotateout') : ls.lt.rotateOut;
- curSubRotateX = sublayer.data('rotatexout') ? sublayer.data('rotatexout') : ls.lt.rotateXOut;
- curSubRotateY = sublayer.data('rotateyout') ? sublayer.data('rotateyout') : ls.lt.rotateYOut;
- curSubScale = sublayer.data('scaleout') ? sublayer.data('scaleout') : ls.lt.scaleOut;
- curSubSkewX = sublayer.data('skewxout') ? sublayer.data('skewxout') : ls.lt.skewXOut;
- curSubSkewY = sublayer.data('skewyout') ? sublayer.data('skewyout') : ls.lt.skewYOut;
- if( curSubScale === 1 ){
- curSubScaleX = sublayer.data('scalexout') ? sublayer.data('scalexout') : ls.lt.scaleXOut;
- curSubScaleY = sublayer.data('scaleyout') ? sublayer.data('scaleyout') : ls.lt.scaleYOut;
- }else{
- curSubScaleX = curSubScaleY = curSubScale;
- }
- var too = sublayer.data('transformoriginout') ? sublayer.data('transformoriginout').split(' ') : ls.lt.transformOriginOut;
- for(var t =0;t<too.length;t++){
- if( too[t].indexOf('%') === -1 && too[t].indexOf('left') !== -1 && too[t].indexOf('right') !== -1 && too[t].indexOf('top') !== -1 && too[t].indexOf('bottom') !== -1 ){
- too[t] = '' + parseInt( too[t] ) * ls.g.ratio + 'px';
- }
- }
- var curSubTransformOrigin = too.join(' ');
- var curSubPerspective = sublayer.data('perspectiveout') ? sublayer.data('perspectiveout') : ls.lt.perspectiveOut;
- // }
- // IMPROVEMENT v4.0 Distance (P.level): -1
- var endLeft = parseInt( sublayer.css('left') );
- var endTop = parseInt( sublayer.css('top') );
- var curSubPLevel = parseInt( sublayer.attr('class').split('ls-l')[1] );
- var wh = sublayer.outerWidth() > sublayer.outerHeight() ? sublayer.outerWidth() : sublayer.outerHeight();
- var modX = parseInt( curSubRotate ) === 0 ? sublayer.outerWidth() : wh;
- var modY = parseInt( curSubRotate ) === 0 ? sublayer.outerHeight() : wh;
- if( ( curSubPLevel === -1 && curSubSlideOutDir !== 'new' ) || ( sublayer.data('offsetxout') === 'left' || sublayer.data('offsetxout') === 'right' ) ){
- if( lml < 0 ){
- lml = - ( ls.g.sliderWidth() - endLeft + ( curSubScaleX / 2 - .5 ) * modX + 100 );
- }else if( lml > 0 ){
- lml = endLeft + ( curSubScaleX / 2 + .5 ) * modX + 100;
- }
- }else{
- lml = lml * ls.g.ratio;
- }
- if( ( curSubPLevel === -1 && curSubSlideOutDir !== 'new' ) || ( sublayer.data('offsetyout') === 'top' || sublayer.data('offsetyout') === 'bottom' ) ){
- if( lmt < 0 ){
- lmt = - ( ls.g.sliderHeight() - endTop + ( curSubScaleY / 2 - .5 ) * modY + 100 );
- }else if( lmt > 0 ){
- lmt = endTop + ( curSubScaleY / 2 + .5 ) * modY + 100;
- }
- }else{
- lmt = lmt * ls.g.ratio;
- }
- if( curSubPLevel === -1 || curSubSlideOutDir === 'new' ){
- var curSubPar = 1;
- }else{
- var curSubParMod = ls.g.curLayer.data('parallaxout') ? parseInt(ls.g.curLayer.data('parallaxout')) : ls.o.parallaxOut;
- var curSubPar = curSubPLevel * curSubParMod;
- }
- // var curSubDelay = parseInt( sublayer.data('showuntil') );
- if( sublayer.data('transitiontype') === 'new' ){
- var duO = ls.lt.durationOut;
- var eO = ls.lt.easingOut;
- }else{
- var duO = ls.o.durationOut;
- var eO = ls.o.easingOut;
- }
- var curSubTime = sublayer.data('durationout') ? parseInt(sublayer.data('durationout')) : duO;
- // BUGFIX v5.2.0 duration cannot be 0
- if( curSubTime === 0 ){ curSubTime = 1 }
- var curSubEasing = sublayer.data('easingout') ? sublayer.data('easingout') : eO;
- var css = {
- visibility : 'hidden'
- };
- var transition = {
- rotation : curSubRotate,
- rotationX : curSubRotateX,
- rotationY : curSubRotateY,
- skewX : curSubSkewX,
- skewY : curSubSkewY,
- scaleX : curSubScaleX,
- scaleY : curSubScaleY,
- x : -lml * curSubPar,
- y : -lmt * curSubPar,
- ease : lsConvertEasing( curSubEasing ),
- onComplete : function(){
- sublayer.css( css );
- }
- };
- if( curSubSlideOutDir == 'fade' || ( !curSubSlideOutDir && curSubSlideDir == 'fade' ) || ( sublayer.data('fadeout') !== 'false' && sublayer.data('transitiontype') === 'new' ) ){
- transition['opacity'] = 0;
- css['opacity'] = sublayer.data( 'originalOpacity' );
- }
- TweenLite.set( sublayer[0],{
- transformPerspective : curSubPerspective,
- transformOrigin : curSubTransformOrigin
- });
- TweenLite.to(sublayer[0],curSubTime/1000,transition);
- // sublayer.stop(true,false).animate( transition, curSubTime, curSubEasing,function(){
- // sublayer.css( css );
- // });
- };
- // v3.6 Improved Debug Mode
- // ls.debug = function(){
- // ls.d = {
- // history : $('<div>'),
- // // adds a H1 (title)
- // aT : function(content){
- // $('<h1>'+content+'</h1>').appendTo( ls.d.history );
- // },
- // // adds an empty UL
- // aeU : function(){
- // $('<ul>').appendTo( ls.d.history );
- // },
- // // adds an UL with a LI
- // aU : function(content){
- // $('<ul><li>'+content+'</li></ul>').appendTo( ls.d.history );
- // },
- // // adds a LI into the last UL
- // aL : function(content){
- // $('<li>'+content+'</li>').appendTo( ls.d.history.find('ul:last') );
- // },
- // // adds an UL into the last LI of the last UL
- // aUU : function(content){
- // $('<ul>').appendTo( ls.d.history.find('ul:last li:last') );
- // },
- // // adds a Function to the first LI inside the last UL
- // aF : function(elem){
- // ls.d.history.find('ul:last li:last').hover(
- // function(){
- // elem.css({
- // border: '2px solid red',
- // marginTop : parseInt( elem.css('margin-top') ) - 2,
- // marginLeft : parseInt( elem.css('margin-left') ) - 2
- // });
- // },
- // function(){
- // elem.css({
- // border: '0px',
- // marginTop : parseInt( elem.css('margin-top') ) + 2,
- // marginLeft : parseInt( elem.css('margin-left') ) + 2
- // });
- // }
- // );
- // },
- // show : function(){
- // if( !$('body').find('.ls-debug-console').length ){
- // if( !ls.d.putData ){
- // // Init code
- // ls.d.aT('Init code');
- // ls.d.aeU();
- // for( var prop in ls.o ){
- // ls.d.aL(prop+': <strong>' + ls.o[prop] + '</strong>');
- // }
- // // ls.d.aL('sliderOriginalWidth: <strong>' + ls.g.sliderOriginalWidth + '</strong>');
- // // ls.d.aL('sliderOriginalHeight: <strong>' + ls.g.sliderOriginalHeight + '</strong>');
- // // Slides, layers data
- // ls.d.aT('LayerSlider Content');
- // ls.d.aU('Number of slides found: <strong>' + $(el).find('.ls-slide').length + '</strong>');
- // $(el).find('.ls-inner .ls-slide, .ls-inner *[class*="ls-l"]').each(function(){
- // if( $(this).hasClass('ls-slide') ){
- // ls.d.aU('<strong>SLIDE ' + ( $(this).index() + 1 ) + '</strong>');
- // ls.d.aUU();
- // ls.d.aL('<strong>SLIDE ' + ( $(this).index() + 1 ) + ' properties:</strong><br><br>');
- // }else{
- // ls.d.aU(' Layer ( '+$(this).prop('tagName')+' )');
- // ls.d.aF($(this));
- // ls.d.aUU();
- // ls.d.aL('<strong>'+$(this).prop('tagName')+' layer properties:</strong><br><br>');
- // ls.d.aL('distance / class: <strong>'+$(this).attr('class')+'</strong>');
- // }
- // $.each( $(this).data(),function(name, val) {
- // ls.d.aL( name +': <strong>' + val + '</strong>');
- // });
- // });
- // ls.d.putData = true;
- // }
- // var dc = $('<div>').addClass('ls-debug-console').css({
- // position: 'fixed',
- // zIndex: '10000000000',
- // top: '10px',
- // right: '10px',
- // width: '300px',
- // padding: '20px',
- // background: 'black',
- // 'border-radius': '10px',
- // height: $(window).height() - 60,
- // opacity: 0,
- // marginRight: 150
- // }).appendTo( $('body') ).css({
- // marginRight: 0,
- // opacity: .9
- // }).click(function(e){
- // if(e.shiftKey && e.altKey){
- // $(this).remove();
- // }
- // });
- // var ds = $('<div>').css({
- // width: '100%',
- // height: '100%',
- // overflow: 'auto'
- // }).appendTo( dc );
- // var dd = $('<div>').css({
- // width: '100%'
- // }).appendTo( ds ).append( ls.d.history );
- // }
- // },
- // hide : function(){
- // $('body').find('.ls-debug-console').remove();
- // }
- // };
- // $(el).click(function(e){
- // if(e.shiftKey && e.altKey){
- // ls.d.show();
- // }
- // });
- // };
- // initializing
- ls.load();
- };
- var lsConvertEasing = function( e ){
- var t;
- if( e.toLowerCase().indexOf('swing') !== -1 || e.toLowerCase().indexOf('linear') !== -1 ){
- t = Linear.easeNone;
- }else if( e.toLowerCase().indexOf('easeinout') !== -1 ){
- var ee = e.toLowerCase().split('easeinout')[1];
- t = window[ee.charAt(0).toUpperCase() + ee.slice(1)].easeInOut;
- }else if( e.toLowerCase().indexOf('easeout') !== -1 ){
- var ee = e.toLowerCase().split('easeout')[1];
- t = window[ee.charAt(0).toUpperCase() + ee.slice(1)].easeOut;
- }else if( e.toLowerCase().indexOf('easein') !== -1 ){
- var ee = e.toLowerCase().split('easein')[1];
- t = window[ee.charAt(0).toUpperCase() + ee.slice(1)].easeIn;
- }
- return t;
- };
- var lsConvertTransition = function( t, e, type, undef ){
- if( typeof e === 'undefined' ){
- var e = 'easeInOutQuart';
- }
- var tt = {};
- if( t.rotate !== undef ){
- tt.rotation = t.rotate;
- }
- if( t.rotateY !== undef ){
- tt.rotationY = t.rotateY;
- }
- if( t.rotateX !== undef ){
- tt.rotationX = t.rotateX;
- }
- if( type === 'after' ){
- tt.scaleX = tt.scaleY = tt.scaleZ = 1;
- }else if( t.scale3d !== undef ){
- tt.scaleX = tt.scaleY = tt.scaleZ = t.scale3d;
- }
- if( t.delay ){
- tt.delay = type === 'after' ? t.delay/1000 : t.delay;
- }
- tt.ease = lsConvertEasing( e );
- return tt;
- };
- // Support3D checks the CSS3 3D capability of the browser (based on the idea of Modernizr.js)
- var lsSupport3D = function( el ) {
- var testEl = $('<div>'),
- s3d1 = false,
- s3d2 = false,
- properties = ['perspective', 'OPerspective', 'msPerspective', 'MozPerspective', 'WebkitPerspective'];
- transform = ['transformStyle','OTransformStyle','msTransformStyle','MozTransformStyle','WebkitTransformStyle'];
- for (var i = properties.length - 1; i >= 0; i--){
- s3d1 = s3d1 ? s3d1 : testEl[0].style[properties[i]] != undefined;
- };
- // preserve 3D test
- for (var i = transform.length - 1; i >= 0; i--){
- testEl.css( 'transform-style', 'preserve-3d' );
- s3d2 = s3d2 ? s3d2 : testEl[0].style[transform[i]] == 'preserve-3d';
- };
- // If browser has perspective capability and it is webkit, we must check it with this solution because Chrome can give false positive result if GPU acceleration is disabled
- if (s3d1 && testEl[0].style[properties[4]] != undefined){
- testEl.attr('id','ls-test3d').appendTo( el );
- s3d1 = testEl[0].offsetHeight === 3 && testEl[0].offsetLeft === 9;
- testEl.remove();
- }
- return (s3d1 && s3d2);
- };
- // Order array function
- var lsOrderArray = function(x,y,dir) {
- var i = [];
- if(dir=='forward'){
- for( var a=0; a<x;a++){
- for( var b=0; b<y; b++){
- i.push(a+b*x);
- }
- }
- }else{
- for( var a=x-1; a>-1;a--){
- for( var b=y-1; b>-1; b--){
- i.push(a+b*x);
- }
- }
- }
- return i;
- };
- // CountProp counts the properties in an object
- var lsCountProp = function(obj) {
- var count = 0;
- for(var prop in obj) {
- if(obj.hasOwnProperty(prop)){
- ++count;
- }
- }
- return count;
- };
- // We need the browser function (removed from jQuery 1.9)
- var lsBrowser = function(){
- uaMatch = function( ua ) {
- ua = ua.toLowerCase();
- var match = /(chrome)[ \/]([\w.]+)/.exec( ua ) ||
- /(webkit)[ \/]([\w.]+)/.exec( ua ) ||
- /(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) ||
- /(msie) ([\w.]+)/.exec( ua ) ||
- ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) ||
- [];
- return {
- browser: match[ 1 ] || "",
- version: match[ 2 ] || "0"
- };
- };
- var matched = uaMatch( navigator.userAgent ), browser = {};
- if ( matched.browser ) {
- browser[ matched.browser ] = true;
- browser.version = matched.version;
- }
- if ( browser.chrome ) {
- browser.webkit = true;
- } else if ( browser.webkit ) {
- browser.safari = true;
- }
- return browser;
- };
- lsPrefixes = function(obj, method){
- var pfx = ['webkit', 'khtml', 'moz', 'ms', 'o', ''];
- var p = 0, m, t;
- while (p < pfx.length && !obj[m]) {
- m = method;
- if (pfx[p] == '') {
- m = m.substr(0,1).toLowerCase() + m.substr(1);
- }
- m = pfx[p] + m;
- t = typeof obj[m];
- if (t != 'undefined') {
- pfx = [pfx[p]];
- return (t == 'function' ? obj[m]() : obj[m]);
- }
- p++;
- }
- };
- // Global parameters (Do not change these settings!)
- layerSlider.global = {
- version : '5.3.0',
- isMobile : function(){
- if( navigator.userAgent.match(/Android/i) || navigator.userAgent.match(/webOS/i) || navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPad/i) || navigator.userAgent.match(/iPod/i) || navigator.userAgent.match(/BlackBerry/i) || navigator.userAgent.match(/Windows Phone/i) ){
- return true;
- }else{
- return false;
- }
- },
- isHideOn3D : function(el){
- if( el.css('padding-bottom') == 'auto' || el.css('padding-bottom') == 'none' || el.css('padding-bottom') == 0 || el.css('padding-bottom') == '0px' ){
- return true;
- }else{
- return false;
- }
- },
- ie78 : lsBrowser().msie && lsBrowser().version < 9 ? true : false,
- originalAutoStart : false,
- paused : false,
- pausedByVideo : false,
- autoSlideshow : false,
- isAnimating : false,
- layersNum : null,
- prevNext : 'next',
- slideTimer : null,
- sliderWidth : null,
- sliderHeight : null,
- slideDirections : {
- prev : {
- left : 'right',
- right : 'left',
- top : 'bottom',
- bottom : 'top'
- },
- next : {
- left : 'left',
- right : 'right',
- top : 'top',
- bottom : 'bottom'
- }
- },
- // Default delay time, fadeout and fadein durations of videoPreview images
- v : {
- d : 500,
- fo : 750,
- fi : 500
- }
- };
- // Layer Transition Defaults
- layerSlider.layerTransitions = {
- offsetXIn : 80,
- offsetYIn : 0,
- durationIn : 1000,
- delayIn : 0,
- easingIn : 'easeInOutQuint',
- fadeIn : true,
- rotateIn : 0,
- rotateXIn : 0,
- rotateYIn : 0,
- scaleIn : 1,
- scaleXIn : 1,
- scaleYIn : 1,
- skewXIn : 0,
- skewYIn : 0,
- transformOriginIn : ['50%','50%','0'],
- perspectiveIn : 500,
- offsetXOut : -80,
- offsetYOut : 0,
- durationOut : 400,
- showUntil : 0,
- easingOut : 'easeInOutQuint',
- fadeOut : true,
- rotateOut : 0,
- rotateXOut : 0,
- rotateYOut : 0,
- scaleOut : 1,
- scaleXOut : 1,
- scaleYOut : 1,
- skewXOut : 0,
- skewYOut : 0,
- transformOriginOut : ['50%','50%','0'],
- perspectiveOut : 500
- };
- layerSlider.slideTransitions = {
- slideDelay : 4000 // Time before the next slide will be loading.
- };
- // Global settings (can be modified)
- layerSlider.options = {
- // Layout
- responsive : true,
- responsiveUnder : 0,
- layersContainer : 0,
- fullScreen : false, // NEW FEATURE 5.5.0
- appendTo : '', // NEW FEATURE 5.5.0
- // Slideshow
- autoStart : true,
- startInViewport : true, // NEW FEATURE v5.2.0
- pauseOnHover : true,
- firstSlide : 1,
- animateFirstSlide : true,
- sliderFadeInDuration: 350, // NEW FEATURE v5.2.0
- loops : 0,
- forceLoopNum : true,
- twoWaySlideshow : false,
- randomSlideshow : false,
- // Appearance
- skin : 'v5',
- skinsPath : '/layerslider/skins/',
- globalBGColor : 'transparent',
- globalBGImage : false,
- // Navigation Area
- navPrevNext : true,
- navStartStop : true,
- navButtons : true,
- keybNav : true,
- touchNav : true,
- hoverPrevNext : true,
- hoverBottomNav : false,
- showBarTimer : false,
- showCircleTimer : true,
- // Thumbnail navigation
- thumbnailNavigation : 'hover',
- tnContainerWidth : '60%',
- tnWidth : 100,
- tnHeight : 60,
- tnActiveOpacity : 35,
- tnInactiveOpacity : 100,
- // Videos
- autoPlayVideos : true,
- autoPauseSlideshow : 'auto',
- youtubePreview : 'maxresdefault.jpg',
- // Preload
- imgPreload : true,
- lazyLoad : true,
- // YourLogo
- yourLogo : false,
- yourLogoStyle : 'left: -10px; top: -10px;',
- yourLogoLink : false,
- yourLogoTarget : '_self',
- // Optimize for IE7 and IE8
- optimizeForMobile : true,
- optimizeForIE78 : true,
- // NEW FEATURES 5.2.0 Mobile features
- hideOnMobile : false,
- hideUnder : 0,
- hideOver : 1000000,
- staticImage : '', // will be available in 5.5.0
- // API functions
- cbInit : function(element){},
- cbStart : function(data){},
- cbStop : function(data){},
- cbPause : function(data){},
- cbAnimStart : function(data){},
- cbAnimStop : function(data){},
- cbPrev : function(data){},
- cbNext : function(data){},
- // !!! IMPORTANT !!! The following properties are deprecated from version 5.0.0 DO NOT USE THEM.
- // The slider will recognize these properties in the init code or if you add these properties into the style attribute of the layer
- // but we recommend you to use to new html5 data attribute (data-ls) with the new properties
- slideDelay : 4000,
- slideDirection : 'right',
- parallaxIn : .45,
- parallaxOut : .45,
- durationIn : 1000,
- durationOut : 1000,
- easingIn : 'easeInOutQuint',
- easingOut : 'easeInOutQuint',
- delayIn : 0,
- delayOut : 0
- };
- })(jQuery);
|