1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255 |
- /*
- * jQuery carouFredSel 6.2.1
- * Demo's and documentation:
- * caroufredsel.dev7studios.com
- *
- * Copyright (c) 2013 Fred Heusschen
- * www.frebsite.nl
- *
- * Dual licensed under the MIT and GPL licenses.
- * http://en.wikipedia.org/wiki/MIT_License
- * http://en.wikipedia.org/wiki/GNU_General_Public_License
- */
- (function($) {
- // LOCAL
- if ( $.fn.carouFredSel )
- {
- return;
- }
- $.fn.caroufredsel = $.fn.carouFredSel = function(options, configs)
- {
- // no element
- if (this.length == 0)
- {
- debug( true, 'No element found for "' + this.selector + '".' );
- return this;
- }
- // multiple elements
- if (this.length > 1)
- {
- return this.each(function() {
- $(this).carouFredSel(options, configs);
- });
- }
- var $cfs = this,
- $tt0 = this[0],
- starting_position = false;
- if ($cfs.data('_cfs_isCarousel'))
- {
- starting_position = $cfs.triggerHandler('_cfs_triggerEvent', 'currentPosition');
- $cfs.trigger('_cfs_triggerEvent', ['destroy', true]);
- }
- var FN = {};
- FN._init = function(o, setOrig, start)
- {
- o = go_getObject($tt0, o);
- o.items = go_getItemsObject($tt0, o.items);
- o.scroll = go_getScrollObject($tt0, o.scroll);
- o.auto = go_getAutoObject($tt0, o.auto);
- o.prev = go_getPrevNextObject($tt0, o.prev);
- o.next = go_getPrevNextObject($tt0, o.next);
- o.pagination = go_getPaginationObject($tt0, o.pagination);
- o.swipe = go_getSwipeObject($tt0, o.swipe);
- o.mousewheel = go_getMousewheelObject($tt0, o.mousewheel);
- if (setOrig)
- {
- opts_orig = $.extend(true, {}, $.fn.carouFredSel.defaults, o);
- }
- opts = $.extend(true, {}, $.fn.carouFredSel.defaults, o);
- opts.d = cf_getDimensions(opts);
- crsl.direction = (opts.direction == 'up' || opts.direction == 'left') ? 'next' : 'prev';
- var a_itm = $cfs.children(),
- avail_primary = ms_getParentSize($wrp, opts, 'width');
- if (is_true(opts.cookie))
- {
- opts.cookie = 'caroufredsel_cookie_' + conf.serialNumber;
- }
- opts.maxDimension = ms_getMaxDimension(opts, avail_primary);
- // complement items and sizes
- opts.items = in_complementItems(opts.items, opts, a_itm, start);
- opts[opts.d['width']] = in_complementPrimarySize(opts[opts.d['width']], opts, a_itm);
- opts[opts.d['height']] = in_complementSecondarySize(opts[opts.d['height']], opts, a_itm);
- // primary size not set for a responsive carousel
- if (opts.responsive)
- {
- if (!is_percentage(opts[opts.d['width']]))
- {
- opts[opts.d['width']] = '100%';
- }
- }
- // primary size is percentage
- if (is_percentage(opts[opts.d['width']]))
- {
- crsl.upDateOnWindowResize = true;
- crsl.primarySizePercentage = opts[opts.d['width']];
- opts[opts.d['width']] = ms_getPercentage(avail_primary, crsl.primarySizePercentage);
- if (!opts.items.visible)
- {
- opts.items.visibleConf.variable = true;
- }
- }
- if (opts.responsive)
- {
- opts.usePadding = false;
- opts.padding = [0, 0, 0, 0];
- opts.align = false;
- opts.items.visibleConf.variable = false;
- }
- else
- {
- // visible-items not set
- if (!opts.items.visible)
- {
- opts = in_complementVisibleItems(opts, avail_primary);
- }
- // primary size not set -> calculate it or set to "variable"
- if (!opts[opts.d['width']])
- {
- if (!opts.items.visibleConf.variable && is_number(opts.items[opts.d['width']]) && opts.items.filter == '*')
- {
- opts[opts.d['width']] = opts.items.visible * opts.items[opts.d['width']];
- opts.align = false;
- }
- else
- {
- opts[opts.d['width']] = 'variable';
- }
- }
- // align not set -> set to center if primary size is number
- if (is_undefined(opts.align))
- {
- opts.align = (is_number(opts[opts.d['width']]))
- ? 'center'
- : false;
- }
- // set variabe visible-items
- if (opts.items.visibleConf.variable)
- {
- opts.items.visible = gn_getVisibleItemsNext(a_itm, opts, 0);
- }
- }
- // set visible items by filter
- if (opts.items.filter != '*' && !opts.items.visibleConf.variable)
- {
- opts.items.visibleConf.org = opts.items.visible;
- opts.items.visible = gn_getVisibleItemsNextFilter(a_itm, opts, 0);
- }
- opts.items.visible = cf_getItemsAdjust(opts.items.visible, opts, opts.items.visibleConf.adjust, $tt0);
- opts.items.visibleConf.old = opts.items.visible;
- if (opts.responsive)
- {
- if (!opts.items.visibleConf.min)
- {
- opts.items.visibleConf.min = opts.items.visible;
- }
- if (!opts.items.visibleConf.max)
- {
- opts.items.visibleConf.max = opts.items.visible;
- }
- opts = in_getResponsiveValues(opts, a_itm, avail_primary);
- }
- else
- {
- opts.padding = cf_getPadding(opts.padding);
- if (opts.align == 'top')
- {
- opts.align = 'left';
- }
- else if (opts.align == 'bottom')
- {
- opts.align = 'right';
- }
- switch (opts.align)
- {
- // align: center, left or right
- case 'center':
- case 'left':
- case 'right':
- if (opts[opts.d['width']] != 'variable')
- {
- opts = in_getAlignPadding(opts, a_itm);
- opts.usePadding = true;
- }
- break;
- // padding
- default:
- opts.align = false;
- opts.usePadding = (
- opts.padding[0] == 0 &&
- opts.padding[1] == 0 &&
- opts.padding[2] == 0 &&
- opts.padding[3] == 0
- ) ? false : true;
- break;
- }
- }
- if (!is_number(opts.scroll.duration))
- {
- opts.scroll.duration = 500;
- }
- if (is_undefined(opts.scroll.items))
- {
- opts.scroll.items = (opts.responsive || opts.items.visibleConf.variable || opts.items.filter != '*')
- ? 'visible'
- : opts.items.visible;
- }
- opts.auto = $.extend(true, {}, opts.scroll, opts.auto);
- opts.prev = $.extend(true, {}, opts.scroll, opts.prev);
- opts.next = $.extend(true, {}, opts.scroll, opts.next);
- opts.pagination = $.extend(true, {}, opts.scroll, opts.pagination);
- // swipe and mousewheel extend later on, per direction
- opts.auto = go_complementAutoObject($tt0, opts.auto);
- opts.prev = go_complementPrevNextObject($tt0, opts.prev);
- opts.next = go_complementPrevNextObject($tt0, opts.next);
- opts.pagination = go_complementPaginationObject($tt0, opts.pagination);
- opts.swipe = go_complementSwipeObject($tt0, opts.swipe);
- opts.mousewheel = go_complementMousewheelObject($tt0, opts.mousewheel);
- if (opts.synchronise)
- {
- opts.synchronise = cf_getSynchArr(opts.synchronise);
- }
- // DEPRECATED
- if (opts.auto.onPauseStart)
- {
- opts.auto.onTimeoutStart = opts.auto.onPauseStart;
- deprecated('auto.onPauseStart', 'auto.onTimeoutStart');
- }
- if (opts.auto.onPausePause)
- {
- opts.auto.onTimeoutPause = opts.auto.onPausePause;
- deprecated('auto.onPausePause', 'auto.onTimeoutPause');
- }
- if (opts.auto.onPauseEnd)
- {
- opts.auto.onTimeoutEnd = opts.auto.onPauseEnd;
- deprecated('auto.onPauseEnd', 'auto.onTimeoutEnd');
- }
- if (opts.auto.pauseDuration)
- {
- opts.auto.timeoutDuration = opts.auto.pauseDuration;
- deprecated('auto.pauseDuration', 'auto.timeoutDuration');
- }
- // /DEPRECATED
- }; // /init
- FN._build = function() {
- $cfs.data('_cfs_isCarousel', true);
- var a_itm = $cfs.children(),
- orgCSS = in_mapCss($cfs, ['textAlign', 'float', 'position', 'top', 'right', 'bottom', 'left', 'zIndex', 'width', 'height', 'marginTop', 'marginRight', 'marginBottom', 'marginLeft']),
- newPosition = 'relative';
- switch (orgCSS.position)
- {
- case 'absolute':
- case 'fixed':
- newPosition = orgCSS.position;
- break;
- }
- if (conf.wrapper == 'parent')
- {
- sz_storeOrigCss($wrp);
- }
- else
- {
- $wrp.css(orgCSS);
- }
- $wrp.css({
- 'overflow' : 'hidden',
- 'position' : newPosition
- });
- sz_storeOrigCss($cfs);
- $cfs.data('_cfs_origCssZindex', orgCSS.zIndex);
- $cfs.css({
- 'textAlign' : 'left',
- 'float' : 'none',
- 'position' : 'absolute',
- 'top' : 0,
- 'right' : 'auto',
- 'bottom' : 'auto',
- 'left' : 0,
- 'marginTop' : 0,
- 'marginRight' : 0,
- 'marginBottom' : 0,
- 'marginLeft' : 0
- });
- sz_storeMargin(a_itm, opts);
- sz_storeOrigCss(a_itm);
- if (opts.responsive)
- {
- sz_setResponsiveSizes(opts, a_itm);
- }
- }; // /build
- FN._bind_events = function() {
- FN._unbind_events();
- // stop event
- $cfs.bind(cf_e('stop', conf), function(e, imm) {
- e.stopPropagation();
- // button
- if (!crsl.isStopped)
- {
- if (opts.auto.button)
- {
- opts.auto.button.addClass(cf_c('stopped', conf));
- }
- }
- // set stopped
- crsl.isStopped = true;
- if (opts.auto.play)
- {
- opts.auto.play = false;
- $cfs.trigger(cf_e('pause', conf), imm);
- }
- return true;
- });
- // finish event
- $cfs.bind(cf_e('finish', conf), function(e) {
- e.stopPropagation();
- if (crsl.isScrolling)
- {
- sc_stopScroll(scrl);
- }
- return true;
- });
- // pause event
- $cfs.bind(cf_e('pause', conf), function(e, imm, res) {
- e.stopPropagation();
- tmrs = sc_clearTimers(tmrs);
- // immediately pause
- if (imm && crsl.isScrolling)
- {
- scrl.isStopped = true;
- var nst = getTime() - scrl.startTime;
- scrl.duration -= nst;
- if (scrl.pre)
- {
- scrl.pre.duration -= nst;
- }
- if (scrl.post)
- {
- scrl.post.duration -= nst;
- }
- sc_stopScroll(scrl, false);
- }
- // update remaining pause-time
- if (!crsl.isPaused && !crsl.isScrolling)
- {
- if (res)
- {
- tmrs.timePassed += getTime() - tmrs.startTime;
- }
- }
- // button
- if (!crsl.isPaused)
- {
- if (opts.auto.button)
- {
- opts.auto.button.addClass(cf_c('paused', conf));
- }
- }
- // set paused
- crsl.isPaused = true;
- // pause pause callback
- if (opts.auto.onTimeoutPause)
- {
- var dur1 = opts.auto.timeoutDuration - tmrs.timePassed,
- perc = 100 - Math.ceil( dur1 * 100 / opts.auto.timeoutDuration );
- opts.auto.onTimeoutPause.call($tt0, perc, dur1);
- }
- return true;
- });
- // play event
- $cfs.bind(cf_e('play', conf), function(e, dir, del, res) {
- e.stopPropagation();
- tmrs = sc_clearTimers(tmrs);
- // sort params
- var v = [dir, del, res],
- t = ['string', 'number', 'boolean'],
- a = cf_sortParams(v, t);
- dir = a[0];
- del = a[1];
- res = a[2];
- if (dir != 'prev' && dir != 'next')
- {
- dir = crsl.direction;
- }
- if (!is_number(del))
- {
- del = 0;
- }
- if (!is_boolean(res))
- {
- res = false;
- }
- // stopped?
- if (res)
- {
- crsl.isStopped = false;
- opts.auto.play = true;
- }
- if (!opts.auto.play)
- {
- e.stopImmediatePropagation();
- return debug(conf, 'Carousel stopped: Not scrolling.');
- }
- // button
- if (crsl.isPaused)
- {
- if (opts.auto.button)
- {
- opts.auto.button.removeClass(cf_c('stopped', conf));
- opts.auto.button.removeClass(cf_c('paused', conf));
- }
- }
- // set playing
- crsl.isPaused = false;
- tmrs.startTime = getTime();
- // timeout the scrolling
- var dur1 = opts.auto.timeoutDuration + del;
- dur2 = dur1 - tmrs.timePassed;
- perc = 100 - Math.ceil(dur2 * 100 / dur1);
- if (opts.auto.progress)
- {
- tmrs.progress = setInterval(function() {
- var pasd = getTime() - tmrs.startTime + tmrs.timePassed,
- perc = Math.ceil(pasd * 100 / dur1);
- opts.auto.progress.updater.call(opts.auto.progress.bar[0], perc);
- }, opts.auto.progress.interval);
- }
- tmrs.auto = setTimeout(function() {
- if (opts.auto.progress)
- {
- opts.auto.progress.updater.call(opts.auto.progress.bar[0], 100);
- }
- if (opts.auto.onTimeoutEnd)
- {
- opts.auto.onTimeoutEnd.call($tt0, perc, dur2);
- }
- if (crsl.isScrolling)
- {
- $cfs.trigger(cf_e('play', conf), dir);
- }
- else
- {
- $cfs.trigger(cf_e(dir, conf), opts.auto);
- }
- }, dur2);
- // pause start callback
- if (opts.auto.onTimeoutStart)
- {
- opts.auto.onTimeoutStart.call($tt0, perc, dur2);
- }
- return true;
- });
- // resume event
- $cfs.bind(cf_e('resume', conf), function(e) {
- e.stopPropagation();
- if (scrl.isStopped)
- {
- scrl.isStopped = false;
- crsl.isPaused = false;
- crsl.isScrolling = true;
- scrl.startTime = getTime();
- sc_startScroll(scrl, conf);
- }
- else
- {
- $cfs.trigger(cf_e('play', conf));
- }
- return true;
- });
- // prev + next events
- $cfs.bind(cf_e('prev', conf)+' '+cf_e('next', conf), function(e, obj, num, clb, que) {
- e.stopPropagation();
- // stopped or hidden carousel, don't scroll, don't queue
- if (crsl.isStopped || $cfs.is(':hidden'))
- {
- e.stopImmediatePropagation();
- return debug(conf, 'Carousel stopped or hidden: Not scrolling.');
- }
- // not enough items
- var minimum = (is_number(opts.items.minimum)) ? opts.items.minimum : opts.items.visible + 1;
- if (minimum > itms.total)
- {
- e.stopImmediatePropagation();
- return debug(conf, 'Not enough items ('+itms.total+' total, '+minimum+' needed): Not scrolling.');
- }
- // get config
- var v = [obj, num, clb, que],
- t = ['object', 'number/string', 'function', 'boolean'],
- a = cf_sortParams(v, t);
- obj = a[0];
- num = a[1];
- clb = a[2];
- que = a[3];
- var eType = e.type.slice(conf.events.prefix.length);
- if (!is_object(obj))
- {
- obj = {};
- }
- if (is_function(clb))
- {
- obj.onAfter = clb;
- }
- if (is_boolean(que))
- {
- obj.queue = que;
- }
- obj = $.extend(true, {}, opts[eType], obj);
- // test conditions callback
- if (obj.conditions && !obj.conditions.call($tt0, eType))
- {
- e.stopImmediatePropagation();
- return debug(conf, 'Callback "conditions" returned false.');
- }
- if (!is_number(num))
- {
- if (opts.items.filter != '*')
- {
- num = 'visible';
- }
- else
- {
- var arr = [num, obj.items, opts[eType].items];
- for (var a = 0, l = arr.length; a < l; a++)
- {
- if (is_number(arr[a]) || arr[a] == 'page' || arr[a] == 'visible') {
- num = arr[a];
- break;
- }
- }
- }
- switch(num) {
- case 'page':
- e.stopImmediatePropagation();
- return $cfs.triggerHandler(cf_e(eType+'Page', conf), [obj, clb]);
- break;
- case 'visible':
- if (!opts.items.visibleConf.variable && opts.items.filter == '*')
- {
- num = opts.items.visible;
- }
- break;
- }
- }
- // resume animation, add current to queue
- if (scrl.isStopped)
- {
- $cfs.trigger(cf_e('resume', conf));
- $cfs.trigger(cf_e('queue', conf), [eType, [obj, num, clb]]);
- e.stopImmediatePropagation();
- return debug(conf, 'Carousel resumed scrolling.');
- }
- // queue if scrolling
- if (obj.duration > 0)
- {
- if (crsl.isScrolling)
- {
- if (obj.queue)
- {
- if (obj.queue == 'last')
- {
- queu = [];
- }
- if (obj.queue != 'first' || queu.length == 0)
- {
- $cfs.trigger(cf_e('queue', conf), [eType, [obj, num, clb]]);
- }
- }
- e.stopImmediatePropagation();
- return debug(conf, 'Carousel currently scrolling.');
- }
- }
- tmrs.timePassed = 0;
- $cfs.trigger(cf_e('slide_'+eType, conf), [obj, num]);
- // synchronise
- if (opts.synchronise)
- {
- var s = opts.synchronise,
- c = [obj, num];
- for (var j = 0, l = s.length; j < l; j++) {
- var d = eType;
- if (!s[j][2])
- {
- d = (d == 'prev') ? 'next' : 'prev';
- }
- if (!s[j][1])
- {
- c[0] = s[j][0].triggerHandler('_cfs_triggerEvent', ['configuration', d]);
- }
- c[1] = num + s[j][3];
- s[j][0].trigger('_cfs_triggerEvent', ['slide_'+d, c]);
- }
- }
- return true;
- });
- // prev event
- $cfs.bind(cf_e('slide_prev', conf), function(e, sO, nI) {
- e.stopPropagation();
- var a_itm = $cfs.children();
- // non-circular at start, scroll to end
- if (!opts.circular)
- {
- if (itms.first == 0)
- {
- if (opts.infinite)
- {
- $cfs.trigger(cf_e('next', conf), itms.total-1);
- }
- return e.stopImmediatePropagation();
- }
- }
- sz_resetMargin(a_itm, opts);
- // find number of items to scroll
- if (!is_number(nI))
- {
- if (opts.items.visibleConf.variable)
- {
- nI = gn_getVisibleItemsPrev(a_itm, opts, itms.total-1);
- }
- else if (opts.items.filter != '*')
- {
- var xI = (is_number(sO.items)) ? sO.items : gn_getVisibleOrg($cfs, opts);
- nI = gn_getScrollItemsPrevFilter(a_itm, opts, itms.total-1, xI);
- }
- else
- {
- nI = opts.items.visible;
- }
- nI = cf_getAdjust(nI, opts, sO.items, $tt0);
- }
- // prevent non-circular from scrolling to far
- if (!opts.circular)
- {
- if (itms.total - nI < itms.first)
- {
- nI = itms.total - itms.first;
- }
- }
- // set new number of visible items
- opts.items.visibleConf.old = opts.items.visible;
- if (opts.items.visibleConf.variable)
- {
- var vI = cf_getItemsAdjust(gn_getVisibleItemsNext(a_itm, opts, itms.total-nI), opts, opts.items.visibleConf.adjust, $tt0);
- if (opts.items.visible+nI <= vI && nI < itms.total)
- {
- nI++;
- vI = cf_getItemsAdjust(gn_getVisibleItemsNext(a_itm, opts, itms.total-nI), opts, opts.items.visibleConf.adjust, $tt0);
- }
- opts.items.visible = vI;
- }
- else if (opts.items.filter != '*')
- {
- var vI = gn_getVisibleItemsNextFilter(a_itm, opts, itms.total-nI);
- opts.items.visible = cf_getItemsAdjust(vI, opts, opts.items.visibleConf.adjust, $tt0);
- }
- sz_resetMargin(a_itm, opts, true);
- // scroll 0, don't scroll
- if (nI == 0)
- {
- e.stopImmediatePropagation();
- return debug(conf, '0 items to scroll: Not scrolling.');
- }
- debug(conf, 'Scrolling '+nI+' items backward.');
- // save new config
- itms.first += nI;
- while (itms.first >= itms.total)
- {
- itms.first -= itms.total;
- }
- // non-circular callback
- if (!opts.circular)
- {
- if (itms.first == 0 && sO.onEnd)
- {
- sO.onEnd.call($tt0, 'prev');
- }
- if (!opts.infinite)
- {
- nv_enableNavi(opts, itms.first, conf);
- }
- }
- // rearrange items
- $cfs.children().slice(itms.total-nI, itms.total).prependTo($cfs);
- if (itms.total < opts.items.visible + nI)
- {
- $cfs.children().slice(0, (opts.items.visible+nI)-itms.total).clone(true).appendTo($cfs);
- }
- // the needed items
- var a_itm = $cfs.children(),
- i_old = gi_getOldItemsPrev(a_itm, opts, nI),
- i_new = gi_getNewItemsPrev(a_itm, opts),
- i_cur_l = a_itm.eq(nI-1),
- i_old_l = i_old.last(),
- i_new_l = i_new.last();
- sz_resetMargin(a_itm, opts);
- var pL = 0,
- pR = 0;
- if (opts.align)
- {
- var p = cf_getAlignPadding(i_new, opts);
- pL = p[0];
- pR = p[1];
- }
- var oL = (pL < 0) ? opts.padding[opts.d[3]] : 0;
- // hide items for fx directscroll
- var hiddenitems = false,
- i_skp = $();
- if (opts.items.visible < nI)
- {
- i_skp = a_itm.slice(opts.items.visibleConf.old, nI);
- if (sO.fx == 'directscroll')
- {
- var orgW = opts.items[opts.d['width']];
- hiddenitems = i_skp;
- i_cur_l = i_new_l;
- sc_hideHiddenItems(hiddenitems);
- opts.items[opts.d['width']] = 'variable';
- }
- }
- // save new sizes
- var $cf2 = false,
- i_siz = ms_getTotalSize(a_itm.slice(0, nI), opts, 'width'),
- w_siz = cf_mapWrapperSizes(ms_getSizes(i_new, opts, true), opts, !opts.usePadding),
- i_siz_vis = 0,
- a_cfs = {},
- a_wsz = {},
- a_cur = {},
- a_old = {},
- a_new = {},
- a_lef = {},
- a_lef_vis = {},
- a_dur = sc_getDuration(sO, opts, nI, i_siz);
- switch(sO.fx)
- {
- case 'cover':
- case 'cover-fade':
- i_siz_vis = ms_getTotalSize(a_itm.slice(0, opts.items.visible), opts, 'width');
- break;
- }
- if (hiddenitems)
- {
- opts.items[opts.d['width']] = orgW;
- }
- sz_resetMargin(a_itm, opts, true);
- if (pR >= 0)
- {
- sz_resetMargin(i_old_l, opts, opts.padding[opts.d[1]]);
- }
- if (pL >= 0)
- {
- sz_resetMargin(i_cur_l, opts, opts.padding[opts.d[3]]);
- }
- if (opts.align)
- {
- opts.padding[opts.d[1]] = pR;
- opts.padding[opts.d[3]] = pL;
- }
- a_lef[opts.d['left']] = -(i_siz - oL);
- a_lef_vis[opts.d['left']] = -(i_siz_vis - oL);
- a_wsz[opts.d['left']] = w_siz[opts.d['width']];
- // scrolling functions
- var _s_wrapper = function() {},
- _a_wrapper = function() {},
- _s_paddingold = function() {},
- _a_paddingold = function() {},
- _s_paddingnew = function() {},
- _a_paddingnew = function() {},
- _s_paddingcur = function() {},
- _a_paddingcur = function() {},
- _onafter = function() {},
- _moveitems = function() {},
- _position = function() {};
- // clone carousel
- switch(sO.fx)
- {
- case 'crossfade':
- case 'cover':
- case 'cover-fade':
- case 'uncover':
- case 'uncover-fade':
- $cf2 = $cfs.clone(true).appendTo($wrp);
- break;
- }
- switch(sO.fx)
- {
- case 'crossfade':
- case 'uncover':
- case 'uncover-fade':
- $cf2.children().slice(0, nI).remove();
- $cf2.children().slice(opts.items.visibleConf.old).remove();
- break;
- case 'cover':
- case 'cover-fade':
- $cf2.children().slice(opts.items.visible).remove();
- $cf2.css(a_lef_vis);
- break;
- }
- $cfs.css(a_lef);
- // reset all scrolls
- scrl = sc_setScroll(a_dur, sO.easing, conf);
- // animate / set carousel
- a_cfs[opts.d['left']] = (opts.usePadding) ? opts.padding[opts.d[3]] : 0;
- // animate / set wrapper
- if (opts[opts.d['width']] == 'variable' || opts[opts.d['height']] == 'variable')
- {
- _s_wrapper = function() {
- $wrp.css(w_siz);
- };
- _a_wrapper = function() {
- scrl.anims.push([$wrp, w_siz]);
- };
- }
- // animate / set items
- if (opts.usePadding)
- {
- if (i_new_l.not(i_cur_l).length)
- {
- a_cur[opts.d['marginRight']] = i_cur_l.data('_cfs_origCssMargin');
- if (pL < 0)
- {
- i_cur_l.css(a_cur);
- }
- else
- {
- _s_paddingcur = function() {
- i_cur_l.css(a_cur);
- };
- _a_paddingcur = function() {
- scrl.anims.push([i_cur_l, a_cur]);
- };
- }
- }
- switch(sO.fx)
- {
- case 'cover':
- case 'cover-fade':
- $cf2.children().eq(nI-1).css(a_cur);
- break;
- }
- if (i_new_l.not(i_old_l).length)
- {
- a_old[opts.d['marginRight']] = i_old_l.data('_cfs_origCssMargin');
- _s_paddingold = function() {
- i_old_l.css(a_old);
- };
- _a_paddingold = function() {
- scrl.anims.push([i_old_l, a_old]);
- };
- }
- if (pR >= 0)
- {
- a_new[opts.d['marginRight']] = i_new_l.data('_cfs_origCssMargin') + opts.padding[opts.d[1]];
- _s_paddingnew = function() {
- i_new_l.css(a_new);
- };
- _a_paddingnew = function() {
- scrl.anims.push([i_new_l, a_new]);
- };
- }
- }
- // set position
- _position = function() {
- $cfs.css(a_cfs);
- };
- var overFill = opts.items.visible+nI-itms.total;
- // rearrange items
- _moveitems = function() {
- if (overFill > 0)
- {
- $cfs.children().slice(itms.total).remove();
- i_old = $( $cfs.children().slice(itms.total-(opts.items.visible-overFill)).get().concat( $cfs.children().slice(0, overFill).get() ) );
- }
- sc_showHiddenItems(hiddenitems);
- if (opts.usePadding)
- {
- var l_itm = $cfs.children().eq(opts.items.visible+nI-1);
- l_itm.css(opts.d['marginRight'], l_itm.data('_cfs_origCssMargin'));
- }
- };
- var cb_arguments = sc_mapCallbackArguments(i_old, i_skp, i_new, nI, 'prev', a_dur, w_siz);
- // fire onAfter callbacks
- _onafter = function() {
- sc_afterScroll($cfs, $cf2, sO);
- crsl.isScrolling = false;
- clbk.onAfter = sc_fireCallbacks($tt0, sO, 'onAfter', cb_arguments, clbk);
- queu = sc_fireQueue($cfs, queu, conf);
- if (!crsl.isPaused)
- {
- $cfs.trigger(cf_e('play', conf));
- }
- };
- // fire onBefore callback
- crsl.isScrolling = true;
- tmrs = sc_clearTimers(tmrs);
- clbk.onBefore = sc_fireCallbacks($tt0, sO, 'onBefore', cb_arguments, clbk);
- switch(sO.fx)
- {
- case 'none':
- $cfs.css(a_cfs);
- _s_wrapper();
- _s_paddingold();
- _s_paddingnew();
- _s_paddingcur();
- _position();
- _moveitems();
- _onafter();
- break;
- case 'fade':
- scrl.anims.push([$cfs, { 'opacity': 0 }, function() {
- _s_wrapper();
- _s_paddingold();
- _s_paddingnew();
- _s_paddingcur();
- _position();
- _moveitems();
- scrl = sc_setScroll(a_dur, sO.easing, conf);
- scrl.anims.push([$cfs, { 'opacity': 1 }, _onafter]);
- sc_startScroll(scrl, conf);
- }]);
- break;
- case 'crossfade':
- $cfs.css({ 'opacity': 0 });
- scrl.anims.push([$cf2, { 'opacity': 0 }]);
- scrl.anims.push([$cfs, { 'opacity': 1 }, _onafter]);
- _a_wrapper();
- _s_paddingold();
- _s_paddingnew();
- _s_paddingcur();
- _position();
- _moveitems();
- break;
- case 'cover':
- scrl.anims.push([$cf2, a_cfs, function() {
- _s_paddingold();
- _s_paddingnew();
- _s_paddingcur();
- _position();
- _moveitems();
- _onafter();
- }]);
- _a_wrapper();
- break;
- case 'cover-fade':
- scrl.anims.push([$cfs, { 'opacity': 0 }]);
- scrl.anims.push([$cf2, a_cfs, function() {
- _s_paddingold();
- _s_paddingnew();
- _s_paddingcur();
- _position();
- _moveitems();
- _onafter();
- }]);
- _a_wrapper();
- break;
- case 'uncover':
- scrl.anims.push([$cf2, a_wsz, _onafter]);
- _a_wrapper();
- _s_paddingold();
- _s_paddingnew();
- _s_paddingcur();
- _position();
- _moveitems();
- break;
- case 'uncover-fade':
- $cfs.css({ 'opacity': 0 });
- scrl.anims.push([$cfs, { 'opacity': 1 }]);
- scrl.anims.push([$cf2, a_wsz, _onafter]);
- _a_wrapper();
- _s_paddingold();
- _s_paddingnew();
- _s_paddingcur();
- _position();
- _moveitems();
- break;
- default:
- scrl.anims.push([$cfs, a_cfs, function() {
- _moveitems();
- _onafter();
- }]);
- _a_wrapper();
- _a_paddingold();
- _a_paddingnew();
- _a_paddingcur();
- break;
- }
- sc_startScroll(scrl, conf);
- cf_setCookie(opts.cookie, $cfs, conf);
- $cfs.trigger(cf_e('updatePageStatus', conf), [false, w_siz]);
- return true;
- });
- // next event
- $cfs.bind(cf_e('slide_next', conf), function(e, sO, nI) {
- e.stopPropagation();
- var a_itm = $cfs.children();
- // non-circular at end, scroll to start
- if (!opts.circular)
- {
- if (itms.first == opts.items.visible)
- {
- if (opts.infinite)
- {
- $cfs.trigger(cf_e('prev', conf), itms.total-1);
- }
- return e.stopImmediatePropagation();
- }
- }
- sz_resetMargin(a_itm, opts);
- // find number of items to scroll
- if (!is_number(nI))
- {
- if (opts.items.filter != '*')
- {
- var xI = (is_number(sO.items)) ? sO.items : gn_getVisibleOrg($cfs, opts);
- nI = gn_getScrollItemsNextFilter(a_itm, opts, 0, xI);
- }
- else
- {
- nI = opts.items.visible;
- }
- nI = cf_getAdjust(nI, opts, sO.items, $tt0);
- }
- var lastItemNr = (itms.first == 0) ? itms.total : itms.first;
- // prevent non-circular from scrolling to far
- if (!opts.circular)
- {
- if (opts.items.visibleConf.variable)
- {
- var vI = gn_getVisibleItemsNext(a_itm, opts, nI),
- xI = gn_getVisibleItemsPrev(a_itm, opts, lastItemNr-1);
- }
- else
- {
- var vI = opts.items.visible,
- xI = opts.items.visible;
- }
- if (nI + vI > lastItemNr)
- {
- nI = lastItemNr - xI;
- }
- }
- // set new number of visible items
- opts.items.visibleConf.old = opts.items.visible;
- if (opts.items.visibleConf.variable)
- {
- var vI = cf_getItemsAdjust(gn_getVisibleItemsNextTestCircular(a_itm, opts, nI, lastItemNr), opts, opts.items.visibleConf.adjust, $tt0);
- while (opts.items.visible-nI >= vI && nI < itms.total)
- {
- nI++;
- vI = cf_getItemsAdjust(gn_getVisibleItemsNextTestCircular(a_itm, opts, nI, lastItemNr), opts, opts.items.visibleConf.adjust, $tt0);
- }
- opts.items.visible = vI;
- }
- else if (opts.items.filter != '*')
- {
- var vI = gn_getVisibleItemsNextFilter(a_itm, opts, nI);
- opts.items.visible = cf_getItemsAdjust(vI, opts, opts.items.visibleConf.adjust, $tt0);
- }
- sz_resetMargin(a_itm, opts, true);
- // scroll 0, don't scroll
- if (nI == 0)
- {
- e.stopImmediatePropagation();
- return debug(conf, '0 items to scroll: Not scrolling.');
- }
- debug(conf, 'Scrolling '+nI+' items forward.');
- // save new config
- itms.first -= nI;
- while (itms.first < 0)
- {
- itms.first += itms.total;
- }
- // non-circular callback
- if (!opts.circular)
- {
- if (itms.first == opts.items.visible && sO.onEnd)
- {
- sO.onEnd.call($tt0, 'next');
- }
- if (!opts.infinite)
- {
- nv_enableNavi(opts, itms.first, conf);
- }
- }
- // rearrange items
- if (itms.total < opts.items.visible+nI)
- {
- $cfs.children().slice(0, (opts.items.visible+nI)-itms.total).clone(true).appendTo($cfs);
- }
- // the needed items
- var a_itm = $cfs.children(),
- i_old = gi_getOldItemsNext(a_itm, opts),
- i_new = gi_getNewItemsNext(a_itm, opts, nI),
- i_cur_l = a_itm.eq(nI-1),
- i_old_l = i_old.last(),
- i_new_l = i_new.last();
- sz_resetMargin(a_itm, opts);
- var pL = 0,
- pR = 0;
- if (opts.align)
- {
- var p = cf_getAlignPadding(i_new, opts);
- pL = p[0];
- pR = p[1];
- }
- // hide items for fx directscroll
- var hiddenitems = false,
- i_skp = $();
- if (opts.items.visibleConf.old < nI)
- {
- i_skp = a_itm.slice(opts.items.visibleConf.old, nI);
- if (sO.fx == 'directscroll')
- {
- var orgW = opts.items[opts.d['width']];
- hiddenitems = i_skp;
- i_cur_l = i_old_l;
- sc_hideHiddenItems(hiddenitems);
- opts.items[opts.d['width']] = 'variable';
- }
- }
- // save new sizes
- var $cf2 = false,
- i_siz = ms_getTotalSize(a_itm.slice(0, nI), opts, 'width'),
- w_siz = cf_mapWrapperSizes(ms_getSizes(i_new, opts, true), opts, !opts.usePadding),
- i_siz_vis = 0,
- a_cfs = {},
- a_cfs_vis = {},
- a_cur = {},
- a_old = {},
- a_lef = {},
- a_dur = sc_getDuration(sO, opts, nI, i_siz);
- switch(sO.fx)
- {
- case 'uncover':
- case 'uncover-fade':
- i_siz_vis = ms_getTotalSize(a_itm.slice(0, opts.items.visibleConf.old), opts, 'width');
- break;
- }
- if (hiddenitems)
- {
- opts.items[opts.d['width']] = orgW;
- }
- if (opts.align)
- {
- if (opts.padding[opts.d[1]] < 0)
- {
- opts.padding[opts.d[1]] = 0;
- }
- }
- sz_resetMargin(a_itm, opts, true);
- sz_resetMargin(i_old_l, opts, opts.padding[opts.d[1]]);
- if (opts.align)
- {
- opts.padding[opts.d[1]] = pR;
- opts.padding[opts.d[3]] = pL;
- }
- a_lef[opts.d['left']] = (opts.usePadding) ? opts.padding[opts.d[3]] : 0;
- // scrolling functions
- var _s_wrapper = function() {},
- _a_wrapper = function() {},
- _s_paddingold = function() {},
- _a_paddingold = function() {},
- _s_paddingcur = function() {},
- _a_paddingcur = function() {},
- _onafter = function() {},
- _moveitems = function() {},
- _position = function() {};
- // clone carousel
- switch(sO.fx)
- {
- case 'crossfade':
- case 'cover':
- case 'cover-fade':
- case 'uncover':
- case 'uncover-fade':
- $cf2 = $cfs.clone(true).appendTo($wrp);
- $cf2.children().slice(opts.items.visibleConf.old).remove();
- break;
- }
- switch(sO.fx)
- {
- case 'crossfade':
- case 'cover':
- case 'cover-fade':
- $cfs.css('zIndex', 1);
- $cf2.css('zIndex', 0);
- break;
- }
- // reset all scrolls
- scrl = sc_setScroll(a_dur, sO.easing, conf);
- // animate / set carousel
- a_cfs[opts.d['left']] = -i_siz;
- a_cfs_vis[opts.d['left']] = -i_siz_vis;
- if (pL < 0)
- {
- a_cfs[opts.d['left']] += pL;
- }
- // animate / set wrapper
- if (opts[opts.d['width']] == 'variable' || opts[opts.d['height']] == 'variable')
- {
- _s_wrapper = function() {
- $wrp.css(w_siz);
- };
- _a_wrapper = function() {
- scrl.anims.push([$wrp, w_siz]);
- };
- }
- // animate / set items
- if (opts.usePadding)
- {
- var i_new_l_m = i_new_l.data('_cfs_origCssMargin');
- if (pR >= 0)
- {
- i_new_l_m += opts.padding[opts.d[1]];
- }
- i_new_l.css(opts.d['marginRight'], i_new_l_m);
- if (i_cur_l.not(i_old_l).length)
- {
- a_old[opts.d['marginRight']] = i_old_l.data('_cfs_origCssMargin');
- }
- _s_paddingold = function() {
- i_old_l.css(a_old);
- };
- _a_paddingold = function() {
- scrl.anims.push([i_old_l, a_old]);
- };
- var i_cur_l_m = i_cur_l.data('_cfs_origCssMargin');
- if (pL > 0)
- {
- i_cur_l_m += opts.padding[opts.d[3]];
- }
- a_cur[opts.d['marginRight']] = i_cur_l_m;
- _s_paddingcur = function() {
- i_cur_l.css(a_cur);
- };
- _a_paddingcur = function() {
- scrl.anims.push([i_cur_l, a_cur]);
- };
- }
- // set position
- _position = function() {
- $cfs.css(a_lef);
- };
- var overFill = opts.items.visible+nI-itms.total;
- // rearrange items
- _moveitems = function() {
- if (overFill > 0)
- {
- $cfs.children().slice(itms.total).remove();
- }
- var l_itm = $cfs.children().slice(0, nI).appendTo($cfs).last();
- if (overFill > 0)
- {
- i_new = gi_getCurrentItems(a_itm, opts);
- }
- sc_showHiddenItems(hiddenitems);
- if (opts.usePadding)
- {
- if (itms.total < opts.items.visible+nI) {
- var i_cur_l = $cfs.children().eq(opts.items.visible-1);
- i_cur_l.css(opts.d['marginRight'], i_cur_l.data('_cfs_origCssMargin') + opts.padding[opts.d[1]]);
- }
- l_itm.css(opts.d['marginRight'], l_itm.data('_cfs_origCssMargin'));
- }
- };
- var cb_arguments = sc_mapCallbackArguments(i_old, i_skp, i_new, nI, 'next', a_dur, w_siz);
- // fire onAfter callbacks
- _onafter = function() {
- $cfs.css('zIndex', $cfs.data('_cfs_origCssZindex'));
- sc_afterScroll($cfs, $cf2, sO);
- crsl.isScrolling = false;
- clbk.onAfter = sc_fireCallbacks($tt0, sO, 'onAfter', cb_arguments, clbk);
- queu = sc_fireQueue($cfs, queu, conf);
-
- if (!crsl.isPaused)
- {
- $cfs.trigger(cf_e('play', conf));
- }
- };
- // fire onBefore callbacks
- crsl.isScrolling = true;
- tmrs = sc_clearTimers(tmrs);
- clbk.onBefore = sc_fireCallbacks($tt0, sO, 'onBefore', cb_arguments, clbk);
- switch(sO.fx)
- {
- case 'none':
- $cfs.css(a_cfs);
- _s_wrapper();
- _s_paddingold();
- _s_paddingcur();
- _position();
- _moveitems();
- _onafter();
- break;
- case 'fade':
- scrl.anims.push([$cfs, { 'opacity': 0 }, function() {
- _s_wrapper();
- _s_paddingold();
- _s_paddingcur();
- _position();
- _moveitems();
- scrl = sc_setScroll(a_dur, sO.easing, conf);
- scrl.anims.push([$cfs, { 'opacity': 1 }, _onafter]);
- sc_startScroll(scrl, conf);
- }]);
- break;
- case 'crossfade':
- $cfs.css({ 'opacity': 0 });
- scrl.anims.push([$cf2, { 'opacity': 0 }]);
- scrl.anims.push([$cfs, { 'opacity': 1 }, _onafter]);
- _a_wrapper();
- _s_paddingold();
- _s_paddingcur();
- _position();
- _moveitems();
- break;
- case 'cover':
- $cfs.css(opts.d['left'], $wrp[opts.d['width']]());
- scrl.anims.push([$cfs, a_lef, _onafter]);
- _a_wrapper();
- _s_paddingold();
- _s_paddingcur();
- _moveitems();
- break;
- case 'cover-fade':
- $cfs.css(opts.d['left'], $wrp[opts.d['width']]());
- scrl.anims.push([$cf2, { 'opacity': 0 }]);
- scrl.anims.push([$cfs, a_lef, _onafter]);
- _a_wrapper();
- _s_paddingold();
- _s_paddingcur();
- _moveitems();
- break;
- case 'uncover':
- scrl.anims.push([$cf2, a_cfs_vis, _onafter]);
- _a_wrapper();
- _s_paddingold();
- _s_paddingcur();
- _position();
- _moveitems();
- break;
- case 'uncover-fade':
- $cfs.css({ 'opacity': 0 });
- scrl.anims.push([$cfs, { 'opacity': 1 }]);
- scrl.anims.push([$cf2, a_cfs_vis, _onafter]);
- _a_wrapper();
- _s_paddingold();
- _s_paddingcur();
- _position();
- _moveitems();
- break;
- default:
- scrl.anims.push([$cfs, a_cfs, function() {
- _position();
- _moveitems();
- _onafter();
- }]);
- _a_wrapper();
- _a_paddingold();
- _a_paddingcur();
- break;
- }
- sc_startScroll(scrl, conf);
- cf_setCookie(opts.cookie, $cfs, conf);
- $cfs.trigger(cf_e('updatePageStatus', conf), [false, w_siz]);
- return true;
- });
- // slideTo event
- $cfs.bind(cf_e('slideTo', conf), function(e, num, dev, org, obj, dir, clb) {
- e.stopPropagation();
- var v = [num, dev, org, obj, dir, clb],
- t = ['string/number/object', 'number', 'boolean', 'object', 'string', 'function'],
- a = cf_sortParams(v, t);
- obj = a[3];
- dir = a[4];
- clb = a[5];
- num = gn_getItemIndex(a[0], a[1], a[2], itms, $cfs);
- if (num == 0)
- {
- return false;
- }
- if (!is_object(obj))
- {
- obj = false;
- }
- if (dir != 'prev' && dir != 'next')
- {
- if (opts.circular)
- {
- dir = (num <= itms.total / 2) ? 'next' : 'prev';
- }
- else
- {
- dir = (itms.first == 0 || itms.first > num) ? 'next' : 'prev';
- }
- }
- if (dir == 'prev')
- {
- num = itms.total-num;
- }
- $cfs.trigger(cf_e(dir, conf), [obj, num, clb]);
- return true;
- });
- // prevPage event
- $cfs.bind(cf_e('prevPage', conf), function(e, obj, clb) {
- e.stopPropagation();
- var cur = $cfs.triggerHandler(cf_e('currentPage', conf));
- return $cfs.triggerHandler(cf_e('slideToPage', conf), [cur-1, obj, 'prev', clb]);
- });
- // nextPage event
- $cfs.bind(cf_e('nextPage', conf), function(e, obj, clb) {
- e.stopPropagation();
- var cur = $cfs.triggerHandler(cf_e('currentPage', conf));
- return $cfs.triggerHandler(cf_e('slideToPage', conf), [cur+1, obj, 'next', clb]);
- });
- // slideToPage event
- $cfs.bind(cf_e('slideToPage', conf), function(e, pag, obj, dir, clb) {
- e.stopPropagation();
- if (!is_number(pag))
- {
- pag = $cfs.triggerHandler(cf_e('currentPage', conf));
- }
- var ipp = opts.pagination.items || opts.items.visible,
- max = Math.ceil(itms.total / ipp)-1;
- if (pag < 0)
- {
- pag = max;
- }
- if (pag > max)
- {
- pag = 0;
- }
- return $cfs.triggerHandler(cf_e('slideTo', conf), [pag*ipp, 0, true, obj, dir, clb]);
- });
- // jumpToStart event
- $cfs.bind(cf_e('jumpToStart', conf), function(e, s) {
- e.stopPropagation();
- if (s)
- {
- s = gn_getItemIndex(s, 0, true, itms, $cfs);
- }
- else
- {
- s = 0;
- }
- s += itms.first;
- if (s != 0)
- {
- if (itms.total > 0)
- {
- while (s > itms.total)
- {
- s -= itms.total;
- }
- }
- $cfs.prepend($cfs.children().slice(s, itms.total));
- }
- return true;
- });
- // synchronise event
- $cfs.bind(cf_e('synchronise', conf), function(e, s) {
- e.stopPropagation();
- if (s)
- {
- s = cf_getSynchArr(s);
- }
- else if (opts.synchronise)
- {
- s = opts.synchronise;
- }
- else
- {
- return debug(conf, 'No carousel to synchronise.');
- }
- var n = $cfs.triggerHandler(cf_e('currentPosition', conf)),
- x = true;
- for (var j = 0, l = s.length; j < l; j++)
- {
- if (!s[j][0].triggerHandler(cf_e('slideTo', conf), [n, s[j][3], true]))
- {
- x = false;
- }
- }
- return x;
- });
- // queue event
- $cfs.bind(cf_e('queue', conf), function(e, dir, opt) {
- e.stopPropagation();
- if (is_function(dir))
- {
- dir.call($tt0, queu);
- }
- else if (is_array(dir))
- {
- queu = dir;
- }
- else if (!is_undefined(dir))
- {
- queu.push([dir, opt]);
- }
- return queu;
- });
- // insertItem event
- $cfs.bind(cf_e('insertItem', conf), function(e, itm, num, org, dev) {
- e.stopPropagation();
- var v = [itm, num, org, dev],
- t = ['string/object', 'string/number/object', 'boolean', 'number'],
- a = cf_sortParams(v, t);
- itm = a[0];
- num = a[1];
- org = a[2];
- dev = a[3];
- if (is_object(itm) && !is_jquery(itm))
- {
- itm = $(itm);
- }
- else if (is_string(itm))
- {
- itm = $(itm);
- }
- if (!is_jquery(itm) || itm.length == 0)
- {
- return debug(conf, 'Not a valid object.');
- }
- if (is_undefined(num))
- {
- num = 'end';
- }
- sz_storeMargin(itm, opts);
- sz_storeOrigCss(itm);
- var orgNum = num,
- before = 'before';
- if (num == 'end')
- {
- if (org)
- {
- if (itms.first == 0)
- {
- num = itms.total-1;
- before = 'after';
- }
- else
- {
- num = itms.first;
- itms.first += itm.length;
- }
- if (num < 0)
- {
- num = 0;
- }
- }
- else
- {
- num = itms.total-1;
- before = 'after';
- }
- }
- else
- {
- num = gn_getItemIndex(num, dev, org, itms, $cfs);
- }
- var $cit = $cfs.children().eq(num);
- if ($cit.length)
- {
- $cit[before](itm);
- }
- else
- {
- debug(conf, 'Correct insert-position not found! Appending item to the end.');
- $cfs.append(itm);
- }
- if (orgNum != 'end' && !org)
- {
- if (num < itms.first)
- {
- itms.first += itm.length;
- }
- }
- itms.total = $cfs.children().length;
- if (itms.first >= itms.total)
- {
- itms.first -= itms.total;
- }
- $cfs.trigger(cf_e('updateSizes', conf));
- $cfs.trigger(cf_e('linkAnchors', conf));
- return true;
- });
- // removeItem event
- $cfs.bind(cf_e('removeItem', conf), function(e, num, org, dev) {
- e.stopPropagation();
- var v = [num, org, dev],
- t = ['string/number/object', 'boolean', 'number'],
- a = cf_sortParams(v, t);
- num = a[0];
- org = a[1];
- dev = a[2];
- var removed = false;
- if (num instanceof $ && num.length > 1)
- {
- $removed = $();
- num.each(function(i, el) {
- var $rem = $cfs.trigger(cf_e('removeItem', conf), [$(this), org, dev]);
- if ( $rem )
- {
- $removed = $removed.add($rem);
- }
- });
- return $removed;
- }
- if (is_undefined(num) || num == 'end')
- {
- $removed = $cfs.children().last();
- }
- else
- {
- num = gn_getItemIndex(num, dev, org, itms, $cfs);
- var $removed = $cfs.children().eq(num);
- if ( $removed.length )
- {
- if (num < itms.first)
- {
- itms.first -= $removed.length;
- }
- }
- }
- if ( $removed && $removed.length )
- {
- $removed.detach();
- itms.total = $cfs.children().length;
- $cfs.trigger(cf_e('updateSizes', conf));
- }
- return $removed;
- });
- // onBefore and onAfter event
- $cfs.bind(cf_e('onBefore', conf)+' '+cf_e('onAfter', conf), function(e, fn) {
- e.stopPropagation();
- var eType = e.type.slice(conf.events.prefix.length);
- if (is_array(fn))
- {
- clbk[eType] = fn;
- }
- if (is_function(fn))
- {
- clbk[eType].push(fn);
- }
- return clbk[eType];
- });
- // currentPosition event
- $cfs.bind(cf_e('currentPosition', conf), function(e, fn) {
- e.stopPropagation();
- if (itms.first == 0)
- {
- var val = 0;
- }
- else
- {
- var val = itms.total - itms.first;
- }
- if (is_function(fn))
- {
- fn.call($tt0, val);
- }
- return val;
- });
- // currentPage event
- $cfs.bind(cf_e('currentPage', conf), function(e, fn) {
- e.stopPropagation();
- var ipp = opts.pagination.items || opts.items.visible,
- max = Math.ceil(itms.total/ipp-1),
- nr;
- if (itms.first == 0)
- {
- nr = 0;
- }
- else if (itms.first < itms.total % ipp)
- {
- nr = 0;
- }
- else if (itms.first == ipp && !opts.circular)
- {
- nr = max;
- }
- else
- {
- nr = Math.round((itms.total-itms.first)/ipp);
- }
- if (nr < 0)
- {
- nr = 0;
- }
- if (nr > max)
- {
- nr = max;
- }
- if (is_function(fn))
- {
- fn.call($tt0, nr);
- }
- return nr;
- });
- // currentVisible event
- $cfs.bind(cf_e('currentVisible', conf), function(e, fn) {
- e.stopPropagation();
- var $i = gi_getCurrentItems($cfs.children(), opts);
- if (is_function(fn))
- {
- fn.call($tt0, $i);
- }
- return $i;
- });
- // slice event
- $cfs.bind(cf_e('slice', conf), function(e, f, l, fn) {
- e.stopPropagation();
- if (itms.total == 0)
- {
- return false;
- }
- var v = [f, l, fn],
- t = ['number', 'number', 'function'],
- a = cf_sortParams(v, t);
- f = (is_number(a[0])) ? a[0] : 0;
- l = (is_number(a[1])) ? a[1] : itms.total;
- fn = a[2];
- f += itms.first;
- l += itms.first;
- if (items.total > 0)
- {
- while (f > itms.total)
- {
- f -= itms.total;
- }
- while (l > itms.total)
- {
- l -= itms.total;
- }
- while (f < 0)
- {
- f += itms.total;
- }
- while (l < 0)
- {
- l += itms.total;
- }
- }
- var $iA = $cfs.children(),
- $i;
- if (l > f)
- {
- $i = $iA.slice(f, l);
- }
- else
- {
- $i = $( $iA.slice(f, itms.total).get().concat( $iA.slice(0, l).get() ) );
- }
- if (is_function(fn))
- {
- fn.call($tt0, $i);
- }
- return $i;
- });
- // isPaused, isStopped and isScrolling events
- $cfs.bind(cf_e('isPaused', conf)+' '+cf_e('isStopped', conf)+' '+cf_e('isScrolling', conf), function(e, fn) {
- e.stopPropagation();
- var eType = e.type.slice(conf.events.prefix.length),
- value = crsl[eType];
- if (is_function(fn))
- {
- fn.call($tt0, value);
- }
- return value;
- });
- // configuration event
- $cfs.bind(cf_e('configuration', conf), function(e, a, b, c) {
- e.stopPropagation();
- var reInit = false;
- // return entire configuration-object
- if (is_function(a))
- {
- a.call($tt0, opts);
- }
- // set multiple options via object
- else if (is_object(a))
- {
- opts_orig = $.extend(true, {}, opts_orig, a);
- if (b !== false) reInit = true;
- else opts = $.extend(true, {}, opts, a);
- }
- else if (!is_undefined(a))
- {
- // callback function for specific option
- if (is_function(b))
- {
- var val = eval('opts.'+a);
- if (is_undefined(val))
- {
- val = '';
- }
- b.call($tt0, val);
- }
- // set individual option
- else if (!is_undefined(b))
- {
- if (typeof c !== 'boolean') c = true;
- eval('opts_orig.'+a+' = b');
- if (c !== false) reInit = true;
- else eval('opts.'+a+' = b');
- }
- // return value for specific option
- else
- {
- return eval('opts.'+a);
- }
- }
- if (reInit)
- {
- sz_resetMargin($cfs.children(), opts);
- FN._init(opts_orig);
- FN._bind_buttons();
- var sz = sz_setSizes($cfs, opts);
- $cfs.trigger(cf_e('updatePageStatus', conf), [true, sz]);
- }
- return opts;
- });
- // linkAnchors event
- $cfs.bind(cf_e('linkAnchors', conf), function(e, $con, sel) {
- e.stopPropagation();
- if (is_undefined($con))
- {
- $con = $('body');
- }
- else if (is_string($con))
- {
- $con = $($con);
- }
- if (!is_jquery($con) || $con.length == 0)
- {
- return debug(conf, 'Not a valid object.');
- }
- if (!is_string(sel))
- {
- sel = 'a.caroufredsel';
- }
- $con.find(sel).each(function() {
- var h = this.hash || '';
- if (h.length > 0 && $cfs.children().index($(h)) != -1)
- {
- $(this).unbind('click').click(function(e) {
- e.preventDefault();
- $cfs.trigger(cf_e('slideTo', conf), h);
- });
- }
- });
- return true;
- });
- // updatePageStatus event
- $cfs.bind(cf_e('updatePageStatus', conf), function(e, build, sizes) {
- e.stopPropagation();
- if (!opts.pagination.container)
- {
- return;
- }
- var ipp = opts.pagination.items || opts.items.visible,
- pgs = Math.ceil(itms.total/ipp);
- if (build)
- {
- if (opts.pagination.anchorBuilder)
- {
- opts.pagination.container.children().remove();
- opts.pagination.container.each(function() {
- for (var a = 0; a < pgs; a++)
- {
- var i = $cfs.children().eq( gn_getItemIndex(a*ipp, 0, true, itms, $cfs) );
- $(this).append(opts.pagination.anchorBuilder.call(i[0], a+1));
- }
- });
- }
- opts.pagination.container.each(function() {
- $(this).children().unbind(opts.pagination.event).each(function(a) {
- $(this).bind(opts.pagination.event, function(e) {
- e.preventDefault();
- $cfs.trigger(cf_e('slideTo', conf), [a*ipp, -opts.pagination.deviation, true, opts.pagination]);
- });
- });
- });
- }
- var selected = $cfs.triggerHandler(cf_e('currentPage', conf)) + opts.pagination.deviation;
- if (selected >= pgs)
- {
- selected = 0;
- }
- if (selected < 0)
- {
- selected = pgs-1;
- }
- opts.pagination.container.each(function() {
- $(this).children().removeClass(cf_c('selected', conf)).eq(selected).addClass(cf_c('selected', conf));
- });
- return true;
- });
- // updateSizes event
- $cfs.bind(cf_e('updateSizes', conf), function(e) {
- var vI = opts.items.visible,
- a_itm = $cfs.children(),
- avail_primary = ms_getParentSize($wrp, opts, 'width');
- itms.total = a_itm.length;
- if (crsl.primarySizePercentage)
- {
- opts.maxDimension = avail_primary;
- opts[opts.d['width']] = ms_getPercentage(avail_primary, crsl.primarySizePercentage);
- }
- else
- {
- opts.maxDimension = ms_getMaxDimension(opts, avail_primary);
- }
- if (opts.responsive)
- {
- opts.items.width = opts.items.sizesConf.width;
- opts.items.height = opts.items.sizesConf.height;
- opts = in_getResponsiveValues(opts, a_itm, avail_primary);
- vI = opts.items.visible;
- sz_setResponsiveSizes(opts, a_itm);
- }
- else if (opts.items.visibleConf.variable)
- {
- vI = gn_getVisibleItemsNext(a_itm, opts, 0);
- }
- else if (opts.items.filter != '*')
- {
- vI = gn_getVisibleItemsNextFilter(a_itm, opts, 0);
- }
- if (!opts.circular && itms.first != 0 && vI > itms.first) {
- if (opts.items.visibleConf.variable)
- {
- var nI = gn_getVisibleItemsPrev(a_itm, opts, itms.first) - itms.first;
- }
- else if (opts.items.filter != '*')
- {
- var nI = gn_getVisibleItemsPrevFilter(a_itm, opts, itms.first) - itms.first;
- }
- else
- {
- var nI = opts.items.visible - itms.first;
- }
- debug(conf, 'Preventing non-circular: sliding '+nI+' items backward.');
- $cfs.trigger(cf_e('prev', conf), nI);
- }
- opts.items.visible = cf_getItemsAdjust(vI, opts, opts.items.visibleConf.adjust, $tt0);
- opts.items.visibleConf.old = opts.items.visible;
- opts = in_getAlignPadding(opts, a_itm);
- var sz = sz_setSizes($cfs, opts);
- $cfs.trigger(cf_e('updatePageStatus', conf), [true, sz]);
- nv_showNavi(opts, itms.total, conf);
- nv_enableNavi(opts, itms.first, conf);
- return sz;
- });
- // destroy event
- $cfs.bind(cf_e('destroy', conf), function(e, orgOrder) {
- e.stopPropagation();
- tmrs = sc_clearTimers(tmrs);
- $cfs.data('_cfs_isCarousel', false);
- $cfs.trigger(cf_e('finish', conf));
- if (orgOrder)
- {
- $cfs.trigger(cf_e('jumpToStart', conf));
- }
- sz_restoreOrigCss($cfs.children());
- sz_restoreOrigCss($cfs);
- FN._unbind_events();
- FN._unbind_buttons();
- if (conf.wrapper == 'parent')
- {
- sz_restoreOrigCss($wrp);
- }
- else
- {
- $wrp.replaceWith($cfs);
- }
- return true;
- });
- // debug event
- $cfs.bind(cf_e('debug', conf), function(e) {
- debug(conf, 'Carousel width: ' + opts.width);
- debug(conf, 'Carousel height: ' + opts.height);
- debug(conf, 'Item widths: ' + opts.items.width);
- debug(conf, 'Item heights: ' + opts.items.height);
- debug(conf, 'Number of items visible: ' + opts.items.visible);
- if (opts.auto.play)
- {
- debug(conf, 'Number of items scrolled automatically: ' + opts.auto.items);
- }
- if (opts.prev.button)
- {
- debug(conf, 'Number of items scrolled backward: ' + opts.prev.items);
- }
- if (opts.next.button)
- {
- debug(conf, 'Number of items scrolled forward: ' + opts.next.items);
- }
- return conf.debug;
- });
- // triggerEvent, making prefixed and namespaced events accessible from outside
- $cfs.bind('_cfs_triggerEvent', function(e, n, o) {
- e.stopPropagation();
- return $cfs.triggerHandler(cf_e(n, conf), o);
- });
- }; // /bind_events
- FN._unbind_events = function() {
- $cfs.unbind(cf_e('', conf));
- $cfs.unbind(cf_e('', conf, false));
- $cfs.unbind('_cfs_triggerEvent');
- }; // /unbind_events
- FN._bind_buttons = function() {
- FN._unbind_buttons();
- nv_showNavi(opts, itms.total, conf);
- nv_enableNavi(opts, itms.first, conf);
- if (opts.auto.pauseOnHover)
- {
- var pC = bt_pauseOnHoverConfig(opts.auto.pauseOnHover);
- $wrp.bind(cf_e('mouseenter', conf, false), function() { $cfs.trigger(cf_e('pause', conf), pC); })
- .bind(cf_e('mouseleave', conf, false), function() { $cfs.trigger(cf_e('resume', conf)); });
- }
- // play button
- if (opts.auto.button)
- {
- opts.auto.button.bind(cf_e(opts.auto.event, conf, false), function(e) {
- e.preventDefault();
- var ev = false,
- pC = null;
- if (crsl.isPaused)
- {
- ev = 'play';
- }
- else if (opts.auto.pauseOnEvent)
- {
- ev = 'pause';
- pC = bt_pauseOnHoverConfig(opts.auto.pauseOnEvent);
- }
- if (ev)
- {
- $cfs.trigger(cf_e(ev, conf), pC);
- }
- });
- }
- // prev button
- if (opts.prev.button)
- {
- opts.prev.button.bind(cf_e(opts.prev.event, conf, false), function(e) {
- e.preventDefault();
- $cfs.trigger(cf_e('prev', conf));
- });
- if (opts.prev.pauseOnHover)
- {
- var pC = bt_pauseOnHoverConfig(opts.prev.pauseOnHover);
- opts.prev.button.bind(cf_e('mouseenter', conf, false), function() { $cfs.trigger(cf_e('pause', conf), pC); })
- .bind(cf_e('mouseleave', conf, false), function() { $cfs.trigger(cf_e('resume', conf)); });
- }
- }
- // next butotn
- if (opts.next.button)
- {
- opts.next.button.bind(cf_e(opts.next.event, conf, false), function(e) {
- e.preventDefault();
- $cfs.trigger(cf_e('next', conf));
- });
- if (opts.next.pauseOnHover)
- {
- var pC = bt_pauseOnHoverConfig(opts.next.pauseOnHover);
- opts.next.button.bind(cf_e('mouseenter', conf, false), function() { $cfs.trigger(cf_e('pause', conf), pC); })
- .bind(cf_e('mouseleave', conf, false), function() { $cfs.trigger(cf_e('resume', conf)); });
- }
- }
- // pagination
- if (opts.pagination.container)
- {
- if (opts.pagination.pauseOnHover)
- {
- var pC = bt_pauseOnHoverConfig(opts.pagination.pauseOnHover);
- opts.pagination.container.bind(cf_e('mouseenter', conf, false), function() { $cfs.trigger(cf_e('pause', conf), pC); })
- .bind(cf_e('mouseleave', conf, false), function() { $cfs.trigger(cf_e('resume', conf)); });
- }
- }
- // prev/next keys
- if (opts.prev.key || opts.next.key)
- {
- $(document).bind(cf_e('keyup', conf, false, true, true), function(e) {
- var k = e.keyCode;
- if (k == opts.next.key)
- {
- e.preventDefault();
- $cfs.trigger(cf_e('next', conf));
- }
- if (k == opts.prev.key)
- {
- e.preventDefault();
- $cfs.trigger(cf_e('prev', conf));
- }
- });
- }
- // pagination keys
- if (opts.pagination.keys)
- {
- $(document).bind(cf_e('keyup', conf, false, true, true), function(e) {
- var k = e.keyCode;
- if (k >= 49 && k < 58)
- {
- k = (k-49) * opts.items.visible;
- if (k <= itms.total)
- {
- e.preventDefault();
- $cfs.trigger(cf_e('slideTo', conf), [k, 0, true, opts.pagination]);
- }
- }
- });
- }
- // swipe
- if ($.fn.swipe)
- {
- var isTouch = 'ontouchstart' in window;
- if ((isTouch && opts.swipe.onTouch) || (!isTouch && opts.swipe.onMouse))
- {
- var scP = $.extend(true, {}, opts.prev, opts.swipe),
- scN = $.extend(true, {}, opts.next, opts.swipe),
- swP = function() { $cfs.trigger(cf_e('prev', conf), [scP]) },
- swN = function() { $cfs.trigger(cf_e('next', conf), [scN]) };
- switch (opts.direction)
- {
- case 'up':
- case 'down':
- opts.swipe.options.swipeUp = swN;
- opts.swipe.options.swipeDown = swP;
- break;
- default:
- opts.swipe.options.swipeLeft = swN;
- opts.swipe.options.swipeRight = swP;
- }
- if (crsl.swipe)
- {
- $cfs.swipe('destroy');
- }
- $wrp.swipe(opts.swipe.options);
- $wrp.css('cursor', 'move');
- crsl.swipe = true;
- }
- }
- // mousewheel
- if ($.fn.mousewheel)
- {
- if (opts.mousewheel)
- {
- var mcP = $.extend(true, {}, opts.prev, opts.mousewheel),
- mcN = $.extend(true, {}, opts.next, opts.mousewheel);
- if (crsl.mousewheel)
- {
- $wrp.unbind(cf_e('mousewheel', conf, false));
- }
- $wrp.bind(cf_e('mousewheel', conf, false), function(e, delta) {
- e.preventDefault();
- if (delta > 0)
- {
- $cfs.trigger(cf_e('prev', conf), [mcP]);
- }
- else
- {
- $cfs.trigger(cf_e('next', conf), [mcN]);
- }
- });
- crsl.mousewheel = true;
- }
- }
- if (opts.auto.play)
- {
- $cfs.trigger(cf_e('play', conf), opts.auto.delay);
- }
- if (crsl.upDateOnWindowResize)
- {
- var resizeFn = function(e) {
- $cfs.trigger(cf_e('finish', conf));
- if (opts.auto.pauseOnResize && !crsl.isPaused)
- {
- $cfs.trigger(cf_e('play', conf));
- }
- sz_resetMargin($cfs.children(), opts);
- $cfs.trigger(cf_e('updateSizes', conf));
- };
- var $w = $(window),
- onResize = null;
- if ($.debounce && conf.onWindowResize == 'debounce')
- {
- onResize = $.debounce(200, resizeFn);
- }
- else if ($.throttle && conf.onWindowResize == 'throttle')
- {
- onResize = $.throttle(300, resizeFn);
- }
- else
- {
- var _windowWidth = 0,
- _windowHeight = 0;
- onResize = function() {
- var nw = $w.width(),
- nh = $w.height();
- if (nw != _windowWidth || nh != _windowHeight)
- {
- resizeFn();
- _windowWidth = nw;
- _windowHeight = nh;
- }
- };
- }
- $w.bind(cf_e('resize', conf, false, true, true), onResize);
- }
- }; // /bind_buttons
- FN._unbind_buttons = function() {
- var ns1 = cf_e('', conf),
- ns2 = cf_e('', conf, false);
- ns3 = cf_e('', conf, false, true, true);
- $(document).unbind(ns3);
- $(window).unbind(ns3);
- $wrp.unbind(ns2);
- if (opts.auto.button)
- {
- opts.auto.button.unbind(ns2);
- }
- if (opts.prev.button)
- {
- opts.prev.button.unbind(ns2);
- }
- if (opts.next.button)
- {
- opts.next.button.unbind(ns2);
- }
- if (opts.pagination.container)
- {
- opts.pagination.container.unbind(ns2);
- if (opts.pagination.anchorBuilder)
- {
- opts.pagination.container.children().remove();
- }
- }
- if (crsl.swipe)
- {
- $cfs.swipe('destroy');
- $wrp.css('cursor', 'default');
- crsl.swipe = false;
- }
- if (crsl.mousewheel)
- {
- crsl.mousewheel = false;
- }
- nv_showNavi(opts, 'hide', conf);
- nv_enableNavi(opts, 'removeClass', conf);
- }; // /unbind_buttons
- // START
- if (is_boolean(configs))
- {
- configs = {
- 'debug': configs
- };
- }
- // set vars
- var crsl = {
- 'direction' : 'next',
- 'isPaused' : true,
- 'isScrolling' : false,
- 'isStopped' : false,
- 'mousewheel' : false,
- 'swipe' : false
- },
- itms = {
- 'total' : $cfs.children().length,
- 'first' : 0
- },
- tmrs = {
- 'auto' : null,
- 'progress' : null,
- 'startTime' : getTime(),
- 'timePassed' : 0
- },
- scrl = {
- 'isStopped' : false,
- 'duration' : 0,
- 'startTime' : 0,
- 'easing' : '',
- 'anims' : []
- },
- clbk = {
- 'onBefore' : [],
- 'onAfter' : []
- },
- queu = [],
- conf = $.extend(true, {}, $.fn.carouFredSel.configs, configs),
- opts = {},
- opts_orig = $.extend(true, {}, options),
- $wrp = (conf.wrapper == 'parent')
- ? $cfs.parent()
- : $cfs.wrap('<'+conf.wrapper.element+' class="'+conf.wrapper.classname+'" />').parent();
- conf.selector = $cfs.selector;
- conf.serialNumber = $.fn.carouFredSel.serialNumber++;
- conf.transition = (conf.transition && $.fn.transition) ? 'transition' : 'animate';
- // create carousel
- FN._init(opts_orig, true, starting_position);
- FN._build();
- FN._bind_events();
- FN._bind_buttons();
- // find item to start
- if (is_array(opts.items.start))
- {
- var start_arr = opts.items.start;
- }
- else
- {
- var start_arr = [];
- if (opts.items.start != 0)
- {
- start_arr.push(opts.items.start);
- }
- }
- if (opts.cookie)
- {
- start_arr.unshift(parseInt(cf_getCookie(opts.cookie), 10));
- }
- if (start_arr.length > 0)
- {
- for (var a = 0, l = start_arr.length; a < l; a++)
- {
- var s = start_arr[a];
- if (s == 0)
- {
- continue;
- }
- if (s === true)
- {
- s = window.location.hash;
- if (s.length < 1)
- {
- continue;
- }
- }
- else if (s === 'random')
- {
- s = Math.floor(Math.random()*itms.total);
- }
- if ($cfs.triggerHandler(cf_e('slideTo', conf), [s, 0, true, { fx: 'none' }]))
- {
- break;
- }
- }
- }
- var siz = sz_setSizes($cfs, opts),
- itm = gi_getCurrentItems($cfs.children(), opts);
- if (opts.onCreate)
- {
- opts.onCreate.call($tt0, {
- 'width': siz.width,
- 'height': siz.height,
- 'items': itm
- });
- }
- $cfs.trigger(cf_e('updatePageStatus', conf), [true, siz]);
- $cfs.trigger(cf_e('linkAnchors', conf));
- if (conf.debug)
- {
- $cfs.trigger(cf_e('debug', conf));
- }
- return $cfs;
- };
- // GLOBAL PUBLIC
- $.fn.carouFredSel.serialNumber = 1;
- $.fn.carouFredSel.defaults = {
- 'synchronise' : false,
- 'infinite' : true,
- 'circular' : true,
- 'responsive' : false,
- 'direction' : 'left',
- 'items' : {
- 'start' : 0
- },
- 'scroll' : {
- 'easing' : 'swing',
- 'duration' : 500,
- 'pauseOnHover' : false,
- 'event' : 'click',
- 'queue' : false
- }
- };
- $.fn.carouFredSel.configs = {
- 'debug' : false,
- 'transition' : false,
- 'onWindowResize': 'throttle',
- 'events' : {
- 'prefix' : '',
- 'namespace' : 'cfs'
- },
- 'wrapper' : {
- 'element' : 'div',
- 'classname' : 'caroufredsel_wrapper'
- },
- 'classnames' : {}
- };
- $.fn.carouFredSel.pageAnchorBuilder = function(nr) {
- return '<a href="#"><span>'+nr+'</span></a>';
- };
- $.fn.carouFredSel.progressbarUpdater = function(perc) {
- $(this).css('width', perc+'%');
- };
- $.fn.carouFredSel.cookie = {
- get: function(n) {
- n += '=';
- var ca = document.cookie.split(';');
- for (var a = 0, l = ca.length; a < l; a++)
- {
- var c = ca[a];
- while (c.charAt(0) == ' ')
- {
- c = c.slice(1);
- }
- if (c.indexOf(n) == 0)
- {
- return c.slice(n.length);
- }
- }
- return 0;
- },
- set: function(n, v, d) {
- var e = "";
- if (d)
- {
- var date = new Date();
- date.setTime(date.getTime() + (d * 24 * 60 * 60 * 1000));
- e = "; expires=" + date.toGMTString();
- }
- document.cookie = n + '=' + v + e + '; path=/';
- },
- remove: function(n) {
- $.fn.carouFredSel.cookie.set(n, "", -1);
- }
- };
- // GLOBAL PRIVATE
- // scrolling functions
- function sc_setScroll(d, e, c) {
- if (c.transition == 'transition')
- {
- if (e == 'swing')
- {
- e = 'ease';
- }
- }
- return {
- anims: [],
- duration: d,
- orgDuration: d,
- easing: e,
- startTime: getTime()
- };
- }
- function sc_startScroll(s, c) {
- for (var a = 0, l = s.anims.length; a < l; a++)
- {
- var b = s.anims[a];
- if (!b)
- {
- continue;
- }
- b[0][c.transition](b[1], s.duration, s.easing, b[2]);
- }
- }
- function sc_stopScroll(s, finish) {
- if (!is_boolean(finish))
- {
- finish = true;
- }
- if (is_object(s.pre))
- {
- sc_stopScroll(s.pre, finish);
- }
- for (var a = 0, l = s.anims.length; a < l; a++)
- {
- var b = s.anims[a];
- b[0].stop(true);
- if (finish)
- {
- b[0].css(b[1]);
- if (is_function(b[2]))
- {
- b[2]();
- }
- }
- }
- if (is_object(s.post))
- {
- sc_stopScroll(s.post, finish);
- }
- }
- function sc_afterScroll( $c, $c2, o ) {
- if ($c2)
- {
- $c2.remove();
- }
- switch(o.fx) {
- case 'fade':
- case 'crossfade':
- case 'cover-fade':
- case 'uncover-fade':
- $c.css('opacity', 1);
- $c.css('filter', '');
- break;
- }
- }
- function sc_fireCallbacks($t, o, b, a, c) {
- if (o[b])
- {
- o[b].call($t, a);
- }
- if (c[b].length)
- {
- for (var i = 0, l = c[b].length; i < l; i++)
- {
- c[b][i].call($t, a);
- }
- }
- return [];
- }
- function sc_fireQueue($c, q, c) {
- if (q.length)
- {
- $c.trigger(cf_e(q[0][0], c), q[0][1]);
- q.shift();
- }
- return q;
- }
- function sc_hideHiddenItems(hiddenitems) {
- hiddenitems.each(function() {
- var hi = $(this);
- hi.data('_cfs_isHidden', hi.is(':hidden')).hide();
- });
- }
- function sc_showHiddenItems(hiddenitems) {
- if (hiddenitems)
- {
- hiddenitems.each(function() {
- var hi = $(this);
- if (!hi.data('_cfs_isHidden'))
- {
- hi.show();
- }
- });
- }
- }
- function sc_clearTimers(t) {
- if (t.auto)
- {
- clearTimeout(t.auto);
- }
- if (t.progress)
- {
- clearInterval(t.progress);
- }
- return t;
- }
- function sc_mapCallbackArguments(i_old, i_skp, i_new, s_itm, s_dir, s_dur, w_siz) {
- return {
- 'width': w_siz.width,
- 'height': w_siz.height,
- 'items': {
- 'old': i_old,
- 'skipped': i_skp,
- 'visible': i_new
- },
- 'scroll': {
- 'items': s_itm,
- 'direction': s_dir,
- 'duration': s_dur
- }
- };
- }
- function sc_getDuration( sO, o, nI, siz ) {
- var dur = sO.duration;
- if (sO.fx == 'none')
- {
- return 0;
- }
- if (dur == 'auto')
- {
- dur = o.scroll.duration / o.scroll.items * nI;
- }
- else if (dur < 10)
- {
- dur = siz / dur;
- }
- if (dur < 1)
- {
- return 0;
- }
- if (sO.fx == 'fade')
- {
- dur = dur / 2;
- }
- return Math.round(dur);
- }
- // navigation functions
- function nv_showNavi(o, t, c) {
- var minimum = (is_number(o.items.minimum)) ? o.items.minimum : o.items.visible + 1;
- if (t == 'show' || t == 'hide')
- {
- var f = t;
- }
- else if (minimum > t)
- {
- debug(c, 'Not enough items ('+t+' total, '+minimum+' needed): Hiding navigation.');
- var f = 'hide';
- }
- else
- {
- var f = 'show';
- }
- var s = (f == 'show') ? 'removeClass' : 'addClass',
- h = cf_c('hidden', c);
- if (o.auto.button)
- {
- o.auto.button[f]()[s](h);
- }
- if (o.prev.button)
- {
- o.prev.button[f]()[s](h);
- }
- if (o.next.button)
- {
- o.next.button[f]()[s](h);
- }
- if (o.pagination.container)
- {
- o.pagination.container[f]()[s](h);
- }
- }
- function nv_enableNavi(o, f, c) {
- if (o.circular || o.infinite) return;
- var fx = (f == 'removeClass' || f == 'addClass') ? f : false,
- di = cf_c('disabled', c);
- if (o.auto.button && fx)
- {
- o.auto.button[fx](di);
- }
- if (o.prev.button)
- {
- var fn = fx || (f == 0) ? 'addClass' : 'removeClass';
- o.prev.button[fn](di);
- }
- if (o.next.button)
- {
- var fn = fx || (f == o.items.visible) ? 'addClass' : 'removeClass';
- o.next.button[fn](di);
- }
- }
- // get object functions
- function go_getObject($tt, obj) {
- if (is_function(obj))
- {
- obj = obj.call($tt);
- }
- else if (is_undefined(obj))
- {
- obj = {};
- }
- return obj;
- }
- function go_getItemsObject($tt, obj) {
- obj = go_getObject($tt, obj);
- if (is_number(obj))
- {
- obj = {
- 'visible': obj
- };
- }
- else if (obj == 'variable')
- {
- obj = {
- 'visible': obj,
- 'width': obj,
- 'height': obj
- };
- }
- else if (!is_object(obj))
- {
- obj = {};
- }
- return obj;
- }
- function go_getScrollObject($tt, obj) {
- obj = go_getObject($tt, obj);
- if (is_number(obj))
- {
- if (obj <= 50)
- {
- obj = {
- 'items': obj
- };
- }
- else
- {
- obj = {
- 'duration': obj
- };
- }
- }
- else if (is_string(obj))
- {
- obj = {
- 'easing': obj
- };
- }
- else if (!is_object(obj))
- {
- obj = {};
- }
- return obj;
- }
- function go_getNaviObject($tt, obj) {
- obj = go_getObject($tt, obj);
- if (is_string(obj))
- {
- var temp = cf_getKeyCode(obj);
- if (temp == -1)
- {
- obj = $(obj);
- }
- else
- {
- obj = temp;
- }
- }
- return obj;
- }
- function go_getAutoObject($tt, obj) {
- obj = go_getNaviObject($tt, obj);
- if (is_jquery(obj))
- {
- obj = {
- 'button': obj
- };
- }
- else if (is_boolean(obj))
- {
- obj = {
- 'play': obj
- };
- }
- else if (is_number(obj))
- {
- obj = {
- 'timeoutDuration': obj
- };
- }
- if (obj.progress)
- {
- if (is_string(obj.progress) || is_jquery(obj.progress))
- {
- obj.progress = {
- 'bar': obj.progress
- };
- }
- }
- return obj;
- }
- function go_complementAutoObject($tt, obj) {
- if (is_function(obj.button))
- {
- obj.button = obj.button.call($tt);
- }
- if (is_string(obj.button))
- {
- obj.button = $(obj.button);
- }
- if (!is_boolean(obj.play))
- {
- obj.play = true;
- }
- if (!is_number(obj.delay))
- {
- obj.delay = 0;
- }
- if (is_undefined(obj.pauseOnEvent))
- {
- obj.pauseOnEvent = true;
- }
- if (!is_boolean(obj.pauseOnResize))
- {
- obj.pauseOnResize = true;
- }
- if (!is_number(obj.timeoutDuration))
- {
- obj.timeoutDuration = (obj.duration < 10)
- ? 2500
- : obj.duration * 5;
- }
- if (obj.progress)
- {
- if (is_function(obj.progress.bar))
- {
- obj.progress.bar = obj.progress.bar.call($tt);
- }
- if (is_string(obj.progress.bar))
- {
- obj.progress.bar = $(obj.progress.bar);
- }
- if (obj.progress.bar)
- {
- if (!is_function(obj.progress.updater))
- {
- obj.progress.updater = $.fn.carouFredSel.progressbarUpdater;
- }
- if (!is_number(obj.progress.interval))
- {
- obj.progress.interval = 50;
- }
- }
- else
- {
- obj.progress = false;
- }
- }
- return obj;
- }
- function go_getPrevNextObject($tt, obj) {
- obj = go_getNaviObject($tt, obj);
- if (is_jquery(obj))
- {
- obj = {
- 'button': obj
- };
- }
- else if (is_number(obj))
- {
- obj = {
- 'key': obj
- };
- }
- return obj;
- }
- function go_complementPrevNextObject($tt, obj) {
- if (is_function(obj.button))
- {
- obj.button = obj.button.call($tt);
- }
- if (is_string(obj.button))
- {
- obj.button = $(obj.button);
- }
- if (is_string(obj.key))
- {
- obj.key = cf_getKeyCode(obj.key);
- }
- return obj;
- }
- function go_getPaginationObject($tt, obj) {
- obj = go_getNaviObject($tt, obj);
- if (is_jquery(obj))
- {
- obj = {
- 'container': obj
- };
- }
- else if (is_boolean(obj))
- {
- obj = {
- 'keys': obj
- };
- }
- return obj;
- }
- function go_complementPaginationObject($tt, obj) {
- if (is_function(obj.container))
- {
- obj.container = obj.container.call($tt);
- }
- if (is_string(obj.container))
- {
- obj.container = $(obj.container);
- }
- if (!is_number(obj.items))
- {
- obj.items = false;
- }
- if (!is_boolean(obj.keys))
- {
- obj.keys = false;
- }
- if (!is_function(obj.anchorBuilder) && !is_false(obj.anchorBuilder))
- {
- obj.anchorBuilder = $.fn.carouFredSel.pageAnchorBuilder;
- }
- if (!is_number(obj.deviation))
- {
- obj.deviation = 0;
- }
- return obj;
- }
- function go_getSwipeObject($tt, obj) {
- if (is_function(obj))
- {
- obj = obj.call($tt);
- }
- if (is_undefined(obj))
- {
- obj = {
- 'onTouch': false
- };
- }
- if (is_true(obj))
- {
- obj = {
- 'onTouch': obj
- };
- }
- else if (is_number(obj))
- {
- obj = {
- 'items': obj
- };
- }
- return obj;
- }
- function go_complementSwipeObject($tt, obj) {
- if (!is_boolean(obj.onTouch))
- {
- obj.onTouch = true;
- }
- if (!is_boolean(obj.onMouse))
- {
- obj.onMouse = false;
- }
- if (!is_object(obj.options))
- {
- obj.options = {};
- }
- if (!is_boolean(obj.options.triggerOnTouchEnd))
- {
- obj.options.triggerOnTouchEnd = false;
- }
- return obj;
- }
- function go_getMousewheelObject($tt, obj) {
- if (is_function(obj))
- {
- obj = obj.call($tt);
- }
- if (is_true(obj))
- {
- obj = {};
- }
- else if (is_number(obj))
- {
- obj = {
- 'items': obj
- };
- }
- else if (is_undefined(obj))
- {
- obj = false;
- }
- return obj;
- }
- function go_complementMousewheelObject($tt, obj) {
- return obj;
- }
- // get number functions
- function gn_getItemIndex(num, dev, org, items, $cfs) {
- if (is_string(num))
- {
- num = $(num, $cfs);
- }
- if (is_object(num))
- {
- num = $(num, $cfs);
- }
- if (is_jquery(num))
- {
- num = $cfs.children().index(num);
- if (!is_boolean(org))
- {
- org = false;
- }
- }
- else
- {
- if (!is_boolean(org))
- {
- org = true;
- }
- }
- if (!is_number(num))
- {
- num = 0;
- }
- if (!is_number(dev))
- {
- dev = 0;
- }
- if (org)
- {
- num += items.first;
- }
- num += dev;
- if (items.total > 0)
- {
- while (num >= items.total)
- {
- num -= items.total;
- }
- while (num < 0)
- {
- num += items.total;
- }
- }
- return num;
- }
- // items prev
- function gn_getVisibleItemsPrev(i, o, s) {
- var t = 0,
- x = 0;
- for (var a = s; a >= 0; a--)
- {
- var j = i.eq(a);
- t += (j.is(':visible')) ? j[o.d['outerWidth']](true) : 0;
- if (t > o.maxDimension)
- {
- return x;
- }
- if (a == 0)
- {
- a = i.length;
- }
- x++;
- }
- }
- function gn_getVisibleItemsPrevFilter(i, o, s) {
- return gn_getItemsPrevFilter(i, o.items.filter, o.items.visibleConf.org, s);
- }
- function gn_getScrollItemsPrevFilter(i, o, s, m) {
- return gn_getItemsPrevFilter(i, o.items.filter, m, s);
- }
- function gn_getItemsPrevFilter(i, f, m, s) {
- var t = 0,
- x = 0;
- for (var a = s, l = i.length; a >= 0; a--)
- {
- x++;
- if (x == l)
- {
- return x;
- }
- var j = i.eq(a);
- if (j.is(f))
- {
- t++;
- if (t == m)
- {
- return x;
- }
- }
- if (a == 0)
- {
- a = l;
- }
- }
- }
- function gn_getVisibleOrg($c, o) {
- return o.items.visibleConf.org || $c.children().slice(0, o.items.visible).filter(o.items.filter).length;
- }
- // items next
- function gn_getVisibleItemsNext(i, o, s) {
- var t = 0,
- x = 0;
- for (var a = s, l = i.length-1; a <= l; a++)
- {
- var j = i.eq(a);
- t += (j.is(':visible')) ? j[o.d['outerWidth']](true) : 0;
- if (t > o.maxDimension)
- {
- return x;
- }
- x++;
- if (x == l+1)
- {
- return x;
- }
- if (a == l)
- {
- a = -1;
- }
- }
- }
- function gn_getVisibleItemsNextTestCircular(i, o, s, l) {
- var v = gn_getVisibleItemsNext(i, o, s);
- if (!o.circular)
- {
- if (s + v > l)
- {
- v = l - s;
- }
- }
- return v;
- }
- function gn_getVisibleItemsNextFilter(i, o, s) {
- return gn_getItemsNextFilter(i, o.items.filter, o.items.visibleConf.org, s, o.circular);
- }
- function gn_getScrollItemsNextFilter(i, o, s, m) {
- return gn_getItemsNextFilter(i, o.items.filter, m+1, s, o.circular) - 1;
- }
- function gn_getItemsNextFilter(i, f, m, s, c) {
- var t = 0,
- x = 0;
- for (var a = s, l = i.length-1; a <= l; a++)
- {
- x++;
- if (x >= l)
- {
- return x;
- }
- var j = i.eq(a);
- if (j.is(f))
- {
- t++;
- if (t == m)
- {
- return x;
- }
- }
- if (a == l)
- {
- a = -1;
- }
- }
- }
- // get items functions
- function gi_getCurrentItems(i, o) {
- return i.slice(0, o.items.visible);
- }
- function gi_getOldItemsPrev(i, o, n) {
- return i.slice(n, o.items.visibleConf.old+n);
- }
- function gi_getNewItemsPrev(i, o) {
- return i.slice(0, o.items.visible);
- }
- function gi_getOldItemsNext(i, o) {
- return i.slice(0, o.items.visibleConf.old);
- }
- function gi_getNewItemsNext(i, o, n) {
- return i.slice(n, o.items.visible+n);
- }
- // sizes functions
- function sz_storeMargin(i, o, d) {
- if (o.usePadding)
- {
- if (!is_string(d))
- {
- d = '_cfs_origCssMargin';
- }
- i.each(function() {
- var j = $(this),
- m = parseInt(j.css(o.d['marginRight']), 10);
- if (!is_number(m))
- {
- m = 0;
- }
- j.data(d, m);
- });
- }
- }
- function sz_resetMargin(i, o, m) {
- if (o.usePadding)
- {
- var x = (is_boolean(m)) ? m : false;
- if (!is_number(m))
- {
- m = 0;
- }
- sz_storeMargin(i, o, '_cfs_tempCssMargin');
- i.each(function() {
- var j = $(this);
- j.css(o.d['marginRight'], ((x) ? j.data('_cfs_tempCssMargin') : m + j.data('_cfs_origCssMargin')));
- });
- }
- }
- function sz_storeOrigCss(i) {
- i.each(function() {
- var j = $(this);
- j.data('_cfs_origCss', j.attr('style') || '');
- });
- }
- function sz_restoreOrigCss(i) {
- i.each(function() {
- var j = $(this);
- j.attr('style', j.data('_cfs_origCss') || '');
- });
- }
- function sz_setResponsiveSizes(o, all) {
- var visb = o.items.visible,
- newS = o.items[o.d['width']],
- seco = o[o.d['height']],
- secp = is_percentage(seco);
- all.each(function() {
- var $t = $(this),
- nw = newS - ms_getPaddingBorderMargin($t, o, 'Width');
- $t[o.d['width']](nw);
- if (secp)
- {
- $t[o.d['height']](ms_getPercentage(nw, seco));
- }
- });
- }
- function sz_setSizes($c, o) {
- var $w = $c.parent(),
- $i = $c.children(),
- $v = gi_getCurrentItems($i, o),
- sz = cf_mapWrapperSizes(ms_getSizes($v, o, true), o, false);
- $w.css(sz);
- if (o.usePadding)
- {
- var p = o.padding,
- r = p[o.d[1]];
- if (o.align && r < 0)
- {
- r = 0;
- }
- var $l = $v.last();
- $l.css(o.d['marginRight'], $l.data('_cfs_origCssMargin') + r);
- $c.css(o.d['top'], p[o.d[0]]);
- $c.css(o.d['left'], p[o.d[3]]);
- }
- $c.css(o.d['width'], sz[o.d['width']]+(ms_getTotalSize($i, o, 'width')*2));
- $c.css(o.d['height'], ms_getLargestSize($i, o, 'height'));
- return sz;
- }
- // measuring functions
- function ms_getSizes(i, o, wrapper) {
- return [ms_getTotalSize(i, o, 'width', wrapper), ms_getLargestSize(i, o, 'height', wrapper)];
- }
- function ms_getLargestSize(i, o, dim, wrapper) {
- if (!is_boolean(wrapper))
- {
- wrapper = false;
- }
- if (is_number(o[o.d[dim]]) && wrapper)
- {
- return o[o.d[dim]];
- }
- if (is_number(o.items[o.d[dim]]))
- {
- return o.items[o.d[dim]];
- }
- dim = (dim.toLowerCase().indexOf('width') > -1) ? 'outerWidth' : 'outerHeight';
- return ms_getTrueLargestSize(i, o, dim);
- }
- function ms_getTrueLargestSize(i, o, dim) {
- var s = 0;
- for (var a = 0, l = i.length; a < l; a++)
- {
- var j = i.eq(a);
- var m = (j.is(':visible')) ? j[o.d[dim]](true) : 0;
- if (s < m)
- {
- s = m;
- }
- }
- return s;
- }
- function ms_getTotalSize(i, o, dim, wrapper) {
- if (!is_boolean(wrapper))
- {
- wrapper = false;
- }
- if (is_number(o[o.d[dim]]) && wrapper)
- {
- return o[o.d[dim]];
- }
- if (is_number(o.items[o.d[dim]]))
- {
- return o.items[o.d[dim]] * i.length;
- }
- var d = (dim.toLowerCase().indexOf('width') > -1) ? 'outerWidth' : 'outerHeight',
- s = 0;
- for (var a = 0, l = i.length; a < l; a++)
- {
- var j = i.eq(a);
- s += (j.is(':visible')) ? j[o.d[d]](true) : 0;
- }
- return s;
- }
- function ms_getParentSize($w, o, d) {
- var isVisible = $w.is(':visible');
- if (isVisible)
- {
- $w.hide();
- }
- var s = $w.parent()[o.d[d]]();
- if (isVisible)
- {
- $w.show();
- }
- return s;
- }
- function ms_getMaxDimension(o, a) {
- return (is_number(o[o.d['width']])) ? o[o.d['width']] : a;
- }
- function ms_hasVariableSizes(i, o, dim) {
- var s = false,
- v = false;
- for (var a = 0, l = i.length; a < l; a++)
- {
- var j = i.eq(a);
- var c = (j.is(':visible')) ? j[o.d[dim]](true) : 0;
- if (s === false)
- {
- s = c;
- }
- else if (s != c)
- {
- v = true;
- }
- if (s == 0)
- {
- v = true;
- }
- }
- return v;
- }
- function ms_getPaddingBorderMargin(i, o, d) {
- return i[o.d['outer'+d]](true) - i[o.d[d.toLowerCase()]]();
- }
- function ms_getPercentage(s, o) {
- if (is_percentage(o))
- {
- o = parseInt( o.slice(0, -1), 10 );
- if (!is_number(o))
- {
- return s;
- }
- s *= o/100;
- }
- return s;
- }
- // config functions
- function cf_e(n, c, pf, ns, rd) {
- if (!is_boolean(pf))
- {
- pf = true;
- }
- if (!is_boolean(ns))
- {
- ns = true;
- }
- if (!is_boolean(rd))
- {
- rd = false;
- }
- if (pf)
- {
- n = c.events.prefix + n;
- }
- if (ns)
- {
- n = n +'.'+ c.events.namespace;
- }
- if (ns && rd)
- {
- n += c.serialNumber;
- }
- return n;
- }
- function cf_c(n, c) {
- return (is_string(c.classnames[n])) ? c.classnames[n] : n;
- }
- function cf_mapWrapperSizes(ws, o, p) {
- if (!is_boolean(p))
- {
- p = true;
- }
- var pad = (o.usePadding && p) ? o.padding : [0, 0, 0, 0];
- var wra = {};
- wra[o.d['width']] = ws[0] + pad[1] + pad[3];
- wra[o.d['height']] = ws[1] + pad[0] + pad[2];
- return wra;
- }
- function cf_sortParams(vals, typs) {
- var arr = [];
- for (var a = 0, l1 = vals.length; a < l1; a++)
- {
- for (var b = 0, l2 = typs.length; b < l2; b++)
- {
- if (typs[b].indexOf(typeof vals[a]) > -1 && is_undefined(arr[b]))
- {
- arr[b] = vals[a];
- break;
- }
- }
- }
- return arr;
- }
- function cf_getPadding(p) {
- if (is_undefined(p))
- {
- return [0, 0, 0, 0];
- }
- if (is_number(p))
- {
- return [p, p, p, p];
- }
- if (is_string(p))
- {
- p = p.split('px').join('').split('em').join('').split(' ');
- }
- if (!is_array(p))
- {
- return [0, 0, 0, 0];
- }
- for (var i = 0; i < 4; i++)
- {
- p[i] = parseInt(p[i], 10);
- }
- switch (p.length)
- {
- case 0:
- return [0, 0, 0, 0];
- case 1:
- return [p[0], p[0], p[0], p[0]];
- case 2:
- return [p[0], p[1], p[0], p[1]];
- case 3:
- return [p[0], p[1], p[2], p[1]];
- default:
- return [p[0], p[1], p[2], p[3]];
- }
- }
- function cf_getAlignPadding(itm, o) {
- var x = (is_number(o[o.d['width']])) ? Math.ceil(o[o.d['width']] - ms_getTotalSize(itm, o, 'width')) : 0;
- switch (o.align)
- {
- case 'left':
- return [0, x];
- case 'right':
- return [x, 0];
- case 'center':
- default:
- return [Math.ceil(x/2), Math.floor(x/2)];
- }
- }
- function cf_getDimensions(o) {
- var dm = [
- ['width' , 'innerWidth' , 'outerWidth' , 'height' , 'innerHeight' , 'outerHeight' , 'left', 'top' , 'marginRight' , 0, 1, 2, 3],
- ['height' , 'innerHeight' , 'outerHeight' , 'width' , 'innerWidth' , 'outerWidth' , 'top' , 'left', 'marginBottom', 3, 2, 1, 0]
- ];
- var dl = dm[0].length,
- dx = (o.direction == 'right' || o.direction == 'left') ? 0 : 1;
- var dimensions = {};
- for (var d = 0; d < dl; d++)
- {
- dimensions[dm[0][d]] = dm[dx][d];
- }
- return dimensions;
- }
- function cf_getAdjust(x, o, a, $t) {
- var v = x;
- if (is_function(a))
- {
- v = a.call($t, v);
- }
- else if (is_string(a))
- {
- var p = a.split('+'),
- m = a.split('-');
- if (m.length > p.length)
- {
- var neg = true,
- sta = m[0],
- adj = m[1];
- }
- else
- {
- var neg = false,
- sta = p[0],
- adj = p[1];
- }
- switch(sta)
- {
- case 'even':
- v = (x % 2 == 1) ? x-1 : x;
- break;
- case 'odd':
- v = (x % 2 == 0) ? x-1 : x;
- break;
- default:
- v = x;
- break;
- }
- adj = parseInt(adj, 10);
- if (is_number(adj))
- {
- if (neg)
- {
- adj = -adj;
- }
- v += adj;
- }
- }
- if (!is_number(v) || v < 1)
- {
- v = 1;
- }
- return v;
- }
- function cf_getItemsAdjust(x, o, a, $t) {
- return cf_getItemAdjustMinMax(cf_getAdjust(x, o, a, $t), o.items.visibleConf);
- }
- function cf_getItemAdjustMinMax(v, i) {
- if (is_number(i.min) && v < i.min)
- {
- v = i.min;
- }
- if (is_number(i.max) && v > i.max)
- {
- v = i.max;
- }
- if (v < 1)
- {
- v = 1;
- }
- return v;
- }
- function cf_getSynchArr(s) {
- if (!is_array(s))
- {
- s = [[s]];
- }
- if (!is_array(s[0]))
- {
- s = [s];
- }
- for (var j = 0, l = s.length; j < l; j++)
- {
- if (is_string(s[j][0]))
- {
- s[j][0] = $(s[j][0]);
- }
- if (!is_boolean(s[j][1]))
- {
- s[j][1] = true;
- }
- if (!is_boolean(s[j][2]))
- {
- s[j][2] = true;
- }
- if (!is_number(s[j][3]))
- {
- s[j][3] = 0;
- }
- }
- return s;
- }
- function cf_getKeyCode(k) {
- if (k == 'right')
- {
- return 39;
- }
- if (k == 'left')
- {
- return 37;
- }
- if (k == 'up')
- {
- return 38;
- }
- if (k == 'down')
- {
- return 40;
- }
- return -1;
- }
- function cf_setCookie(n, $c, c) {
- if (n)
- {
- var v = $c.triggerHandler(cf_e('currentPosition', c));
- $.fn.carouFredSel.cookie.set(n, v);
- }
- }
- function cf_getCookie(n) {
- var c = $.fn.carouFredSel.cookie.get(n);
- return (c == '') ? 0 : c;
- }
- // init function
- function in_mapCss($elem, props) {
- var css = {};
- for (var p = 0, l = props.length; p < l; p++)
- {
- css[props[p]] = $elem.css(props[p]);
- }
- return css;
- }
- function in_complementItems(obj, opt, itm, sta) {
- if (!is_object(obj.visibleConf))
- {
- obj.visibleConf = {};
- }
- if (!is_object(obj.sizesConf))
- {
- obj.sizesConf = {};
- }
- if (obj.start == 0 && is_number(sta))
- {
- obj.start = sta;
- }
- // visible items
- if (is_object(obj.visible))
- {
- obj.visibleConf.min = obj.visible.min;
- obj.visibleConf.max = obj.visible.max;
- obj.visible = false;
- }
- else if (is_string(obj.visible))
- {
- // variable visible items
- if (obj.visible == 'variable')
- {
- obj.visibleConf.variable = true;
- }
- // adjust string visible items
- else
- {
- obj.visibleConf.adjust = obj.visible;
- }
- obj.visible = false;
- }
- else if (is_function(obj.visible))
- {
- obj.visibleConf.adjust = obj.visible;
- obj.visible = false;
- }
- // set items filter
- if (!is_string(obj.filter))
- {
- obj.filter = (itm.filter(':hidden').length > 0) ? ':visible' : '*';
- }
- // primary item-size not set
- if (!obj[opt.d['width']])
- {
- // responsive carousel -> set to largest
- if (opt.responsive)
- {
- debug(true, 'Set a '+opt.d['width']+' for the items!');
- obj[opt.d['width']] = ms_getTrueLargestSize(itm, opt, 'outerWidth');
- }
- // non-responsive -> measure it or set to "variable"
- else
- {
- obj[opt.d['width']] = (ms_hasVariableSizes(itm, opt, 'outerWidth'))
- ? 'variable'
- : itm[opt.d['outerWidth']](true);
- }
- }
- // secondary item-size not set -> measure it or set to "variable"
- if (!obj[opt.d['height']])
- {
- obj[opt.d['height']] = (ms_hasVariableSizes(itm, opt, 'outerHeight'))
- ? 'variable'
- : itm[opt.d['outerHeight']](true);
- }
- obj.sizesConf.width = obj.width;
- obj.sizesConf.height = obj.height;
- return obj;
- }
- function in_complementVisibleItems(opt, avl) {
- // primary item-size variable -> set visible items variable
- if (opt.items[opt.d['width']] == 'variable')
- {
- opt.items.visibleConf.variable = true;
- }
- if (!opt.items.visibleConf.variable) {
- // primary size is number -> calculate visible-items
- if (is_number(opt[opt.d['width']]))
- {
- opt.items.visible = Math.floor(opt[opt.d['width']] / opt.items[opt.d['width']]);
- }
- // measure and calculate primary size and visible-items
- else
- {
- opt.items.visible = Math.floor(avl / opt.items[opt.d['width']]);
- opt[opt.d['width']] = opt.items.visible * opt.items[opt.d['width']];
- if (!opt.items.visibleConf.adjust)
- {
- opt.align = false;
- }
- }
- if (opt.items.visible == 'Infinity' || opt.items.visible < 1)
- {
- debug(true, 'Not a valid number of visible items: Set to "variable".');
- opt.items.visibleConf.variable = true;
- }
- }
- return opt;
- }
- function in_complementPrimarySize(obj, opt, all) {
- // primary size set to auto -> measure largest item-size and set it
- if (obj == 'auto')
- {
- obj = ms_getTrueLargestSize(all, opt, 'outerWidth');
- }
- return obj;
- }
- function in_complementSecondarySize(obj, opt, all) {
- // secondary size set to auto -> measure largest item-size and set it
- if (obj == 'auto')
- {
- obj = ms_getTrueLargestSize(all, opt, 'outerHeight');
- }
- // secondary size not set -> set to secondary item-size
- if (!obj)
- {
- obj = opt.items[opt.d['height']];
- }
- return obj;
- }
- function in_getAlignPadding(o, all) {
- var p = cf_getAlignPadding(gi_getCurrentItems(all, o), o);
- o.padding[o.d[1]] = p[1];
- o.padding[o.d[3]] = p[0];
- return o;
- }
- function in_getResponsiveValues(o, all, avl) {
- var visb = cf_getItemAdjustMinMax(Math.ceil(o[o.d['width']] / o.items[o.d['width']]), o.items.visibleConf);
- if (visb > all.length)
- {
- visb = all.length;
- }
- var newS = Math.floor(o[o.d['width']]/visb);
- o.items.visible = visb;
- o.items[o.d['width']] = newS;
- o[o.d['width']] = visb * newS;
- return o;
- }
- // buttons functions
- function bt_pauseOnHoverConfig(p) {
- if (is_string(p))
- {
- var i = (p.indexOf('immediate') > -1) ? true : false,
- r = (p.indexOf('resume') > -1) ? true : false;
- }
- else
- {
- var i = r = false;
- }
- return [i, r];
- }
- function bt_mousesheelNumber(mw) {
- return (is_number(mw)) ? mw : null
- }
- // helper functions
- function is_null(a) {
- return (a === null);
- }
- function is_undefined(a) {
- return (is_null(a) || typeof a == 'undefined' || a === '' || a === 'undefined');
- }
- function is_array(a) {
- return (a instanceof Array);
- }
- function is_jquery(a) {
- return (a instanceof jQuery);
- }
- function is_object(a) {
- return ((a instanceof Object || typeof a == 'object') && !is_null(a) && !is_jquery(a) && !is_array(a) && !is_function(a));
- }
- function is_number(a) {
- return ((a instanceof Number || typeof a == 'number') && !isNaN(a));
- }
- function is_string(a) {
- return ((a instanceof String || typeof a == 'string') && !is_undefined(a) && !is_true(a) && !is_false(a));
- }
- function is_function(a) {
- return (a instanceof Function || typeof a == 'function');
- }
- function is_boolean(a) {
- return (a instanceof Boolean || typeof a == 'boolean' || is_true(a) || is_false(a));
- }
- function is_true(a) {
- return (a === true || a === 'true');
- }
- function is_false(a) {
- return (a === false || a === 'false');
- }
- function is_percentage(x) {
- return (is_string(x) && x.slice(-1) == '%');
- }
- function getTime() {
- return new Date().getTime();
- }
- function deprecated( o, n ) {
- debug(true, o+' is DEPRECATED, support for it will be removed. Use '+n+' instead.');
- }
- function debug(d, m) {
- if (!is_undefined(window.console) && !is_undefined(window.console.log))
- {
- if (is_object(d))
- {
- var s = ' ('+d.selector+')';
- d = d.debug;
- }
- else
- {
- var s = '';
- }
- if (!d)
- {
- return false;
- }
-
- if (is_string(m))
- {
- m = 'carouFredSel'+s+': ' + m;
- }
- else
- {
- m = ['carouFredSel'+s+':', m];
- }
- window.console.log(m);
- }
- return false;
- }
- // EASING FUNCTIONS
- $.extend($.easing, {
- 'quadratic': function(t) {
- var t2 = t * t;
- return t * (-t2 * t + 4 * t2 - 6 * t + 4);
- },
- 'cubic': function(t) {
- return t * (4 * t * t - 9 * t + 6);
- },
- 'elastic': function(t) {
- var t2 = t * t;
- return t * (33 * t2 * t2 - 106 * t2 * t + 126 * t2 - 67 * t + 15);
- }
- });
- })(jQuery);
|