layerslider.js 203 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164
  1. /*
  2. * LayerSlider
  3. *
  4. * (c) 2011-2014 George Krupa, John Gera & Kreatura Media
  5. *
  6. * Plugin web: http://kreaturamedia.com/
  7. * licenses: http://codecanyon.net/licenses/
  8. */
  9. function lsShowNotice(lsobj,issue,ver){
  10. var el;
  11. if( typeof lsobj == 'string' ){
  12. el = jQuery('#'+lsobj);
  13. }else if( typeof lsobj == 'object' ){
  14. el = lsobj;
  15. }
  16. var errorTitle, errorText;
  17. switch(issue){
  18. case 'jquery':
  19. errorTitle = 'multiple jQuery issue';
  20. 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>';
  21. break;
  22. case 'oldjquery':
  23. errorTitle = 'old jQuery issue';
  24. 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>';
  25. break;
  26. }
  27. el.addClass('ls-error');
  28. el.append('<p class="ls-exclam">!</p>');
  29. el.append('<p class="ls-error-title">LayerSlider: '+errorTitle+'</p>');
  30. el.append('<p class="ls-error-text">'+errorText+'</p>');
  31. }
  32. (function($) {
  33. $.fn.layerSlider = function( options ){
  34. // IMPROVEMENT v4.1.0 Checking jQuery version
  35. // IMPROVEMENT v4.1.3 Changed required version from 1.7.2 to 1.7.0
  36. var reqVer = '1.7.0';
  37. var curVer = $.fn.jquery;
  38. var el = $(this);
  39. var checkVersions = function(v1,v2){
  40. var v1parts = v1.split('.');
  41. var v2parts = v2.split('.');
  42. for (var i = 0; i < v1parts.length; ++i) {
  43. if (v2parts.length == i) {
  44. return false;
  45. }
  46. if(parseInt(v1parts[i]) == parseInt(v2parts[i])){
  47. continue;
  48. }else if (parseInt(v1parts[i]) > parseInt(v2parts[i])){
  49. return false;
  50. }else{
  51. return true;
  52. }
  53. }
  54. if (v1parts.length != v2parts.length) {
  55. return true;
  56. }
  57. return true;
  58. };
  59. if( !checkVersions('1.8.0',curVer) ){
  60. el.addClass('ls-norotate');
  61. }
  62. // Initializing if jQuery version is greater than 1.7.0
  63. if( !checkVersions(reqVer,curVer) ){
  64. lsShowNotice( el, 'oldjquery', curVer );
  65. }else{
  66. if( (typeof(options)).match('object|undefined') ){
  67. return this.each(function(i){
  68. new layerSlider(this, options);
  69. });
  70. }else{
  71. if( options === 'data' ){
  72. var lsData = $(this).data('LayerSlider').g;
  73. if( lsData ){
  74. return lsData;
  75. }
  76. // NEW FEATURES v5.2.0 option to get userInitData & defaultInitData
  77. }else if( options === 'userInitData' ){
  78. var lsInitData = $(this).data('LayerSlider').o;
  79. if( lsInitData ){
  80. return lsInitData;
  81. }
  82. }else if( options === 'defaultInitData' ){
  83. var lsInitData = $(this).data('LayerSlider').defaults;
  84. if( lsInitData ){
  85. return lsInitData;
  86. }
  87. }else{
  88. return this.each(function(i){
  89. // Control functions: prev, next, start, stop & change
  90. var lsData = $(this).data('LayerSlider');
  91. if( lsData ){
  92. if( !lsData.g.isAnimating && !lsData.g.isLoading ){
  93. if( typeof options == 'number' ){
  94. if( options > 0 && options < lsData.g.layersNum + 1 && options != lsData.g.curLayerIndex ){
  95. lsData.change(options);
  96. }
  97. }else{
  98. switch(options){
  99. case 'prev':
  100. lsData.o.cbPrev(lsData.g);
  101. lsData.prev('clicked');
  102. break;
  103. case 'next':
  104. lsData.o.cbNext(lsData.g);
  105. lsData.next('clicked');
  106. break;
  107. case 'start':
  108. if( !lsData.g.autoSlideshow ){
  109. lsData.o.cbStart(lsData.g);
  110. lsData.g.originalAutoSlideshow = true;
  111. lsData.start();
  112. }
  113. break;
  114. }
  115. }
  116. }
  117. // if( options === 'debug' ){
  118. // lsData.d.show();
  119. // }
  120. if( options === 'redraw' ){
  121. lsData.resize();
  122. }
  123. if( ( lsData.g.autoSlideshow || ( !lsData.g.autoSlideshow && lsData.g.originalAutoSlideshow ) ) && options == 'stop' ){
  124. lsData.o.cbStop(lsData.g);
  125. lsData.g.originalAutoSlideshow = false;
  126. lsData.g.curLayer.find('iframe[src*="youtube.com"], iframe[src*="youtu.be"], iframe[src*="player.vimeo"]').each(function(){
  127. // Clearing videoTimeouts
  128. clearTimeout( $(this).data( 'videoTimer') );
  129. });
  130. lsData.stop();
  131. }
  132. if( options == 'forceStop'){
  133. lsData.forcestop();
  134. }
  135. }
  136. });
  137. }
  138. }
  139. }
  140. };
  141. // LayerSlider methods
  142. var layerSlider = function(el, options) {
  143. var ls = this;
  144. ls.$el = $(el).addClass('ls-container');
  145. ls.$el.data('LayerSlider', ls);
  146. ls.load = function(){
  147. // Setting options (user settings) and global (not modificable) parameters
  148. ls.defaults = layerSlider.options;
  149. ls.o = $.extend({},ls.defaults, options);
  150. ls.g = $.extend({},layerSlider.global);
  151. ls.lt = $.extend({},layerSlider.layerTransitions );
  152. ls.st = $.extend({},layerSlider.slideTransitions );
  153. ls.g.enableCSS3 = $(el).hasClass('ls-norotate') ? false : true;
  154. // NEW FEATURE v5.2.0 saving original HTML Markup
  155. ls.g.originalMarkup = $(el).html();
  156. if( ls.g.ie78 ){
  157. ls.o.lazyLoad = false;
  158. }
  159. // WP parameters
  160. if( ls.o.autoPauseSlideshow === 'enabled' ){
  161. ls.o.autoPauseSlideshow = true;
  162. }
  163. if( ls.o.autoPauseSlideshow === 'disabled' ){
  164. ls.o.autoPauseSlideshow = false;
  165. }
  166. // If layerslider.transitions.js is loaded...
  167. if( typeof layerSliderTransitions !== 'undefined' ){
  168. ls.t = $.extend({},layerSliderTransitions);
  169. }
  170. // If custom transitions are loaded...
  171. if( typeof layerSliderCustomTransitions !== 'undefined' ){
  172. ls.ct = $.extend({},layerSliderCustomTransitions);
  173. }
  174. // NEW IMPROVEMENT v3.6 forbid to call the init code more than once on the same element
  175. if( !ls.g.initialized ){
  176. ls.g.initialized = true;
  177. // Added debug mode v3.5
  178. // ls.debug();
  179. if( $('html').find('meta[content*="WordPress"]').length ){
  180. ls.g.wpVersion = $('html').find('meta[content*="WordPress"]').attr('content').split('WordPress')[1];
  181. }
  182. if( $('html').find('script[src*="layerslider"]').length ){
  183. if( $('html').find('script[src*="layerslider"]').attr('src').indexOf('?') != -1 ){
  184. ls.g.lswpVersion = $('html').find('script[src*="layerslider"]').attr('src').split('?')[1].split('=')[1];
  185. }
  186. }
  187. // Debug mode controls
  188. // ls.d.aT('LayerSlider controls');
  189. // ls.d.aU('<a href="#">prev</a> | <a href="#">next</a> | <a href="#">start</a> | <a href="#">stop</a> | <a href="#">force stop</a>');
  190. // ls.d.history.find('a').each(function(){
  191. // $(this).click(function(e){
  192. // e.preventDefault();
  193. // $(el).layerSlider($(this).text());
  194. // });
  195. // });
  196. // ls.d.aT('LayerSlider version information');
  197. // ls.d.aU('JS version: <strong>' + ls.g.version + '</strong>');
  198. // if(ls.g.lswpVersion){
  199. // ls.d.aL('WP version: <strong>' + ls.g.lswpVersion + '</strong>');
  200. // }
  201. // if(ls.g.wpVersion){
  202. // ls.d.aL('WordPress version: <strong>' + ls.g.wpVersion + '</strong>');
  203. // }
  204. // ls.d.aL('jQuery version: <strong>' + $().jquery + '</strong>');
  205. // if( $(el).attr('id') ){
  206. // ls.d.aT('LayerSlider container');
  207. // ls.d.aU('#'+$(el).attr('id'));
  208. // }
  209. // NEW LOAD METHOD v3.5
  210. // FIXED v4.0 If the selected skin is already loaded, calling the ls.init() function immediately
  211. if( !ls.o.skin || ls.o.skin == '' || !ls.o.skinsPath || ls.o.skinsPath == '' ){
  212. // ls.d.aT('Loading without skin. Possibilities: mistyped skin and / or skinsPath.');
  213. ls.init();
  214. }else{
  215. // ls.d.aT('Trying to load with skin: '+ls.o.skin, true);
  216. // Applying skin
  217. $(el).addClass('ls-'+ls.o.skin);
  218. var skinStyle = ls.o.skinsPath+ls.o.skin+'/skin.css';
  219. cssContainer = $('head');
  220. if( !$('head').length ){
  221. cssContainer = $('body');
  222. }
  223. if( $('link[href="'+skinStyle+'"]').length ){
  224. // ls.d.aU('Skin "'+ls.o.skin+'" is already loaded.');
  225. curSkin = $('link[href="'+skinStyle+'"]');
  226. if( !ls.g.loaded ){
  227. ls.g.loaded = true;
  228. // IMPROVEMENT v4.5.0 Added delay because of caching bugs
  229. ls.g.t1 = setTimeout(function(){
  230. ls.init();
  231. },150);
  232. }
  233. }else{
  234. if (document.createStyleSheet){
  235. document.createStyleSheet(skinStyle);
  236. var curSkin = $('link[href="'+skinStyle+'"]');
  237. }else{
  238. var curSkin = $('<link rel="stylesheet" href="'+skinStyle+'" type="text/css" />').appendTo( cssContainer );
  239. }
  240. }
  241. // curSkin.load(); function for most of the browsers.
  242. curSkin.load(function(){
  243. if( !ls.g.loaded ){
  244. // ls.d.aU('curSkin.load(); fired');
  245. ls.g.loaded = true;
  246. // IMPROVEMENT v4.5.0 Added delay because of caching bugs
  247. ls.g.t2 = setTimeout(function(){
  248. ls.init();
  249. },150);
  250. }
  251. });
  252. // $(window).load(); function for older webkit ( < v536 ).
  253. $(window).load(function(){
  254. if( !ls.g.loaded ){
  255. // ls.d.aU('$(window).load(); fired');
  256. ls.g.loaded = true;
  257. // IMPROVEMENT v4.5.0 Added delay because of caching bugs
  258. ls.g.t3 = setTimeout(function(){
  259. ls.init();
  260. },150);
  261. }
  262. });
  263. // Fallback: if $(window).load(); not fired in 2 secs after $(document).ready(),
  264. // curSkin.load(); not fired at all or the name of the skin and / or the skinsPath
  265. // mistyped, we must call the init function manually.
  266. ls.g.t4 = setTimeout( function(){
  267. if( !ls.g.loaded ){
  268. // ls.d.aT('Fallback mode: Neither curSkin.load(); or $(window).load(); were fired');
  269. ls.g.loaded = true;
  270. ls.init();
  271. }
  272. }, 1000);
  273. }
  274. }
  275. };
  276. ls.init = function(){
  277. // NEW FEATURE v5.5.0 Appending the slider element into the element specified in appendTo
  278. $(el).prependTo( $( ls.o.appendTo ) );
  279. // IMPROVEMENT v4.0.1 Trying to add special ID to <body> or <html> (required to overwrite WordPresss global styles)
  280. if( !$('html').attr('id') ){
  281. $('html').attr('id','ls-global');
  282. }else if( !$('body').attr('id') ){
  283. $('body').attr('id','ls-global');
  284. }
  285. // NEW FEATURES v5.5.0 Hiding the slider on mobile devices, smaller resolutions
  286. // or changing it to a static but responsive image
  287. if( ls.g.isMobile() === true && ls.o.hideOnMobile === true ){
  288. $(el).addClass('ls-forcehide');
  289. $(el).closest('.ls-wp-fullwidth-container').addClass('ls-forcehide');
  290. }
  291. var showHide = function(){
  292. if( ls.o.hideOnMobile === true && ls.g.isMobile() === true ){
  293. $(el).addClass('ls-forcehide');
  294. $(el).closest('.ls-wp-fullwidth-container').addClass('ls-forcehide');
  295. ls.o.autoStart = false;
  296. }else{
  297. if( $(window).width() < ls.o.hideUnder || $(window).width() > ls.o.hideOver ){
  298. $(el).addClass('ls-forcehide');
  299. $(el).closest('.ls-wp-fullwidth-container').addClass('ls-forcehide');
  300. }else{
  301. $(el).removeClass('ls-forcehide');
  302. $(el).closest('.ls-wp-fullwidth-container').removeClass('ls-forcehide');
  303. }
  304. }
  305. };
  306. $(window).resize( function(){
  307. showHide();
  308. });
  309. showHide();
  310. // NEW FEATURE v1.7 making the slider responsive
  311. ls.g.sliderWidth = function(){
  312. return $(el).width();
  313. }
  314. ls.g.sliderHeight = function(){
  315. return $(el).height();
  316. }
  317. // Compatibility mode v5.0.0
  318. // .ls-layer -> .ls-slide
  319. // .ls-s -> .ls-l
  320. $(el).find('.ls-layer').removeClass('ls-layer').addClass('ls-slide');
  321. $(el).find('.ls-slide > *[class*="ls-s"]').each(function(){
  322. var oldDistanceNum = $(this).attr('class').split('ls-s')[1].split(' ')[0];
  323. $(this).removeClass('ls-s'+oldDistanceNum).addClass('ls-l'+oldDistanceNum);
  324. });
  325. if( ls.o.firstLayer ){
  326. ls.o.firstSlide = ls.o.firstLayer;
  327. }
  328. if( ls.o.animateFirstLayer === false ){
  329. ls.o.animateFirstSlide = false;
  330. }
  331. // REPLACED FEATURE v2.0 If there is only ONE layer, instead of duplicating it, turning off slideshow and loops, hiding all controls, etc.
  332. if( $(el).find('.ls-slide').length == 1 ){
  333. ls.o.autoStart = false;
  334. ls.o.navPrevNext = false;
  335. ls.o.navStartStop = false;
  336. ls.o.navButtons = false;
  337. ls.o.loops = 0;
  338. ls.o.forceLoopNum = false;
  339. ls.o.autoPauseSlideshow = true;
  340. ls.o.firstSlide = 1;
  341. ls.o.thumbnailNavigation = 'disabled';
  342. }
  343. // 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
  344. // BUGFIX v5.3.0 An additional check required (with the original improvement full-width sliders with "normal" responsiveness couldn't be created)
  345. if( $(el).parent().hasClass('ls-wp-fullwidth-helper') && ls.o.responsiveUnder !== 0 ){
  346. $(el)[0].style.width = '100%';
  347. }
  348. // NEW FEATURE v3.0 added "normal" responsive mode with image and font resizing
  349. // NEW FEATURE v3.5 responsiveUnder
  350. if( ls.o.width ){
  351. ls.g.sliderOriginalWidthRU = ls.g.sliderOriginalWidth = '' + ls.o.width;
  352. }else{
  353. ls.g.sliderOriginalWidthRU = ls.g.sliderOriginalWidth = $(el)[0].style.width;
  354. }
  355. if( ls.o.height ){
  356. ls.g.sliderOriginalHeight = '' + ls.o.height;
  357. }else{
  358. ls.g.sliderOriginalHeight = $(el)[0].style.height;
  359. }
  360. if( ls.g.sliderOriginalWidth.indexOf('%') == -1 && ls.g.sliderOriginalWidth.indexOf('px') == -1 ){
  361. ls.g.sliderOriginalWidth += 'px';
  362. }
  363. if( ls.g.sliderOriginalHeight.indexOf('%') == -1 && ls.g.sliderOriginalHeight.indexOf('px') == -1 ){
  364. ls.g.sliderOriginalHeight += 'px';
  365. }
  366. if( ls.o.responsive && ls.g.sliderOriginalWidth.indexOf('px') != -1 && ls.g.sliderOriginalHeight.indexOf('px') != -1 ){
  367. ls.g.responsiveMode = true;
  368. }else{
  369. ls.g.responsiveMode = false;
  370. }
  371. // NEW FEATURE v5.5.0 We must overwrite some user settings if fullScreen mode is enabled
  372. if( ls.o.fullScreen === true ){
  373. ls.o.responsiveUnder = 0;
  374. ls.g.responsiveMode = true;
  375. if( ls.g.sliderOriginalWidth.indexOf('%') != -1 ){
  376. ls.g.sliderOriginalWidth = parseInt( ls.g.sliderOriginalWidth) + 'px';
  377. }
  378. if( ls.g.sliderOriginalHeight.indexOf('%') != -1 ){
  379. ls.g.sliderOriginalHeight = parseInt( ls.g.sliderOriginalHeight) + 'px';
  380. }
  381. }
  382. // IMPROVEMENT v3.0 preventing WordPress to wrap your sublayers in <code> or <p> elements
  383. $(el).find('*[class*="ls-l"], *[class*="ls-bg"]').each(function(){
  384. if( !$(this).parent().hasClass('ls-slide') ){
  385. $(this).insertBefore( $(this).parent() );
  386. }
  387. });
  388. $(el).find('.ls-slide').each(function(){
  389. $(this).children(':not([class*="ls-"])').each(function(){
  390. $(this).remove();
  391. });
  392. var hd = $('<div>').addClass('ls-gpuhack');
  393. if( $(this).find('.ls-bg').length ){
  394. hd.insertAfter( $(this).find('.ls-bg').eq('0') );
  395. }else{
  396. hd.prependTo( $(this) );
  397. }
  398. });
  399. $(el).find('.ls-slide, *[class*="ls-l"]').each(function(){
  400. if( $(this).data('ls') || $(this).attr('rel') || $(this).attr('style') ){
  401. if( $(this).data('ls') ){
  402. var params = $(this).data('ls').toLowerCase().split(';');
  403. }else if( $(this).attr('rel') && $(this).attr('rel').indexOf(':') != -1 && $(this).attr('rel').indexOf(';') != -1 ){
  404. var params = $(this).attr('rel').toLowerCase().split(';');
  405. }else{
  406. var params = $(this).attr('style').toLowerCase().split(';');
  407. }
  408. for(x=0;x<params.length;x++){
  409. param = params[x].split(':');
  410. if( param[0].indexOf('easing') != -1 ){
  411. param[1] = ls.ieEasing( param[1] );
  412. }
  413. var p2 = '';
  414. if( param[2] ){
  415. p2 = ':'+$.trim(param[2]);
  416. }
  417. if( param[0] != ' ' && param[0] != '' ){
  418. $(this).data( $.trim(param[0]), $.trim(param[1]) + p2 );
  419. }
  420. }
  421. }
  422. // NEW FEATURE v5.2.0 Starts the slider only if it is in the viewport
  423. if( ls.o.startInViewport === true && ls.o.autoStart === true ){
  424. ls.o.autoStart = false;
  425. ls.g.originalAutoStart = true;
  426. }
  427. // NEW FEATURE v1.7 and v3.0 making the slider responsive - we have to use style.left instead of jQuery's .css('left') function!
  428. var sl = $(this);
  429. sl.data( 'originalLeft', sl[0].style.left );
  430. sl.data( 'originalTop', sl[0].style.top );
  431. if( $(this).is('a') && $(this).children().length > 0 ){
  432. sl = $(this).children();
  433. }
  434. var _w = sl.width();
  435. var _h = sl.height();
  436. if( sl[0].style.width && sl[0].style.width.indexOf('%') != -1 ){
  437. _w = sl[0].style.width;
  438. }
  439. if( sl[0].style.height && sl[0].style.height.indexOf('%') != -1 ){
  440. _h = sl[0].style.height;
  441. }
  442. sl.data( 'originalWidth', _w );
  443. sl.data( 'originalHeight', _h );
  444. sl.data( 'originalPaddingLeft', sl.css('padding-left') );
  445. sl.data( 'originalPaddingRight', sl.css('padding-right') );
  446. sl.data( 'originalPaddingTop', sl.css('padding-top') );
  447. sl.data( 'originalPaddingBottom', sl.css('padding-bottom') );
  448. // iOS fade bug when GPU acceleration is enabled #1
  449. var _o = typeof parseFloat( sl.css('opacity') ) == 'number' ? Math.round( parseFloat( sl.css('opacity') ) * 100 ) / 100 : 1;
  450. $(this).data( 'originalOpacity', _o );
  451. if( sl.css('border-left-width').indexOf('px') == -1 ){
  452. sl.data( 'originalBorderLeft', sl[0].style.borderLeftWidth );
  453. }else{
  454. sl.data( 'originalBorderLeft', sl.css('border-left-width') );
  455. }
  456. if( sl.css('border-right-width').indexOf('px') == -1 ){
  457. sl.data( 'originalBorderRight', sl[0].style.borderRightWidth );
  458. }else{
  459. sl.data( 'originalBorderRight', sl.css('border-right-width') );
  460. }
  461. if( sl.css('border-top-width').indexOf('px') == -1 ){
  462. sl.data( 'originalBorderTop', sl[0].style.borderTopWidth );
  463. }else{
  464. sl.data( 'originalBorderTop', sl.css('border-top-width') );
  465. }
  466. if( sl.css('border-bottom-width').indexOf('px') == -1 ){
  467. sl.data( 'originalBorderBottom', sl[0].style.borderBottomWidth );
  468. }else{
  469. sl.data( 'originalBorderBottom', sl.css('border-bottom-width') );
  470. }
  471. sl.data( 'originalFontSize', sl.css('font-size') );
  472. sl.data( 'originalLineHeight', sl.css('line-height') );
  473. });
  474. // CHANGED FEATURE v3.5 url- / deep linking layers
  475. if( document.location.hash ){
  476. for( var dl = 0; dl < $(el).find('.ls-slide').length; dl++ ){
  477. if( $(el).find('.ls-slide').eq(dl).data('deeplink') == document.location.hash.split('#')[1] ){
  478. ls.o.firstSlide = dl+1;
  479. }
  480. }
  481. }
  482. // NEW FEATURE v2.0 linkTo
  483. $(el).find('*[class*="ls-linkto-"]').each(function(){
  484. var lClasses = $(this).attr('class').split(' ');
  485. for( var ll=0; ll<lClasses.length; ll++ ){
  486. if( lClasses[ll].indexOf('ls-linkto-') != -1 ){
  487. var linkTo = parseInt( lClasses[ll].split('ls-linkto-')[1] );
  488. $(this).css({
  489. cursor: 'pointer'
  490. }).click(function(e){
  491. e.preventDefault();
  492. $(el).layerSlider( linkTo );
  493. });
  494. }
  495. }
  496. });
  497. // Setting variables
  498. ls.g.layersNum = $(el).find('.ls-slide').length;
  499. // NEW FEATURE v3.5 randomSlideshow
  500. if( ls.o.randomSlideshow && ls.g.layersNum > 2 ){
  501. ls.o.firstSlide == 'random';
  502. ls.o.twoWaySlideshow = false;
  503. }else{
  504. ls.o.randomSlideshow = false;
  505. }
  506. // NEW FEATURE v3.0 random firstSlide
  507. if( ls.o.firstSlide == 'random' ){
  508. ls.o.firstSlide = Math.floor(Math.random() * ls.g.layersNum+1);
  509. }
  510. ls.o.fisrtSlide = ls.o.fisrtSlide < ls.g.layersNum + 1 ? ls.o.fisrtSlide : 1;
  511. ls.o.fisrtSlide = ls.o.fisrtSlide < 1 ? 1 : ls.o.fisrtSlide;
  512. // NEW FEATURE v2.0 loops
  513. ls.g.nextLoop = 1;
  514. if( ls.o.animateFirstSlide ){
  515. ls.g.nextLoop = 0;
  516. }
  517. // NEW FEATURE v2.0 videoPreview
  518. // IMPROVEMENT v4.6.0 http / https support of embedded videos
  519. var HTTP = document.location.href.indexOf('file:') === -1 ? '' : 'http:';
  520. // Youtube videos
  521. $(el).find('iframe[src*="youtube.com"], iframe[src*="youtu.be"]').each(function(){
  522. // BUGFIX v4.1.0 Firefox embedded video fix
  523. $(this).parent().addClass('ls-video-layer');
  524. if( $(this).parent('[class*="ls-l"]') ){
  525. var iframe = $(this);
  526. var http = HTTP;
  527. // Getting thumbnail
  528. $.getJSON( http + '//gdata.youtube.com/feeds/api/videos/' + $(this).attr('src').split('embed/')[1].split('?')[0] + '?v=2&alt=json&callback=?', function(data) {
  529. iframe.data( 'videoDuration', parseInt(data['entry']['media$group']['yt$duration']['seconds']) * 1000 );
  530. });
  531. var vpContainer = $('<div>').addClass('ls-vpcontainer').appendTo( $(this).parent() );
  532. // if( ls.o.lazyLoad ){
  533. // $('<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 );
  534. // }else{
  535. $('<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 );
  536. // }
  537. $('<div>').appendTo( vpContainer ).addClass('ls-playvideo');
  538. $(this).parent().css({
  539. width : $(this).width(),
  540. height : $(this).height()
  541. }).click(function(){
  542. // IMPROVEMENT v5.2.0 if video playing is in progress, video layers with auto play will skip showuntil feature
  543. if( $(this).data('showuntil') > 0 && $(this).data('showUntilTimer') ){
  544. clearTimeout( $(this).data('showUntilTimer') );
  545. }
  546. ls.g.isAnimating = true;
  547. if( ls.g.paused ){
  548. if( ls.o.autoPauseSlideshow != false ){
  549. ls.g.paused = false;
  550. }
  551. ls.g.originalAutoSlideshow = true;
  552. }else{
  553. ls.g.originalAutoSlideshow = ls.g.autoSlideshow;
  554. }
  555. if( ls.o.autoPauseSlideshow != false ){
  556. ls.stop();
  557. }
  558. ls.g.pausedByVideo = true;
  559. http = $(this).find('iframe').data('videoSrc').indexOf('http') === -1 ? HTTP : '';
  560. $(this).find('iframe').attr('src', http + $(this).find('iframe').data('videoSrc') );
  561. $(this).find('.ls-vpcontainer').delay(ls.g.v.d).fadeOut(ls.g.v.fo, function(){
  562. if( ls.o.autoPauseSlideshow == 'auto' && ls.g.originalAutoSlideshow == true ){
  563. var videoTimer = setTimeout(function() {
  564. ls.start();
  565. }, iframe.data( 'videoDuration') - ls.g.v.d );
  566. iframe.data( 'videoTimer', videoTimer );
  567. }
  568. ls.g.isAnimating = false;
  569. if( ls.g.resize == true ){
  570. ls.makeResponsive( ls.g.curLayer, function(){
  571. ls.g.resize = false;
  572. });
  573. }
  574. });
  575. });
  576. var sep = '&';
  577. if( $(this).attr('src').indexOf('?') == -1 ){
  578. sep = '?';
  579. }
  580. // BUGFIX v5.1.0 Fixed several issues with embedded videos (mostly under Firefox and IE)
  581. // fixed 'only audio but no video' bug, fixed 'unclickable video controls' bug, fixed 'hidden slider controls' bug
  582. var videoFix = '&wmode=opaque&html5=1';
  583. // BUGFIX v5.1.0 Fixed autoplay parameter
  584. if( $(this).attr('src').indexOf('autoplay') == -1 ){
  585. $(this).data( 'videoSrc', $(this).attr('src') + sep + 'autoplay=1' + videoFix );
  586. }else{
  587. $(this).data( 'videoSrc', $(this).attr('src').replace('autoplay=0','autoplay=1') + videoFix );
  588. }
  589. $(this).data( 'originalWidth', $(this).attr('width') );
  590. $(this).data( 'originalHeight', $(this).attr('height') );
  591. $(this).attr('src','');
  592. }
  593. });
  594. // Vimeo videos
  595. $(el).find('iframe[src*="player.vimeo"]').each(function(){
  596. // BUGFIX v4.1.0 Firefox embedded video fix
  597. $(this).parent().addClass('ls-video-layer');
  598. if( $(this).parent('[class*="ls-l"]') ){
  599. var iframe = $(this);
  600. var http = HTTP;
  601. // Getting thumbnail
  602. var vpContainer = $('<div>').addClass('ls-vpcontainer').appendTo( $(this).parent() );
  603. $.getJSON( http + '//vimeo.com/api/v2/video/'+ ( $(this).attr('src').split('video/')[1].split('?')[0] ) +'.json?callback=?', function(data){
  604. // if( ls.o.lazyLoad ){
  605. // $('<img>').appendTo( vpContainer ).addClass('ls-videopreview').attr('alt', 'Play video').data('src', data[0]['thumbnail_large'] );
  606. // }else{
  607. $('<img>').appendTo( vpContainer ).addClass('ls-videopreview').attr('alt', 'Play video').attr('src', data[0]['thumbnail_large'] );
  608. // }
  609. iframe.data( 'videoDuration', parseInt( data[0]['duration'] ) * 1000 );
  610. $('<div>').appendTo( vpContainer ).addClass('ls-playvideo');
  611. });
  612. $(this).parent().css({
  613. width : $(this).width(),
  614. height : $(this).height()
  615. }).click(function(){
  616. // IMPROVEMENT v5.2.0 if video playing is in progress, video layers with auto play will skip showuntil feature
  617. if( $(this).data('showuntil') > 0 && $(this).data('showUntilTimer') ){
  618. clearTimeout( $(this).data('showUntilTimer') );
  619. }
  620. ls.g.isAnimating = true;
  621. if( ls.g.paused ){
  622. if( ls.o.autoPauseSlideshow != false ){
  623. ls.g.paused = false;
  624. }
  625. ls.g.originalAutoSlideshow = true;
  626. }else{
  627. ls.g.originalAutoSlideshow = ls.g.autoSlideshow;
  628. }
  629. if( ls.o.autoPauseSlideshow != false ){
  630. ls.stop();
  631. }
  632. ls.g.pausedByVideo = true;
  633. http = $(this).find('iframe').data('videoSrc').indexOf('http') === -1 ? HTTP : '';
  634. $(this).find('iframe').attr('src', http + $(this).find('iframe').data('videoSrc') );
  635. $(this).find('.ls-vpcontainer').delay(ls.g.v.d).fadeOut(ls.g.v.fo, function(){
  636. if( ls.o.autoPauseSlideshow == 'auto' && ls.g.originalAutoSlideshow == true ){
  637. var videoTimer = setTimeout(function() {
  638. ls.start();
  639. }, iframe.data( 'videoDuration') - ls.g.v.d );
  640. iframe.data( 'videoTimer', videoTimer );
  641. }
  642. ls.g.isAnimating = false;
  643. if( ls.g.resize == true ){
  644. ls.makeResponsive( ls.g.curLayer, function(){
  645. ls.g.resize = false;
  646. });
  647. }
  648. });
  649. });
  650. var sep = '&';
  651. if( $(this).attr('src').indexOf('?') == -1 ){
  652. sep = '?';
  653. }
  654. // BUGFIX v5.1.0 Fixed several issues with embedded videos (mostly under Firefox and IE)
  655. // fixed 'only audio but no video' bug, fixed 'unclickable video controls' bug, fixed 'hidden slider controls' bug
  656. var videoFix = '&wmode=opaque';
  657. // BUGFIX v5.1.0 Fixed autoplay parameter
  658. if( $(this).attr('src').indexOf('autoplay') == -1 ){
  659. $(this).data( 'videoSrc', $(this).attr('src') + sep + 'autoplay=1' + videoFix );
  660. }else{
  661. $(this).data( 'videoSrc', $(this).attr('src').replace('autoplay=0','autoplay=1') + videoFix );
  662. }
  663. $(this).data( 'originalWidth', $(this).attr('width') );
  664. $(this).data( 'originalHeight', $(this).attr('height') );
  665. $(this).attr('src','');
  666. }
  667. });
  668. // NEW FEATURE v5.0.0 HTML5 Video Support
  669. $(el).find('video, audio').each(function(){
  670. // BUGFIX v5.1.0 fixed HTML5 video sizing issue (again :)
  671. var ow = typeof $(this).attr('width') !== 'undefined' ? $(this).attr('width') : '640';
  672. var oh = typeof $(this).attr('height') !== 'undefined' ? $(this).attr('height') : '' + $(this).height();
  673. if( ow.indexOf('%') === -1 ){
  674. ow = parseInt( ow );
  675. }
  676. if( oh.indexOf('%') === -1 ){
  677. oh = parseInt( oh );
  678. }
  679. if( ow === '100%' && ( oh === 0 || oh === '0' || oh === '100%' ) ){
  680. $(this).attr('height', '100%');
  681. oh = 'auto';
  682. }
  683. $(this).parent().addClass('ls-video-layer').css({
  684. width : ow,
  685. height : oh
  686. }).data({
  687. originalWidth : ow,
  688. originalHeight : oh
  689. });
  690. var curVideo = $(this);
  691. // BUGFIX v5.3.0 'ended' function removed from 'click' function due to multiply
  692. $(this).on('ended', function(){
  693. if( ls.o.autoPauseSlideshow === 'auto' && ls.g.originalAutoSlideshow === true ){
  694. ls.start();
  695. }
  696. });
  697. $(this).removeAttr('width').removeAttr('height').css({
  698. width : '100%',
  699. height : '100%'
  700. }).click(function(e){
  701. // BUGFIX v5.3.0 autoplay didn't work in all cases
  702. if( !ls.g.pausedByVideo ){
  703. if( this.paused ){
  704. e.preventDefault();
  705. }
  706. this.play();
  707. ls.g.isAnimating = true;
  708. if( ls.g.paused ){
  709. if( ls.o.autoPauseSlideshow !== false ){
  710. ls.g.paused = false;
  711. }
  712. ls.g.originalAutoSlideshow = true;
  713. }else{
  714. ls.g.originalAutoSlideshow = ls.g.autoSlideshow;
  715. }
  716. if( ls.o.autoPauseSlideshow !== false ){
  717. ls.stop();
  718. }
  719. ls.g.pausedByVideo = true;
  720. ls.g.isAnimating = false;
  721. if( ls.g.resize === true ){
  722. ls.makeResponsive( ls.g.curLayer, function(){
  723. ls.g.resize = false;
  724. });
  725. }
  726. }
  727. });
  728. });
  729. // NEW FEATURE v1.7 animating first layer
  730. if( ls.o.animateFirstSlide ){
  731. ls.o.firstSlide = ls.o.firstSlide - 1 === 0 ? ls.g.layersNum : ls.o.firstSlide-1;
  732. }
  733. ls.g.curLayerIndex = ls.o.firstSlide;
  734. ls.g.curLayer = $(el).find('.ls-slide:eq('+(ls.g.curLayerIndex-1)+')');
  735. // Moving all layers to .ls-inner container
  736. $(el).find('.ls-slide').wrapAll('<div class="ls-inner"></div>');
  737. // NEW FEATURE v4.5.0 Timers
  738. if( ls.o.showBarTimer ){
  739. ls.g.barTimer = $('<div>').addClass('ls-bar-timer').appendTo( $(el).find('.ls-inner') );
  740. }
  741. if( ls.o.showCircleTimer && !ls.g.ie78 ){
  742. ls.g.circleTimer = $('<div>').addClass('ls-circle-timer').appendTo( $(el).find('.ls-inner') );
  743. 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>') );
  744. }
  745. // NEW FEATURE v4.0 Adding loading indicator into the element
  746. ls.g.li = $('<div>').css({
  747. zIndex: -1,
  748. display: 'none'
  749. }).addClass('ls-loading-container').appendTo( $(el) );
  750. $('<div>').addClass('ls-loading-indicator').appendTo( ls.g.li );
  751. // Adding styles
  752. if( $(el).css('position') == 'static' ){
  753. $(el).css('position','relative');
  754. }
  755. // IMPROVEMENT & BUGFIX v4.6.0 Fixed transparent global background issue under IE7 & IE8
  756. if( ls.o.globalBGImage ){
  757. $(el).find('.ls-inner').css({
  758. backgroundImage : 'url('+ls.o.globalBGImage+')'
  759. });
  760. }else{
  761. $(el).find('.ls-inner').css({
  762. backgroundColor : ls.o.globalBGColor
  763. });
  764. }
  765. if( ls.o.globalBGColor == 'transparent' && ls.o.globalBGImage == false ){
  766. $(el).find('.ls-inner').css({
  767. background : 'none transparent !important'
  768. });
  769. }
  770. // NEW FEATURES v5.0.0 Lazy-load & remove unnecessary width & height attributes from images
  771. $(el).find('.ls-slide img').each(function(){
  772. $(this).removeAttr('width').removeAttr('height');
  773. if( ls.o.imgPreload === true && ls.o.lazyLoad === true ){
  774. if( typeof $(this).data('src') !== 'string' ){
  775. $(this).data('src', $(this).attr('src') );
  776. var src = ls.o.skinsPath+'../css/blank.gif';
  777. $(this).attr('src',src);
  778. }
  779. }else{
  780. if( typeof $(this).data('src') === 'string' ){
  781. $(this).attr('src',$(this).data('src'));
  782. $(this).removeAttr('data-src');
  783. }
  784. }
  785. });
  786. // NEW FEATURE v5.0.0 Parallax layers by mousemove
  787. $(el).find('.ls-slide').on('mouseenter',function(e){
  788. ls.g.parallaxStartX = e.pageX - $(this).parent().offset().left;
  789. ls.g.parallaxStartY = e.pageY - $(this).parent().offset().top;
  790. });
  791. $(el).find('.ls-slide').on('mousemove',function(e){
  792. var mX0 = $(this).parent().offset().left + ls.g.parallaxStartX;
  793. var mY0 = $(this).parent().offset().top + ls.g.parallaxStartY;
  794. var mX = e.pageX - mX0;
  795. var mY = e.pageY - mY0;
  796. $(this).find('> *:not(.ls-bg)').each(function(){
  797. if( typeof $(this).data('parallaxlevel') !== 'undefined' && parseInt( $(this).data('parallaxlevel') ) !== 0 ){
  798. $(this).css({
  799. marginLeft : -mX / 100 * parseInt( $(this).data('parallaxlevel') ),
  800. marginTop : -mY / 100 * parseInt( $(this).data('parallaxlevel') )
  801. });
  802. }
  803. });
  804. });
  805. $(el).find('.ls-slide').on('mouseleave',function(){
  806. $(this).find('> *:not(.ls-bg)').each(function(){
  807. if( typeof $(this).data('parallaxlevel') !== 'undefined' && parseInt( $(this).data('parallaxlevel') ) !== 0 ){
  808. TweenLite.to( this, .4, {css:{
  809. marginLeft : 0,
  810. marginTop : 0
  811. }
  812. });
  813. }
  814. });
  815. });
  816. // Creating navigation
  817. if( ls.o.navPrevNext ){
  818. $('<a class="ls-nav-prev" href="#" />').click(function(e){
  819. e.preventDefault();
  820. $(el).layerSlider('prev');
  821. }).appendTo($(el));
  822. $('<a class="ls-nav-next" href="#" />').click(function(e){
  823. e.preventDefault();
  824. $(el).layerSlider('next');
  825. }).appendTo($(el));
  826. if( ls.o.hoverPrevNext ){
  827. $(el).find('.ls-nav-prev, .ls-nav-next').css({
  828. display: 'none'
  829. });
  830. $(el).hover(
  831. function(){
  832. if( !ls.g.forceHideControls ){
  833. if( ls.g.ie78 ){
  834. $(el).find('.ls-nav-prev, .ls-nav-next').css('display','block');
  835. }else{
  836. $(el).find('.ls-nav-prev, .ls-nav-next').stop(true,true).fadeIn(300);
  837. }
  838. }
  839. },
  840. function(){
  841. if( ls.g.ie78 ){
  842. $(el).find('.ls-nav-prev, .ls-nav-next').css('display','none');
  843. }else{
  844. $(el).find('.ls-nav-prev, .ls-nav-next').stop(true,true).fadeOut(300);
  845. }
  846. }
  847. );
  848. }
  849. }
  850. // Creating bottom navigation
  851. if( ls.o.navStartStop || ls.o.navButtons ){
  852. var bottomNav = $('<div class="ls-bottom-nav-wrapper" />').appendTo( $(el) );
  853. ls.g.bottomWrapper = bottomNav;
  854. if( ls.o.thumbnailNavigation == 'always' ){
  855. bottomNav.addClass('ls-above-thumbnails');
  856. }
  857. if( ls.o.navButtons && ls.o.thumbnailNavigation != 'always' ){
  858. $('<span class="ls-bottom-slidebuttons" />').appendTo( $(el).find('.ls-bottom-nav-wrapper') );
  859. // NEW FEATURE v3.5 thumbnailNavigation ('hover')
  860. if( ls.o.thumbnailNavigation == 'hover' ){
  861. 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') );
  862. }
  863. for(x=1;x<ls.g.layersNum+1;x++){
  864. var btn = $('<a href="#" />').appendTo( $(el).find('.ls-bottom-slidebuttons') ).click(function(e){
  865. e.preventDefault();
  866. $(el).layerSlider( ($(this).index() + 1) );
  867. });
  868. // NEW FEATURE v3.5 thumbnailNavigation ('hover')
  869. if( ls.o.thumbnailNavigation == 'hover' ){
  870. $(el).find('.ls-thumbnail-hover, .ls-thumbnail-hover-img').css({
  871. width : ls.o.tnWidth,
  872. height : ls.o.tnHeight
  873. });
  874. var th = $(el).find('.ls-thumbnail-hover');
  875. var ti = th.find('img').css({
  876. height : ls.o.tnHeight
  877. });
  878. var thi = $(el).find('.ls-thumbnail-hover-inner').css({
  879. visibility : 'hidden',
  880. display: 'block'
  881. });
  882. btn.hover(
  883. function(){
  884. var hoverLayer = $(el).find('.ls-slide').eq( $(this).index() );
  885. var tnSrc;
  886. if( ls.o.imgPreload === true && ls.o.lazyLoad === true ){
  887. if( hoverLayer.find('.ls-tn').length ){
  888. tnSrc = hoverLayer.find('.ls-tn').data('src');
  889. }else if( hoverLayer.find('.ls-videopreview').length ){
  890. tnSrc = hoverLayer.find('.ls-videopreview').attr('src');
  891. }else if( hoverLayer.find('.ls-bg').length ){
  892. tnSrc = hoverLayer.find('.ls-bg').data('src');
  893. }else{
  894. tnSrc = ls.o.skinsPath+ls.o.skin+'/nothumb.png';
  895. }
  896. }else{
  897. if( hoverLayer.find('.ls-tn').length ){
  898. tnSrc = hoverLayer.find('.ls-tn').attr('src');
  899. }else if( hoverLayer.find('.ls-videopreview').length ){
  900. tnSrc = hoverLayer.find('.ls-videopreview').attr('src');
  901. }else if( hoverLayer.find('.ls-bg').length ){
  902. tnSrc = hoverLayer.find('.ls-bg').attr('src');
  903. }else{
  904. tnSrc = ls.o.skinsPath+ls.o.skin+'/nothumb.png';
  905. }
  906. }
  907. $(el).find('.ls-thumbnail-hover-img').css({
  908. left: parseInt( th.css('padding-left') ),
  909. top: parseInt( th.css('padding-top') )
  910. });
  911. ti.load(function(){
  912. if( $(this).width() == 0 ){
  913. ti.css({
  914. position: 'relative',
  915. margin: '0 auto',
  916. left: 'auto'
  917. });
  918. }else{
  919. ti.css({
  920. position: 'absolute',
  921. marginLeft : - $(this).width() / 2,
  922. left: '50%'
  923. });
  924. }
  925. }).attr( 'src', tnSrc );
  926. th.css({
  927. display: 'block'
  928. }).stop().animate({
  929. left: $(this).position().left + ( $(this).width() - th.outerWidth() ) / 2
  930. }, 250 );
  931. thi.css({
  932. display : 'none',
  933. visibility : 'visible'
  934. }).stop().fadeIn(250);
  935. },
  936. function(){
  937. thi.stop().fadeOut(250, function(){
  938. th.css({
  939. visibility : 'hidden',
  940. display: 'block'
  941. });
  942. });
  943. }
  944. );
  945. }
  946. }
  947. if( ls.o.thumbnailNavigation == 'hover' ){
  948. thumbs.appendTo( $(el).find('.ls-bottom-slidebuttons') );
  949. }
  950. $(el).find('.ls-bottom-slidebuttons a:eq('+(ls.o.firstSlide-1)+')').addClass('ls-nav-active');
  951. }
  952. if( ls.o.navStartStop ){
  953. var buttonStart = $('<a class="ls-nav-start" href="#" />').click(function(e){
  954. e.preventDefault();
  955. $(el).layerSlider('start');
  956. }).prependTo( $(el).find('.ls-bottom-nav-wrapper') );
  957. var buttonStop = $('<a class="ls-nav-stop" href="#" />').click(function(e){
  958. e.preventDefault();
  959. $(el).layerSlider('stop');
  960. }).appendTo( $(el).find('.ls-bottom-nav-wrapper') );
  961. }else if( ls.o.thumbnailNavigation != 'always' ){
  962. $('<span class="ls-nav-sides ls-nav-sideleft" />').prependTo( $(el).find('.ls-bottom-nav-wrapper') );
  963. $('<span class="ls-nav-sides ls-nav-sideright" />').appendTo( $(el).find('.ls-bottom-nav-wrapper') );
  964. }
  965. if( ls.o.hoverBottomNav && ls.o.thumbnailNavigation != 'always' ){
  966. bottomNav.css({
  967. display: 'none'
  968. });
  969. $(el).hover(
  970. function(){
  971. if( !ls.g.forceHideControls ){
  972. if( ls.g.ie78 ){
  973. bottomNav.css('display','block');
  974. }else{
  975. bottomNav.stop(true,true).fadeIn(300);
  976. }
  977. }
  978. },
  979. function(){
  980. if( ls.g.ie78 ){
  981. bottomNav.css('display','none');
  982. }else{
  983. bottomNav.stop(true,true).fadeOut(300);
  984. }
  985. }
  986. )
  987. }
  988. }
  989. // NEW FEATURE v3x.5 thumbnailNavigation ('always')
  990. if( ls.o.thumbnailNavigation == 'always' ){
  991. ls.g.thumbsWrapper = $('<div class="ls-thumbnail-wrapper"></div>').appendTo( $(el) );
  992. 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 );
  993. ls.g.thumbnails = $(el).find('.ls-thumbnail-slide-container');
  994. if( !('ontouchstart' in window) ){
  995. ls.g.thumbnails.hover(
  996. function(){
  997. $(this).addClass('ls-thumbnail-slide-hover');
  998. },
  999. function(){
  1000. $(this).removeClass('ls-thumbnail-slide-hover');
  1001. ls.scrollThumb();
  1002. }
  1003. ).mousemove(function(e){
  1004. var mL = parseInt(e.pageX - $(this).offset().left ) / $(this).width() * ( $(this).width() - $(this).find('.ls-thumbnail-slide').width() );
  1005. $(this).find('.ls-thumbnail-slide').stop().css({
  1006. marginLeft : mL
  1007. });
  1008. });
  1009. }else{
  1010. ls.g.thumbnails.addClass('ls-touchscroll');
  1011. }
  1012. $(el).find('.ls-slide').each(function(){
  1013. var tempIndex = $(this).index() + 1;
  1014. var tnSrc;
  1015. if( ls.o.imgPreload === true && ls.o.lazyLoad === true ){
  1016. if( $(this).find('.ls-tn').length ){
  1017. tnSrc = $(this).find('.ls-tn').data('src');
  1018. }else if( $(this).find('.ls-videopreview').length ){
  1019. tnSrc = $(this).find('.ls-videopreview').attr('src');
  1020. }else if( $(this).find('.ls-bg').length ){
  1021. tnSrc = $(this).find('.ls-bg').data('src');
  1022. }else{
  1023. tnSrc = ls.o.skinsPath+ls.o.skin+'/nothumb.png';
  1024. }
  1025. }else{
  1026. if( $(this).find('.ls-tn').length ){
  1027. tnSrc = $(this).find('.ls-tn').attr('src');
  1028. }else if( $(this).find('.ls-videopreview').length ){
  1029. tnSrc = $(this).find('.ls-videopreview').attr('src');
  1030. }else if( $(this).find('.ls-bg').length ){
  1031. tnSrc = $(this).find('.ls-bg').attr('src');
  1032. }else{
  1033. tnSrc = ls.o.skinsPath+ls.o.skin+'/nothumb.png';
  1034. }
  1035. }
  1036. var thumb = $('<a href="#" class="ls-thumb-' + tempIndex + '"><img src="'+tnSrc+'"></a>');
  1037. thumb.appendTo( $(el).find('.ls-thumbnail-slide') );
  1038. if( !('ontouchstart' in window) ){
  1039. thumb.hover(
  1040. function(){
  1041. $(this).children().stop().fadeTo(300,ls.o.tnActiveOpacity/100);
  1042. },
  1043. function(){
  1044. if( !$(this).children().hasClass('ls-thumb-active') ){
  1045. $(this).children().stop().fadeTo(300,ls.o.tnInactiveOpacity/100);
  1046. }
  1047. }
  1048. );
  1049. }
  1050. thumb.click(function(e){
  1051. e.preventDefault();
  1052. $(el).layerSlider( tempIndex );
  1053. });
  1054. });
  1055. if( buttonStart && buttonStop ){
  1056. var lsBottomBelowTN = ls.g.bottomWrapper = $('<div class="ls-bottom-nav-wrapper ls-below-thumbnails"></div>').appendTo( $(el) );
  1057. buttonStart.clone().click(function(e){
  1058. e.preventDefault();
  1059. $(el).layerSlider('start');
  1060. }).appendTo( lsBottomBelowTN );
  1061. buttonStop.clone().click(function(e){
  1062. e.preventDefault();
  1063. $(el).layerSlider('stop');
  1064. }).appendTo( lsBottomBelowTN );
  1065. }
  1066. if( ls.o.hoverBottomNav ){
  1067. ls.g.thumbsWrapper.css('display','none');
  1068. if( lsBottomBelowTN ){
  1069. ls.g.bottomWrapper = lsBottomBelowTN.css('display') == 'block' ? lsBottomBelowTN : $(el).find('.ls-above-thumbnails');
  1070. ls.g.bottomWrapper.css('display','none');
  1071. }
  1072. // BUGFIXES v4.1.3 Added checking of the bottomWrapper variable
  1073. $(el).hover(
  1074. function(){
  1075. $(el).addClass('ls-hover');
  1076. if( !ls.g.forceHideControls ){
  1077. if( ls.g.ie78 ){
  1078. ls.g.thumbsWrapper.css('display','block');
  1079. if( ls.g.bottomWrapper ){
  1080. ls.g.bottomWrapper.css('display','block');
  1081. }
  1082. }else{
  1083. ls.g.thumbsWrapper.stop(true,true).fadeIn(300);
  1084. if( ls.g.bottomWrapper ){
  1085. ls.g.bottomWrapper.stop(true,true).fadeIn(300);
  1086. }
  1087. }
  1088. }
  1089. },
  1090. function(){
  1091. $(el).removeClass('ls-hover');
  1092. if( ls.g.ie78 ){
  1093. ls.g.thumbsWrapper.css('display','none');
  1094. if( ls.g.bottomWrapper ){
  1095. ls.g.bottomWrapper.css('display','none');
  1096. }
  1097. }else{
  1098. ls.g.thumbsWrapper.stop(true,true).fadeOut(300);
  1099. if( ls.g.bottomWrapper ){
  1100. ls.g.bottomWrapper.stop(true,true).fadeOut(300);
  1101. }
  1102. }
  1103. }
  1104. )
  1105. }
  1106. }
  1107. // Adding shadow wrapper
  1108. ls.g.shadow = $('<div class="ls-shadow"></div>').appendTo( $(el) );
  1109. if( ls.g.shadow.css('display') == 'block' && !ls.g.shadow.find('img').length ){
  1110. ls.g.showShadow = function(){
  1111. ls.g.shadow.css({
  1112. display: 'none',
  1113. visibility: 'visible'
  1114. }).fadeIn( 500, function(){
  1115. ls.g.showShadow = false;
  1116. });
  1117. }
  1118. ls.g.shadowImg = $('<img>').attr('src',ls.o.skinsPath+ls.o.skin+'/shadow.png').appendTo( ls.g.shadow );
  1119. ls.g.shadowBtmMod = typeof parseInt( $(el).css('padding-bottom') ) == 'number' ? parseInt( $(el).css('padding-bottom') ) : 0;
  1120. }
  1121. ls.resizeShadow();
  1122. // Adding keyboard navigation if turned on and if number of layers > 1
  1123. if( ls.o.keybNav && $(el).find('.ls-slide').length > 1 ){
  1124. $('body').bind('keydown',function(e){
  1125. if( !ls.g.isAnimating && !ls.g.isLoading ){
  1126. if( e.which == 37 ){
  1127. ls.o.cbPrev(ls.g);
  1128. ls.prev('clicked');
  1129. }else if( e.which == 39 ){
  1130. ls.o.cbNext(ls.g);
  1131. ls.next('clicked');
  1132. }
  1133. }
  1134. });
  1135. }
  1136. // Adding touch-control navigation if number of layers > 1
  1137. if('ontouchstart' in window && $(el).find('.ls-slide').length > 1 && ls.o.touchNav ){
  1138. $(el).find('.ls-inner').bind('touchstart', function( e ) {
  1139. var t = e.touches ? e.touches : e.originalEvent.touches;
  1140. if( t.length == 1 ){
  1141. ls.g.touchStartX = ls.g.touchEndX = t[0].clientX;
  1142. }
  1143. });
  1144. $(el).find('.ls-inner').bind('touchmove', function( e ) {
  1145. var t = e.touches ? e.touches : e.originalEvent.touches;
  1146. if( t.length == 1 ){
  1147. ls.g.touchEndX = t[0].clientX;
  1148. }
  1149. if( Math.abs( ls.g.touchStartX - ls.g.touchEndX ) > 45 ){
  1150. e.preventDefault();
  1151. }
  1152. });
  1153. $(el).find('.ls-inner').bind('touchend',function( e ){
  1154. if( Math.abs( ls.g.touchStartX - ls.g.touchEndX ) > 45 ){
  1155. if( ls.g.touchStartX - ls.g.touchEndX > 0 ){
  1156. ls.o.cbNext(ls.g);
  1157. $(el).layerSlider('next');
  1158. }else{
  1159. ls.o.cbPrev(ls.g);
  1160. $(el).layerSlider('prev');
  1161. }
  1162. }
  1163. });
  1164. }
  1165. // Feature: pauseOnHover (if number of layers > 1)
  1166. if( ls.o.pauseOnHover == true && $(el).find('.ls-slide').length > 1 ){
  1167. // BUGFIX v1.6 stop was not working because of pause on hover
  1168. $(el).find('.ls-inner').hover(
  1169. function(){
  1170. // Calling cbPause callback function
  1171. ls.o.cbPause(ls.g);
  1172. if( ls.g.autoSlideshow ){
  1173. ls.g.paused = true;
  1174. ls.stop();
  1175. // Stopping the animation of Timers
  1176. if( ls.g.barTimer ){
  1177. ls.g.barTimer.stop();
  1178. }
  1179. if( ls.g.circleTimer ){
  1180. if( ls.g.cttl ){
  1181. ls.g.cttl.pause();
  1182. }
  1183. }
  1184. ls.g.pausedSlideTime = new Date().getTime();
  1185. }
  1186. },
  1187. function(){
  1188. if( ls.g.paused == true ){
  1189. ls.start();
  1190. ls.g.paused = false;
  1191. }
  1192. }
  1193. );
  1194. }
  1195. ls.resizeSlider();
  1196. // NEW FEATURE v1.7 added yourLogo
  1197. if( ls.o.yourLogo ){
  1198. ls.g.yourLogo = $('<img>').addClass('ls-yourlogo').appendTo($(el)).attr('style', ls.o.yourLogoStyle ).css({
  1199. visibility: 'hidden',
  1200. display: 'bock'
  1201. }).load(function(){
  1202. // NEW FEATURE v3.0 added responsive yourLogo
  1203. var logoTimeout = 0;
  1204. if( !ls.g.yourLogo ){
  1205. logoTimeout = 1000;
  1206. }
  1207. setTimeout( function(){
  1208. ls.g.yourLogo.data( 'originalWidth', ls.g.yourLogo.width() );
  1209. ls.g.yourLogo.data( 'originalHeight', ls.g.yourLogo.height() );
  1210. if( ls.g.yourLogo.css('left') != 'auto' ){
  1211. ls.g.yourLogo.data( 'originalLeft', ls.g.yourLogo[0].style.left );
  1212. }
  1213. if( ls.g.yourLogo.css('right') != 'auto' ){
  1214. ls.g.yourLogo.data( 'originalRight', ls.g.yourLogo[0].style.right );
  1215. }
  1216. if( ls.g.yourLogo.css('top') != 'auto' ){
  1217. ls.g.yourLogo.data( 'originalTop', ls.g.yourLogo[0].style.top );
  1218. }
  1219. if( ls.g.yourLogo.css('bottom') != 'auto' ){
  1220. ls.g.yourLogo.data( 'originalBottom', ls.g.yourLogo[0].style.bottom );
  1221. }
  1222. // NEW FEATURES v1.8 added yourLogoLink & yourLogoTarget
  1223. if( ls.o.yourLogoLink != false ){
  1224. $('<a>').appendTo($(el)).attr( 'href', ls.o.yourLogoLink ).attr('target', ls.o.yourLogoTarget ).css({
  1225. textDecoration : 'none',
  1226. outline : 'none'
  1227. }).append( ls.g.yourLogo );
  1228. }
  1229. ls.g.yourLogo.css({
  1230. display: 'none',
  1231. visibility: 'visible'
  1232. });
  1233. ls.resizeYourLogo();
  1234. }, logoTimeout );
  1235. }).attr( 'src', ls.o.yourLogo );
  1236. }
  1237. // NEW FEATURE v1.7 added window resize function for make responsive layout better
  1238. $(window).resize(function(){
  1239. ls.resize();
  1240. });
  1241. // BUGFIX v5.3.0 Responsiveness not worked in some cases while changed orientation on mobile devices
  1242. $(window).on('orientationchange',function(){
  1243. $(window).resize();
  1244. });
  1245. ls.g.showSlider = true;
  1246. // NEW FEATURE v1.7 animating first slide
  1247. if( ls.o.animateFirstSlide == true ){
  1248. if( ls.o.autoStart ){
  1249. ls.g.autoSlideshow = true;
  1250. $(el).find('.ls-nav-start').addClass('ls-nav-start-active');
  1251. }else{
  1252. $(el).find('.ls-nav-stop').addClass('ls-nav-stop-active');
  1253. }
  1254. ls.next();
  1255. }else if( typeof ls.g.curLayer[0] !== 'undefined' ){
  1256. ls.imgPreload(ls.g.curLayer,function(){
  1257. ls.g.curLayer.fadeIn(ls.o.sliderFadeInDuration, function(){
  1258. ls.g.isLoading = false;
  1259. $(this).addClass('ls-active');
  1260. // NEW FEATURE v2.0 autoPlayVideos
  1261. if( ls.o.autoPlayVideos ){
  1262. $(this).delay( $(this).data('delayin') + 25 ).queue(function(){
  1263. // YouTube & Vimeo videos
  1264. $(this).find('.ls-videopreview').click();
  1265. // HTML5 videos
  1266. $(this).find('video, audio').each(function(){
  1267. if( typeof $(this)[0].currentTime !== 0){
  1268. $(this)[0].currentTime = 0;
  1269. }
  1270. $(this).click();
  1271. });
  1272. $(this).dequeue();
  1273. });
  1274. }
  1275. // NEW FEATURE v3.0 showUntil sublayers
  1276. ls.g.curLayer.find(' > *[class*="ls-l"]').each(function(){
  1277. // Setting showUntilTimers
  1278. var cursub = $(this);
  1279. // IMPROVEMENT v5.2.0 video layers with auto play will skip showuntil feature
  1280. if( ( !cursub.hasClass('ls-video-layer') || ( cursub.hasClass('ls-video-layer') && ls.o.autoPlayVideos === false ) ) && cursub.data('showuntil') > 0 ){
  1281. // IMPROVEMENT v4.5.0 sublayerShowUntil will be called anly if necessary
  1282. cursub.data('showUntilTimer', setTimeout(function(){
  1283. ls.sublayerShowUntil( cursub );
  1284. }, cursub.data('showuntil') ));
  1285. }
  1286. });
  1287. });
  1288. ls.changeThumb(ls.g.curLayerIndex)
  1289. // If autoStart is true
  1290. if( ls.o.autoStart ){
  1291. ls.g.isLoading = false;
  1292. ls.start();
  1293. }else{
  1294. $(el).find('.ls-nav-stop').addClass('ls-nav-stop-active');
  1295. }
  1296. });
  1297. }
  1298. // NEW FEATURE v1.7 added cbInit function
  1299. ls.o.cbInit($(el));
  1300. };
  1301. ls.resize = function(){
  1302. ls.g.resize = true;
  1303. if( !ls.g.isAnimating ){
  1304. ls.makeResponsive( ls.g.curLayer, function(){
  1305. if( ls.g.ltContainer ){
  1306. ls.g.ltContainer.empty();
  1307. }
  1308. ls.g.resize = false;
  1309. });
  1310. if( ls.g.yourLogo ){
  1311. ls.resizeYourLogo();
  1312. }
  1313. }
  1314. };
  1315. ls.start = function(){
  1316. if( ls.g.autoSlideshow ){
  1317. if( ls.g.prevNext == 'prev' && ls.o.twoWaySlideshow ){
  1318. ls.prev();
  1319. }else{
  1320. ls.next();
  1321. }
  1322. }else{
  1323. ls.g.autoSlideshow = true;
  1324. if( !ls.g.isAnimating && !ls.g.isLoading ){
  1325. ls.timer();
  1326. }
  1327. }
  1328. $(el).find('.ls-nav-start').addClass('ls-nav-start-active');
  1329. $(el).find('.ls-nav-stop').removeClass('ls-nav-stop-active');
  1330. };
  1331. ls.timer = function(){
  1332. if( $(el).find('.ls-active').data('ls') ){
  1333. var sD = ls.st.slideDelay;
  1334. }else{
  1335. var sD = ls.o.slideDelay;
  1336. }
  1337. var delaytime = $(el).find('.ls-active').data('slidedelay') ? parseInt( $(el).find('.ls-active').data('slidedelay') ) : sD;
  1338. // BUGFIX v3.0 delaytime did not work on first layer if animateFirstSlide was set to off
  1339. // BUGFIX v3.5 delaytime did not work on all layers in standalone version after bugfix 3.0 :)
  1340. if( !ls.o.animateFirstSlide && !$(el).find('.ls-active').data('slidedelay') ){
  1341. var tempD = $(el).find('.ls-slide:eq('+(ls.o.firstSlide-1)+')').data('slidedelay');
  1342. delaytime = tempD ? tempD : sD;
  1343. }
  1344. clearTimeout( ls.g.slideTimer );
  1345. // NEW FEATURE v4.5.0 Timers
  1346. if( ls.g.pausedSlideTime ){
  1347. if( !ls.g.startSlideTime ){
  1348. ls.g.startSlideTime = new Date().getTime();
  1349. }
  1350. if( ls.g.startSlideTime > ls.g.pausedSlideTime ){
  1351. ls.g.pausedSlideTime = new Date().getTime();
  1352. }
  1353. if(! ls.g.curSlideTime ){
  1354. ls.g.curSlideTime = delaytime;
  1355. }
  1356. ls.g.curSlideTime -= (ls.g.pausedSlideTime - ls.g.startSlideTime);
  1357. ls.g.pausedSlideTime = false;
  1358. ls.g.startSlideTime = new Date().getTime();
  1359. }else{
  1360. ls.g.curSlideTime = delaytime;
  1361. ls.g.startSlideTime = new Date().getTime();
  1362. }
  1363. // BUGFIX v4.6.0 fixed Bar Timer animation on the fisrt slide if animateFirstSlide is false
  1364. ls.g.curSlideTime = parseInt( ls.g.curSlideTime );
  1365. ls.g.slideTimer = setTimeout(function(){
  1366. ls.g.startSlideTime = ls.g.pausedSlideTime = ls.g.curSlideTime = false;
  1367. ls.start();
  1368. }, ls.g.curSlideTime );
  1369. // Animating Timers
  1370. if( ls.g.barTimer ){
  1371. ls.g.barTimer.animate({
  1372. width : ls.g.sliderWidth()
  1373. }, ls.g.curSlideTime, 'linear', function(){
  1374. $(this).css({
  1375. width: 0
  1376. });
  1377. });
  1378. }
  1379. if( ls.g.circleTimer ){
  1380. var ct1 = ls.g.circleTimer.find('.ls-ct-right .ls-ct-rotate');
  1381. var ct2 = ls.g.circleTimer.find('.ls-ct-left .ls-ct-rotate');
  1382. if( ls.g.circleTimer.css('display') == 'none' ){
  1383. ct1.css({
  1384. rotate : 0
  1385. });
  1386. ct2.css({
  1387. rotate : 0
  1388. });
  1389. ls.g.circleTimer.fadeIn(350);
  1390. }
  1391. if( !ls.g.cttl ){
  1392. ls.g.cttl = new TimelineLite();
  1393. ls.g.cttl.add( TweenLite.fromTo(ct1[0],delaytime/2000,{
  1394. rotation : 0
  1395. },{
  1396. ease : Linear.easeNone,
  1397. rotation : 180,
  1398. onReverseComplete : function(){
  1399. ls.g.cttl = false;
  1400. }
  1401. }));
  1402. ls.g.cttl.add( TweenLite.fromTo(ct2[0],delaytime/2000,{
  1403. rotation : 0
  1404. },{
  1405. ease : Linear.easeNone,
  1406. rotation : 180
  1407. }));
  1408. }else{
  1409. ls.g.cttl.resume();
  1410. }
  1411. }
  1412. };
  1413. ls.stop = function(){
  1414. // Stopping Timers
  1415. ls.g.pausedSlideTime = new Date().getTime();
  1416. if( ls.g.barTimer ){
  1417. ls.g.barTimer.stop();
  1418. }
  1419. if( ls.g.circleTimer ){
  1420. if( ls.g.cttl ){
  1421. ls.g.cttl.pause();
  1422. }
  1423. }
  1424. if( !ls.g.paused && !ls.g.originalAutoSlideshow ){
  1425. $(el).find('.ls-nav-stop').addClass('ls-nav-stop-active');
  1426. $(el).find('.ls-nav-start').removeClass('ls-nav-start-active');
  1427. }
  1428. clearTimeout( ls.g.slideTimer );
  1429. ls.g.autoSlideshow = false;
  1430. };
  1431. ls.forcestop = function(){
  1432. clearTimeout( ls.g.slideTimer );
  1433. ls.g.autoSlideshow = false;
  1434. clearTimeout( ls.g.t1 );
  1435. clearTimeout( ls.g.t2 );
  1436. clearTimeout( ls.g.t3 );
  1437. clearTimeout( ls.g.t4 );
  1438. clearTimeout( ls.g.t5 );
  1439. if( ls.g.barTimer ){
  1440. ls.g.barTimer.stop();
  1441. }
  1442. if( ls.g.circleTimer ){
  1443. if( ls.g.cttl ){
  1444. ls.g.cttl.pause();
  1445. }
  1446. }
  1447. $(el).find('*').stop(true,false).dequeue();
  1448. $(el).find('.ls-slide >').each(function(){
  1449. if( $(this).data('tr') ){
  1450. $(this).data('tr').pause();
  1451. }
  1452. });
  1453. if( !ls.g.paused && !ls.g.originalAutoSlideshow ){
  1454. $(el).find('.ls-nav-stop').addClass('ls-nav-stop-active');
  1455. $(el).find('.ls-nav-start').removeClass('ls-nav-start-active');
  1456. }
  1457. };
  1458. ls.restart = function(){
  1459. $(el).find('*').stop();
  1460. clearTimeout( ls.g.slideTimer );
  1461. ls.change(ls.g.curLayerIndex,ls.g.prevNext);
  1462. };
  1463. // Because of an ie7 bug, we have to check & format the strings correctly
  1464. ls.ieEasing = function( e ){
  1465. // BUGFIX v1.6 and v1.8 some type of animations didn't work properly
  1466. if( $.trim(e.toLowerCase()) == 'swing' || $.trim(e.toLowerCase()) == 'linear'){
  1467. return e.toLowerCase();
  1468. }else{
  1469. 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');
  1470. }
  1471. };
  1472. // Calculating prev layer
  1473. ls.prev = function(clicked){
  1474. // NEW FEATURE v2.0 loops
  1475. if( ls.g.curLayerIndex < 2 ){
  1476. ls.g.nextLoop += 1;
  1477. }
  1478. if( ( ls.g.nextLoop > ls.o.loops ) && ( ls.o.loops > 0 ) && !clicked ){
  1479. ls.g.nextLoop = 0;
  1480. ls.stop();
  1481. if( ls.o.forceLoopNum == false ){
  1482. ls.o.loops = 0;
  1483. }
  1484. }else{
  1485. var prev = ls.g.curLayerIndex < 2 ? ls.g.layersNum : ls.g.curLayerIndex - 1;
  1486. ls.g.prevNext = 'prev';
  1487. ls.change(prev,ls.g.prevNext);
  1488. }
  1489. };
  1490. // Calculating next layer
  1491. ls.next = function(clicked){
  1492. // NEW FEATURE v2.0 loops
  1493. if( !ls.o.randomSlideshow ){
  1494. if( !(ls.g.curLayerIndex < ls.g.layersNum) ){
  1495. ls.g.nextLoop += 1;
  1496. }
  1497. if( ( ls.g.nextLoop > ls.o.loops ) && ( ls.o.loops > 0 ) && !clicked ){
  1498. ls.g.nextLoop = 0;
  1499. ls.stop();
  1500. if( ls.o.forceLoopNum == false ){
  1501. ls.o.loops = 0;
  1502. }
  1503. }else{
  1504. var next = ls.g.curLayerIndex < ls.g.layersNum ? ls.g.curLayerIndex + 1 : 1;
  1505. ls.g.prevNext = 'next';
  1506. ls.change(next,ls.g.prevNext);
  1507. }
  1508. }else if( !clicked ){
  1509. // NEW FEATURE v3.5 randomSlideshow
  1510. var next = ls.g.curLayerIndex;
  1511. var calcRand = function(){
  1512. next = Math.floor(Math.random() * ls.g.layersNum) + 1;
  1513. if( next == ls.g.curLayerIndex ){
  1514. calcRand();
  1515. }else{
  1516. ls.g.prevNext = 'next';
  1517. ls.change(next,ls.g.prevNext);
  1518. }
  1519. }
  1520. calcRand();
  1521. }else if( clicked ){
  1522. var next = ls.g.curLayerIndex < ls.g.layersNum ? ls.g.curLayerIndex + 1 : 1;
  1523. ls.g.prevNext = 'next';
  1524. ls.change(next,ls.g.prevNext);
  1525. }
  1526. };
  1527. ls.change = function(num,prevnext){
  1528. // Stopping Timers if needed
  1529. ls.g.startSlideTime = ls.g.pausedSlideTime = ls.g.curSlideTime = false;
  1530. // IMPROVEMENT v4.6.0 Bar Timer animation
  1531. if( ls.g.barTimer ){
  1532. ls.g.barTimer.stop().delay(300).animate({
  1533. width: 0
  1534. },450);
  1535. }
  1536. if( ls.g.circleTimer ){
  1537. ls.g.circleTimer.fadeOut(500);
  1538. if( ls.g.cttl ){
  1539. ls.g.cttl.reverse().duration(.35);
  1540. }
  1541. }
  1542. // NEW FEATURE v2.0 videoPreview & autoPlayVideos
  1543. if( ls.g.pausedByVideo == true ){
  1544. ls.g.pausedByVideo = false;
  1545. ls.g.autoSlideshow = ls.g.originalAutoSlideshow;
  1546. ls.g.curLayer.find('iframe[src*="youtube.com"], iframe[src*="youtu.be"], iframe[src*="player.vimeo"]').each(function(){
  1547. $(this).parent().find('.ls-vpcontainer').fadeIn(ls.g.v.fi,function(){
  1548. $(this).parent().find('iframe').attr('src','');
  1549. });
  1550. });
  1551. ls.g.curLayer.find('video, audio').each(function(){
  1552. this.pause();
  1553. });
  1554. }
  1555. $(el).find('iframe[src*="youtube.com"], iframe[src*="youtu.be"], iframe[src*="player.vimeo"]').each(function(){
  1556. // Clearing videoTimeouts
  1557. clearTimeout( $(this).data( 'videoTimer') );
  1558. });
  1559. clearTimeout( ls.g.slideTimer );
  1560. ls.g.nextLayerIndex = num;
  1561. ls.g.nextLayer = $(el).find('.ls-slide:eq('+(ls.g.nextLayerIndex-1)+')');
  1562. // BUGFIX v1.6 fixed wrong directions of animations if navigating by slidebuttons
  1563. if( !prevnext ){
  1564. if( ls.g.curLayerIndex < ls.g.nextLayerIndex ){
  1565. ls.g.prevNext = 'next';
  1566. }else{
  1567. ls.g.prevNext = 'prev';
  1568. }
  1569. }
  1570. // Added timeOut to wait for the fade animation of videoPreview image...
  1571. var timeOut = 0;
  1572. if( $(el).find('iframe[src*="youtube.com"], iframe[src*="youtu.be"], iframe[src*="player.vimeo"]').length > 0 ){
  1573. timeOut = ls.g.v.fi;
  1574. }
  1575. if( typeof ls.g.nextLayer[0] !== 'undefined' ){
  1576. ls.imgPreload(ls.g.nextLayer,function(){
  1577. ls.animate();
  1578. });
  1579. }
  1580. };
  1581. // Preloading images
  1582. ls.imgPreload = function(layer,callback){
  1583. ls.g.isLoading = true;
  1584. // Showing slider for the first time
  1585. if( ls.g.showSlider ){
  1586. $(el).css({
  1587. visibility : 'visible'
  1588. });
  1589. }
  1590. // If image preload is on
  1591. if( ls.o.imgPreload ){
  1592. var preImages = [];
  1593. var preloaded = 0;
  1594. // NEW FEATURE v1.8 Preloading background images of layers
  1595. if( layer.css('background-image') != 'none' && layer.css('background-image').indexOf('url') != -1 && !layer.hasClass('ls-preloaded') && !layer.hasClass('ls-not-preloaded') ){
  1596. var bgi = layer.css('background-image');
  1597. bgi = bgi.match(/url\((.*)\)/)[1].replace(/"/gi, '');
  1598. preImages[preImages.length] = [bgi, layer];
  1599. }
  1600. // Images inside layers
  1601. layer.find('img:not(.ls-preloaded, .ls-not-preloaded)').each(function(){
  1602. // NEW FEATURE v5.0.0 Lazy-load
  1603. if( ls.o.lazyLoad === true ){
  1604. $(this).attr('src',$(this).data('src'));
  1605. }
  1606. preImages[preImages.length] = [$(this).attr('src'), $(this)];
  1607. });
  1608. // Background images inside layers
  1609. layer.find('*').each(function(){
  1610. // BUGFIX v1.7 fixed preload bug with sublayers with gradient backgrounds
  1611. if( $(this).css('background-image') != 'none' && $(this).css('background-image').indexOf('url') != -1 && !$(this).hasClass('ls-preloaded') && !$(this).hasClass('ls-not-preloaded') ){
  1612. var bgi = $(this).css('background-image');
  1613. bgi = bgi.match(/url\((.*)\)/)[1].replace(/"/gi, '');
  1614. preImages[preImages.length] = [bgi, $(this)];
  1615. }
  1616. });
  1617. // BUGFIX v1.7 if there are no images in a layer, calling the callback function
  1618. if(preImages.length == 0){
  1619. $('.ls-thumbnail-wrapper, .ls-nav-next, .ls-nav-prev, .ls-bottom-nav-wrapper').css({
  1620. visibility : 'visible'
  1621. });
  1622. ls.makeResponsive(layer, callback);
  1623. }else{
  1624. // NEW FEATURE v4.0 Showing loading indicator
  1625. if( ls.g.ie78 ){
  1626. ls.g.li.css('display','block');
  1627. }else{
  1628. // BUGIFX v4.1.3 Adding delay to the showing of the loading indicator
  1629. ls.g.li.delay(400).fadeIn(300);
  1630. }
  1631. var afterImgLoad = function(){
  1632. // NEW FEATURE v4.0 Hiding loading indicator
  1633. ls.g.li.stop(true,true).css({
  1634. display: 'none'
  1635. });
  1636. $('.ls-thumbnail-wrapper, .ls-nav-next, .ls-nav-prev, .ls-bottom-nav-wrapper').css({
  1637. visibility : 'visible'
  1638. });
  1639. // We love you so much IE... -.-
  1640. if( navigator.userAgent.indexOf('Trident/7') !== -1 || ls.g.ie78 ){
  1641. setTimeout(function(){
  1642. ls.makeResponsive(layer, callback);
  1643. },50);
  1644. }else{
  1645. ls.makeResponsive(layer, callback);
  1646. }
  1647. };
  1648. for(x=0;x<preImages.length;x++){
  1649. $('<img>').data('el',preImages[x]).load(function(){
  1650. $(this).data('el')[1].addClass('ls-preloaded');
  1651. if( ++preloaded == preImages.length ){
  1652. afterImgLoad();
  1653. }
  1654. }).error(function(){
  1655. var imgURL = $(this).data('el')[0].substring($(this).data('el')[0].lastIndexOf("/") + 1, $(this).data('el')[0].length);
  1656. if( window.console ){
  1657. 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.');
  1658. }else{
  1659. 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.');
  1660. }
  1661. $(this).addClass('ls-not-preloaded');
  1662. // IMPROVEMENT v5.2.0 The slider should not stop even if an image cannot be loaded
  1663. if( ++preloaded == preImages.length ){
  1664. afterImgLoad();
  1665. }
  1666. }).attr('src',preImages[x][0]);
  1667. }
  1668. }
  1669. }else{
  1670. $('.ls-thumbnail-wrapper, .ls-nav-next, .ls-nav-prev, .ls-bottom-nav-wrapper').css({
  1671. visibility : 'visible'
  1672. });
  1673. ls.makeResponsive(layer, callback);
  1674. }
  1675. };
  1676. // NEW FEATURE v1.7 making the slider responsive
  1677. ls.makeResponsive = function(layer, callback ){
  1678. layer.css({
  1679. visibility: 'hidden',
  1680. display: 'block'
  1681. });
  1682. if( ls.g.showShadow ){
  1683. ls.g.showShadow();
  1684. }
  1685. ls.resizeSlider();
  1686. if( ls.o.thumbnailNavigation == 'always' ){
  1687. ls.resizeThumb();
  1688. }
  1689. layer.children().each(function(){
  1690. var sl = $(this);
  1691. // positioning
  1692. var ol = sl.data('originalLeft') ? sl.data('originalLeft') : '0';
  1693. var ot = sl.data('originalTop') ? sl.data('originalTop') : '0';
  1694. if( sl.is('a') && sl.children().length > 0 ){
  1695. sl.css({
  1696. display : 'block'
  1697. });
  1698. sl = sl.children();
  1699. }
  1700. var ow = 'auto';
  1701. var oh = 'auto';
  1702. if( sl.data('originalWidth') ){
  1703. if( typeof sl.data('originalWidth') == 'number' ){
  1704. ow = parseInt( sl.data('originalWidth') ) * ls.g.ratio;
  1705. }else if( sl.data('originalWidth').indexOf('%') != -1 ){
  1706. ow = sl.data('originalWidth');
  1707. }
  1708. }
  1709. if( sl.data('originalHeight') ){
  1710. if( typeof sl.data('originalHeight') == 'number' ){
  1711. oh = parseInt( sl.data('originalHeight') ) * ls.g.ratio;
  1712. }else if( sl.data('originalHeight').indexOf('%') != -1 ){
  1713. oh = sl.data('originalHeight');
  1714. }
  1715. }
  1716. // padding
  1717. var opl = sl.data('originalPaddingLeft') ? parseInt( sl.data('originalPaddingLeft') ) * ls.g.ratio : 0;
  1718. var opr = sl.data('originalPaddingRight') ? parseInt( sl.data('originalPaddingRight') ) * ls.g.ratio : 0;
  1719. var opt = sl.data('originalPaddingTop') ? parseInt( sl.data('originalPaddingTop') ) * ls.g.ratio : 0;
  1720. var opb = sl.data('originalPaddingBottom') ? parseInt( sl.data('originalPaddingBottom') ) * ls.g.ratio : 0;
  1721. // border
  1722. var obl = sl.data('originalBorderLeft') ? parseInt( sl.data('originalBorderLeft') ) * ls.g.ratio : 0;
  1723. var obr = sl.data('originalBorderRight') ? parseInt( sl.data('originalBorderRight') ) * ls.g.ratio : 0;
  1724. var obt = sl.data('originalBorderTop') ? parseInt( sl.data('originalBorderTop') ) * ls.g.ratio : 0;
  1725. var obb = sl.data('originalBorderBottom') ? parseInt( sl.data('originalBorderBottom') ) * ls.g.ratio : 0;
  1726. // font
  1727. var ofs = sl.data('originalFontSize');
  1728. var olh = sl.data('originalLineHeight');
  1729. // NEW FEATURE v3.0 added "normal" responsive mode with image and font resizing
  1730. // NEW FEATURE v3.5 added responsiveUnder
  1731. if( ls.g.responsiveMode || ls.o.responsiveUnder > 0 ){
  1732. if( sl.is('img') && !sl.hasClass('ls-bg') && sl.attr('src') ){
  1733. sl.css({
  1734. width: 'auto',
  1735. height: 'auto'
  1736. });
  1737. // IMPROVEMENT v4.5.0 Images can have now starting width / height
  1738. if( ( ow == 0 || ow == 'auto' ) && typeof oh == 'number' && oh != 0 ){
  1739. ow = ( oh / sl.height() ) * sl.width();
  1740. }
  1741. if( ( oh == 0 || oh == 'auto' ) && typeof ow == 'number' && ow != 0 ){
  1742. oh = ( ow / sl.width() ) * sl.height();
  1743. }
  1744. if( ow == 'auto'){
  1745. ow = sl.width() * ls.g.ratio;
  1746. }
  1747. if( oh == 'auto'){
  1748. oh = sl.height() * ls.g.ratio;
  1749. }
  1750. sl.css({
  1751. width : ow,
  1752. height : oh
  1753. });
  1754. }
  1755. if( !sl.is('img') ){
  1756. sl.css({
  1757. width : ow,
  1758. height : oh,
  1759. 'font-size' : parseInt(ofs) * ls.g.ratio +'px',
  1760. 'line-height' : parseInt(olh) * ls.g.ratio + 'px'
  1761. });
  1762. }
  1763. if( sl.is('div') && sl.find('iframe').data('videoSrc') ){
  1764. var videoIframe = sl.find('iframe');
  1765. videoIframe.attr('width', parseInt( videoIframe.data('originalWidth') ) * ls.g.ratio ).attr('height', parseInt( videoIframe.data('originalHeight') ) * ls.g.ratio );
  1766. sl.css({
  1767. width : parseInt( videoIframe.data('originalWidth') ) * ls.g.ratio,
  1768. height : parseInt( videoIframe.data('originalHeight') ) * ls.g.ratio
  1769. });
  1770. }
  1771. sl.css({
  1772. padding : opt + 'px ' + opr + 'px ' + opb + 'px ' + opl + 'px ',
  1773. borderLeftWidth : obl + 'px',
  1774. borderRightWidth : obr + 'px',
  1775. borderTopWidth : obt + 'px',
  1776. borderBottomWidth : obb + 'px'
  1777. });
  1778. }
  1779. // If it is NOT a bg sublayer
  1780. if( !sl.hasClass('ls-bg') ){
  1781. var sl2 = sl;
  1782. if( sl.parent().is('a') ){
  1783. sl = sl.parent();
  1784. }
  1785. // NEW FEATURE v3.5 sublayerContainer
  1786. var slC = 0;
  1787. if( ls.o.layersContainer ){
  1788. slC = ls.o.layersContainer > 0 ? ( ls.g.sliderWidth() - ls.o.layersContainer ) / 2 : 0;
  1789. }else if( ls.o.sublayerContainer ){
  1790. slC = ls.o.sublayerContainer > 0 ? ( ls.g.sliderWidth() - ls.o.sublayerContainer ) / 2 : 0;
  1791. }
  1792. slC = slC < 0 ? 0 : slC;
  1793. // (RE)positioning sublayer (left property)
  1794. if( ol.indexOf('%') != -1 ){
  1795. sl.css({
  1796. left : ls.g.sliderWidth() / 100 * parseInt(ol) - sl2.width() / 2 - opl - obl
  1797. });
  1798. }else if( slC > 0 || ls.g.responsiveMode || ls.o.responsiveUnder > 0 ){
  1799. sl.css({
  1800. left : slC + parseInt(ol) * ls.g.ratio
  1801. });
  1802. }
  1803. // (RE)positioning sublayer (top property)
  1804. if( ot.indexOf('%') != -1 ){
  1805. sl.css({
  1806. top : ls.g.sliderHeight() / 100 * parseInt(ot) - sl2.height() / 2 - opt - obt
  1807. });
  1808. }else if( ls.g.responsiveMode || ls.o.responsiveUnder > 0 ){
  1809. sl.css({
  1810. top : parseInt(ot) * ls.g.ratio
  1811. });
  1812. }
  1813. }else{
  1814. var inner = $(el).find('.ls-inner');
  1815. sl.css({
  1816. width : 'auto',
  1817. height : 'auto'
  1818. });
  1819. ow = sl.width();
  1820. oh = sl.height();
  1821. // IMPROVEMENT v4.5.0 Resizing smaller background images in full width mode as well to fill the whole slide
  1822. var or = ls.g.ratio;
  1823. if( ls.g.sliderOriginalWidth.indexOf('%') != -1 ){
  1824. if( ls.g.sliderWidth() > ow ){
  1825. or = ls.g.sliderWidth() / ow;
  1826. if( ls.g.sliderHeight() > oh * or ){
  1827. or = ls.g.sliderHeight() / oh;
  1828. }
  1829. }else if( ls.g.sliderHeight() > oh ){
  1830. or = ls.g.sliderHeight() / oh;
  1831. if( ls.g.sliderWidth() > ow * or ){
  1832. or = ls.g.sliderWidth() / ow;
  1833. }
  1834. }
  1835. }
  1836. sl.css({
  1837. width : ow * or,
  1838. height : oh * or,
  1839. marginLeft : inner.width() / 2 - ow * or / 2,
  1840. marginTop : inner.height() / 2 - oh * or / 2
  1841. });
  1842. // $('#w2 span:eq(0)').html( ( inner.width() / 2 ) - Math.round( ow * or / 2 ) );
  1843. }
  1844. });
  1845. layer.css({
  1846. display: 'none',
  1847. visibility: 'visible'
  1848. });
  1849. // Resizing shadow
  1850. ls.resizeShadow();
  1851. callback();
  1852. $(this).dequeue();
  1853. };
  1854. // Resizing shadow
  1855. ls.resizeShadow = function(){
  1856. if( ls.g.shadowImg ){
  1857. var resizeShadow = function(){
  1858. if( ls.g.shadowImg.height() > 0 ){
  1859. if( ls.g.shadowBtmMod > 0 ){
  1860. ls.g.shadow.css({
  1861. height: ls.g.shadowImg.height() / 2
  1862. });
  1863. }else{
  1864. ls.g.shadow.css({
  1865. height: ls.g.shadowImg.height(),
  1866. marginTop: - ls.g.shadowImg.height() / 2
  1867. });
  1868. }
  1869. }else{
  1870. setTimeout(function(){
  1871. resizeShadow();
  1872. },50);
  1873. }
  1874. };
  1875. resizeShadow();
  1876. }
  1877. };
  1878. // Resizing the slider
  1879. ls.resizeSlider = function(){
  1880. if( ls.o.responsiveUnder > 0 ){
  1881. if( $(window).width() < ls.o.responsiveUnder ){
  1882. ls.g.responsiveMode = true;
  1883. ls.g.sliderOriginalWidth = ls.o.responsiveUnder + 'px';
  1884. }else{
  1885. ls.g.responsiveMode = false;
  1886. ls.g.sliderOriginalWidth = ls.g.sliderOriginalWidthRU;
  1887. ls.g.ratio = 1;
  1888. }
  1889. }
  1890. // BUGFIX 5.3.0 Fixed full-width resize issue
  1891. if( $(el).closest('.ls-wp-fullwidth-container').length ){
  1892. $(el).closest('.ls-wp-fullwidth-helper').css({
  1893. width : $(window).width()
  1894. });
  1895. }
  1896. // NEW FEATURE v3.0 added "normal" responsive mode with image and font resizing
  1897. if( ls.g.responsiveMode ){
  1898. var parent = $(el).parent();
  1899. // NEW FEATURE v5.5.0 Added fullScreen mode
  1900. if( ls.o.fullScreen === true ){
  1901. $(el).css({
  1902. width : '100%',
  1903. height : $(window).height()
  1904. });
  1905. }else{
  1906. // BUGFIX v4.0 there is no need to subtract the values of the left and right paddings of the container element!
  1907. $(el).css({
  1908. width : parent.width() - parseInt($(el).css('padding-left')) - parseInt($(el).css('padding-right'))
  1909. });
  1910. ls.g.ratio = $(el).width() / parseInt( ls.g.sliderOriginalWidth );
  1911. $(el).css({
  1912. height : ls.g.ratio * parseInt( ls.g.sliderOriginalHeight )
  1913. });
  1914. }
  1915. }else{
  1916. ls.g.ratio = 1;
  1917. $(el).css({
  1918. width : ls.g.sliderOriginalWidth,
  1919. height : ls.g.sliderOriginalHeight
  1920. });
  1921. }
  1922. // WP fullWidth mode (originally forceResponsive mode)
  1923. if( $(el).closest('.ls-wp-fullwidth-container').length ){
  1924. $(el).closest('.ls-wp-fullwidth-helper').css({
  1925. height : $(el).outerHeight(true)
  1926. });
  1927. $(el).closest('.ls-wp-fullwidth-container').css({
  1928. height : $(el).outerHeight(true)
  1929. });
  1930. $(el).closest('.ls-wp-fullwidth-helper').css({
  1931. width : $(window).width(),
  1932. left : - $(el).closest('.ls-wp-fullwidth-container').offset().left
  1933. });
  1934. if( ls.g.sliderOriginalWidth.indexOf('%') != -1 ){
  1935. var percentWidth = parseInt( ls.g.sliderOriginalWidth );
  1936. var newWidth = $('body').width() / 100 * percentWidth - ( $(el).outerWidth() - $(el).width() );
  1937. $(el).width( newWidth );
  1938. }
  1939. }
  1940. $(el).find('.ls-inner, .ls-lt-container').css({
  1941. width : ls.g.sliderWidth(),
  1942. height : ls.g.sliderHeight()
  1943. });
  1944. // BUGFIX v2.0 fixed width problem if firstSlide is not 1
  1945. if( ls.g.curLayer && ls.g.nextLayer ){
  1946. ls.g.curLayer.css({
  1947. width : ls.g.sliderWidth(),
  1948. height : ls.g.sliderHeight()
  1949. });
  1950. ls.g.nextLayer.css({
  1951. width : ls.g.sliderWidth(),
  1952. height : ls.g.sliderHeight()
  1953. });
  1954. }else{
  1955. $(el).find('.ls-slide').css({
  1956. width : ls.g.sliderWidth(),
  1957. height : ls.g.sliderHeight()
  1958. });
  1959. }
  1960. };
  1961. // NEW FEATURE v3.0 added responsive yourLogo
  1962. ls.resizeYourLogo = function(){
  1963. ls.g.yourLogo.css({
  1964. width : ls.g.yourLogo.data( 'originalWidth' ) * ls.g.ratio,
  1965. height : ls.g.yourLogo.data( 'originalHeight' ) * ls.g.ratio
  1966. });
  1967. if( ls.g.ie78 ){
  1968. ls.g.yourLogo.css('display','block');
  1969. }else{
  1970. ls.g.yourLogo.fadeIn(300);
  1971. }
  1972. var oL = oR = oT = oB = 'auto';
  1973. if( ls.g.yourLogo.data( 'originalLeft' ) && ls.g.yourLogo.data( 'originalLeft' ).indexOf('%') != -1 ){
  1974. oL = ls.g.sliderWidth() / 100 * parseInt( ls.g.yourLogo.data( 'originalLeft' ) ) - ls.g.yourLogo.width() / 2 + parseInt( $(el).css('padding-left') );
  1975. }else{
  1976. oL = parseInt( ls.g.yourLogo.data( 'originalLeft' ) ) * ls.g.ratio;
  1977. }
  1978. if( ls.g.yourLogo.data( 'originalRight' ) && ls.g.yourLogo.data( 'originalRight' ).indexOf('%') != -1 ){
  1979. oR = ls.g.sliderWidth() / 100 * parseInt( ls.g.yourLogo.data( 'originalRight' ) ) - ls.g.yourLogo.width() / 2 + parseInt( $(el).css('padding-right') );
  1980. }else{
  1981. oR = parseInt( ls.g.yourLogo.data( 'originalRight' ) ) * ls.g.ratio;
  1982. }
  1983. if( ls.g.yourLogo.data( 'originalTop' ) && ls.g.yourLogo.data( 'originalTop' ).indexOf('%') != -1 ){
  1984. oT = ls.g.sliderHeight() / 100 * parseInt( ls.g.yourLogo.data( 'originalTop' ) ) - ls.g.yourLogo.height() / 2 + parseInt( $(el).css('padding-top') );
  1985. }else{
  1986. oT = parseInt( ls.g.yourLogo.data( 'originalTop' ) ) * ls.g.ratio;
  1987. }
  1988. if( ls.g.yourLogo.data( 'originalBottom' ) && ls.g.yourLogo.data( 'originalBottom' ).indexOf('%') != -1 ){
  1989. oB = ls.g.sliderHeight() / 100 * parseInt( ls.g.yourLogo.data( 'originalBottom' ) ) - ls.g.yourLogo.height() / 2 + parseInt( $(el).css('padding-bottom') );
  1990. }else{
  1991. oB = parseInt( ls.g.yourLogo.data( 'originalBottom' ) ) * ls.g.ratio;
  1992. }
  1993. ls.g.yourLogo.css({
  1994. left : oL,
  1995. right : oR,
  1996. top : oT,
  1997. bottom : oB
  1998. });
  1999. };
  2000. // NEW FEATURE v3.5 thumbnailNavigation ('always')
  2001. // Resizing thumbnails
  2002. ls.resizeThumb = function(){
  2003. ls.bottomNavSizeHelper('on');
  2004. var sliderW = ls.g.sliderOriginalWidth.indexOf('%') == -1 ? parseInt( ls.g.sliderOriginalWidth ) : ls.g.sliderWidth();
  2005. $(el).find('.ls-thumbnail-slide a').css({
  2006. width : parseInt( ls.o.tnWidth * ls.g.ratio ),
  2007. height : parseInt( ls.o.tnHeight * ls.g.ratio )
  2008. });
  2009. $(el).find('.ls-thumbnail-slide a:last').css({
  2010. margin: 0
  2011. });
  2012. $(el).find('.ls-thumbnail-slide').css({
  2013. height : parseInt( ls.o.tnHeight * ls.g.ratio )
  2014. });
  2015. var tn = $(el).find('.ls-thumbnail');
  2016. var originalWidth = ls.o.tnContainerWidth.indexOf('%') == -1 ? parseInt( ls.o.tnContainerWidth ) : parseInt( sliderW / 100 * parseInt( ls.o.tnContainerWidth ) );
  2017. tn.css({
  2018. width : originalWidth * Math.floor( ls.g.ratio * 100 ) / 100
  2019. });
  2020. if( tn.width() > $(el).find('.ls-thumbnail-slide').width() ){
  2021. tn.css({
  2022. width : $(el).find('.ls-thumbnail-slide').width()
  2023. });
  2024. }
  2025. ls.bottomNavSizeHelper('off');
  2026. };
  2027. // Changing thumbnails
  2028. ls.changeThumb = function(index){
  2029. var curIndex = index ? index : ls.g.nextLayerIndex;
  2030. $(el).find('.ls-thumbnail-slide a:not(.ls-thumb-'+curIndex+')').children().each(function(){
  2031. $(this).removeClass('ls-thumb-active').stop().fadeTo(750,ls.o.tnInactiveOpacity/100);
  2032. });
  2033. $(el).find('.ls-thumbnail-slide a.ls-thumb-'+curIndex).children().addClass('ls-thumb-active').stop().fadeTo(750,ls.o.tnActiveOpacity/100);
  2034. };
  2035. // Scrolling thumbnails
  2036. ls.scrollThumb = function(){
  2037. if( !$(el).find('.ls-thumbnail-slide-container').hasClass('ls-thumbnail-slide-hover') ){
  2038. var curThumb = $(el).find('.ls-thumb-active').length ? $(el).find('.ls-thumb-active').parent() : false;
  2039. if( curThumb ){
  2040. var thumbCenter = curThumb.position().left + curThumb.width() / 2;
  2041. var mL = $(el).find('.ls-thumbnail-slide-container').width() / 2 - thumbCenter;
  2042. 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;
  2043. mL = mL > 0 ? 0 : mL;
  2044. $(el).find('.ls-thumbnail-slide').animate({
  2045. marginLeft : mL
  2046. }, 600 );
  2047. }
  2048. }
  2049. };
  2050. // IMPROVEMENT v4.1.3 Changed the working of some Thumbnail and Bottom Navigation features
  2051. ls.bottomNavSizeHelper = function(val){
  2052. if( ls.o.hoverBottomNav && !$(el).hasClass('ls-hover') ){
  2053. switch(val){
  2054. case 'on':
  2055. ls.g.thumbsWrapper.css({
  2056. visibility: 'hidden',
  2057. display: 'block'
  2058. });
  2059. break;
  2060. case 'off':
  2061. ls.g.thumbsWrapper.css({
  2062. visibility: 'visible',
  2063. display: 'none'
  2064. });
  2065. break;
  2066. }
  2067. }
  2068. };
  2069. // Animating layers and sublayers
  2070. ls.animate = function(){
  2071. /* GLOBAL (used by both old and new transitions ) */
  2072. // Changing variables
  2073. // BUGFIX v4.6.0 If there is only one layer, there is no need to set ls.g.isAnimating to true
  2074. if( $(el).find('.ls-slide').length > 1 ){
  2075. ls.g.isAnimating = true;
  2076. }
  2077. ls.g.isLoading = false;
  2078. // Clearing timeouts
  2079. clearTimeout( ls.g.slideTimer );
  2080. clearTimeout( ls.g.changeTimer );
  2081. ls.g.stopLayer = ls.g.curLayer;
  2082. // Calling cbAnimStart callback function
  2083. ls.o.cbAnimStart(ls.g);
  2084. // NEW FEATURE v3.5 thumbnailNavigation ('always')
  2085. if( ls.o.thumbnailNavigation == 'always' ){
  2086. // ChangeThumb
  2087. ls.changeThumb();
  2088. // ScrollThumb
  2089. if( !('ontouchstart' in window) ){
  2090. ls.scrollThumb();
  2091. }
  2092. }
  2093. // Adding .ls-animating class to next layer
  2094. ls.g.nextLayer.addClass('ls-animating');
  2095. /* OLD layer transitions (version 3.x) */
  2096. // Setting position and styling of current and next layers
  2097. var curLayerLeft = curLayerRight = curLayerTop = curLayerBottom = nextLayerLeft = nextLayerRight = nextLayerTop = nextLayerBottom = layerMarginLeft = layerMarginRight = layerMarginTop = layerMarginBottom = 'auto';
  2098. var curLayerWidth = nextLayerWidth = ls.g.sliderWidth();
  2099. var curLayerHeight = nextLayerHeight = ls.g.sliderHeight();
  2100. // Calculating direction
  2101. var prevOrNext = ls.g.prevNext == 'prev' ? ls.g.curLayer : ls.g.nextLayer;
  2102. var chooseDirection = prevOrNext.data('slidedirection') ? prevOrNext.data('slidedirection') : ls.o.slideDirection;
  2103. // Setting the direction of sliding
  2104. var slideDirection = ls.g.slideDirections[ls.g.prevNext][chooseDirection];
  2105. if( slideDirection == 'left' || slideDirection == 'right' ){
  2106. curLayerWidth = curLayerTop = nextLayerWidth = nextLayerTop = 0;
  2107. layerMarginTop = 0;
  2108. }
  2109. if( slideDirection == 'top' || slideDirection == 'bottom' ){
  2110. curLayerHeight = curLayerLeft = nextLayerHeight = nextLayerLeft = 0;
  2111. layerMarginLeft = 0;
  2112. }
  2113. switch(slideDirection){
  2114. case 'left':
  2115. curLayerRight = nextLayerLeft = 0;
  2116. layerMarginLeft = -ls.g.sliderWidth();
  2117. break;
  2118. case 'right':
  2119. curLayerLeft = nextLayerRight = 0;
  2120. layerMarginLeft = ls.g.sliderWidth();
  2121. break;
  2122. case 'top':
  2123. curLayerBottom = nextLayerTop = 0;
  2124. layerMarginTop = -ls.g.sliderHeight();
  2125. break;
  2126. case 'bottom':
  2127. curLayerTop = nextLayerBottom = 0;
  2128. layerMarginTop = ls.g.sliderHeight();
  2129. break;
  2130. }
  2131. // Setting start positions and styles of layers
  2132. ls.g.curLayer.css({
  2133. left : curLayerLeft,
  2134. right : curLayerRight,
  2135. top : curLayerTop,
  2136. bottom : curLayerBottom
  2137. });
  2138. ls.g.nextLayer.css({
  2139. width : nextLayerWidth,
  2140. height : nextLayerHeight,
  2141. left : nextLayerLeft,
  2142. right : nextLayerRight,
  2143. top : nextLayerTop,
  2144. bottom : nextLayerBottom
  2145. });
  2146. // Creating variables for the OLD transitions of CURRENT LAYER
  2147. // BUGFIX v1.6 fixed some wrong parameters of current layer
  2148. // BUGFIX v1.7 fixed using of delayout of current layer
  2149. var curDelay = ls.g.curLayer.data('delayout') ? parseInt(ls.g.curLayer.data('delayout')) : ls.o.delayOut;
  2150. var curDuration = ls.g.curLayer.data('durationout') ? parseInt(ls.g.curLayer.data('durationout')) : ls.o.durationOut;
  2151. var curEasing = ls.g.curLayer.data('easingout') ? ls.g.curLayer.data('easingout') : ls.o.easingOut;
  2152. // Creating variables for the OLD transitions of NEXT LAYER
  2153. var nextDelay = ls.g.nextLayer.data('delayin') ? parseInt(ls.g.nextLayer.data('delayin')) : ls.o.delayIn;
  2154. var nextDuration = ls.g.nextLayer.data('durationin') ? parseInt(ls.g.nextLayer.data('durationin')) : ls.o.durationIn;
  2155. // BUGFIX v5.2.0 duration cannot be 0
  2156. if( nextDuration === 0 ){ nextDuration = 1 }
  2157. var nextEasing = ls.g.nextLayer.data('easingin') ? ls.g.nextLayer.data('easingin') : ls.o.easingIn;
  2158. var curLayer = function(){
  2159. // BUGFIX v1.6 added an additional delaytime to current layer to fix the '1px gap' bug
  2160. // BUGFIX v3.0 modified from curDuration / 80 to curDuration / 15
  2161. ls.g.curLayer.delay( curDelay + curDuration / 15).animate({
  2162. width : curLayerWidth,
  2163. height : curLayerHeight
  2164. }, curDuration, curEasing,function(){
  2165. curLayerCallback();
  2166. });
  2167. };
  2168. var curLayerCallback = function(){
  2169. // Stopping current sublayer animations if needed (they are not visible at this point).
  2170. ls.g.stopLayer.find(' > *[class*="ls-l"]').each(function(){
  2171. if( $(this).data('tr') ){
  2172. $(this).data('tr').kill();
  2173. }
  2174. $(this).css({
  2175. filter: 'none'
  2176. });
  2177. });
  2178. // Setting current layer
  2179. ls.g.curLayer = ls.g.nextLayer;
  2180. // 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)
  2181. ls.g.prevLayerIndex = ls.g.curLayerIndex;
  2182. ls.g.curLayerIndex = ls.g.nextLayerIndex;
  2183. ls.o.cbAnimStop(ls.g);
  2184. // NEW FEATURE v5.0.0 Lazy-load (preloading here the images of the next layer)
  2185. if( ls.o.imgPreload && ls.o.lazyLoad ){
  2186. var preLayerIndex = ls.g.curLayerIndex == ls.g.layersNum ? 1 : ls.g.curLayerIndex + 1;
  2187. $(el).find('.ls-slide').eq(preLayerIndex-1).find('img:not(.ls-preloaded)').each(function(){
  2188. $(this).load(function(){
  2189. $(this).addClass('ls-preloaded');
  2190. }).error(function(){
  2191. var imgURL = $(this).data('src').substring($(this).data('src').lastIndexOf("/") + 1, $(this).data('src').length);
  2192. if( window.console ){
  2193. 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.');
  2194. }else{
  2195. 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.');
  2196. }
  2197. $(this).addClass('ls-not-preloaded');
  2198. }).attr('src', $(this).data('src'));
  2199. });
  2200. }
  2201. // Changing some css classes
  2202. $(el).find('.ls-slide').removeClass('ls-active');
  2203. $(el).find('.ls-slide:eq(' + ( ls.g.curLayerIndex - 1 ) + ')').addClass('ls-active').removeClass('ls-animating');
  2204. $(el).find('.ls-bottom-slidebuttons a').removeClass('ls-nav-active');
  2205. $(el).find('.ls-bottom-slidebuttons a:eq('+( ls.g.curLayerIndex - 1 )+')').addClass('ls-nav-active');
  2206. // Setting timer if needed
  2207. if( ls.g.autoSlideshow ){
  2208. ls.timer();
  2209. }
  2210. // Changing variables
  2211. ls.g.isAnimating = false;
  2212. if( ls.g.resize == true ){
  2213. ls.makeResponsive( ls.g.curLayer, function(){
  2214. ls.g.resize = false;
  2215. });
  2216. }
  2217. };
  2218. var curSubLayers = function(sublayersDurationOut){
  2219. ls.g.curLayer.find(' > *[class*="ls-l"]').each(function(){
  2220. if( !$(this).data('transitiontype') ){
  2221. ls.transitionType( $(this) );
  2222. }
  2223. // BUGFIX v5.1.0 Removing ls-videohack class before starting transition
  2224. $(this).removeClass('ls-videohack');
  2225. var curSubSlideDir = $(this).data('slidedirection') ? $(this).data('slidedirection') : slideDirection;
  2226. var lml, lmt;
  2227. switch(curSubSlideDir){
  2228. case 'left':
  2229. lml = -ls.g.sliderWidth();
  2230. lmt = 0;
  2231. break;
  2232. case 'right':
  2233. lml = ls.g.sliderWidth();
  2234. lmt = 0;
  2235. break;
  2236. case 'top':
  2237. lmt = -ls.g.sliderHeight();
  2238. lml = 0;
  2239. break;
  2240. case 'bottom':
  2241. lmt = ls.g.sliderHeight();
  2242. lml = 0;
  2243. break;
  2244. case 'fade':
  2245. lmt = 0;
  2246. lml = 0;
  2247. break;
  2248. }
  2249. // NEW FEATURE v1.6 added slideoutdirection to sublayers
  2250. // NEW FEATURES 5.0.0 added axis-free transitions with offsetx and offsety properties
  2251. if( $(this).data('transitiontype') === 'new' ){
  2252. var curSubSlideOutDir = 'new';
  2253. }else{
  2254. var curSubSlideOutDir = $(this).data('slideoutdirection') ? $(this).data('slideoutdirection') : false;
  2255. }
  2256. switch(curSubSlideOutDir){
  2257. case 'left':
  2258. lml = ls.g.sliderWidth();
  2259. lmt = 0;
  2260. break;
  2261. case 'right':
  2262. lml = -ls.g.sliderWidth();
  2263. lmt = 0;
  2264. break;
  2265. case 'top':
  2266. lmt = ls.g.sliderHeight();
  2267. lml = 0;
  2268. break;
  2269. case 'bottom':
  2270. lmt = -ls.g.sliderHeight();
  2271. lml = 0;
  2272. break;
  2273. case 'fade':
  2274. lmt = 0;
  2275. lml = 0;
  2276. break;
  2277. case 'new':
  2278. if( $(this).data('offsetxout') ){
  2279. if( $(this).data('offsetxout') === 'left' ){
  2280. lml = ls.g.sliderWidth();
  2281. }else if( $(this).data('offsetxout') === 'right' ){
  2282. lml = -ls.g.sliderWidth();
  2283. }else{
  2284. lml = -parseInt( $(this).data('offsetxout') );
  2285. }
  2286. }else{
  2287. lml = -ls.lt.offsetXOut;
  2288. }
  2289. if( $(this).data('offsetyout') ){
  2290. if( $(this).data('offsetyout') === 'top' ){
  2291. lmt = ls.g.sliderHeight();
  2292. }else if( $(this).data('offsetyout') === 'bottom' ){
  2293. lmt = -ls.g.sliderHeight();
  2294. }else{
  2295. lmt = -parseInt( $(this).data('offsetyout') );
  2296. }
  2297. }else{
  2298. lmt = -ls.lt.offsetYOut;
  2299. }
  2300. break;
  2301. }
  2302. // NEW FEATURES v4.5.0 Rotating & Scaling sublayers
  2303. // BUGFIX v4.5.5 changing the default value from 0 to 'none' (because of old jQuery, 1.7.2)
  2304. // NEW FEATURES v5.0.0 Added SkewX, SkewY, ScaleX, ScaleY, RotateX & RotateY transitions
  2305. var curSubRotate = curSubRotateX = curSubRotateY = curSubScale = curSubSkewX = curSubSkewY = curSubScaleX = curSubScaleY = 'none';
  2306. // if( !ls.g.ie78 && ls.g.enableCSS3 ){
  2307. curSubRotate = $(this).data('rotateout') ? $(this).data('rotateout') : ls.lt.rotateOut;
  2308. curSubRotateX = $(this).data('rotatexout') ? $(this).data('rotatexout') : ls.lt.rotateXOut;
  2309. curSubRotateY = $(this).data('rotateyout') ? $(this).data('rotateyout') : ls.lt.rotateYOut;
  2310. curSubScale = $(this).data('scaleout') ? $(this).data('scaleout') : ls.lt.scaleOut;
  2311. curSubSkewX = $(this).data('skewxout') ? $(this).data('skewxout') : ls.lt.skewXOut;
  2312. curSubSkewY = $(this).data('skewyout') ? $(this).data('skewyout') : ls.lt.skewYOut;
  2313. if( curSubScale === 1 ){
  2314. curSubScaleX = $(this).data('scalexout') ? $(this).data('scalexout') : ls.lt.scaleXOut;
  2315. curSubScaleY = $(this).data('scaleyout') ? $(this).data('scaleyout') : ls.lt.scaleYOut;
  2316. }else{
  2317. curSubScaleX = curSubScaleY = curSubScale;
  2318. }
  2319. var too = $(this).data('transformoriginout') ? $(this).data('transformoriginout').split(' ') : ls.lt.transformOriginOut;
  2320. for(var t =0;t<too.length;t++){
  2321. 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 ){
  2322. too[t] = '' + parseInt( too[t] ) * ls.g.ratio + 'px';
  2323. }
  2324. }
  2325. var curSubTransformOrigin = too.join(' ');
  2326. var curSubPerspective = $(this).data('perspectiveout') ? $(this).data('perspectiveout') : ls.lt.perspectiveOut;
  2327. // }
  2328. // IMPROVEMENT v4.0 Distance (P.level): -1
  2329. var endLeft = parseInt( $(this).css('left') );
  2330. var endTop = parseInt( $(this).css('top') );
  2331. var curSubPLevel = parseInt( $(this).attr('class').split('ls-l')[1] );
  2332. var wh = $(this).outerWidth() > $(this).outerHeight() ? $(this).outerWidth() : $(this).outerHeight();
  2333. var modX = parseInt( curSubRotate ) === 0 ? $(this).outerWidth() : wh;
  2334. var modY = parseInt( curSubRotate ) === 0 ? $(this).outerHeight() : wh;
  2335. if( ( curSubPLevel === -1 && curSubSlideOutDir !== 'new' ) || ( $(this).data('offsetxout') === 'left' || $(this).data('offsetxout') === 'right' ) ){
  2336. if( lml < 0 ){
  2337. lml = - ( ls.g.sliderWidth() - endLeft + ( curSubScaleX / 2 - .5 ) * modX + 100 );
  2338. }else if( lml > 0 ){
  2339. lml = endLeft + ( curSubScaleX / 2 + .5 ) * modX + 100;
  2340. }
  2341. }else{
  2342. lml = lml * ls.g.ratio;
  2343. }
  2344. if( ( curSubPLevel === -1 && curSubSlideOutDir !== 'new' ) || ( $(this).data('offsetyout') === 'top' || $(this).data('offsetyout') === 'bottom' ) ){
  2345. if( lmt < 0 ){
  2346. lmt = - ( ls.g.sliderHeight() - endTop + ( curSubScaleY / 2 - .5 ) * modY + 100 );
  2347. }else if( lmt > 0 ){
  2348. lmt = endTop + ( curSubScaleY / 2 + .5 ) * modY + 100;
  2349. }
  2350. }else{
  2351. lmt = lmt * ls.g.ratio;
  2352. }
  2353. if( curSubPLevel === -1 || curSubSlideOutDir === 'new' ){
  2354. var curSubPar = 1;
  2355. }else{
  2356. var curSubParMod = ls.g.curLayer.data('parallaxout') ? parseInt(ls.g.curLayer.data('parallaxout')) : ls.o.parallaxOut;
  2357. var curSubPar = curSubPLevel * curSubParMod;
  2358. }
  2359. if( $(this).data('transitiontype') === 'new' ){
  2360. var deO = ls.lt.delayOut;
  2361. var duO = ls.lt.durationOut;
  2362. var eO = ls.lt.easingOut;
  2363. }else{
  2364. var deO = ls.o.delayOut;
  2365. var duO = ls.o.durationOut;
  2366. var eO = ls.o.easingOut;
  2367. }
  2368. var curSubDelay = $(this).data('delayout') ? parseInt($(this).data('delayout')) : deO;
  2369. var curSubTime = $(this).data('durationout') ? parseInt($(this).data('durationout')) : duO;
  2370. // BUGFIX v5.2.0 duration cannot be 0
  2371. if( curSubTime === 0 ){ curSubTime = 1 }
  2372. var curSubEasing = $(this).data('easingout') ? $(this).data('easingout') : eO;
  2373. // On new layer transitions, all sublayer will be slide / fade out in 500ms without any delays
  2374. if(sublayersDurationOut){
  2375. curSubDelay = 0;
  2376. curSubTime = sublayersDurationOut;
  2377. // curSubEasing = 'easeInExpo';
  2378. }
  2379. // Clearing showUntilTimers
  2380. if( $(this).data('showUntilTimer') ){
  2381. clearTimeout( $(this).data('showUntilTimer') );
  2382. }
  2383. var css = {
  2384. visibility : 'hidden'
  2385. };
  2386. var el = $(this);
  2387. var transition = {
  2388. rotation : curSubRotate,
  2389. rotationX : curSubRotateX,
  2390. rotationY : curSubRotateY,
  2391. skewX : curSubSkewX,
  2392. skewY : curSubSkewY,
  2393. scaleX : curSubScaleX,
  2394. scaleY : curSubScaleY,
  2395. x : -lml * curSubPar,
  2396. y : -lmt * curSubPar,
  2397. delay : curSubDelay/1000,
  2398. ease : lsConvertEasing( curSubEasing ),
  2399. onComplete : function(){
  2400. el.css( css );
  2401. }
  2402. };
  2403. if( curSubSlideOutDir == 'fade' || ( !curSubSlideOutDir && curSubSlideDir === 'fade' ) || ( $(this).data('fadeout') !== 'false' && $(this).data('transitiontype') === 'new' ) ){
  2404. transition['opacity'] = 0;
  2405. css['opacity'] = $(this).data( 'originalOpacity' );
  2406. }
  2407. if( $(this).data('tr') ){
  2408. $(this).data('tr').kill();
  2409. }
  2410. TweenLite.set( $(this)[0],{
  2411. transformOrigin : curSubTransformOrigin,
  2412. transformPerspective : curSubPerspective
  2413. });
  2414. $(this).data('tr', TweenLite.to($(this)[0],curSubTime/1000,transition) );
  2415. // $(this).stop(true,false).delay( curSubDelay ).animate( transition, curSubTime, curSubEasing,function(){
  2416. // $(this).css( css );
  2417. // });
  2418. });
  2419. };
  2420. var nextLayer = function(){
  2421. ls.g.nextLayer.delay( curDelay + nextDelay ).animate({
  2422. width : ls.g.sliderWidth(),
  2423. height : ls.g.sliderHeight()
  2424. }, nextDuration, nextEasing );
  2425. };
  2426. var nextSubLayers = function(){
  2427. if( ls.g.totalDuration ){
  2428. curDelay = 0;
  2429. }
  2430. // Needed for the Timeline
  2431. if( typeof ls.o.cbTimeLineStart === 'function' ){
  2432. ls.o.cbTimeLineStart(ls.g, curDelay+nextDelay );
  2433. }
  2434. ls.g.nextLayer.find(' > *[class*="ls-l"]').each(function(){
  2435. // Replacing global parameters with unique if need
  2436. // NEW FEATURES 5.0.0 added axis-free transitions with offsetx and offsety properties
  2437. if( !$(this).data('transitiontype') ){
  2438. ls.transitionType( $(this) );
  2439. }
  2440. if( $(this).data('transitiontype') === 'new' ){
  2441. var nextSubSlideDir = 'new';
  2442. }else{
  2443. var nextSubSlideDir = $(this).data('slidedirection') ? $(this).data('slidedirection') : slideDirection;
  2444. }
  2445. var lml, lmt;
  2446. switch(nextSubSlideDir){
  2447. case 'left':
  2448. lml = -ls.g.sliderWidth();
  2449. lmt = 0;
  2450. break;
  2451. case 'right':
  2452. lml = ls.g.sliderWidth();
  2453. lmt = 0;
  2454. break;
  2455. case 'top':
  2456. lmt = -ls.g.sliderHeight();
  2457. lml = 0;
  2458. break;
  2459. case 'bottom':
  2460. lmt = ls.g.sliderHeight();
  2461. lml = 0;
  2462. break;
  2463. case 'fade':
  2464. lmt = 0;
  2465. lml = 0;
  2466. break;
  2467. case 'new':
  2468. if( $(this).data('offsetxin') ){
  2469. if( $(this).data('offsetxin') === 'left' ){
  2470. lml = -ls.g.sliderWidth();
  2471. }else if( $(this).data('offsetxin') === 'right' ){
  2472. lml = ls.g.sliderWidth();
  2473. }else{
  2474. lml = parseInt( $(this).data('offsetxin') );
  2475. }
  2476. }else{
  2477. lml = ls.lt.offsetXIn;
  2478. }
  2479. if( $(this).data('offsetyin') ){
  2480. if( $(this).data('offsetyin') === 'top' ){
  2481. lmt = -ls.g.sliderHeight();
  2482. }else if( $(this).data('offsetyin') === 'bottom' ){
  2483. lmt = ls.g.sliderHeight();
  2484. }else{
  2485. lmt = parseInt( $(this).data('offsetyin') );
  2486. }
  2487. }else{
  2488. lmt = ls.lt.offsetYIn;
  2489. }
  2490. break;
  2491. }
  2492. // NEW FEATURE v4.5.0 Rotating & Scaling sublayers
  2493. // BUGFIX v4.5.5 changing the default value from 0 to 'none' (because of old jQuery, 1.7.2)
  2494. // NEW FEATURES v5.0.0 Added SkewX, SkewY, ScaleX, ScaleY, RotateX & RotateY transitions
  2495. var nextSubRotate = nextSubRotateX = nextSubRotateY = nextSubScale = nextSubSkewX = nextSubSkewY = nextSubScaleX = nextSubScaleY = 'none';
  2496. // if( !ls.g.ie78 && ls.g.enableCSS3 ){
  2497. nextSubRotate = $(this).data('rotatein') ? $(this).data('rotatein') : ls.lt.rotateIn;
  2498. nextSubRotateX = $(this).data('rotatexin') ? $(this).data('rotatexin') : ls.lt.rotateXIn;
  2499. nextSubRotateY = $(this).data('rotateyin') ? $(this).data('rotateyin') : ls.lt.rotateYIn;
  2500. nextSubScale = $(this).data('scalein') ? $(this).data('scalein') : ls.lt.scaleIn;
  2501. nextSubSkewX = $(this).data('skewxin') ? $(this).data('skewxin') : ls.lt.skewXIn;
  2502. nextSubSkewY = $(this).data('skewyin') ? $(this).data('skewyin') : ls.lt.skewYIn;
  2503. if( nextSubScale === 1 ){
  2504. nextSubScaleX = $(this).data('scalexin') ? $(this).data('scalexin') : ls.lt.scaleXIn;
  2505. nextSubScaleY = $(this).data('scaleyin') ? $(this).data('scaleyin') : ls.lt.scaleYIn;
  2506. }else{
  2507. nextSubScaleX = nextSubScaleY = nextSubScale;
  2508. }
  2509. var toi = $(this).data('transformoriginin') ? $(this).data('transformoriginin').split(' ') : ls.lt.transformOriginIn;
  2510. for(var t =0;t<toi.length;t++){
  2511. 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 ){
  2512. toi[t] = '' + parseInt( toi[t] ) * ls.g.ratio + 'px';
  2513. }
  2514. }
  2515. var nextSubTransformOrigin = toi.join(' ');
  2516. var nextSubPerspective = $(this).data('perspectivein') ? $(this).data('perspectivein') : ls.lt.perspectiveIn;
  2517. // }
  2518. // IMPROVEMENT v4.0 Distance (P.level): -1
  2519. var endLeft = parseInt( $(this).css('left') );
  2520. var endTop = parseInt( $(this).css('top') );
  2521. var nextSubPLevel = parseInt( $(this).attr('class').split('ls-l')[1] );
  2522. // BUGFIX v5.0.1 Fixed the starting position of layers with percentage value of width
  2523. if( $(this)[0].style.width.indexOf('%') !== -1 ){
  2524. $(this).css({
  2525. width: ls.g.sliderWidth() / 100 * parseInt( $(this)[0].style.width )
  2526. });
  2527. }
  2528. var wh = $(this).outerWidth() > $(this).outerHeight() ? $(this).outerWidth() : $(this).outerHeight();
  2529. var modX = parseInt( nextSubRotate ) === 0 ? $(this).outerWidth() : wh;
  2530. var modY = parseInt( nextSubRotate ) === 0 ? $(this).outerHeight() : wh;
  2531. // console.log( modX, $(this).outerWidth(), $(this).width(), $(this).height(), $(this)[0].style.width, $(this).outerHeight(), wh );
  2532. if( ( nextSubPLevel === -1 && nextSubSlideDir !== 'new' ) || ( $(this).data('offsetxin') === 'left' || $(this).data('offsetxin') === 'right' ) ){
  2533. if( lml < 0 ){
  2534. lml = - ( endLeft + ( nextSubScaleX / 2 + .5 ) * modX + 100 );
  2535. }else if( lml > 0 ){
  2536. lml = ls.g.sliderWidth() - endLeft + ( nextSubScaleX / 2 - .5 ) * modX + 100;
  2537. }
  2538. }else{
  2539. lml = lml * ls.g.ratio;
  2540. }
  2541. if( ( nextSubPLevel === -1 && nextSubSlideDir !== 'new' ) || ( $(this).data('offsetyin') === 'top' || $(this).data('offsetyin') === 'bottom' ) ){
  2542. if( lmt < 0 ){
  2543. lmt = - ( endTop + ( nextSubScaleY / 2 + .5 ) * modY + 100 );
  2544. }else if( lmt > 0 ){
  2545. lmt = ls.g.sliderHeight() - endTop + ( nextSubScaleY / 2 - .5 ) * modY + 100;
  2546. }
  2547. }else{
  2548. lmt = lmt * ls.g.ratio;
  2549. }
  2550. if( nextSubPLevel === -1 || nextSubSlideDir === 'new'){
  2551. var nextSubPar = 1;
  2552. }else{
  2553. var nextSubParMod = ls.g.nextLayer.data('parallaxin') ? parseInt(ls.g.nextLayer.data('parallaxin')) : ls.o.parallaxIn;
  2554. var nextSubPar = nextSubPLevel * nextSubParMod;
  2555. }
  2556. if( $(this).data('transitiontype') === 'new' ){
  2557. var deI = ls.lt.delayIn;
  2558. var duI = ls.lt.durationIn;
  2559. var eI = ls.lt.easingIn;
  2560. }else{
  2561. var deI = ls.o.delayIn;
  2562. var duI = ls.o.durationIn;
  2563. var eI = ls.o.easingIn;
  2564. }
  2565. var nextSubDelay = $(this).data('delayin') ? parseInt($(this).data('delayin')) : deI;
  2566. var nextSubTime = $(this).data('durationin') ? parseInt($(this).data('durationin')) : duI;
  2567. var nextSubEasing = $(this).data('easingin') ? $(this).data('easingin') : eI;
  2568. var cursub = $(this);
  2569. var nextSubCallback = function(){
  2570. // BUGFIX v5.1.0 Removing transition property from video layers
  2571. if( cursub.hasClass('ls-video-layer') ){
  2572. cursub.addClass('ls-videohack');
  2573. }
  2574. // NEW FEATURE v2.0 autoPlayVideos
  2575. if( ls.o.autoPlayVideos == true ){
  2576. // YouTube & Vimeo videos
  2577. cursub.find('.ls-videopreview').click();
  2578. // HTML5 videos
  2579. cursub.find('video, audio').each(function(){
  2580. if( typeof $(this)[0].currentTime !== 0){
  2581. $(this)[0].currentTime = 0;
  2582. }
  2583. $(this).click();
  2584. });
  2585. }
  2586. // NEW FEATURE v3.0 showUntil sublayers
  2587. // IMPROVEMENT v5.2.0 video layers with auto play will skip showuntil feature
  2588. if( ( !cursub.hasClass('ls-video-layer') || ( cursub.hasClass('ls-video-layer') && ls.o.autoPlayVideos === false ) ) && cursub.data('showuntil') > 0 ){
  2589. // IMPROVEMENT v4.5.0 sublayerShowUntil will be called anly if necessary
  2590. cursub.data('showUntilTimer', setTimeout(function(){
  2591. ls.sublayerShowUntil( cursub );
  2592. }, cursub.data('showuntil') ));
  2593. }
  2594. };
  2595. $(this).css({
  2596. marginLeft : 0,
  2597. marginTop : 0
  2598. });
  2599. var css = {
  2600. scaleX : nextSubScaleX,
  2601. scaleY : nextSubScaleY,
  2602. skewX : nextSubSkewX,
  2603. skewY : nextSubSkewY,
  2604. rotation : nextSubRotate,
  2605. rotationX : nextSubRotateX,
  2606. rotationY : nextSubRotateY,
  2607. visibility : 'visible',
  2608. x : lml * nextSubPar,
  2609. y : lmt * nextSubPar
  2610. };
  2611. var transition = {
  2612. rotation : 0,
  2613. rotationX : 0,
  2614. rotationY : 0,
  2615. skewX : 0,
  2616. skewY : 0,
  2617. scaleX : 1,
  2618. scaleY : 1,
  2619. ease : lsConvertEasing( nextSubEasing ),
  2620. delay : nextSubDelay/1000,
  2621. x : 0,
  2622. y : 0,
  2623. onComplete : function(){
  2624. nextSubCallback();
  2625. }
  2626. };
  2627. if( nextSubSlideDir.indexOf('fade') != -1 || ( $(this).data('fadein') !== 'false' && $(this).data('transitiontype') === 'new' ) ){
  2628. css['opacity'] = 0;
  2629. transition['opacity'] = $(this).data( 'originalOpacity' );
  2630. }
  2631. // $(this).css( css );
  2632. // $(this).stop().delay( curDelay + nextDelay + nextSubDelay ).animate( transition, nextSubTime, nextSubEasing, function(){
  2633. // if( ls.g.ie78 & $(this).data( 'originalOpacity') === 1 ){
  2634. // $(this).get(0).style.removeAttribute('filter');
  2635. // }
  2636. // nextSubCallback();
  2637. // });
  2638. if( $(this).data('tr') ){
  2639. $(this).data('tr').kill();
  2640. }
  2641. TweenLite.set( $(this)[0],{
  2642. transformPerspective : nextSubPerspective,
  2643. transformOrigin : nextSubTransformOrigin
  2644. });
  2645. $(this).data('tr', TweenLite.fromTo($(this)[0],nextSubTime/1000,css,transition) );
  2646. });
  2647. };
  2648. /* NEW FEATURE v4.0 2D & 3D Layer Transitions */
  2649. // Selecting ONE transition (random)
  2650. // If the browser doesn't support CSS3 3D, 2D fallback mode will be used instead
  2651. // In this case, if user didn't specify any 2D transitions, a random will be selected
  2652. var selectTransition = function(){
  2653. // if the browser supports CSS3 3D and user specified at least one of 3D transitions
  2654. if( lsSupport3D( $(el) ) && ( ls.g.nextLayer.data('transition3d') || ls.g.nextLayer.data('customtransition3d') ) ){
  2655. if( ls.g.nextLayer.data('transition3d') && ls.g.nextLayer.data('customtransition3d') ){
  2656. var rnd = Math.floor(Math.random() * 2);
  2657. var rndT = [['3d',ls.g.nextLayer.data('transition3d')],['custom3d',ls.g.nextLayer.data('customtransition3d')]];
  2658. getTransitionType(rndT[rnd][0],rndT[rnd][1]);
  2659. }else if( ls.g.nextLayer.data('transition3d') ){
  2660. getTransitionType('3d',ls.g.nextLayer.data('transition3d'));
  2661. }else{
  2662. getTransitionType('custom3d',ls.g.nextLayer.data('customtransition3d'));
  2663. }
  2664. }else{
  2665. if( ls.g.nextLayer.data('transition2d') && ls.g.nextLayer.data('customtransition2d') ){
  2666. var rnd = Math.floor(Math.random() * 2);
  2667. var rndT = [['2d',ls.g.nextLayer.data('transition2d')],['custom2d',ls.g.nextLayer.data('customtransition2d')]];
  2668. getTransitionType(rndT[rnd][0],rndT[rnd][1]);
  2669. }else if( ls.g.nextLayer.data('transition2d') ){
  2670. getTransitionType('2d',ls.g.nextLayer.data('transition2d'));
  2671. }else if( ls.g.nextLayer.data('customtransition2d') ){
  2672. getTransitionType('custom2d',ls.g.nextLayer.data('customtransition2d'));
  2673. }else{
  2674. getTransitionType('2d','1');
  2675. }
  2676. }
  2677. };
  2678. // Needed by the demo page
  2679. var selectCustomTransition = function(){
  2680. if( lsSupport3D( $(el) ) && LSCustomTransition.indexOf('3d') != -1 ){
  2681. getTransitionType('3d',LSCustomTransition.split(':')[1]);
  2682. }else{
  2683. if( LSCustomTransition.indexOf('3d') != -1){
  2684. getTransitionType('2d','all');
  2685. }else{
  2686. getTransitionType('2d',LSCustomTransition.split(':')[1]);
  2687. }
  2688. }
  2689. };
  2690. // Choosing layer transition type (2d, 3d, or both)
  2691. var getTransitionType = function(type,transitionlist){
  2692. var tr = type.indexOf('custom') == -1 ? ls.t : ls.ct;
  2693. var tt = '3d', lt, number;
  2694. if( type.indexOf('2d') != -1 ){
  2695. tt = '2d';
  2696. }
  2697. if( transitionlist.indexOf('last') != -1 ){
  2698. number = tr['t'+tt].length-1;
  2699. lt = 'last';
  2700. }else if( transitionlist.indexOf('all') != -1){
  2701. number = Math.floor(Math.random() * lsCountProp(tr['t'+tt]) );
  2702. lt = 'random from all';
  2703. }else{
  2704. var t = transitionlist.split(',');
  2705. var l = t.length;
  2706. number = parseInt(t[Math.floor(Math.random() * l)])-1;
  2707. lt = 'random from specified';
  2708. }
  2709. slideTransition(tt,tr['t'+tt][number]);
  2710. // $('.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']);
  2711. };
  2712. // The slideTransition function
  2713. var slideTransition = function(type,prop){
  2714. var inner = $(el).find('.ls-inner');
  2715. // sublayersDurationOut - for future usage
  2716. var sublayersDurationOut = ls.g.curLayer.find('*[class*="ls-l"]').length > 0 ? 1000 : 0;
  2717. // Detecting a carousel transition - Transition name must have the carousel string
  2718. var carousel = prop.name.toLowerCase().indexOf('carousel') == -1 ? false : true;
  2719. // Detecting a crossfade transition - Transition name must have the crossfad string
  2720. var crossfade = prop.name.toLowerCase().indexOf('crossfad') == -1 ? false : true;
  2721. // Calculating cols and rows
  2722. var cols = typeof(prop.cols);
  2723. var rows = typeof(prop.rows);
  2724. switch( cols ){
  2725. case 'number':
  2726. cols = prop.cols;
  2727. break;
  2728. case 'string':
  2729. cols = Math.floor( Math.random() * ( parseInt( prop.cols.split(',')[1] ) - parseInt( prop.cols.split(',')[0] ) + 1) ) + parseInt( prop.cols.split(',')[0] );
  2730. break;
  2731. default:
  2732. cols = Math.floor( Math.random() * ( prop.cols[1] - prop.cols[0] + 1) ) + prop.cols[0];
  2733. break;
  2734. }
  2735. switch( rows ){
  2736. case 'number':
  2737. rows = prop.rows;
  2738. break;
  2739. case 'string':
  2740. rows = Math.floor( Math.random() * ( parseInt( prop.rows.split(',')[1] ) - parseInt( prop.rows.split(',')[0] ) + 1) ) + parseInt( prop.rows.split(',')[0] );
  2741. break;
  2742. default:
  2743. rows = Math.floor( Math.random() * ( prop.rows[1] - prop.rows[0] + 1) ) + prop.rows[0];
  2744. break;
  2745. }
  2746. if( ( ls.g.isMobile() == true && ls.o.optimizeForMobile == true ) || ( ls.g.ie78 && ls.o.optimizeForIE78 == true ) ){
  2747. // Reducing cols in three steps
  2748. if( cols >= 15 ){
  2749. cols = 7;
  2750. }else if( cols >= 5 ){
  2751. cols = 4;
  2752. }else if( cols >= 4 ){
  2753. cols = 3;
  2754. }else if( cols > 2 ){
  2755. cols = 2;
  2756. }
  2757. // Reducing rows in three steps
  2758. if( rows >= 15 ){
  2759. rows = 7;
  2760. }else if( rows >= 5 ){
  2761. rows = 4;
  2762. }else if( rows >= 4 ){
  2763. rows = 3;
  2764. }else if( rows > 2 ){
  2765. rows = 2;
  2766. }
  2767. // Reducing more :)
  2768. if( rows > 2 && cols > 2 ){
  2769. rows = 2;
  2770. if( cols > 4){
  2771. cols = 4;
  2772. }
  2773. }
  2774. }
  2775. var tileWidth = $(el).find('.ls-inner').width() / cols;
  2776. var tileHeight = $(el).find('.ls-inner').height() / rows;
  2777. // Creating HTML markup for layer transitions
  2778. if( !ls.g.ltContainer ){
  2779. ls.g.ltContainer = $('<div>').addClass('ls-lt-container').addClass('ls-overflow-hidden').css({
  2780. width : inner.width(),
  2781. height : inner.height()
  2782. }).prependTo( inner );
  2783. }else{
  2784. ls.g.ltContainer.stop(true,true).empty().css({
  2785. display : 'block',
  2786. width : inner.width(),
  2787. height : inner.height()
  2788. });
  2789. }
  2790. // Setting size
  2791. var restW = inner.width() - Math.floor(tileWidth) * cols;
  2792. var restH = inner.height() - Math.floor(tileHeight) * rows;
  2793. var tileSequence = [];
  2794. // IMPROVEMENT v4.1.3 Array-randomizer is now a local function
  2795. // Randomize array function
  2796. tileSequence.randomize = function() {
  2797. var i = this.length, j, tempi, tempj;
  2798. if ( i == 0 ) return false;
  2799. while ( --i ) {
  2800. j = Math.floor( Math.random() * ( i + 1 ) );
  2801. tempi = this[i];
  2802. tempj = this[j];
  2803. this[i] = tempj;
  2804. this[j] = tempi;
  2805. }
  2806. return this;
  2807. }
  2808. for(var ts=0; ts<cols * rows; ts++){
  2809. tileSequence.push(ts);
  2810. }
  2811. // Setting the sequences of the transition
  2812. switch( prop.tile.sequence ){
  2813. case 'reverse':
  2814. tileSequence.reverse();
  2815. break;
  2816. case 'col-forward':
  2817. tileSequence = lsOrderArray(rows,cols,'forward');
  2818. break;
  2819. case 'col-reverse':
  2820. tileSequence = lsOrderArray(rows,cols,'reverse');
  2821. break;
  2822. case 'random':
  2823. tileSequence.randomize();
  2824. break;
  2825. }
  2826. var curBG = ls.g.curLayer.find('.ls-bg');
  2827. var nextBG = ls.g.nextLayer.find('.ls-bg');
  2828. // IMPROVEMENT v4.6.0 If current and next layer both have no BG, skipping the slide transition
  2829. if( curBG.length == 0 && nextBG.length == 0 ){
  2830. type = '2d';
  2831. prop = $.extend(true, {}, ls.t['t2d'][0]);
  2832. prop.transition.duration = 1
  2833. prop.tile.delay = 0;
  2834. }
  2835. if( type == '3d' ){
  2836. ls.g.totalDuration = ((cols * rows) - 1) * prop.tile.delay;
  2837. var stepDuration = 0;
  2838. if( prop.before && prop.before.duration ){
  2839. stepDuration += prop.before.duration;
  2840. }
  2841. if( prop.animation && prop.animation.duration ){
  2842. stepDuration += prop.animation.duration;
  2843. }
  2844. if( prop.after && prop.after.duration ){
  2845. stepDuration += prop.after.duration;
  2846. }
  2847. ls.g.totalDuration += stepDuration;
  2848. var stepDelay = 0;
  2849. if( prop.before && prop.before.delay ){
  2850. stepDelay += prop.before.delay;
  2851. }
  2852. if( prop.animation && prop.animation.delay ){
  2853. stepDelay += prop.animation.delay;
  2854. }
  2855. if( prop.after && prop.after.delay ){
  2856. stepDelay += prop.after.delay;
  2857. }
  2858. ls.g.totalDuration += stepDelay;
  2859. }else{
  2860. ls.g.totalDuration = ((cols * rows) - 1) * prop.tile.delay + prop.transition.duration;
  2861. // IMPROVEMENT v4.5.0 Creating separated containers for current and next tiles
  2862. ls.g.curTiles = $('<div>').addClass('ls-curtiles').appendTo( ls.g.ltContainer );
  2863. ls.g.nextTiles = $('<div>').addClass('ls-nexttiles').appendTo( ls.g.ltContainer );
  2864. }
  2865. var pn = ls.g.prevNext;
  2866. // Creating cuboids for 3d or tiles for 2d transition (cols * rows)
  2867. for(var tiles=0; tiles < cols * rows; tiles++){
  2868. var rW = tiles%cols == 0 ? restW : 0;
  2869. var rH = tiles > (rows-1)*cols-1 ? restH : 0;
  2870. var tile = $('<div>').addClass('ls-lt-tile').css({
  2871. width : Math.floor(tileWidth) + rW,
  2872. height : Math.floor(tileHeight) + rH
  2873. }).appendTo( ls.g.ltContainer );
  2874. var curTile, nextTile;
  2875. // If current transition is a 3d transition
  2876. if( type == '3d' ){
  2877. tile.addClass('ls-3d-container');
  2878. var W = Math.floor(tileWidth) + rW;
  2879. var H = Math.floor(tileHeight) + rH;
  2880. var D;
  2881. if( prop.animation.direction == 'horizontal' ){
  2882. if( Math.abs(prop.animation.transition.rotateY) > 90 && prop.tile.depth != 'large' ){
  2883. D = Math.floor( W / 7 ) + rW;
  2884. }else{
  2885. D = W;
  2886. }
  2887. }else{
  2888. if( Math.abs(prop.animation.transition.rotateX) > 90 && prop.tile.depth != 'large' ){
  2889. D = Math.floor( H / 7 ) + rH;
  2890. }else{
  2891. D = H;
  2892. }
  2893. }
  2894. var W2 = W/2;
  2895. var H2 = H/2;
  2896. var D2 = D/2;
  2897. // createCuboids function will append cuboids with their style settings to their container
  2898. // BUGFIX v5.1.2 the prefixless transform must be the last property
  2899. var createCuboids = function(c,a,w,h,tx,ty,tz,rx,ry){
  2900. $('<div>').addClass(c).css({
  2901. width: w,
  2902. height: h,
  2903. '-o-transform': 'translate3d('+tx+'px, '+ty+'px, '+tz+'px) rotateX('+rx+'deg) rotateY('+ry+'deg) rotateZ(0deg) scale3d(1, 1, 1)',
  2904. '-ms-transform': 'translate3d('+tx+'px, '+ty+'px, '+tz+'px) rotateX('+rx+'deg) rotateY('+ry+'deg) rotateZ(0deg) scale3d(1, 1, 1)',
  2905. '-moz-transform': 'translate3d('+tx+'px, '+ty+'px, '+tz+'px) rotateX('+rx+'deg) rotateY('+ry+'deg) rotateZ(0deg) scale3d(1, 1, 1)',
  2906. '-webkit-transform': 'translate3d('+tx+'px, '+ty+'px, '+tz+'px) rotateX('+rx+'deg) rotateY('+ry+'deg) rotateZ(0deg) scale3d(1, 1, 1)',
  2907. 'transform': 'translate3d('+tx+'px, '+ty+'px, '+tz+'px) rotateX('+rx+'deg) rotateY('+ry+'deg) rotateZ(0deg) scale3d(1, 1, 1)'
  2908. }).appendTo(a);
  2909. };
  2910. createCuboids('ls-3d-box',tile,0,0,0,0,-D2,0,0);
  2911. var backRotX = 0
  2912. var topRotX = 0
  2913. var bottomRotX = 0
  2914. if( prop.animation.direction == 'vertical' && Math.abs(prop.animation.transition.rotateX) > 90){
  2915. createCuboids('ls-3d-back',tile.find('.ls-3d-box'),W,H,-W2,-H2,-D2,180,0);
  2916. }else{
  2917. createCuboids('ls-3d-back',tile.find('.ls-3d-box'),W,H,-W2,-H2,-D2,0,180);
  2918. }
  2919. createCuboids('ls-3d-bottom',tile.find('.ls-3d-box'),W,D,-W2,H2-D2,0,-90,0);
  2920. createCuboids('ls-3d-top',tile.find('.ls-3d-box'),W,D,-W2,-H2-D2,0,90,0);
  2921. createCuboids('ls-3d-front',tile.find('.ls-3d-box'),W,H,-W2,-H2,D2,0,0);
  2922. createCuboids('ls-3d-left',tile.find('.ls-3d-box'),D,H,-W2-D2,-H2,0,0,-90);
  2923. createCuboids('ls-3d-right',tile.find('.ls-3d-box'),D,H,W2-D2,-H2,0,0,90);
  2924. curTile = tile.find('.ls-3d-front');
  2925. if( prop.animation.direction == 'horizontal' ){
  2926. if( Math.abs(prop.animation.transition.rotateY) > 90 ){
  2927. nextTile = tile.find('.ls-3d-back');
  2928. }else{
  2929. nextTile = tile.find('.ls-3d-left, .ls-3d-right');
  2930. }
  2931. }else{
  2932. if( Math.abs(prop.animation.transition.rotateX) > 90 ){
  2933. nextTile = tile.find('.ls-3d-back');
  2934. }else{
  2935. nextTile = tile.find('.ls-3d-top, .ls-3d-bottom');
  2936. }
  2937. }
  2938. // Animating cuboids
  2939. var curCubDelay = tileSequence[tiles] * prop.tile.delay;
  2940. var curCub = ls.g.ltContainer.find('.ls-3d-container:eq('+tiles+') .ls-3d-box');
  2941. var tl = new TimelineLite();
  2942. if( prop.before && prop.before.transition ){
  2943. prop.before.transition.delay = prop.before.transition.delay ? (prop.before.transition.delay + curCubDelay)/1000 : curCubDelay/1000;
  2944. tl.to( curCub[0],prop.before.duration/1000,lsConvertTransition( prop.before.transition, prop.before.easing ));
  2945. }else{
  2946. prop.animation.transition.delay = prop.animation.transition.delay ? (prop.animation.transition.delay + curCubDelay)/1000 : curCubDelay/1000;
  2947. }
  2948. tl.to( curCub[0],prop.animation.duration/1000,lsConvertTransition( prop.animation.transition, prop.animation.easing ));
  2949. if( prop.after ){
  2950. if( !prop.after.transition ){
  2951. prop.after.transition = {};
  2952. }
  2953. tl.to( curCub[0],prop.after.duration/1000,lsConvertTransition( prop.after.transition, prop.after.easing, 'after' ));
  2954. }
  2955. }else{
  2956. // If current transition is a 2d transition
  2957. var T1 = L1 = T2 = L2 = 'auto';
  2958. var O1 = O2 = 1;
  2959. if( prop.transition.direction == 'random' ){
  2960. var dir = ['top','bottom','right','left'];
  2961. var direction = dir[Math.floor(Math.random() * dir.length )];
  2962. }else{
  2963. var direction = prop.transition.direction;
  2964. }
  2965. // IMPROVEMENT v4.5.0 Reversing animation directions if slider is moving backwards
  2966. if( prop.name.toLowerCase().indexOf('mirror') != -1 && tiles%2 == 0 ){
  2967. if( pn == 'prev' ){
  2968. pn = 'next';
  2969. }else{
  2970. pn = 'prev';
  2971. }
  2972. }
  2973. if( pn == 'prev' ){
  2974. switch( direction ){
  2975. case 'top':
  2976. direction = 'bottom';
  2977. break;
  2978. case 'bottom':
  2979. direction = 'top';
  2980. break;
  2981. case 'left':
  2982. direction = 'right';
  2983. break;
  2984. case 'right':
  2985. direction = 'left';
  2986. break;
  2987. case 'topleft':
  2988. direction = 'bottomright';
  2989. break;
  2990. case 'topright':
  2991. direction = 'bottomleft';
  2992. break;
  2993. case 'bottomleft':
  2994. direction = 'topright';
  2995. break;
  2996. case 'bottomright':
  2997. direction = 'topleft';
  2998. break;
  2999. }
  3000. }
  3001. switch( direction ){
  3002. case 'top':
  3003. T1 = T2 = -tile.height();
  3004. L1 = L2 = 0;
  3005. break;
  3006. case 'bottom':
  3007. T1 = T2 = tile.height();
  3008. L1 = L2 = 0;
  3009. break;
  3010. case 'left':
  3011. T1 = T2 = 0;
  3012. L1 = L2 = -tile.width();
  3013. break;
  3014. case 'right':
  3015. T1 = T2 = 0;
  3016. L1 = L2 = tile.width();
  3017. break;
  3018. case 'topleft':
  3019. T1 = tile.height();
  3020. T2 = 0;
  3021. L1 = tile.width();
  3022. L2 = 0;
  3023. break;
  3024. case 'topright':
  3025. T1 = tile.height();
  3026. T2 = 0;
  3027. L1 = - tile.width();
  3028. L2 = 0;
  3029. break;
  3030. case 'bottomleft':
  3031. T1 = - tile.height();
  3032. T2 = 0;
  3033. L1 = tile.width();
  3034. L2 = 0;
  3035. break;
  3036. case 'bottomright':
  3037. T1 = - tile.height();
  3038. T2 = 0;
  3039. L1 = - tile.width();
  3040. L2 = 0;
  3041. break;
  3042. }
  3043. ls.g.scale2D = prop.transition.scale ? prop.transition.scale : 1;
  3044. if( carousel == true && ls.g.scale2D != 1 ){
  3045. T1 = T1 / 2;
  3046. T2 = T2 / 2;
  3047. L1 = L1 / 2;
  3048. L2 = L2 / 2;
  3049. }
  3050. // Selecting the type of the transition
  3051. // if( !ls.g.ie78 || ( ls.g.ie78 && !ls.o.optimizeForIE78 ) || ( ls.g.ie78 && ls.o.optimizeForIE78 == true && prop.name.toLowerCase().indexOf('crossfade') != -1 ) ){
  3052. switch( prop.transition.type ){
  3053. case 'fade':
  3054. T1 = T2 = L1 = L2 = 0;
  3055. O1 = 0;
  3056. O2 = 1;
  3057. break;
  3058. case 'mixed':
  3059. O1 = 0;
  3060. O2 = 1;
  3061. if( ls.g.scale2D == 1 ){
  3062. T2 = L2 = 0;
  3063. }
  3064. break;
  3065. }
  3066. // }
  3067. // IMPROVEMENT v4.5.0 Implemented Rotation and Scale into 2D Transitions
  3068. if((( prop.transition.rotate || prop.transition.rotateX || prop.transition.rotateY ) || ls.g.scale2D != 1 ) && !ls.g.ie78 && prop.transition.type != 'slide' ){
  3069. tile.css({
  3070. overflow : 'visible'
  3071. });
  3072. }else{
  3073. tile.css({
  3074. overflow : 'hidden'
  3075. });
  3076. }
  3077. if( carousel == true){
  3078. ls.g.curTiles.css({
  3079. overflow: 'visible'
  3080. });
  3081. }else{
  3082. ls.g.curTiles.css({
  3083. overflow: 'hidden'
  3084. });
  3085. }
  3086. if( crossfade == true || prop.transition.type == 'slide' || carousel == true ){
  3087. var tileInCur = tile.appendTo( ls.g.curTiles );
  3088. var tileInNext = tile.clone().appendTo( ls.g.nextTiles );
  3089. curTile = $('<div>').addClass('ls-curtile').appendTo( tileInCur );
  3090. }else{
  3091. var tileInNext = tile.appendTo( ls.g.nextTiles );
  3092. }
  3093. nextTile = $('<div>').addClass('ls-nexttile').appendTo( tileInNext ).css({
  3094. top : -T1,
  3095. left : -L1,
  3096. dispay : 'block',
  3097. opacity : O1
  3098. });
  3099. // Animating tiles
  3100. var curTileDelay = tileSequence[tiles] * prop.tile.delay;
  3101. // IMPROVEMENT v4.5.0 Implemented various types of rotations into 2D Transitions
  3102. var r = prop.transition.rotate ? prop.transition.rotate : 0;
  3103. var rX = prop.transition.rotateX ? prop.transition.rotateX : 0;
  3104. var rY = prop.transition.rotateY ? prop.transition.rotateY : 0;
  3105. // Reversing rotation degrees if slider is moving backwards
  3106. if( pn == 'prev' ){
  3107. r = -r;
  3108. rX = -rX;
  3109. rY = -rY;
  3110. }
  3111. TweenLite.fromTo(nextTile[0],prop.transition.duration/1000,{
  3112. rotation : r,
  3113. rotationX : rX,
  3114. rotationY : rY,
  3115. scale : ls.g.scale2D
  3116. },{
  3117. delay : curTileDelay / 1000,
  3118. top : 0,
  3119. left : 0,
  3120. opacity : O2,
  3121. rotation : 0,
  3122. rotationX : 0,
  3123. rotationY : 0,
  3124. scale : 1,
  3125. ease : lsConvertEasing( prop.transition.easing )
  3126. });
  3127. // IMPROVEMENT v5.0.0 Smart crossfading for semi-transparent PNG and different size JPG backgrounds
  3128. if(
  3129. crossfade == true && (
  3130. nextBG.length < 1 || (
  3131. nextBG.length > 0 && (
  3132. nextBG.attr('src').toLowerCase().indexOf('png') != -1 || (
  3133. nextBG.width() < ls.g.sliderWidth() || nextBG.height() < ls.g.sliderHeight()
  3134. )
  3135. )
  3136. )
  3137. )
  3138. ){
  3139. TweenLite.to(curTile[0],prop.transition.duration/1000,{
  3140. delay : curTileDelay / 1000,
  3141. opacity : 0,
  3142. ease : lsConvertEasing( prop.transition.easing )
  3143. });
  3144. }
  3145. if( ( prop.transition.type == 'slide' || carousel == true ) && prop.name.toLowerCase().indexOf('mirror') == -1 ){
  3146. var r2 = 0;
  3147. if( r != 0 ){
  3148. r2 = -r;
  3149. }
  3150. TweenLite.to(curTile[0],prop.transition.duration/1000,{
  3151. delay : curTileDelay / 1000,
  3152. top : T2,
  3153. left : L2,
  3154. rotation : r2,
  3155. scale : ls.g.scale2D,
  3156. opacity: O1,
  3157. ease : lsConvertEasing( prop.transition.easing )
  3158. });
  3159. }
  3160. }
  3161. // Appending the background images of current and next layers into the tiles on both of 2d & 3d transitions
  3162. // BUGFIX v5.0.0 added Math.floor to prevent '1px bug' under Safari and Firefox
  3163. if( curBG.length ){
  3164. if( type == '3d' || ( type == '2d' && ( crossfade == true || prop.transition.type == 'slide' || carousel == true ) ) ){
  3165. curTile.append($('<img>').attr('src', curBG.attr('src')).css({
  3166. width : curBG[0].style.width,
  3167. height : curBG[0].style.height,
  3168. marginLeft : parseFloat(curBG.css('margin-left')) - parseFloat(tile.position().left),
  3169. marginTop : parseFloat(curBG.css('margin-top')) - parseFloat(tile.position().top)
  3170. }));
  3171. }else if( ls.g.curTiles.children().length == 0 ){
  3172. ls.g.curTiles.append($('<img>').attr('src', curBG.attr('src')).css({
  3173. width : curBG[0].style.width,
  3174. height : curBG[0].style.height,
  3175. marginLeft : parseFloat(curBG.css('margin-left')),
  3176. marginTop : parseFloat(curBG.css('margin-top'))
  3177. }));
  3178. }
  3179. }
  3180. if( nextBG.length ){
  3181. nextTile.append( $('<img>').attr('src', nextBG.attr('src')).css({
  3182. width : nextBG[0].style.width,
  3183. height : nextBG[0].style.height,
  3184. marginLeft : parseFloat(nextBG.css('margin-left')) - parseFloat(tile.position().left),
  3185. marginTop : parseFloat(nextBG.css('margin-top')) - parseFloat(tile.position().top)
  3186. }));
  3187. }
  3188. }
  3189. // Storing current and next layer elements in a local variable (needed by setTimeout functions in some cases)
  3190. var curLayer = ls.g.curLayer;
  3191. var nextLayer = ls.g.nextLayer;
  3192. // Hiding the background image of the current and next layers (immediately)
  3193. setTimeout(function(){
  3194. curLayer.find('.ls-bg').css({
  3195. visibility : 'hidden'
  3196. });
  3197. },50);
  3198. nextLayer.find('.ls-bg').css({
  3199. visibility : 'hidden'
  3200. });
  3201. ls.g.ltContainer.removeClass('ls-overflow-hidden');
  3202. // Sliding out the sublayers of the current layer
  3203. // (immediately, delay out and duration out properties are not applied to the sublayers during the new layer transitions)
  3204. curSubLayers(sublayersDurationOut);
  3205. // BUGFIX v5.2.0 prevents background flickering in some cases
  3206. if( sublayersDurationOut === 0 ){
  3207. sublayersDurationOut = 10;
  3208. }
  3209. // Hiding current layer after its sublayers animated out
  3210. setTimeout(function(){
  3211. curLayer.css({
  3212. width: 0
  3213. });
  3214. }, sublayersDurationOut );
  3215. // Calculating next layer delay
  3216. var nextLayerTimeShift = parseInt(nextLayer.data('timeshift')) ? parseInt(nextLayer.data('timeshift')) : 0;
  3217. var nextLayerDelay = ls.g.totalDuration + nextLayerTimeShift > 0 ? ls.g.totalDuration + nextLayerTimeShift : 0;
  3218. // Showing next layer and sliding sublayers of the next layer in after the current layer transition ended
  3219. setTimeout(function(){
  3220. if( ls.g.resize == true ){
  3221. ls.g.ltContainer.empty();
  3222. curLayer.removeClass('ls-active');
  3223. ls.makeResponsive( nextLayer, function(){
  3224. ls.g.resize = false;
  3225. });
  3226. }
  3227. // Sliding in / fading in the sublayers of the next layer
  3228. nextSubLayers();
  3229. // NEW FEATURE v4.6.0 Hiding background if the next layer has png BG or has no BG
  3230. // BUGFIX v4.6.1 Changed some properties to prevent flickering
  3231. if( nextLayer.find('.ls-bg').length < 1 || ( nextLayer.find('.ls-bg').length > 0 && nextLayer.find('.ls-bg').attr('src').toLowerCase().indexOf('png') != -1 ) ){
  3232. ls.g.ltContainer.delay(350).fadeOut(300,function(){
  3233. $(this).empty().show();
  3234. });
  3235. }
  3236. // Displaying the next layer (immediately)
  3237. nextLayer.css({
  3238. width : ls.g.sliderWidth(),
  3239. height : ls.g.sliderHeight()
  3240. });
  3241. }, nextLayerDelay );
  3242. // BUGFIX v5.0.1 Added a minimal value of ls.g.totalDuration
  3243. // CHANGED in v5.1.0 due to a fading issue in carousel transition
  3244. if( ls.g.totalDuration < 300 ){
  3245. ls.g.totalDuration = 1000;
  3246. }
  3247. // 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
  3248. setTimeout(function(){
  3249. ls.g.ltContainer.addClass('ls-overflow-hidden');
  3250. nextLayer.addClass('ls-active');
  3251. if( nextLayer.find('.ls-bg').length ){
  3252. nextLayer.find('.ls-bg').css({
  3253. display : 'none',
  3254. visibility : 'visible'
  3255. });
  3256. if( ls.g.ie78 ){
  3257. nextLayer.find('.ls-bg').css('display','block');
  3258. setTimeout(function(){
  3259. curLayerCallback();
  3260. },500);
  3261. }else{
  3262. nextLayer.find('.ls-bg').fadeIn(500, function(){
  3263. curLayerCallback();
  3264. });
  3265. }
  3266. }else{
  3267. curLayerCallback();
  3268. }
  3269. }, ls.g.totalDuration );
  3270. };
  3271. /* Selecting and running the transition */
  3272. // NEW FEATURE v5.2.0 Starts the slider only if it is in the viewport
  3273. var startInViewport = function(){
  3274. ls.g.nextLayer.find(' > *[class*="ls-l"]').each(function(){
  3275. $(this).css({
  3276. visibility : 'hidden'
  3277. });
  3278. });
  3279. ls.g.sliderTop = $(el).offset().top;
  3280. $(window).load(function(){
  3281. setTimeout(function(){
  3282. ls.g.sliderTop = $(el).offset().top;
  3283. }, 20);
  3284. });
  3285. var isSliderInViewport = function(){
  3286. if( $(window).scrollTop() + $(window).height() - ( ls.g.sliderHeight() / 2 ) > ls.g.sliderTop ){
  3287. ls.g.firstSlideAnimated = true;
  3288. if( ls.g.originalAutoStart === true ){
  3289. //ls.g.autoSlideshow = true;
  3290. ls.o.autoStart = true;
  3291. ls.start();
  3292. }
  3293. nextSubLayers();
  3294. }
  3295. }
  3296. $(window).scroll(function(){
  3297. if( !ls.g.firstSlideAnimated ){
  3298. isSliderInViewport();
  3299. }
  3300. });
  3301. isSliderInViewport();
  3302. };
  3303. 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';
  3304. if( !ls.g.nextLayer.data('transitiontype') ){
  3305. ls.transitionType( ls.g.nextLayer );
  3306. }
  3307. if( ls.g.nextLayer.data('transitiontype') === 'new' ){
  3308. tType = 'new';
  3309. }
  3310. if( ls.o.slideTransition ){
  3311. tType = 'forced';
  3312. }
  3313. if( ls.o.animateFirstSlide && !ls.g.firstSlideAnimated ){
  3314. // BUGFIX v3.5 there is no need to animate 'current' layer if the following conditions are true
  3315. // this fixes the sublayer animation direction bug
  3316. if( ls.g.layersNum == 1 ){
  3317. var curDelay = 0;
  3318. // IMPROVEMENT v4.1.0 Calling cbAnimStop(); function if only one layer is in the slider
  3319. ls.o.cbAnimStop(ls.g);
  3320. }else{
  3321. var nextLayerTimeShift = parseInt(ls.g.nextLayer.data('timeshift')) ? parseInt(ls.g.nextLayer.data('timeshift')) : 0;
  3322. var d = tType == 'new' ? 0 : curDuration;
  3323. ls.g.t5 = setTimeout(function(){
  3324. curLayerCallback();
  3325. }, d + Math.abs(nextLayerTimeShift) );
  3326. }
  3327. // curDelay must be 0!
  3328. ls.g.totalDuration = true;
  3329. // Animating SUBLAYERS of the first layer
  3330. if( ls.o.startInViewport === true ){
  3331. startInViewport();
  3332. }else{
  3333. ls.g.firstSlideAnimated = true;
  3334. nextSubLayers();
  3335. }
  3336. // Displaying the first layer (immediately)
  3337. ls.g.nextLayer.css({
  3338. width : ls.g.sliderWidth(),
  3339. height : ls.g.sliderHeight()
  3340. });
  3341. if( !ls.g.ie78 ){
  3342. ls.g.nextLayer.find('.ls-bg').css({
  3343. display : 'none'
  3344. }).fadeIn(ls.o.sliderFadeInDuration);
  3345. }
  3346. ls.g.isLoading = false;
  3347. }else{
  3348. switch(tType){
  3349. // Old transitions (sliding layers)
  3350. case 'old':
  3351. ls.g.totalDuration = false;
  3352. // BUGFIX v4.5.0 Removing elements from ls-lt-container is necessary
  3353. if( ls.g.ltContainer ){
  3354. ls.g.ltContainer.empty();
  3355. }
  3356. // Animating CURRENT LAYER and its SUBLAYERS
  3357. curLayer();
  3358. curSubLayers();
  3359. // Animating NEXT LAYER and its SUBLAYERS
  3360. nextLayer();
  3361. nextSubLayers();
  3362. break;
  3363. // NEW FEATURE v4.0 2D & 3D Layer Transitions
  3364. case 'new':
  3365. if( typeof LSCustomTransition != 'undefined' ){
  3366. selectCustomTransition();
  3367. }else{
  3368. selectTransition();
  3369. }
  3370. break;
  3371. case 'forced':
  3372. slideTransition( ls.o.slideTransition.type, ls.o.slideTransition.obj );
  3373. break;
  3374. }
  3375. }
  3376. };
  3377. ls.transitionType = function( el ){
  3378. var ttype = el.data('ls') ||
  3379. ( !el.data('ls') &&
  3380. !el.data('slidedelay') &&
  3381. !el.data('slidedirection') &&
  3382. !el.data('slideoutdirection') &&
  3383. !el.data('delayin') &&
  3384. !el.data('delayout') &&
  3385. !el.data('durationin') &&
  3386. !el.data('durationout') &&
  3387. !el.data('showuntil') &&
  3388. !el.data('easingin') &&
  3389. !el.data('easingout') &&
  3390. !el.data('scalein') &&
  3391. !el.data('scaleout') &&
  3392. !el.data('rotatein') &&
  3393. !el.data('rotateout')
  3394. ) ? 'new' : 'old';
  3395. el.data('transitiontype', ttype);
  3396. };
  3397. ls.sublayerShowUntil = function( sublayer ){
  3398. if( !sublayer.data('transitiontype') ){
  3399. ls.transitionType( sublayer );
  3400. }
  3401. // BUGFIX v5.1.0 Removing ls-videohack class before starting transition
  3402. sublayer.removeClass('ls-videohack');
  3403. var prevOrNext = ls.g.curLayer;
  3404. if( ls.g.prevNext != 'prev' && ls.g.nextLayer ){
  3405. prevOrNext = ls.g.nextLayer;
  3406. }
  3407. var chooseDirection = prevOrNext.data('slidedirection') ? prevOrNext.data('slidedirection') : ls.o.slideDirection;
  3408. // Setting the direction of sliding
  3409. var slideDirection = ls.g.slideDirections[ls.g.prevNext][chooseDirection];
  3410. var curSubSlideDir = sublayer.data('slidedirection') ? sublayer.data('slidedirection') : slideDirection;
  3411. var lml, lmt;
  3412. switch(curSubSlideDir){
  3413. case 'left':
  3414. lml = -ls.g.sliderWidth();
  3415. lmt = 0;
  3416. break;
  3417. case 'right':
  3418. lml = ls.g.sliderWidth();
  3419. lmt = 0;
  3420. break;
  3421. case 'top':
  3422. lmt = -ls.g.sliderHeight();
  3423. lml = 0;
  3424. break;
  3425. case 'bottom':
  3426. lmt = ls.g.sliderHeight();
  3427. lml = 0;
  3428. break;
  3429. case 'fade':
  3430. lmt = 0;
  3431. lml = 0;
  3432. break;
  3433. }
  3434. // NEW FEATURE v1.6 added slideoutdirection to sublayers
  3435. // NEW FEATURES 5.0.0 added axis-free transitions with offsetx and offsety properties
  3436. if( sublayer.data('transitiontype') === 'new' ){
  3437. var curSubSlideOutDir = 'new';
  3438. }else{
  3439. var curSubSlideOutDir = sublayer.data('slideoutdirection') ? sublayer.data('slideoutdirection') : false;
  3440. }
  3441. switch(curSubSlideOutDir){
  3442. case 'left':
  3443. lml = ls.g.sliderWidth();
  3444. lmt = 0;
  3445. break;
  3446. case 'right':
  3447. lml = -ls.g.sliderWidth();
  3448. lmt = 0;
  3449. break;
  3450. case 'top':
  3451. lmt = ls.g.sliderHeight();
  3452. lml = 0;
  3453. break;
  3454. case 'bottom':
  3455. lmt = -ls.g.sliderHeight();
  3456. lml = 0;
  3457. break;
  3458. case 'fade':
  3459. lmt = 0;
  3460. lml = 0;
  3461. break;
  3462. case 'new':
  3463. if( sublayer.data('offsetxout') ){
  3464. if( sublayer.data('offsetxout') === 'left' ){
  3465. lml = ls.g.sliderWidth();
  3466. }else if( sublayer.data('offsetxout') === 'right' ){
  3467. lml = -ls.g.sliderWidth();
  3468. }else{
  3469. lml = -parseInt( sublayer.data('offsetxout') );
  3470. }
  3471. }else{
  3472. lml = -ls.lt.offsetXOut;
  3473. }
  3474. if( sublayer.data('offsetyout') ){
  3475. if( sublayer.data('offsetyout') === 'top' ){
  3476. lmt = ls.g.sliderHeight();
  3477. }else if( sublayer.data('offsetyout') === 'bottom' ){
  3478. lmt = -ls.g.sliderHeight();
  3479. }else{
  3480. lmt = -parseInt( sublayer.data('offsetyout') );
  3481. }
  3482. }else{
  3483. lmt = -ls.lt.offsetYOut;
  3484. }
  3485. break;
  3486. }
  3487. // NEW FEATURE v4.5.0 Rotating & Scaling sublayers
  3488. // BUGFIX v4.5.5 changing the default value from 0 to 'none' (because of old jQuery, 1.7.2)
  3489. // NEW FEATURES v5.0.0 Added SkewX, SkewY, ScaleX, ScaleY, RotateX & RotateY transitions
  3490. var curSubRotate = curSubRotateX = curSubRotateY = curSubScale = curSubSkewX = curSubSkewY = curSubScaleX = curSubScaleY = 'none';
  3491. // if( !ls.g.ie78 && ls.g.enableCSS3 ){
  3492. curSubRotate = sublayer.data('rotateout') ? sublayer.data('rotateout') : ls.lt.rotateOut;
  3493. curSubRotateX = sublayer.data('rotatexout') ? sublayer.data('rotatexout') : ls.lt.rotateXOut;
  3494. curSubRotateY = sublayer.data('rotateyout') ? sublayer.data('rotateyout') : ls.lt.rotateYOut;
  3495. curSubScale = sublayer.data('scaleout') ? sublayer.data('scaleout') : ls.lt.scaleOut;
  3496. curSubSkewX = sublayer.data('skewxout') ? sublayer.data('skewxout') : ls.lt.skewXOut;
  3497. curSubSkewY = sublayer.data('skewyout') ? sublayer.data('skewyout') : ls.lt.skewYOut;
  3498. if( curSubScale === 1 ){
  3499. curSubScaleX = sublayer.data('scalexout') ? sublayer.data('scalexout') : ls.lt.scaleXOut;
  3500. curSubScaleY = sublayer.data('scaleyout') ? sublayer.data('scaleyout') : ls.lt.scaleYOut;
  3501. }else{
  3502. curSubScaleX = curSubScaleY = curSubScale;
  3503. }
  3504. var too = sublayer.data('transformoriginout') ? sublayer.data('transformoriginout').split(' ') : ls.lt.transformOriginOut;
  3505. for(var t =0;t<too.length;t++){
  3506. 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 ){
  3507. too[t] = '' + parseInt( too[t] ) * ls.g.ratio + 'px';
  3508. }
  3509. }
  3510. var curSubTransformOrigin = too.join(' ');
  3511. var curSubPerspective = sublayer.data('perspectiveout') ? sublayer.data('perspectiveout') : ls.lt.perspectiveOut;
  3512. // }
  3513. // IMPROVEMENT v4.0 Distance (P.level): -1
  3514. var endLeft = parseInt( sublayer.css('left') );
  3515. var endTop = parseInt( sublayer.css('top') );
  3516. var curSubPLevel = parseInt( sublayer.attr('class').split('ls-l')[1] );
  3517. var wh = sublayer.outerWidth() > sublayer.outerHeight() ? sublayer.outerWidth() : sublayer.outerHeight();
  3518. var modX = parseInt( curSubRotate ) === 0 ? sublayer.outerWidth() : wh;
  3519. var modY = parseInt( curSubRotate ) === 0 ? sublayer.outerHeight() : wh;
  3520. if( ( curSubPLevel === -1 && curSubSlideOutDir !== 'new' ) || ( sublayer.data('offsetxout') === 'left' || sublayer.data('offsetxout') === 'right' ) ){
  3521. if( lml < 0 ){
  3522. lml = - ( ls.g.sliderWidth() - endLeft + ( curSubScaleX / 2 - .5 ) * modX + 100 );
  3523. }else if( lml > 0 ){
  3524. lml = endLeft + ( curSubScaleX / 2 + .5 ) * modX + 100;
  3525. }
  3526. }else{
  3527. lml = lml * ls.g.ratio;
  3528. }
  3529. if( ( curSubPLevel === -1 && curSubSlideOutDir !== 'new' ) || ( sublayer.data('offsetyout') === 'top' || sublayer.data('offsetyout') === 'bottom' ) ){
  3530. if( lmt < 0 ){
  3531. lmt = - ( ls.g.sliderHeight() - endTop + ( curSubScaleY / 2 - .5 ) * modY + 100 );
  3532. }else if( lmt > 0 ){
  3533. lmt = endTop + ( curSubScaleY / 2 + .5 ) * modY + 100;
  3534. }
  3535. }else{
  3536. lmt = lmt * ls.g.ratio;
  3537. }
  3538. if( curSubPLevel === -1 || curSubSlideOutDir === 'new' ){
  3539. var curSubPar = 1;
  3540. }else{
  3541. var curSubParMod = ls.g.curLayer.data('parallaxout') ? parseInt(ls.g.curLayer.data('parallaxout')) : ls.o.parallaxOut;
  3542. var curSubPar = curSubPLevel * curSubParMod;
  3543. }
  3544. // var curSubDelay = parseInt( sublayer.data('showuntil') );
  3545. if( sublayer.data('transitiontype') === 'new' ){
  3546. var duO = ls.lt.durationOut;
  3547. var eO = ls.lt.easingOut;
  3548. }else{
  3549. var duO = ls.o.durationOut;
  3550. var eO = ls.o.easingOut;
  3551. }
  3552. var curSubTime = sublayer.data('durationout') ? parseInt(sublayer.data('durationout')) : duO;
  3553. // BUGFIX v5.2.0 duration cannot be 0
  3554. if( curSubTime === 0 ){ curSubTime = 1 }
  3555. var curSubEasing = sublayer.data('easingout') ? sublayer.data('easingout') : eO;
  3556. var css = {
  3557. visibility : 'hidden'
  3558. };
  3559. var transition = {
  3560. rotation : curSubRotate,
  3561. rotationX : curSubRotateX,
  3562. rotationY : curSubRotateY,
  3563. skewX : curSubSkewX,
  3564. skewY : curSubSkewY,
  3565. scaleX : curSubScaleX,
  3566. scaleY : curSubScaleY,
  3567. x : -lml * curSubPar,
  3568. y : -lmt * curSubPar,
  3569. ease : lsConvertEasing( curSubEasing ),
  3570. onComplete : function(){
  3571. sublayer.css( css );
  3572. }
  3573. };
  3574. if( curSubSlideOutDir == 'fade' || ( !curSubSlideOutDir && curSubSlideDir == 'fade' ) || ( sublayer.data('fadeout') !== 'false' && sublayer.data('transitiontype') === 'new' ) ){
  3575. transition['opacity'] = 0;
  3576. css['opacity'] = sublayer.data( 'originalOpacity' );
  3577. }
  3578. TweenLite.set( sublayer[0],{
  3579. transformPerspective : curSubPerspective,
  3580. transformOrigin : curSubTransformOrigin
  3581. });
  3582. TweenLite.to(sublayer[0],curSubTime/1000,transition);
  3583. // sublayer.stop(true,false).animate( transition, curSubTime, curSubEasing,function(){
  3584. // sublayer.css( css );
  3585. // });
  3586. };
  3587. // v3.6 Improved Debug Mode
  3588. // ls.debug = function(){
  3589. // ls.d = {
  3590. // history : $('<div>'),
  3591. // // adds a H1 (title)
  3592. // aT : function(content){
  3593. // $('<h1>'+content+'</h1>').appendTo( ls.d.history );
  3594. // },
  3595. // // adds an empty UL
  3596. // aeU : function(){
  3597. // $('<ul>').appendTo( ls.d.history );
  3598. // },
  3599. // // adds an UL with a LI
  3600. // aU : function(content){
  3601. // $('<ul><li>'+content+'</li></ul>').appendTo( ls.d.history );
  3602. // },
  3603. // // adds a LI into the last UL
  3604. // aL : function(content){
  3605. // $('<li>'+content+'</li>').appendTo( ls.d.history.find('ul:last') );
  3606. // },
  3607. // // adds an UL into the last LI of the last UL
  3608. // aUU : function(content){
  3609. // $('<ul>').appendTo( ls.d.history.find('ul:last li:last') );
  3610. // },
  3611. // // adds a Function to the first LI inside the last UL
  3612. // aF : function(elem){
  3613. // ls.d.history.find('ul:last li:last').hover(
  3614. // function(){
  3615. // elem.css({
  3616. // border: '2px solid red',
  3617. // marginTop : parseInt( elem.css('margin-top') ) - 2,
  3618. // marginLeft : parseInt( elem.css('margin-left') ) - 2
  3619. // });
  3620. // },
  3621. // function(){
  3622. // elem.css({
  3623. // border: '0px',
  3624. // marginTop : parseInt( elem.css('margin-top') ) + 2,
  3625. // marginLeft : parseInt( elem.css('margin-left') ) + 2
  3626. // });
  3627. // }
  3628. // );
  3629. // },
  3630. // show : function(){
  3631. // if( !$('body').find('.ls-debug-console').length ){
  3632. // if( !ls.d.putData ){
  3633. // // Init code
  3634. // ls.d.aT('Init code');
  3635. // ls.d.aeU();
  3636. // for( var prop in ls.o ){
  3637. // ls.d.aL(prop+': <strong>' + ls.o[prop] + '</strong>');
  3638. // }
  3639. // // ls.d.aL('sliderOriginalWidth: <strong>' + ls.g.sliderOriginalWidth + '</strong>');
  3640. // // ls.d.aL('sliderOriginalHeight: <strong>' + ls.g.sliderOriginalHeight + '</strong>');
  3641. // // Slides, layers data
  3642. // ls.d.aT('LayerSlider Content');
  3643. // ls.d.aU('Number of slides found: <strong>' + $(el).find('.ls-slide').length + '</strong>');
  3644. // $(el).find('.ls-inner .ls-slide, .ls-inner *[class*="ls-l"]').each(function(){
  3645. // if( $(this).hasClass('ls-slide') ){
  3646. // ls.d.aU('<strong>SLIDE ' + ( $(this).index() + 1 ) + '</strong>');
  3647. // ls.d.aUU();
  3648. // ls.d.aL('<strong>SLIDE ' + ( $(this).index() + 1 ) + ' properties:</strong><br><br>');
  3649. // }else{
  3650. // ls.d.aU('&nbsp;&nbsp;&nbsp;&nbsp;Layer ( '+$(this).prop('tagName')+' )');
  3651. // ls.d.aF($(this));
  3652. // ls.d.aUU();
  3653. // ls.d.aL('<strong>'+$(this).prop('tagName')+' layer properties:</strong><br><br>');
  3654. // ls.d.aL('distance / class: <strong>'+$(this).attr('class')+'</strong>');
  3655. // }
  3656. // $.each( $(this).data(),function(name, val) {
  3657. // ls.d.aL( name +': <strong>' + val + '</strong>');
  3658. // });
  3659. // });
  3660. // ls.d.putData = true;
  3661. // }
  3662. // var dc = $('<div>').addClass('ls-debug-console').css({
  3663. // position: 'fixed',
  3664. // zIndex: '10000000000',
  3665. // top: '10px',
  3666. // right: '10px',
  3667. // width: '300px',
  3668. // padding: '20px',
  3669. // background: 'black',
  3670. // 'border-radius': '10px',
  3671. // height: $(window).height() - 60,
  3672. // opacity: 0,
  3673. // marginRight: 150
  3674. // }).appendTo( $('body') ).css({
  3675. // marginRight: 0,
  3676. // opacity: .9
  3677. // }).click(function(e){
  3678. // if(e.shiftKey && e.altKey){
  3679. // $(this).remove();
  3680. // }
  3681. // });
  3682. // var ds = $('<div>').css({
  3683. // width: '100%',
  3684. // height: '100%',
  3685. // overflow: 'auto'
  3686. // }).appendTo( dc );
  3687. // var dd = $('<div>').css({
  3688. // width: '100%'
  3689. // }).appendTo( ds ).append( ls.d.history );
  3690. // }
  3691. // },
  3692. // hide : function(){
  3693. // $('body').find('.ls-debug-console').remove();
  3694. // }
  3695. // };
  3696. // $(el).click(function(e){
  3697. // if(e.shiftKey && e.altKey){
  3698. // ls.d.show();
  3699. // }
  3700. // });
  3701. // };
  3702. // initializing
  3703. ls.load();
  3704. };
  3705. var lsConvertEasing = function( e ){
  3706. var t;
  3707. if( e.toLowerCase().indexOf('swing') !== -1 || e.toLowerCase().indexOf('linear') !== -1 ){
  3708. t = Linear.easeNone;
  3709. }else if( e.toLowerCase().indexOf('easeinout') !== -1 ){
  3710. var ee = e.toLowerCase().split('easeinout')[1];
  3711. t = window[ee.charAt(0).toUpperCase() + ee.slice(1)].easeInOut;
  3712. }else if( e.toLowerCase().indexOf('easeout') !== -1 ){
  3713. var ee = e.toLowerCase().split('easeout')[1];
  3714. t = window[ee.charAt(0).toUpperCase() + ee.slice(1)].easeOut;
  3715. }else if( e.toLowerCase().indexOf('easein') !== -1 ){
  3716. var ee = e.toLowerCase().split('easein')[1];
  3717. t = window[ee.charAt(0).toUpperCase() + ee.slice(1)].easeIn;
  3718. }
  3719. return t;
  3720. };
  3721. var lsConvertTransition = function( t, e, type, undef ){
  3722. if( typeof e === 'undefined' ){
  3723. var e = 'easeInOutQuart';
  3724. }
  3725. var tt = {};
  3726. if( t.rotate !== undef ){
  3727. tt.rotation = t.rotate;
  3728. }
  3729. if( t.rotateY !== undef ){
  3730. tt.rotationY = t.rotateY;
  3731. }
  3732. if( t.rotateX !== undef ){
  3733. tt.rotationX = t.rotateX;
  3734. }
  3735. if( type === 'after' ){
  3736. tt.scaleX = tt.scaleY = tt.scaleZ = 1;
  3737. }else if( t.scale3d !== undef ){
  3738. tt.scaleX = tt.scaleY = tt.scaleZ = t.scale3d;
  3739. }
  3740. if( t.delay ){
  3741. tt.delay = type === 'after' ? t.delay/1000 : t.delay;
  3742. }
  3743. tt.ease = lsConvertEasing( e );
  3744. return tt;
  3745. };
  3746. // Support3D checks the CSS3 3D capability of the browser (based on the idea of Modernizr.js)
  3747. var lsSupport3D = function( el ) {
  3748. var testEl = $('<div>'),
  3749. s3d1 = false,
  3750. s3d2 = false,
  3751. properties = ['perspective', 'OPerspective', 'msPerspective', 'MozPerspective', 'WebkitPerspective'];
  3752. transform = ['transformStyle','OTransformStyle','msTransformStyle','MozTransformStyle','WebkitTransformStyle'];
  3753. for (var i = properties.length - 1; i >= 0; i--){
  3754. s3d1 = s3d1 ? s3d1 : testEl[0].style[properties[i]] != undefined;
  3755. };
  3756. // preserve 3D test
  3757. for (var i = transform.length - 1; i >= 0; i--){
  3758. testEl.css( 'transform-style', 'preserve-3d' );
  3759. s3d2 = s3d2 ? s3d2 : testEl[0].style[transform[i]] == 'preserve-3d';
  3760. };
  3761. // 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
  3762. if (s3d1 && testEl[0].style[properties[4]] != undefined){
  3763. testEl.attr('id','ls-test3d').appendTo( el );
  3764. s3d1 = testEl[0].offsetHeight === 3 && testEl[0].offsetLeft === 9;
  3765. testEl.remove();
  3766. }
  3767. return (s3d1 && s3d2);
  3768. };
  3769. // Order array function
  3770. var lsOrderArray = function(x,y,dir) {
  3771. var i = [];
  3772. if(dir=='forward'){
  3773. for( var a=0; a<x;a++){
  3774. for( var b=0; b<y; b++){
  3775. i.push(a+b*x);
  3776. }
  3777. }
  3778. }else{
  3779. for( var a=x-1; a>-1;a--){
  3780. for( var b=y-1; b>-1; b--){
  3781. i.push(a+b*x);
  3782. }
  3783. }
  3784. }
  3785. return i;
  3786. };
  3787. // CountProp counts the properties in an object
  3788. var lsCountProp = function(obj) {
  3789. var count = 0;
  3790. for(var prop in obj) {
  3791. if(obj.hasOwnProperty(prop)){
  3792. ++count;
  3793. }
  3794. }
  3795. return count;
  3796. };
  3797. // We need the browser function (removed from jQuery 1.9)
  3798. var lsBrowser = function(){
  3799. uaMatch = function( ua ) {
  3800. ua = ua.toLowerCase();
  3801. var match = /(chrome)[ \/]([\w.]+)/.exec( ua ) ||
  3802. /(webkit)[ \/]([\w.]+)/.exec( ua ) ||
  3803. /(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) ||
  3804. /(msie) ([\w.]+)/.exec( ua ) ||
  3805. ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) ||
  3806. [];
  3807. return {
  3808. browser: match[ 1 ] || "",
  3809. version: match[ 2 ] || "0"
  3810. };
  3811. };
  3812. var matched = uaMatch( navigator.userAgent ), browser = {};
  3813. if ( matched.browser ) {
  3814. browser[ matched.browser ] = true;
  3815. browser.version = matched.version;
  3816. }
  3817. if ( browser.chrome ) {
  3818. browser.webkit = true;
  3819. } else if ( browser.webkit ) {
  3820. browser.safari = true;
  3821. }
  3822. return browser;
  3823. };
  3824. lsPrefixes = function(obj, method){
  3825. var pfx = ['webkit', 'khtml', 'moz', 'ms', 'o', ''];
  3826. var p = 0, m, t;
  3827. while (p < pfx.length && !obj[m]) {
  3828. m = method;
  3829. if (pfx[p] == '') {
  3830. m = m.substr(0,1).toLowerCase() + m.substr(1);
  3831. }
  3832. m = pfx[p] + m;
  3833. t = typeof obj[m];
  3834. if (t != 'undefined') {
  3835. pfx = [pfx[p]];
  3836. return (t == 'function' ? obj[m]() : obj[m]);
  3837. }
  3838. p++;
  3839. }
  3840. };
  3841. // Global parameters (Do not change these settings!)
  3842. layerSlider.global = {
  3843. version : '5.3.0',
  3844. isMobile : function(){
  3845. 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) ){
  3846. return true;
  3847. }else{
  3848. return false;
  3849. }
  3850. },
  3851. isHideOn3D : function(el){
  3852. if( el.css('padding-bottom') == 'auto' || el.css('padding-bottom') == 'none' || el.css('padding-bottom') == 0 || el.css('padding-bottom') == '0px' ){
  3853. return true;
  3854. }else{
  3855. return false;
  3856. }
  3857. },
  3858. ie78 : lsBrowser().msie && lsBrowser().version < 9 ? true : false,
  3859. originalAutoStart : false,
  3860. paused : false,
  3861. pausedByVideo : false,
  3862. autoSlideshow : false,
  3863. isAnimating : false,
  3864. layersNum : null,
  3865. prevNext : 'next',
  3866. slideTimer : null,
  3867. sliderWidth : null,
  3868. sliderHeight : null,
  3869. slideDirections : {
  3870. prev : {
  3871. left : 'right',
  3872. right : 'left',
  3873. top : 'bottom',
  3874. bottom : 'top'
  3875. },
  3876. next : {
  3877. left : 'left',
  3878. right : 'right',
  3879. top : 'top',
  3880. bottom : 'bottom'
  3881. }
  3882. },
  3883. // Default delay time, fadeout and fadein durations of videoPreview images
  3884. v : {
  3885. d : 500,
  3886. fo : 750,
  3887. fi : 500
  3888. }
  3889. };
  3890. // Layer Transition Defaults
  3891. layerSlider.layerTransitions = {
  3892. offsetXIn : 80,
  3893. offsetYIn : 0,
  3894. durationIn : 1000,
  3895. delayIn : 0,
  3896. easingIn : 'easeInOutQuint',
  3897. fadeIn : true,
  3898. rotateIn : 0,
  3899. rotateXIn : 0,
  3900. rotateYIn : 0,
  3901. scaleIn : 1,
  3902. scaleXIn : 1,
  3903. scaleYIn : 1,
  3904. skewXIn : 0,
  3905. skewYIn : 0,
  3906. transformOriginIn : ['50%','50%','0'],
  3907. perspectiveIn : 500,
  3908. offsetXOut : -80,
  3909. offsetYOut : 0,
  3910. durationOut : 400,
  3911. showUntil : 0,
  3912. easingOut : 'easeInOutQuint',
  3913. fadeOut : true,
  3914. rotateOut : 0,
  3915. rotateXOut : 0,
  3916. rotateYOut : 0,
  3917. scaleOut : 1,
  3918. scaleXOut : 1,
  3919. scaleYOut : 1,
  3920. skewXOut : 0,
  3921. skewYOut : 0,
  3922. transformOriginOut : ['50%','50%','0'],
  3923. perspectiveOut : 500
  3924. };
  3925. layerSlider.slideTransitions = {
  3926. slideDelay : 4000 // Time before the next slide will be loading.
  3927. };
  3928. // Global settings (can be modified)
  3929. layerSlider.options = {
  3930. // Layout
  3931. responsive : true,
  3932. responsiveUnder : 0,
  3933. layersContainer : 0,
  3934. fullScreen : false, // NEW FEATURE 5.5.0
  3935. appendTo : '', // NEW FEATURE 5.5.0
  3936. // Slideshow
  3937. autoStart : true,
  3938. startInViewport : true, // NEW FEATURE v5.2.0
  3939. pauseOnHover : true,
  3940. firstSlide : 1,
  3941. animateFirstSlide : true,
  3942. sliderFadeInDuration: 350, // NEW FEATURE v5.2.0
  3943. loops : 0,
  3944. forceLoopNum : true,
  3945. twoWaySlideshow : false,
  3946. randomSlideshow : false,
  3947. // Appearance
  3948. skin : 'v5',
  3949. skinsPath : '/layerslider/skins/',
  3950. globalBGColor : 'transparent',
  3951. globalBGImage : false,
  3952. // Navigation Area
  3953. navPrevNext : true,
  3954. navStartStop : true,
  3955. navButtons : true,
  3956. keybNav : true,
  3957. touchNav : true,
  3958. hoverPrevNext : true,
  3959. hoverBottomNav : false,
  3960. showBarTimer : false,
  3961. showCircleTimer : true,
  3962. // Thumbnail navigation
  3963. thumbnailNavigation : 'hover',
  3964. tnContainerWidth : '60%',
  3965. tnWidth : 100,
  3966. tnHeight : 60,
  3967. tnActiveOpacity : 35,
  3968. tnInactiveOpacity : 100,
  3969. // Videos
  3970. autoPlayVideos : true,
  3971. autoPauseSlideshow : 'auto',
  3972. youtubePreview : 'maxresdefault.jpg',
  3973. // Preload
  3974. imgPreload : true,
  3975. lazyLoad : true,
  3976. // YourLogo
  3977. yourLogo : false,
  3978. yourLogoStyle : 'left: -10px; top: -10px;',
  3979. yourLogoLink : false,
  3980. yourLogoTarget : '_self',
  3981. // Optimize for IE7 and IE8
  3982. optimizeForMobile : true,
  3983. optimizeForIE78 : true,
  3984. // NEW FEATURES 5.2.0 Mobile features
  3985. hideOnMobile : false,
  3986. hideUnder : 0,
  3987. hideOver : 1000000,
  3988. staticImage : '', // will be available in 5.5.0
  3989. // API functions
  3990. cbInit : function(element){},
  3991. cbStart : function(data){},
  3992. cbStop : function(data){},
  3993. cbPause : function(data){},
  3994. cbAnimStart : function(data){},
  3995. cbAnimStop : function(data){},
  3996. cbPrev : function(data){},
  3997. cbNext : function(data){},
  3998. // !!! IMPORTANT !!! The following properties are deprecated from version 5.0.0 DO NOT USE THEM.
  3999. // The slider will recognize these properties in the init code or if you add these properties into the style attribute of the layer
  4000. // but we recommend you to use to new html5 data attribute (data-ls) with the new properties
  4001. slideDelay : 4000,
  4002. slideDirection : 'right',
  4003. parallaxIn : .45,
  4004. parallaxOut : .45,
  4005. durationIn : 1000,
  4006. durationOut : 1000,
  4007. easingIn : 'easeInOutQuint',
  4008. easingOut : 'easeInOutQuint',
  4009. delayIn : 0,
  4010. delayOut : 0
  4011. };
  4012. })(jQuery);