fl-slideshow.js 234 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583
  1. /**
  2. * Slideshow JS Bundle
  3. */
  4. YUI.add('fl-event-move', function(Y) {
  5. /**
  6. * Adds gesturemovevertical, gesturemoveverticalend, gesturemovehorizontal
  7. * and gesturemovehorizontalend events.
  8. *
  9. * @module fl-event-move
  10. */
  11. var _eventBase = {
  12. _isEndEvent: false,
  13. on: function(node, subscriber, ce)
  14. {
  15. if(this.type.indexOf('end') > -1) {
  16. this._isEndEvent = true;
  17. }
  18. subscriber._direction = this.type.replace('gesturemove', '').replace('end', '');
  19. if(window.navigator.msPointerEnabled) {
  20. subscriber._startHandle = node.on('MSPointerDown', this._onStart, this, node, subscriber, ce);
  21. subscriber._moveHandle = node.on('MSPointerMove', this._onMove, this, node, subscriber, ce);
  22. subscriber._endHandle = node.on('MSPointerUp', this._onEnd, this, node, subscriber, ce);
  23. }
  24. else {
  25. subscriber._startHandle = node.on('gesturemovestart', this._onStart, null, this, node, subscriber, ce);
  26. subscriber._moveHandle = node.on('gesturemove', this._onMove, null, this, node, subscriber, ce);
  27. subscriber._endHandle = node.on('gesturemoveend', this._onEnd, { standAlone: true }, this, node, subscriber, ce);
  28. }
  29. },
  30. detach: function(node, subscriber, ce)
  31. {
  32. subscriber._startHandle.detach();
  33. subscriber._startHandle = null;
  34. subscriber._moveHandle.detach();
  35. subscriber._moveHandle = null;
  36. subscriber._endHandle.detach();
  37. subscriber._endHandle = null;
  38. },
  39. _onStart: function(e, node, subscriber, ce)
  40. {
  41. subscriber._doMove = null;
  42. subscriber._startX = e.pageX;
  43. subscriber._startY = e.pageY;
  44. },
  45. _onMove: function(e, node, subscriber, ce)
  46. {
  47. if(this._checkDirection(e, subscriber)) {
  48. subscriber._doMove = true;
  49. }
  50. else {
  51. subscriber._doMove = false;
  52. }
  53. if(subscriber._doMove && !this._isEndEvent) {
  54. ce.fire(e);
  55. }
  56. },
  57. _onEnd: function(e, node, subscriber, ce)
  58. {
  59. if(subscriber._doMove && this._isEndEvent) {
  60. e.startPageX = subscriber._startX;
  61. e.startPageY = subscriber._startY;
  62. ce.fire(e);
  63. }
  64. subscriber._doMove = null;
  65. },
  66. _checkDirection: function(e, subscriber)
  67. {
  68. var xDelta = Math.abs(subscriber._startX - e.pageX),
  69. yDelta = Math.abs(subscriber._startY - e.pageY);
  70. if(yDelta > xDelta && subscriber._startY > e.pageY && subscriber._direction == 'vertical') {
  71. return true;
  72. }
  73. else if(yDelta > xDelta && subscriber._startY < e.pageY && subscriber._direction == 'vertical') {
  74. return true;
  75. }
  76. else if(yDelta < xDelta && subscriber._startX > e.pageX && subscriber._direction == 'horizontal') {
  77. return true;
  78. }
  79. else if(yDelta < xDelta && subscriber._startX < e.pageX && subscriber._direction == 'horizontal') {
  80. return true;
  81. }
  82. return false;
  83. }
  84. };
  85. /**
  86. * @event gesturemovevertical
  87. * @param type {String} "gesturemovevertical"
  88. * @param fn {Function} The method the event invokes.
  89. * @param ctx {Object} Context for the method the event invokes.
  90. */
  91. Y.Event.define('gesturemovevertical', _eventBase);
  92. /**
  93. * @event gesturemoveverticalend
  94. * @param type {String} "gesturemoveverticalend"
  95. * @param fn {Function} The method the event invokes.
  96. * @param ctx {Object} Context for the method the event invokes.
  97. */
  98. Y.Event.define('gesturemoveverticalend', _eventBase);
  99. /**
  100. * @event gesturemovehorizontal
  101. * @param type {String} "gesturemovehorizontal"
  102. * @param fn {Function} The method the event invokes.
  103. * @param ctx {Object} Context for the method the event invokes.
  104. */
  105. Y.Event.define('gesturemovehorizontal', _eventBase);
  106. /**
  107. * @event gesturemovehorizontalend
  108. * @param type {String} "gesturemovehorizontalend"
  109. * @param fn {Function} The method the event invokes.
  110. * @param ctx {Object} Context for the method the event invokes.
  111. */
  112. Y.Event.define('gesturemovehorizontalend', _eventBase);
  113. }, '2.0.0' ,{requires:['event-move']});
  114. YUI.add('fl-slideshow', function(Y) {
  115. /**
  116. * @module fl-slideshow
  117. */
  118. /**
  119. * Caption widget used in slideshows.
  120. *
  121. * @namespace FL
  122. * @class SlideshowCaption
  123. * @constructor
  124. * @param config {Object} Configuration object
  125. * @extends Widget
  126. */
  127. Y.namespace('FL').SlideshowCaption = Y.Base.create('fl-slideshow-caption', Y.Widget, [Y.WidgetChild], {
  128. /**
  129. * Flag for whether the text has been
  130. * toggled or not.
  131. *
  132. * @property _textToggled
  133. * @type Boolean
  134. * @default false
  135. * @protected
  136. */
  137. _textToggled: false,
  138. /**
  139. * An anchor node used for the toggle link.
  140. *
  141. * @property _textToggleLink
  142. * @type Object
  143. * @default null
  144. * @protected
  145. */
  146. _textToggleLink: null,
  147. /**
  148. * @method renderUI
  149. * @protected
  150. */
  151. renderUI: function()
  152. {
  153. var root = this.get('root'),
  154. bb = this.get('boundingBox');
  155. this._textToggleLink = Y.Node.create('<a href="javascript:void(0);"></a>');
  156. this._textToggleLink.addClass('fl-slideshow-caption-toggle');
  157. this._textToggleLink.set('innerHTML', root.get('captionMoreLinkText'));
  158. bb.appendChild(this._textToggleLink);
  159. },
  160. /**
  161. * @method bindUI
  162. * @protected
  163. */
  164. bindUI: function()
  165. {
  166. this.get('root').on('imageLoadComplete', Y.bind(this._setText, this));
  167. this._textToggleLink.on('click', Y.bind(this._toggleText, this));
  168. },
  169. /**
  170. * Sets the caption text and displays the
  171. * toggle link if necessary.
  172. *
  173. * @method _setText
  174. * @protected
  175. */
  176. _setText: function()
  177. {
  178. var root = this.get('root'),
  179. text = root.imageInfo.caption,
  180. textLength = root.get('captionTextLength'),
  181. cb = this.get('contentBox');
  182. if(!root.imageInfo.caption || root.imageInfo.caption === '') {
  183. cb.set('innerHTML', '');
  184. this._textToggleLink.setStyle('display', 'none');
  185. return;
  186. }
  187. else if(textLength > -1) {
  188. if(!this._textToggled && textLength < text.length) {
  189. text = this._shortenText(text);
  190. this._textToggleLink.setStyle('display', 'inline-block');
  191. }
  192. else if(this._textToggled && textLength < text.length) {
  193. text = this._stripTags(text);
  194. this._textToggleLink.setStyle('display', 'inline-block');
  195. }
  196. else {
  197. text = this._stripTags(text);
  198. this._textToggleLink.setStyle('display', 'none');
  199. }
  200. }
  201. else {
  202. text = this._stripTags(text);
  203. }
  204. cb.set('innerHTML', text);
  205. },
  206. /**
  207. * Shows or hides the full text when the
  208. * toggle link is clicked.
  209. *
  210. * @method _toggleText
  211. * @protected
  212. */
  213. _toggleText: function()
  214. {
  215. var root = this.get('root'),
  216. text = root.imageInfo.caption,
  217. cb = this.get('contentBox');
  218. if(this._textToggled) {
  219. text = this._shortenText(text);
  220. this._textToggleLink.set('innerHTML', root.get('captionMoreLinkText'));
  221. this._textToggled = false;
  222. }
  223. else {
  224. text = this._stripTags(text);
  225. this._textToggleLink.set('innerHTML', root.get('captionLessLinkText'));
  226. this._textToggled = true;
  227. }
  228. cb.set('innerHTML', text);
  229. },
  230. /**
  231. * Strips out HTML tags from the caption text.
  232. *
  233. * @method _stripTags
  234. * @param text {String} The text to strip HTML tags from.
  235. * @param ignoreSettings {Boolean} If true, will strip tags even if
  236. * the stripTags attribute is set to false.
  237. * @protected
  238. */
  239. _stripTags: function(text, ignoreSettings)
  240. {
  241. var root = this.get('root'), textDiv;
  242. if(ignoreSettings || root.get('captionStripTags')) {
  243. textDiv = document.createElement('div');
  244. textDiv.innerHTML = text;
  245. text = textDiv.textContent || textDiv.innerText;
  246. }
  247. return text;
  248. },
  249. /**
  250. * Shortens the caption text to the length of
  251. * the textLength attribute.
  252. *
  253. * @method _shortenText
  254. * @protected
  255. */
  256. _shortenText: function(text)
  257. {
  258. var root = this.get('root');
  259. text = this._stripTags(text, true).substring(0, root.get('captionTextLength'));
  260. return Y.Lang.trim(text.substring(0, text.lastIndexOf(' '))) + ' ...';
  261. }
  262. }, {
  263. /**
  264. * Custom CSS class name for the widget.
  265. *
  266. * @property CSS_PREFIX
  267. * @type String
  268. * @protected
  269. * @static
  270. */
  271. CSS_PREFIX: 'fl-slideshow-caption',
  272. /**
  273. * Static property used to define the default attribute configuration of
  274. * the Widget.
  275. *
  276. * @property ATTRS
  277. * @type Object
  278. * @protected
  279. * @static
  280. */
  281. ATTRS: {
  282. }
  283. });
  284. /**
  285. * A widget for loading and transitioning between SlideshowImage
  286. * instances. Each SlideshowImage instance is a child widget of
  287. * SlideshowFrame. SlideshowFrame is a child widget of the main
  288. * slideshow widget.
  289. *
  290. * @namespace FL
  291. * @class SlideshowFrame
  292. * @constructor
  293. * @param config {Object} Configuration object
  294. * @extends Widget
  295. */
  296. Y.namespace('FL').SlideshowFrame = Y.Base.create('fl-slideshow-frame', Y.Widget, [Y.WidgetParent, Y.WidgetChild], {
  297. /**
  298. * The imageInfo object used to load the active image.
  299. *
  300. * @property info
  301. * @type Object
  302. * @default null
  303. * @protected
  304. */
  305. _imageInfo: null,
  306. /**
  307. * The active FL.SlideshowImage instance in the frame.
  308. *
  309. * @property _activeImage
  310. * @type FL.SlideshowImage
  311. * @default null
  312. * @protected
  313. */
  314. _activeImage: null,
  315. /**
  316. * A FL.SlideshowImage instance used to load the
  317. * next image and transition it into the frame.
  318. *
  319. * @property _nextImage
  320. * @type FL.SlideshowImage
  321. * @default null
  322. * @protected
  323. */
  324. _nextImage: null,
  325. /**
  326. * Used to store imageInfo if a load request is
  327. * made while the frame is transitioning. If not null
  328. * when the transition completes, a new image will
  329. * be loaded using the imageInfo.
  330. *
  331. * @property _loadQueue
  332. * @type Object
  333. * @default false
  334. * @protected
  335. */
  336. _loadQueue: null,
  337. /**
  338. * An instance of FL.SlideshowTransition used for
  339. * the current transition in progress.
  340. *
  341. * @property _transition
  342. * @type FL.SlideshowTransition
  343. * @default null
  344. * @protected
  345. */
  346. _transition: null,
  347. /**
  348. * A flag for whether the frame is currently transitioning or not.
  349. *
  350. * @property _transitioning
  351. * @type Boolean
  352. * @default false
  353. * @protected
  354. */
  355. _transitioning: false,
  356. /**
  357. * Flag for whether to resize when the current transition
  358. * completes. Set to true when a resize request is made
  359. * during a transition.
  360. *
  361. * @property _resizeAfterTransition
  362. * @type Boolean
  363. * @default false
  364. * @protected
  365. */
  366. _resizeAfterTransition: false,
  367. /**
  368. * Provides functionality for gesture based transitions
  369. * between the active and next images.
  370. *
  371. * @property _gestures
  372. * @type FL.SlideshowGestures
  373. * @default null
  374. * @protected
  375. */
  376. _gestures: null,
  377. /**
  378. * Creates new instances of FL.SlideshowImage used in the frame.
  379. *
  380. * @method initializer
  381. * @protected
  382. */
  383. initializer: function()
  384. {
  385. var imageConfig = this.get('imageConfig');
  386. this._activeImage = new Y.FL.SlideshowImage(imageConfig);
  387. this._nextImage = new Y.FL.SlideshowImage(imageConfig);
  388. },
  389. /**
  390. * Renders the FL.SlideshowImage instances used in the frame.
  391. *
  392. * @method renderUI
  393. * @protected
  394. */
  395. renderUI: function()
  396. {
  397. this.add(this._activeImage);
  398. this.add(this._nextImage);
  399. },
  400. /**
  401. * @method bindUI
  402. * @protected
  403. */
  404. bindUI: function()
  405. {
  406. var activeBB = this._activeImage.get('boundingBox'),
  407. nextBB = this._nextImage.get('boundingBox'),
  408. transition = this.get('transition');
  409. if(('ontouchstart' in window || window.navigator.msPointerEnabled) && this.get('touchSupport')) {
  410. this._gestures = new Y.FL.SlideshowGestures({
  411. direction: transition == 'slideVertical' ? 'vertical' : 'horizontal',
  412. activeItem: activeBB,
  413. nextItem: nextBB
  414. });
  415. this._gestures.on('moveStart', this._gesturesMoveStart, this);
  416. this._gestures.on('endComplete', this._gesturesEndComplete, this);
  417. }
  418. },
  419. /**
  420. * Functional styles for the UI.
  421. *
  422. * @method syncUI
  423. * @protected
  424. */
  425. syncUI: function()
  426. {
  427. var activeBB = this._activeImage.get('boundingBox'),
  428. nextBB = this._nextImage.get('boundingBox'),
  429. cb = this.get('contentBox');
  430. activeBB.setStyle('position', 'absolute');
  431. activeBB.setStyle('top', '0px');
  432. activeBB.setStyle('left', '-9999px');
  433. nextBB.setStyle('position', 'absolute');
  434. nextBB.setStyle('top', '0px');
  435. nextBB.setStyle('left', '-9999px');
  436. cb.setStyle('position', 'relative');
  437. cb.setStyle('overflow', 'hidden');
  438. },
  439. /**
  440. * Checks whether the imageInfo should be loaded or queued.
  441. * Initializes a new transition if loading is ok.
  442. *
  443. * @method load
  444. * @param imageInfo {Object} The image info to load.
  445. */
  446. load: function(imageInfo)
  447. {
  448. var activeInfo = this._activeImage._imageInfo;
  449. if(this._transitioning) {
  450. this._loadQueue = imageInfo;
  451. return;
  452. }
  453. else if(activeInfo && activeInfo.largeURL == imageInfo.largeURL) {
  454. return;
  455. }
  456. this._imageInfo = imageInfo;
  457. this._transitionInit(imageInfo);
  458. },
  459. /**
  460. * Preloads the next image using the provided imageInfo.
  461. *
  462. * @method preload
  463. * @param imageInfo {Object} The imageInfo to preload.
  464. * @param width {Number} The width to preload.
  465. * @param height {Number} The height to preload.
  466. */
  467. preload: function(imageInfo, width, height)
  468. {
  469. this._imageInfo = imageInfo;
  470. this._nextImage.preload(imageInfo, width, height);
  471. },
  472. /**
  473. * Unloads the active and next image instances.
  474. *
  475. * @method unload
  476. */
  477. unload: function()
  478. {
  479. this._imageInfo = null;
  480. this._loadQueue = null;
  481. this._transitioning = false;
  482. this._transition = null;
  483. this._activeImage.detachAll();
  484. this._activeImage.unload();
  485. this._activeImage.get('boundingBox').setStyle('left', '-9999px');
  486. this._nextImage.detachAll();
  487. this._nextImage.unload();
  488. this._nextImage.get('boundingBox').setStyle('left', '-9999px');
  489. },
  490. /**
  491. * Resizes the bounding box and active image.
  492. *
  493. * @method resize
  494. * @param width {Number} The width value.
  495. * @param height {Number} The height value.
  496. */
  497. resize: function(width, height)
  498. {
  499. if(!width || !height) {
  500. return;
  501. }
  502. var bb = this.get('boundingBox'),
  503. padding = [
  504. parseInt(bb.getComputedStyle('paddingTop'), 10),
  505. parseInt(bb.getComputedStyle('paddingRight'), 10),
  506. parseInt(bb.getComputedStyle('paddingBottom'), 10),
  507. parseInt(bb.getComputedStyle('paddingLeft'), 10)
  508. ];
  509. width = width - padding[1] - padding[3];
  510. height = height - padding[0] - padding[2];
  511. this.set('width', width);
  512. this.set('height', height);
  513. if(this._transitioning) {
  514. this._resizeAfterTransition = true;
  515. }
  516. else {
  517. this._activeImage.resize(width, height);
  518. this._nextImage.resize(width, height);
  519. }
  520. },
  521. /**
  522. * Gets the current transition to use.
  523. *
  524. * @method _getTransition
  525. * @protected
  526. */
  527. _getTransition: function()
  528. {
  529. var root = this.get('root'),
  530. lastIndex = root.albumInfo.images.length - 1,
  531. direction = 'next',
  532. transition = root.get('transition');
  533. if(root.lastImageIndex === null) {
  534. direction = '';
  535. }
  536. else if(root.imageIndex == lastIndex && root.lastImageIndex === 0) {
  537. direction = 'prev';
  538. }
  539. else if(root.imageIndex === 0 && root.lastImageIndex == lastIndex) {
  540. direction = 'next';
  541. }
  542. else if(root.lastImageIndex > root.imageIndex) {
  543. direction = 'prev';
  544. }
  545. else if(root.lastImageIndex < root.imageIndex) {
  546. direction = 'next';
  547. }
  548. if(direction == 'next') {
  549. transition = transition.replace('slideHorizontal', 'slideLeft');
  550. transition = transition.replace('slideVertical', 'slideUp');
  551. }
  552. else if(direction == 'prev') {
  553. transition = transition.replace('slideHorizontal', 'slideRight');
  554. transition = transition.replace('slideVertical', 'slideDown');
  555. }
  556. return transition;
  557. },
  558. /**
  559. * Fires the transitionInit event and loads the next image.
  560. * The transition starts when the image's loadComplete
  561. * event is fired.
  562. *
  563. * @method _transitionInit
  564. * @param imageInfo {Object} The imageInfo to load before transitioning.
  565. * @protected
  566. */
  567. _transitionInit: function(imageInfo)
  568. {
  569. this._transitioning = true;
  570. // Disable gestures if set.
  571. if(this._gestures) {
  572. this._gestures.disable();
  573. }
  574. /**
  575. * Fires when the next image is loading before a new transition.
  576. *
  577. * @event transitionInit
  578. */
  579. this.fire('transitionInit');
  580. if(imageInfo) {
  581. this._nextImage.once('loadComplete', this._transitionStart, this);
  582. this._nextImage.load(imageInfo);
  583. }
  584. else {
  585. this._transitionStart();
  586. }
  587. },
  588. /**
  589. * Fires the transitionStart event and starts the transition
  590. * using a new instance of FL.SlideshowTransition.
  591. *
  592. * @method _transitionStart
  593. * @protected
  594. */
  595. _transitionStart: function()
  596. {
  597. var root = this.get('root');
  598. /**
  599. * Fires when the next image has finished loading
  600. * and a new transition starts.
  601. *
  602. * @event transitionStart
  603. */
  604. this.fire('transitionStart');
  605. this._transition = new Y.FL.SlideshowTransition({
  606. itemIn: this._nextImage._imageInfo ? this._nextImage.get('boundingBox') : null,
  607. itemOut: this._activeImage._imageInfo ? this._activeImage.get('boundingBox') : null,
  608. type: this._getTransition(),
  609. duration: root.get('transitionDuration'),
  610. easing: root.get('transitionEasing'),
  611. kenBurnsDuration: root.get('speed')/1000,
  612. kenBurnsZoom: root.get('kenBurnsZoom')
  613. });
  614. if(this._nextImage._imageInfo) {
  615. this._nextImage.get('boundingBox').setStyle('left', '0px');
  616. }
  617. this._transition.once('complete', this._transitionComplete, this);
  618. this._transition.run();
  619. },
  620. /**
  621. * Switches the next and active image variables, unloads the
  622. * last image, fires the transitionComplete event and loads
  623. * or resizes if appropriate.
  624. *
  625. * @method _transitionComplete
  626. * @protected
  627. */
  628. _transitionComplete: function()
  629. {
  630. var root = this.get('root');
  631. // Swap image container references.
  632. this._swapImageRefs();
  633. /**
  634. * Fired when the current transition completes.
  635. *
  636. * @event transitionComplete
  637. */
  638. this.fire('transitionComplete');
  639. this._transition = null;
  640. this._transitioning = false;
  641. // Enable gestures if set.
  642. if(this._gestures) {
  643. if(root && root.albumInfo.images.length <= 1) {
  644. this._gestures.disable();
  645. }
  646. else {
  647. this._gestures.enable();
  648. }
  649. }
  650. // Load from the queue?
  651. if(this._loadQueue) {
  652. this.load(this._loadQueue);
  653. this._loadQueue = null;
  654. }
  655. // Resize the active image?
  656. else if(this._resizeAfterTransition) {
  657. this._resizeAfterTransition = false;
  658. this._activeImage.resize(this.get('width'), this.get('height'));
  659. this._nextImage.resize(this.get('width'), this.get('height'));
  660. }
  661. },
  662. /**
  663. * @method _gesturesMoveStart
  664. * @param e {Object} The event object.
  665. * @protected
  666. */
  667. _gesturesMoveStart: function(e)
  668. {
  669. var index = 0,
  670. root = this.get('root');
  671. index = e.direction == 'next' ? root.imageIndex + 1 : root.imageIndex - 1;
  672. index = index < 0 ? root.albumInfo.images.length - 1 : index;
  673. index = index >= root.albumInfo.images.length ? 0 : index;
  674. root.pause();
  675. root._hideLoadingImage();
  676. root._showLoadingImageWithDelay();
  677. Y.FL.SlideshowImageLoader.removeGroup(this._nextImage.get('loadGroup'));
  678. this._nextImage.once('loadComplete', root._hideLoadingImage, root);
  679. this._nextImage.load(root.albumInfo.images[index]);
  680. },
  681. /**
  682. * @method _gesturesEndComplete
  683. * @protected
  684. */
  685. _gesturesEndComplete: function()
  686. {
  687. var root = this.get('root'),
  688. index = 0;
  689. if(this._nextImage._imageInfo){
  690. index = this._nextImage._imageInfo.index;
  691. this._swapImageRefs();
  692. this._imageInfo = root.albumInfo.images[index];
  693. root.loadImage(index);
  694. }
  695. },
  696. /**
  697. * @method _swapImageRefs
  698. * @protected
  699. */
  700. _swapImageRefs: function()
  701. {
  702. var active = this._activeImage;
  703. this._activeImage = this._nextImage;
  704. this._nextImage = active;
  705. if(this._nextImage._imageInfo) {
  706. this._nextImage.unload();
  707. this._nextImage.get('boundingBox').setStyle('left', '-9999px');
  708. }
  709. if(this._gestures) {
  710. this._gestures.set('activeItem', this._activeImage.get('boundingBox'));
  711. this._gestures.set('nextItem', this._nextImage.get('boundingBox'));
  712. }
  713. }
  714. }, {
  715. /**
  716. * Custom CSS class name for the widget.
  717. * @property CSS_PREFIX
  718. * @type String
  719. * @protected
  720. * @static
  721. */
  722. CSS_PREFIX: 'fl-slideshow-frame',
  723. /**
  724. * Static property used to define the default attribute configuration of
  725. * the Widget.
  726. *
  727. * @property ATTRS
  728. * @type Object
  729. * @protected
  730. * @static
  731. */
  732. ATTRS: {
  733. /**
  734. * The configuration object used to create new instances of
  735. * FL.SlideshowImage. See the API docs for {@link FL.SlideshowImage}
  736. * for a complete list of configuration attributes.
  737. *
  738. * @attribute imageConfig
  739. * @type Object
  740. * @default null
  741. */
  742. imageConfig: {
  743. value: null
  744. },
  745. /**
  746. * Whether to use touch gestures, when available,
  747. * to transition between images or not.
  748. *
  749. * @attribute touchSupport
  750. * @type Boolean
  751. * @default false
  752. */
  753. touchSupport: {
  754. value: false
  755. }
  756. }
  757. });
  758. /**
  759. * A plugin for fullscreen slideshow functionality.
  760. *
  761. * @namespace FL
  762. * @class SlideshowFullscreen
  763. * @constructor
  764. * @param config {Object} Configuration object
  765. * @extends Plugin.Base
  766. */
  767. Y.namespace('FL').SlideshowFullscreen = Y.Base.create('fl-slideshow-fullscreen', Y.Plugin.Base, [], {
  768. /**
  769. * Flag for whether the slideshow is in
  770. * fullscreen mode.
  771. *
  772. * @property active
  773. * @type Boolean
  774. * @default false
  775. */
  776. active: false,
  777. /**
  778. * A div containing the close message.
  779. *
  780. * @property _closeMessage
  781. * @type Node
  782. * @default null
  783. * @protected
  784. */
  785. _closeMessage: null,
  786. /**
  787. * A timer for hiding the close message.
  788. *
  789. * @property _closeMessageTimer
  790. * @type Object
  791. * @default null
  792. * @protected
  793. */
  794. _closeMessageTimer: null,
  795. /**
  796. * The initial styles of the host's bounding box
  797. * before entering fullscreen mode.
  798. *
  799. * @property _initialStyles
  800. * @type Object
  801. * @protected
  802. */
  803. _initialStyles: {
  804. position: 'static',
  805. top: '0px',
  806. left: '0px'
  807. },
  808. /**
  809. * @method initializer
  810. * @protected
  811. */
  812. initializer: function()
  813. {
  814. var host = this.get('host'),
  815. bb = host.get('boundingBox'),
  816. self = this;
  817. bb.addClass('fl-fullscreen-enabled');
  818. if(Y.FL.SlideshowFullscreen.OS_SUPPORT) {
  819. document.addEventListener('fullscreenchange', function(){ self._osChange(); }, false);
  820. document.addEventListener('mozfullscreenchange', function(){ self._osChange(); }, false);
  821. document.addEventListener('webkitfullscreenchange', function(){ self._osChange(); }, false);
  822. }
  823. else {
  824. this._renderCloseMessage();
  825. }
  826. },
  827. /**
  828. * Exits fullscreen if it is currently active
  829. * otherwise it enters fullscreen.
  830. *
  831. * @method toggle
  832. */
  833. toggle: function()
  834. {
  835. if(this.active) {
  836. this.exit();
  837. }
  838. else {
  839. this.enter();
  840. }
  841. },
  842. /**
  843. * Enters OS fullscreen mode if supported, otherwise
  844. * the slideshow takes over the browser window.
  845. *
  846. * @method enter
  847. */
  848. enter: function()
  849. {
  850. if(Y.FL.SlideshowFullscreen.OS_SUPPORT) {
  851. this._osEnter();
  852. }
  853. else {
  854. this._browserEnter();
  855. }
  856. },
  857. /**
  858. * Exits fullscreen mode.
  859. *
  860. * @method exit
  861. */
  862. exit: function()
  863. {
  864. if(Y.FL.SlideshowFullscreen.OS_SUPPORT) {
  865. this._osExit();
  866. }
  867. else {
  868. this._browserExit();
  869. }
  870. },
  871. /**
  872. * Enters OS fullscreen mode.
  873. *
  874. * @method _osEnter
  875. * @protected
  876. */
  877. _osEnter: function()
  878. {
  879. var bbNode = this.get('host').get('boundingBox')._node;
  880. if(bbNode.webkitRequestFullScreen) {
  881. bbNode.webkitRequestFullScreen();
  882. }
  883. else if(bbNode.mozRequestFullScreen) {
  884. bbNode.mozRequestFullScreen();
  885. }
  886. else if(bbNode.requestFullScreen) {
  887. bbNode.requestFullScreen();
  888. }
  889. },
  890. /**
  891. * Exits OS fullscreen mode.
  892. *
  893. * @method _osExit
  894. * @protected
  895. */
  896. _osExit: function()
  897. {
  898. if(document.exitFullscreen) {
  899. document.exitFullscreen();
  900. }
  901. else if(document.mozCancelFullScreen) {
  902. document.mozCancelFullScreen();
  903. }
  904. else if(document.webkitCancelFullScreen) {
  905. document.webkitCancelFullScreen();
  906. }
  907. },
  908. /**
  909. * Called when the OS fullscreenchange event fires and enters
  910. * or exits standard fullscreen mode which positions and
  911. * resizes the slideshow.
  912. *
  913. * @method _osChange
  914. * @protected
  915. */
  916. _osChange: function()
  917. {
  918. var host = this.get('host');
  919. // Transitions break on Safari while entering and
  920. // exiting fullscreen. This fixes them!
  921. if(host.frame && host.frame._transitioning) {
  922. host.frame._transitionComplete();
  923. }
  924. if(this.active) {
  925. this._exit();
  926. }
  927. else {
  928. this._enter();
  929. }
  930. },
  931. /**
  932. * Enter browser fullscreen mode.
  933. *
  934. * @method _browserEnter
  935. * @protected
  936. */
  937. _browserEnter: function()
  938. {
  939. var bb = this.get('host').get('boundingBox');
  940. this._initialStyles = {
  941. position: bb.getStyle('position'),
  942. top: bb.getStyle('top'),
  943. left: bb.getStyle('left'),
  944. zIndex: bb.getStyle('zIndex')
  945. };
  946. bb.setStyles({
  947. position: 'fixed',
  948. top: '0px',
  949. left: '0px',
  950. zIndex: 10000
  951. });
  952. Y.Node.one('body').on('fl-fullscreen|keydown', Y.bind(this._onKey, this));
  953. this._showCloseMessage();
  954. this._enter();
  955. },
  956. /**
  957. * Exit browser fullscreen mode.
  958. *
  959. * @method _browserExit
  960. * @protected
  961. */
  962. _browserExit: function()
  963. {
  964. var bb = this.get('host').get('boundingBox');
  965. bb.setStyles({
  966. position: this._initialStyles.position,
  967. top: this._initialStyles.top,
  968. left: this._initialStyles.left,
  969. zIndex: this._initialStyles.zIndex
  970. });
  971. Y.Node.one('body').detach('fl-fullscreen|keydown');
  972. this._hideCloseMessage();
  973. this._exit();
  974. },
  975. /**
  976. * Enters fullscreen mode.
  977. *
  978. * @method _enter
  979. * @protected
  980. */
  981. _enter: function()
  982. {
  983. var host = this.get('host'),
  984. bb = host.get('boundingBox');
  985. bb.addClass('fl-fullscreen-active');
  986. this.active = true;
  987. host.resize();
  988. },
  989. /**
  990. * Exits fullscreen mode.
  991. *
  992. * @method _exit
  993. * @protected
  994. */
  995. _exit: function()
  996. {
  997. var host = this.get('host'),
  998. bb = host.get('boundingBox');
  999. bb.removeClass('fl-fullscreen-active');
  1000. this.active = false;
  1001. host.resize();
  1002. },
  1003. /**
  1004. * Keyboard input for the esc button.
  1005. *
  1006. * @method _onKey
  1007. * @protected
  1008. */
  1009. _onKey: function(e)
  1010. {
  1011. if(e.keyCode == 27) {
  1012. this.exit();
  1013. return false;
  1014. }
  1015. },
  1016. /**
  1017. * Creates the close message if one is
  1018. * not already available in the document.
  1019. *
  1020. * @method _initCloseMessage
  1021. * @protected
  1022. */
  1023. _renderCloseMessage: function()
  1024. {
  1025. this._closeMessage = Y.Node.create('<div class="fl-fullscreen-close-message"></div>');
  1026. this._closeMessage.set('innerHTML', '<span>Press the "esc" button to exit fullscreen mode.</span>');
  1027. this._closeMessage.setStyle('display', 'none');
  1028. this.get('host').get('boundingBox').insert(this._closeMessage);
  1029. },
  1030. /**
  1031. * Shows the close message.
  1032. *
  1033. * @method _showCloseMessage
  1034. * @protected
  1035. */
  1036. _showCloseMessage: function()
  1037. {
  1038. if(this._closeMessageTimer) {
  1039. this._closeMessageTimer.cancel();
  1040. this._closeMessageTimer = null;
  1041. }
  1042. this._closeMessage.show(true);
  1043. this._closeMessageTimer = Y.later(4000, this, this._hideCloseMessage);
  1044. },
  1045. /**
  1046. * Hides the close message.
  1047. *
  1048. * @method _hideCloseMessage
  1049. * @protected
  1050. */
  1051. _hideCloseMessage: function()
  1052. {
  1053. if(this._closeMessageTimer) {
  1054. this._closeMessageTimer.cancel();
  1055. this._closeMessageTimer = null;
  1056. }
  1057. this._closeMessage.hide(true);
  1058. }
  1059. }, {
  1060. /**
  1061. * Namespace for the plugin.
  1062. *
  1063. * @property NS
  1064. * @type String
  1065. * @protected
  1066. * @static
  1067. */
  1068. NS: 'fullscreen',
  1069. OS_SUPPORT: (function(){
  1070. var doc = document.documentElement;
  1071. return doc.webkitRequestFullScreen || doc.mozRequestFullScreen || doc.requestFullScreen;
  1072. })()
  1073. });
  1074. /**
  1075. * Provides functionality for gesture based transitions
  1076. * between two slideshow components.
  1077. *
  1078. * @namespace FL
  1079. * @class SlideshowGestures
  1080. * @constructor
  1081. * @param config {Object} Configuration object
  1082. * @extends Base
  1083. */
  1084. Y.namespace('FL').SlideshowGestures = Y.Base.create('fl-slideshow-gestures', Y.Base, [], {
  1085. /**
  1086. * The x coordinate for where a gesture event starts.
  1087. *
  1088. * @property _startX
  1089. * @type Number
  1090. * @default null
  1091. * @protected
  1092. */
  1093. _startX: null,
  1094. /**
  1095. * The y coordinate for where a gesture event starts.
  1096. *
  1097. * @property _startY
  1098. * @type Number
  1099. * @default null
  1100. * @protected
  1101. */
  1102. _startY: null,
  1103. /**
  1104. * A flag for whether a gesture is moving or not.
  1105. *
  1106. * @property _moving
  1107. * @type Boolean
  1108. * @default false
  1109. * @protected
  1110. */
  1111. _touchMoving: false,
  1112. /**
  1113. * Whether the gesture is moving or not.
  1114. *
  1115. * @property _moving
  1116. * @type Boolean
  1117. * @default false
  1118. * @protected
  1119. */
  1120. _moving: false,
  1121. /**
  1122. * The direction the current gesture event
  1123. * is moving in (either next or prev).
  1124. *
  1125. * @property _movingDirection
  1126. * @type String
  1127. * @default null
  1128. * @protected
  1129. */
  1130. _movingDirection: null,
  1131. /**
  1132. * A flag for whether a gesture gesture is currently
  1133. * transitioning or not.
  1134. *
  1135. * @property _transitioning
  1136. * @type Boolean
  1137. * @default false
  1138. * @protected
  1139. */
  1140. _transitioning: false,
  1141. /**
  1142. * @method initializer
  1143. * @protected
  1144. */
  1145. initializer: function()
  1146. {
  1147. this.enable();
  1148. },
  1149. /**
  1150. * @method enable
  1151. */
  1152. enable: function()
  1153. {
  1154. var id = this.get('id'),
  1155. direction = this.get('direction'),
  1156. active = this.get('activeItem'),
  1157. next = this.get('nextItem');
  1158. active.on(id + '|gesturemovestart', Y.bind(this._onStart, this));
  1159. next.on(id + '|gesturemovestart', Y.bind(this._onStart, this));
  1160. next.on(id + '|transitionend', Y.bind(this._onEndComplete, this) );
  1161. next.on(id + '|oTransitionEnd', Y.bind(this._onEndComplete, this) );
  1162. next.on(id + '|webkitTransitionEnd', Y.bind(this._onEndComplete, this) );
  1163. if(direction == 'horizontal') {
  1164. active.on(id + '|gesturemovehorizontal', Y.bind(this._onMoveHorizontal, this));
  1165. active.on(id + '|gesturemovehorizontalend', Y.bind(this._onEndHorizontal, this));
  1166. next.on(id + '|gesturemovehorizontal', Y.bind(this._onMoveHorizontal, this));
  1167. next.on(id + '|gesturemovehorizontalend', Y.bind(this._onEndHorizontal, this));
  1168. }
  1169. else {
  1170. active.on(id + '|gesturemovevertical', Y.bind(this._onMoveVertical, this));
  1171. active.on(id + '|gesturemoveverticalend', Y.bind(this._onEndVertical, this));
  1172. next.on(id + '|gesturemovevertical', Y.bind(this._onMoveVertical, this));
  1173. next.on(id + '|gesturemoveverticalend', Y.bind(this._onEndVertical, this));
  1174. }
  1175. },
  1176. /**
  1177. * @method disable
  1178. */
  1179. disable: function()
  1180. {
  1181. var id = this.get('id'),
  1182. active = this.get('activeItem'),
  1183. next = this.get('nextItem');
  1184. active.detach(id + '|*');
  1185. next.detach(id + '|*');
  1186. },
  1187. /**
  1188. * @method _onStart
  1189. * @param e {Object} The event object.
  1190. * @protected
  1191. */
  1192. _onStart: function(e)
  1193. {
  1194. var direction = this.get('direction');
  1195. if(this._transitioning) {
  1196. this._onEndComplete();
  1197. }
  1198. if(direction == 'horizontal') {
  1199. this._startX = e.pageX;
  1200. }
  1201. else {
  1202. this._startY = e.pageY;
  1203. }
  1204. /**
  1205. * @event start
  1206. */
  1207. this.fire('start');
  1208. },
  1209. /**
  1210. * @method _onMoveHorizontal
  1211. * @param e {Object} The event object.
  1212. * @protected
  1213. */
  1214. _onMoveHorizontal: function(e)
  1215. {
  1216. var x = this._startX - e.pageX,
  1217. active = this.get('activeItem'),
  1218. next = this.get('nextItem'),
  1219. width = parseInt(active.getComputedStyle('width'), 10),
  1220. translate = x < 0 ? Math.abs(x) : -x,
  1221. direction = x < 0 ? 'prev' : 'next';
  1222. e.preventDefault();
  1223. if(!this._moving || this._movingDirection != direction) {
  1224. active.setStyle('left', 0);
  1225. next.setStyles({
  1226. 'opacity': 1,
  1227. 'left': x < 0 ? -width : width
  1228. });
  1229. this._moving = true;
  1230. this._movingDirection = direction;
  1231. /**
  1232. * @event moveStart
  1233. */
  1234. this.fire('moveStart', { direction: direction });
  1235. }
  1236. active.setStyle('-webkit-transform', 'translate('+ translate +'px, 0px) translateZ(0px)');
  1237. active.setStyle('-ms-transform', 'translate('+ translate +'px, 0px) translateZ(0px)');
  1238. next.setStyle('-webkit-transform', 'translate('+ translate +'px, 0px) translateZ(0px)');
  1239. next.setStyle('-ms-transform', 'translate('+ translate +'px, 0px) translateZ(0px)');
  1240. /**
  1241. * @event move
  1242. */
  1243. this.fire('move');
  1244. },
  1245. /**
  1246. * @method _onMoveVertical
  1247. * @param e {Object} The event object.
  1248. * @protected
  1249. */
  1250. _onMoveVertical: function(e)
  1251. {
  1252. var y = this._startY - e.pageY,
  1253. active = this.get('activeItem'),
  1254. next = this.get('nextItem'),
  1255. height = parseInt(active.getComputedStyle('height'), 10),
  1256. translate = y < 0 ? Math.abs(y) : -y,
  1257. direction = y < 0 ? 'prev' : 'next';
  1258. e.preventDefault();
  1259. if(!this._moving || this._movingDirection != direction) {
  1260. active.setStyle('top', 0);
  1261. next.setStyles({
  1262. 'opacity': 1,
  1263. 'left' : 'auto',
  1264. 'top': y < 0 ? -height : height
  1265. });
  1266. this._moving = true;
  1267. this._movingDirection = direction;
  1268. /**
  1269. * @event moveStart
  1270. */
  1271. this.fire('moveStart', { direction: direction });
  1272. }
  1273. active.setStyle('-webkit-transform', 'translate(0px, '+ translate +'px) translateZ(0px)');
  1274. active.setStyle('-ms-transform', 'translate(0px, '+ translate +'px) translateZ(0px)');
  1275. next.setStyle('-webkit-transform', 'translate(0px, '+ translate +'px) translateZ(0px)');
  1276. next.setStyle('-ms-transform', 'translate(0px, '+ translate +'px) translateZ(0px)');
  1277. /**
  1278. * @event move
  1279. */
  1280. this.fire('move');
  1281. },
  1282. /**
  1283. * @method _onEndHorizontal
  1284. * @param e {Object} The event object.
  1285. * @protected
  1286. */
  1287. _onEndHorizontal: function(e)
  1288. {
  1289. if(!this._moving) {
  1290. return;
  1291. }
  1292. var x = this._startX - e.pageX,
  1293. active = this.get('activeItem'),
  1294. next = this.get('nextItem'),
  1295. width = parseInt(next.getComputedStyle('width'), 10),
  1296. translate = x < 0 ? width : -width;
  1297. active.transition({
  1298. 'transform': 'translate('+ translate +'px, 0px)'
  1299. });
  1300. next.transition({
  1301. 'transform': 'translate('+ translate +'px, 0px)'
  1302. });
  1303. this._transitioning = true;
  1304. /**
  1305. * @event end
  1306. */
  1307. this.fire('end');
  1308. },
  1309. /**
  1310. * @method _onEndVertical
  1311. * @param e {Object} The event object.
  1312. * @protected
  1313. */
  1314. _onEndVertical: function(e)
  1315. {
  1316. if(!this._moving) {
  1317. return;
  1318. }
  1319. var y = this._startY - e.pageY,
  1320. active = this.get('activeItem'),
  1321. next = this.get('nextItem'),
  1322. height = parseInt(next.getComputedStyle('height'), 10),
  1323. translate = y < 0 ? height : -height;
  1324. active.transition({
  1325. 'transform': 'translate(0px, '+ translate +'px)'
  1326. });
  1327. next.transition({
  1328. 'transform': 'translate(0px, '+ translate +'px)'
  1329. });
  1330. this._transitioning = true;
  1331. /**
  1332. * @event end
  1333. */
  1334. this.fire('end');
  1335. },
  1336. /**
  1337. * @method _onEndComplete
  1338. * @protected
  1339. */
  1340. _onEndComplete: function()
  1341. {
  1342. var direction = this.get('direction'),
  1343. active = this.get('activeItem'),
  1344. next = this.get('nextItem');
  1345. active.setStyles({
  1346. 'opacity': 0,
  1347. '-webkit-transform': '',
  1348. '-webkit-transition': '',
  1349. '-ms-transform': '',
  1350. '-ms-transition': ''
  1351. });
  1352. next.setStyles({
  1353. '-webkit-transform': '',
  1354. '-webkit-transition': '',
  1355. '-ms-transform': '',
  1356. '-ms-transition': ''
  1357. });
  1358. if(direction == 'horizontal') {
  1359. active.setStyle('left', '-9999px');
  1360. next.setStyle('left', '0px');
  1361. }
  1362. else {
  1363. active.setStyle('top', '-9999px');
  1364. next.setStyle('top', '0px');
  1365. }
  1366. this.set('activeItem', next);
  1367. this.set('nextItem', active);
  1368. this._moving = false;
  1369. this._movingDirection = null;
  1370. this._transitioning = false;
  1371. /**
  1372. * @event endComplete
  1373. */
  1374. this.fire('endComplete');
  1375. }
  1376. }, {
  1377. /**
  1378. * Static property used to define the default attribute configuration of
  1379. * the Widget.
  1380. *
  1381. * @property ATTRS
  1382. * @type Object
  1383. * @protected
  1384. * @static
  1385. */
  1386. ATTRS: {
  1387. /**
  1388. * The gesture direction to use. Possible values are
  1389. * horizontal and vertical.
  1390. *
  1391. * @attribute direction
  1392. * @type String
  1393. * @default horizontal
  1394. */
  1395. direction: {
  1396. value: 'horizontal'
  1397. },
  1398. /**
  1399. * The Node that is currently visible.
  1400. *
  1401. * @attribute activeItem
  1402. * @type Node
  1403. * @default null
  1404. */
  1405. activeItem: {
  1406. value: null
  1407. },
  1408. /**
  1409. * The Node that will be transitioned in.
  1410. *
  1411. * @attribute nextItem
  1412. * @type Node
  1413. * @default null
  1414. */
  1415. nextItem: {
  1416. value: null
  1417. }
  1418. }
  1419. });
  1420. /**
  1421. * A load queue for slideshow images.
  1422. *
  1423. * @namespace FL
  1424. * @class SlideshowImageLoader
  1425. * @static
  1426. */
  1427. Y.namespace('FL').SlideshowImageLoader = {
  1428. /**
  1429. * Whether an image is being loaded or not.
  1430. *
  1431. * @property _loading
  1432. * @type Boolean
  1433. * @default false
  1434. * @protected
  1435. */
  1436. _loading: false,
  1437. /**
  1438. * An node for loading the next image.
  1439. *
  1440. * @property _currentImage
  1441. * @type Node
  1442. * @default null
  1443. * @protected
  1444. */
  1445. _currentImage: null,
  1446. /**
  1447. * An object containing the group, src and callback
  1448. * for the current image that is being loaded.
  1449. *
  1450. * @property _currentImageData
  1451. * @type Object
  1452. * @default null
  1453. * @protected
  1454. */
  1455. _currentImageData: null,
  1456. /**
  1457. * An array of image data objects that contain the group,
  1458. * src and callback for each image that will be loaded.
  1459. *
  1460. * @property _queue
  1461. * @type Array
  1462. * @default []
  1463. * @protected
  1464. */
  1465. _queue: [],
  1466. /**
  1467. * Adds an image to the queue.
  1468. *
  1469. * @method add
  1470. * @param group {String} The group this image is associated with.
  1471. * Used to remove images in bulk.
  1472. * @param src {String} The image url to load.
  1473. * @param callback {Function} A function to call when the image
  1474. * has finished loading.
  1475. * @param bump {Boolean} If true, the image will be added to
  1476. * the first position in the queue.
  1477. */
  1478. add: function(group, src, callback, bump)
  1479. {
  1480. var imgData = {
  1481. group : group,
  1482. src : src,
  1483. callback : callback
  1484. };
  1485. if(bump) {
  1486. this._queue.unshift(imgData);
  1487. }
  1488. else {
  1489. this._queue.push(imgData);
  1490. }
  1491. if(!this._loading) {
  1492. this._load();
  1493. }
  1494. },
  1495. /**
  1496. * Removes a group of images from the queue.
  1497. *
  1498. * @method removeGroup
  1499. * @param group {String} The group to remove.
  1500. */
  1501. removeGroup: function(group)
  1502. {
  1503. var i = this._queue.length - 1;
  1504. for( ; i > -1 ; i--) {
  1505. if(this._queue[i].group == group) {
  1506. this._queue.splice(i, 1);
  1507. }
  1508. }
  1509. if(this._currentImageData && this._currentImageData.group == group) {
  1510. this._currentImage.detachAll();
  1511. this._currentImage = null;
  1512. this._currentImageData = null;
  1513. if(this._queue.length > 0) {
  1514. this._load();
  1515. }
  1516. else {
  1517. this._loading = false;
  1518. }
  1519. }
  1520. },
  1521. /**
  1522. * Loads the next image in the queue.
  1523. *
  1524. * @method _load
  1525. * @protected
  1526. */
  1527. _load: function()
  1528. {
  1529. this._loading = true;
  1530. this._currentImageData = this._queue.shift();
  1531. this._currentImage = Y.Node.create('<img />');
  1532. this._currentImage.on('error', Y.bind(this._loadComplete, this));
  1533. this._currentImage.on('load', Y.bind(this._loadComplete, this));
  1534. this._currentImage.set('src', this._currentImageData.src);
  1535. },
  1536. /**
  1537. * Calls the current image's callback function if set
  1538. * and loads the next image if the queue is not empty.
  1539. *
  1540. * @method _loadComplete
  1541. * @protected
  1542. */
  1543. _loadComplete: function()
  1544. {
  1545. if(this._currentImageData.callback) {
  1546. this._currentImageData.callback(this._currentImage);
  1547. }
  1548. if(this._queue.length > 0) {
  1549. this._load();
  1550. }
  1551. else {
  1552. this._loading = false;
  1553. this._currentImage = null;
  1554. this._currentImageData = null;
  1555. }
  1556. }
  1557. };
  1558. /**
  1559. * Loads an image or video using the provided imageInfo object.
  1560. *
  1561. * @namespace FL
  1562. * @class SlideshowImage
  1563. * @constructor
  1564. * @param config {Object} Configuration object
  1565. * @extends Widget
  1566. */
  1567. Y.namespace('FL').SlideshowImage = Y.Base.create('fl-slideshow-image', Y.Widget, [Y.WidgetChild], {
  1568. /**
  1569. * The imageInfo object used to load the image and
  1570. * its various sizes.
  1571. *
  1572. * @property info
  1573. * @type Object
  1574. * @default null
  1575. * @protected
  1576. */
  1577. _imageInfo: null,
  1578. /**
  1579. * A reference to the current image node in the bounding box.
  1580. *
  1581. * @property _image
  1582. * @type Node
  1583. * @default null
  1584. * @protected
  1585. */
  1586. _image: null,
  1587. /**
  1588. * Whether or not new imageInfo is loading.
  1589. *
  1590. * @property _loading
  1591. * @type Boolean
  1592. * @default false
  1593. * @protected
  1594. */
  1595. _loading: false,
  1596. /**
  1597. * The URL that is currently being loaded.
  1598. *
  1599. * @property _loadingURL
  1600. * @type Boolean
  1601. * @default null
  1602. * @protected
  1603. */
  1604. _loadingURL: null,
  1605. /**
  1606. * An anchor node used for the video play button.
  1607. *
  1608. * @property _videoButton
  1609. * @type Node
  1610. * @default null
  1611. * @protected
  1612. */
  1613. _videoButton: null,
  1614. /**
  1615. * A div node used to hold the video iframe.
  1616. *
  1617. * @property _videoBox
  1618. * @type Node
  1619. * @default null
  1620. * @protected
  1621. */
  1622. _videoBox: null,
  1623. /**
  1624. * An iframe node used to render the video.
  1625. *
  1626. * @property _video
  1627. * @type Node
  1628. * @default null
  1629. * @protected
  1630. */
  1631. _video: null,
  1632. /**
  1633. * The default content template for the image
  1634. * inherited from Y.Widget. Set to null since
  1635. * only the bounding box is needed.
  1636. *
  1637. * @property CONTENT_TEMPLATE
  1638. * @type String
  1639. * @default null
  1640. * @protected
  1641. */
  1642. CONTENT_TEMPLATE: null,
  1643. /**
  1644. * Initial styling for the bounding box.
  1645. *
  1646. * @method syncUI
  1647. * @protected
  1648. */
  1649. syncUI: function()
  1650. {
  1651. var bb = this.get('boundingBox');
  1652. if(this.get('crop')) {
  1653. bb.setStyle('overflow', 'hidden');
  1654. bb.addClass('fl-slideshow-image-cropped');
  1655. }
  1656. },
  1657. /**
  1658. * Sets the imageInfo object and
  1659. * loads the appropriate image size.
  1660. *
  1661. * @method load
  1662. * @param imageInfo {Object} The imageInfo object.
  1663. */
  1664. load: function(imageInfo)
  1665. {
  1666. this._imageInfo = imageInfo;
  1667. this._loading = true;
  1668. this._load();
  1669. },
  1670. /**
  1671. * Sets the width and height of the bounding box and
  1672. * preloads an image using the provided imageInfo object.
  1673. *
  1674. * @method preload
  1675. * @param imageInfo {Object} The imageInfo to preload.
  1676. * @param width {Number} The width to preload.
  1677. * @param height {Number} The height to preload.
  1678. */
  1679. preload: function(imageInfo, width, height)
  1680. {
  1681. var isVideo = this._isVideo(),
  1682. loadVideos = this.get('loadVideos'),
  1683. showVideoButton = this.get('showVideoButton');
  1684. this.unload();
  1685. this.set('width', width);
  1686. this.set('height', height);
  1687. this._imageInfo = imageInfo;
  1688. if(!isVideo || !loadVideos || (isVideo && loadVideos && showVideoButton)) {
  1689. Y.FL.SlideshowImageLoader.add(
  1690. this.get('loadGroup'),
  1691. this._getImageURL(),
  1692. Y.bind(this._imagePreloaded, this),
  1693. this.get('loadPriority')
  1694. );
  1695. }
  1696. },
  1697. /**
  1698. * Called when preloading completes.
  1699. *
  1700. * @method _imagePreloaded
  1701. * @param img {Object} The image that was preloaded.
  1702. * @protected
  1703. */
  1704. _imagePreloaded: function(img)
  1705. {
  1706. this._image = img;
  1707. },
  1708. /**
  1709. * Unloads the image if there is one loaded
  1710. * and sets the imageInfo object to null.
  1711. *
  1712. * @method unload
  1713. */
  1714. unload: function()
  1715. {
  1716. if(this._image) {
  1717. this._image.remove();
  1718. this._image.detachAll();
  1719. this._image.set('src', '');
  1720. this._image = null;
  1721. }
  1722. if(this._video) {
  1723. this._video.remove();
  1724. this._video = null;
  1725. }
  1726. if(this._videoButton) {
  1727. this._videoButton.remove();
  1728. this._videoButton = null;
  1729. }
  1730. if(this._videoBox) {
  1731. this._removeVideoBox();
  1732. }
  1733. this._imageInfo = null;
  1734. this._loading = false;
  1735. this._loadingURL = null;
  1736. },
  1737. /**
  1738. * Resizes the bounding box and loads the
  1739. * appropriate image size if necessary.
  1740. *
  1741. * @method resize
  1742. * @param width {Number} The width value.
  1743. * @param height {Number} The height value.
  1744. */
  1745. resize: function(width, height)
  1746. {
  1747. var borderWidth = parseInt(this.get('boundingBox').getComputedStyle('borderTopWidth'), 10) * 2,
  1748. bb = this.get('boundingBox');
  1749. this.set('width', width - borderWidth);
  1750. this.set('height', height - borderWidth);
  1751. bb.setStyle('width', width - borderWidth + 'px');
  1752. bb.setStyle('height', height - borderWidth + 'px');
  1753. if(this._videoButton) {
  1754. this._positionVideoButton();
  1755. }
  1756. if(this._videoBox) {
  1757. this._loadVideo();
  1758. }
  1759. if(!this._loading) {
  1760. if(this._imageInfo) {
  1761. this._load();
  1762. }
  1763. if(this._image) {
  1764. this._positionImage();
  1765. }
  1766. }
  1767. },
  1768. /**
  1769. * Loads (or reloads) the image or video.
  1770. *
  1771. * @method _load
  1772. * @protected
  1773. */
  1774. _load: function()
  1775. {
  1776. var loadVideos = this.get('loadVideos'),
  1777. showVideoButton = this.get('showVideoButton');
  1778. if(this._isVideo() && loadVideos && !showVideoButton && !('ontouchstart' in window)) {
  1779. this._loadVideo();
  1780. }
  1781. else {
  1782. this._loadImage();
  1783. }
  1784. },
  1785. /**
  1786. * Loads the appropriate image size if
  1787. * it is not already loading.
  1788. *
  1789. * @method _loadImage
  1790. * @protected
  1791. */
  1792. _loadImage: function()
  1793. {
  1794. var url = this._getImageURL(),
  1795. loadVideos = this.get('loadVideos');
  1796. // Already loading.
  1797. if(url == this._loadingURL) {
  1798. return;
  1799. }
  1800. // New URL to load.
  1801. this._loadingURL = url;
  1802. // Load the new image.
  1803. Y.FL.SlideshowImageLoader.add(
  1804. this.get('loadGroup'),
  1805. this._loadingURL,
  1806. Y.bind(this._loadImageComplete, this),
  1807. this.get('loadPriority')
  1808. );
  1809. // Initial load?
  1810. if(this._loading) {
  1811. if(this._isVideo() && loadVideos) {
  1812. this._insertVideoButton();
  1813. }
  1814. /**
  1815. * Only fires when a new image is being
  1816. * loaded, not a different size.
  1817. *
  1818. * @event loadStart
  1819. */
  1820. this.fire('loadStart');
  1821. }
  1822. },
  1823. /**
  1824. * Fires when the image has finished loading.
  1825. *
  1826. * @method _loadImageComplete
  1827. * @protected
  1828. */
  1829. _loadImageComplete: function(img)
  1830. {
  1831. var bb = this.get('boundingBox'),
  1832. showVideoButton = this.get('showVideoButton'),
  1833. showAria = this.get('root').get('bgslideshow')
  1834. this._image = img;
  1835. this._image.setStyle('visibility', 'hidden');
  1836. this._image.addClass('fl-slideshow-image-img');
  1837. if( showAria ) {
  1838. this._image.set( 'aria-hidden', 'true')
  1839. this._image.set( 'alt', "")
  1840. }
  1841. else {
  1842. this._image.set( 'alt', this._imageInfo.alt )
  1843. }
  1844. // Remove load events.
  1845. this._image.detachAll();
  1846. // Remove previous videos.
  1847. if(this._video && !showVideoButton) {
  1848. this._video.remove();
  1849. this._video = null;
  1850. }
  1851. // Remove the old image.
  1852. bb.all('img').remove();
  1853. // Append the new image.
  1854. bb.append(this._image);
  1855. // Setup, scale and position the new image.
  1856. this._setupImage();
  1857. this._resizeImage();
  1858. this._positionImage();
  1859. this._image.setStyle('visibility', 'visible');
  1860. // Clear the loading url.
  1861. this._loadingURL = null;
  1862. // Finish an initial load?
  1863. if(this._loading) {
  1864. this._loading = false;
  1865. /**
  1866. * Only fires when a new image is being
  1867. * loaded, not a different size.
  1868. *
  1869. * @event loadComplete
  1870. */
  1871. this.fire('loadComplete');
  1872. }
  1873. },
  1874. /**
  1875. * UI setup for the new image.
  1876. *
  1877. * @method _setupImage
  1878. * @protected
  1879. */
  1880. _setupImage: function()
  1881. {
  1882. var bb = this.get('boundingBox');
  1883. // IE interpolation
  1884. if(typeof this._image._node.style.msInterpolationMode != 'undefined') {
  1885. this._image._node.style.msInterpolationMode = 'bicubic';
  1886. }
  1887. // Protection
  1888. if(this.get('protect')) {
  1889. bb.delegate('contextmenu', this._protectImage, 'img');
  1890. bb.delegate('mousedown', this._protectImage, 'img');
  1891. }
  1892. },
  1893. /**
  1894. * Fires on contextmenu or mousedown in attempt
  1895. * to keep the image from being copied.
  1896. *
  1897. * @method _protectImage
  1898. * @return {Boolean} Returns false to prevent the default event.
  1899. * @protected
  1900. */
  1901. _protectImage: function(e)
  1902. {
  1903. e.preventDefault();
  1904. return false;
  1905. },
  1906. /**
  1907. * Resizes the image node.
  1908. *
  1909. * @method _resizeImage
  1910. * @protected
  1911. */
  1912. _resizeImage: function()
  1913. {
  1914. var borderWidth = parseInt(this._image.getComputedStyle('borderTopWidth'), 10) * 2,
  1915. imageWidth = this._image.get('width'),
  1916. imageHeight = this._image.get('height'),
  1917. targetWidth = parseInt(this.get('boundingBox').getComputedStyle('width'), 10),
  1918. targetHeight = parseInt(this.get('boundingBox').getComputedStyle('height'), 10),
  1919. newWidth = 0,
  1920. newHeight = 0,
  1921. xScale = 0,
  1922. yScale = 0,
  1923. cropHorizontalsOnly = this.get('cropHorizontalsOnly'),
  1924. isHorizontal = imageHeight > imageWidth,
  1925. noCrop = false;
  1926. if(this._imageInfo && this.get('checkFilenamesForNoCrop')) {
  1927. noCrop = this._imageInfo.filename.indexOf('nocrop') > -1;
  1928. }
  1929. if(this.get('crop') && !(cropHorizontalsOnly && isHorizontal) && !noCrop) {
  1930. newWidth = targetWidth;
  1931. newHeight = Math.round(imageHeight * targetWidth/imageWidth);
  1932. if(newHeight < targetHeight) {
  1933. newHeight = targetHeight;
  1934. newWidth = Math.round(imageWidth * targetHeight/imageHeight);
  1935. }
  1936. }
  1937. else {
  1938. xScale = imageWidth/targetWidth;
  1939. yScale = imageHeight/targetHeight;
  1940. if (yScale > xScale){
  1941. newWidth = Math.round(imageWidth * (1/yScale));
  1942. newHeight = Math.round(imageHeight * (1/yScale));
  1943. }
  1944. else {
  1945. newWidth = Math.round(imageWidth * (1/xScale));
  1946. newHeight = Math.round(imageHeight * (1/xScale));
  1947. }
  1948. }
  1949. // Don't resize past the original size?
  1950. if(!this.get('crop') && !this.get('upsize') && (newWidth > imageWidth || newHeight > imageHeight)) {
  1951. newWidth = imageWidth;
  1952. newHeight = imageHeight;
  1953. }
  1954. // Compensate for borders.
  1955. newWidth -= borderWidth;
  1956. newHeight -= borderWidth;
  1957. // Resize the image.
  1958. this._image.setStyle('width', newWidth + 'px');
  1959. this._image.setStyle('height', newHeight + 'px');
  1960. // Constrain bounding box to image size.
  1961. if(!this.get('crop') && this.get('constrainWidth')) {
  1962. this.set('width', newWidth + 'px');
  1963. }
  1964. if(!this.get('crop') && this.get('constrainHeight')) {
  1965. this.set('height', newHeight + 'px');
  1966. }
  1967. },
  1968. /**
  1969. * Positions the image within the bounding box.
  1970. *
  1971. * @method _positionImage
  1972. * @protected
  1973. */
  1974. _positionImage: function()
  1975. {
  1976. var pos = this.get('position').split(' '),
  1977. x = pos[0] === '' ? 'center' : pos[0],
  1978. y = pos[1] === '' ? 'center' : pos[1],
  1979. newX = 0,
  1980. newY = 0,
  1981. bbWidth = parseInt(this.get('boundingBox').getComputedStyle('width'), 10),
  1982. bbHeight = parseInt(this.get('boundingBox').getComputedStyle('height'), 10),
  1983. borderWidth = parseInt(this._image.getComputedStyle('borderTopWidth'), 10) * 2,
  1984. imageWidth = parseInt(this._image.getComputedStyle('width'), 10) + borderWidth,
  1985. imageHeight = parseInt(this._image.getComputedStyle('height'), 10) + borderWidth;
  1986. if(isNaN(imageWidth) && isNaN(imageHeight)) {
  1987. return;
  1988. }
  1989. if(x == 'left') {
  1990. newX = 0;
  1991. }
  1992. if(x == 'center') {
  1993. newX = (bbWidth - imageWidth)/2;
  1994. }
  1995. if(x == 'right') {
  1996. newX = bbWidth - imageWidth;
  1997. }
  1998. if(y == 'top') {
  1999. newY = 0;
  2000. }
  2001. if(y == 'center') {
  2002. newY = (bbHeight - imageHeight)/2;
  2003. }
  2004. if(y == 'bottom') {
  2005. newY = bbHeight - imageHeight;
  2006. }
  2007. this._image.setStyles({
  2008. 'left': newX,
  2009. 'top': newY
  2010. });
  2011. },
  2012. /**
  2013. * Gets the appropriate image url based
  2014. * on the size of the bounding box.
  2015. *
  2016. * @method _getImageURL
  2017. * @return {String} The url to load.
  2018. * @protected
  2019. */
  2020. _getImageURL: function()
  2021. {
  2022. var imageWidth = 0,
  2023. imageHeight = 0,
  2024. size = 0,
  2025. targetWidth = this.get('width'),
  2026. targetHeight = this.get('height'),
  2027. useThumbSizes = this.get('useThumbSizes'),
  2028. i = this._imageInfo,
  2029. sizes = [
  2030. i.tinyURL || i.thumbURL || i.largeURL,
  2031. i.thumbURL || i.largeURL,
  2032. i.smallURL || i.largeURL,
  2033. i.mediumURL || i.largeURL || i.smallURL,
  2034. i.largeURL || i.mediumURL || i.smallURL,
  2035. i.xlargeURL || i.largeURL || i.mediumURL || i.smallURL,
  2036. i.x2largeURL || i.largeURL || i.mediumURL || i.smallURL,
  2037. i.x3largeURL || i.x2largeURL || i.largeURL || i.mediumURL || i.smallURL
  2038. ];
  2039. // Width
  2040. if(useThumbSizes && targetWidth <= 100) {
  2041. imageWidth = 0;
  2042. }
  2043. else if(useThumbSizes && targetWidth <= 150) {
  2044. imageWidth = 1;
  2045. }
  2046. else if(targetWidth <= 400) {
  2047. imageWidth = 2;
  2048. }
  2049. else if(targetWidth >= 400 && targetWidth <= 600) {
  2050. imageWidth = 3;
  2051. }
  2052. else if(targetWidth >= 600 && targetWidth <= 800) {
  2053. imageWidth = 4;
  2054. }
  2055. else if(targetWidth >= 800 && targetWidth <= 1024) {
  2056. imageWidth = 5;
  2057. }
  2058. else if(targetWidth >= 1024 && targetWidth <= 1280) {
  2059. imageWidth = 6;
  2060. }
  2061. else {
  2062. imageWidth = 7;
  2063. }
  2064. // Height
  2065. if(useThumbSizes && targetHeight <= 100) {
  2066. imageHeight = 0;
  2067. }
  2068. else if(useThumbSizes && targetHeight <= 150) {
  2069. imageHeight = 1;
  2070. }
  2071. else if(targetHeight <= 300) {
  2072. imageHeight = 2;
  2073. }
  2074. else if(targetHeight >= 300 && targetHeight <= 450) {
  2075. imageHeight = 3;
  2076. }
  2077. else if(targetHeight >= 450 && targetHeight <= 600) {
  2078. imageHeight = 4;
  2079. }
  2080. else if(targetHeight >= 600 && targetHeight <= 768) {
  2081. imageHeight = 5;
  2082. }
  2083. else if(targetHeight >= 768 && targetHeight <= 960) {
  2084. imageHeight = 6;
  2085. }
  2086. else {
  2087. imageHeight = 7;
  2088. }
  2089. // Get the size number.
  2090. size = Math.max(imageWidth, imageHeight);
  2091. return sizes[size];
  2092. },
  2093. /**
  2094. * Checks whether this is a video or not.
  2095. *
  2096. * @method _isVideo
  2097. * @protected
  2098. */
  2099. _isVideo: function()
  2100. {
  2101. if(!this._imageInfo) {
  2102. return false;
  2103. }
  2104. else if(this._imageInfo.format == 'mp4' && this._imageInfo.sourceType == 'smugmug') {
  2105. return true;
  2106. }
  2107. else if(this._imageInfo.iframe !== '') {
  2108. return true;
  2109. }
  2110. return false;
  2111. },
  2112. /**
  2113. * @method _loadVideo
  2114. * @protected
  2115. */
  2116. _loadVideo: function()
  2117. {
  2118. var bb = this.get('boundingBox'),
  2119. showVideoButton = this.get('showVideoButton'),
  2120. autoPlay = showVideoButton ? true : false;
  2121. // Remove previous videos
  2122. if(this._video) {
  2123. this._video.remove();
  2124. this._video = null;
  2125. }
  2126. // Get the video code
  2127. if(this._imageInfo.format == 'mp4' && this._imageInfo.sourceType == 'smugmug') {
  2128. this._video = this._getSmugMugVideoEmbed(this._imageInfo, autoPlay);
  2129. }
  2130. else if(this._imageInfo.iframe !== '') {
  2131. this._video = this._getIframeVideoEmbed(this._imageInfo, autoPlay);
  2132. }
  2133. // Insert the video
  2134. if(this._videoBox) {
  2135. this._videoBox.one('.fl-slideshow-video-wrap').insert(this._video);
  2136. }
  2137. else {
  2138. bb.all('img').remove();
  2139. bb.append(this._video);
  2140. }
  2141. // Finish an initial load?
  2142. if(this._loading) {
  2143. this._loading = false;
  2144. this.fire('loadComplete');
  2145. }
  2146. },
  2147. /**
  2148. * @method _insertVideoButton
  2149. * @protected
  2150. */
  2151. _insertVideoButton: function()
  2152. {
  2153. var bb = this.get('boundingBox'),
  2154. event = 'ontouchstart' in window ? 'touchstart' : 'click';
  2155. this._videoButton = Y.Node.create('<a class="fl-slideshow-video-button" href="javascript:void(0);"></a>');
  2156. this._videoButton.on(event, Y.bind(this._showVideoBox, this));
  2157. bb.insert(this._videoButton);
  2158. this._positionVideoButton();
  2159. },
  2160. /**
  2161. * @method _positionVideoButton
  2162. * @protected
  2163. */
  2164. _positionVideoButton: function()
  2165. {
  2166. var bbWidth = this.get('width'),
  2167. bbHeight = this.get('height'),
  2168. buttonWidth = parseInt(this._videoButton.getStyle('width'), 10),
  2169. buttonHeight = parseInt(this._videoButton.getStyle('height'), 10);
  2170. this._videoButton.setStyles({
  2171. left: (bbWidth - buttonWidth)/2,
  2172. top: (bbHeight - buttonHeight)/2
  2173. });
  2174. },
  2175. /**
  2176. * @method _showVideoBox
  2177. * @protected
  2178. */
  2179. _showVideoBox: function()
  2180. {
  2181. var root = this.get('root'),
  2182. wrap = Y.Node.create('<div class="fl-slideshow-video-wrap"></div>'),
  2183. close = Y.Node.create('<a class="fl-slideshow-video-close" href="javascript:void(0);"></a>'),
  2184. event = 'ontouchstart' in window ? 'touchstart' : 'click';
  2185. this._videoBox = Y.Node.create('<div class="fl-slideshow-video"></div>');
  2186. this._videoBox.setStyle('padding', root.get('boundingBox').getStyle('padding'));
  2187. this._videoBox.insert(wrap);
  2188. this._videoBox.insert(close);
  2189. this._videoBox.on(event, Y.bind(this._removeVideoBox, this));
  2190. close.on(event, Y.bind(this._removeVideoBox, this));
  2191. if(typeof YUI.Env.mods['sm-fonticon'] !== 'undefined') {
  2192. close.addClass('sm-fonticon sm-fonticon-XCrossEncircled sm-button-skin-default sm-button-nochrome');
  2193. }
  2194. Y.one('body').insert(this._videoBox);
  2195. this._loadVideo();
  2196. Y.one('body').on('fl-slideshow-image|keydown', this._onKey, this);
  2197. },
  2198. /**
  2199. * Get the embed code for a SmugMug video.
  2200. *
  2201. * @method _getSmugMugVideoEmbed
  2202. * @param imageInfo {Object} The image info for the embed.
  2203. * @param autoPlay {Boolean} Whether to auto play videos or not.
  2204. * @protected
  2205. */
  2206. _getSmugMugVideoEmbed: function(imageInfo, autoPlay)
  2207. {
  2208. var test = document.createElement('video'),
  2209. width = 0,
  2210. mp4 = '',
  2211. vars = '',
  2212. code = '';
  2213. if(Y.UA.mobile !== null && !!test.canPlayType && test.canPlayType('video/mp4')) {
  2214. width = this.get('width');
  2215. mp4 = 'https://www.smugmug.com/photos/' + imageInfo.id + '_' + imageInfo.key + '-' + width + '.mp4';
  2216. code += '<video width="100%" height="100%" poster="'+ this._getImageURL() +'" controls preload="none"';
  2217. if(autoPlay) {
  2218. code += ' autoplay';
  2219. }
  2220. code += '>';
  2221. code += '<source src="'+ mp4 +'" type="video/mp4" />';
  2222. code += '</video>';
  2223. }
  2224. else {
  2225. vars = 'imageId=' + imageInfo.id;
  2226. vars += '&amp;imageKey=' + imageInfo.key;
  2227. vars += '&amp;albumId=' + imageInfo.albumId;
  2228. vars += '&amp;albumKey=' + imageInfo.albumKey;
  2229. vars += '&amp;apiURL=https://api.smugmug.com/&amp;hostLevel=live&amp;isPro=true';
  2230. if(autoPlay) {
  2231. vars += '&amp;autoPlay=true';
  2232. }
  2233. else {
  2234. vars += '&amp;autoPlay=false';
  2235. }
  2236. code += '<object type="application/x-shockwave-flash" width="100%" height="100%" data="https://cdn.smugmug.com/img/ria/SmugPlayer/2012102601.swf">';
  2237. code += '<param name="movie" value="https://cdn.smugmug.com/img/ria/SmugPlayer/2012102601.swf">';
  2238. code += '<param name="allowFullScreen" value="true">';
  2239. code += '<param name="wmode" value="transparent">';
  2240. code += '<param name="flashVars" value="' + vars + '">';
  2241. code += '<embed src="https://cdn.smugmug.com/img/ria/SmugPlayer/2012102601.swf" flashvars="'+ vars +'" width="100%" height="100%" type="application/x-shockwave-flash" allowfullscreen="true" wmode="transparent">';
  2242. code += '</object>';
  2243. }
  2244. return Y.Node.create(code);
  2245. },
  2246. /**
  2247. * Get the iframe video embed code.
  2248. *
  2249. * @method _getIframeVideoEmbed
  2250. * @param imageInfo {Object} The image info for the embed.
  2251. * @param autoPlay {Boolean} Whether to auto play videos or not.
  2252. * @protected
  2253. */
  2254. _getIframeVideoEmbed: function(imageInfo, autoPlay)
  2255. {
  2256. var code = '<iframe width="100%" height="100%" allowfullscreen ',
  2257. url = imageInfo.iframe;
  2258. if(autoPlay) {
  2259. url += url.indexOf('?') > -1 ? '&autoplay=1' : '?autoplay=1';
  2260. }
  2261. code += 'src="'+ url +'"></iframe>';
  2262. return Y.Node.create(code);
  2263. },
  2264. /**
  2265. * @method _removeVideoBox
  2266. * @protected
  2267. */
  2268. _removeVideoBox: function(e)
  2269. {
  2270. if(typeof e !== 'undefined' && e.target) {
  2271. if(e.target.get('className').indexOf('fl-slideshow-video') < 0) {
  2272. return;
  2273. }
  2274. }
  2275. if(this._videoBox !== null) {
  2276. this._videoBox.remove();
  2277. this._videoBox = null;
  2278. this._video = null;
  2279. }
  2280. Y.one('body').detach('fl-slideshow-image|keydown', this._onKey);
  2281. },
  2282. /**
  2283. * Keyboard input for the esc button.
  2284. *
  2285. * @method _onKey
  2286. * @protected
  2287. */
  2288. _onKey: function(e)
  2289. {
  2290. if(e.keyCode == 27) {
  2291. this._removeVideoBox();
  2292. return false;
  2293. }
  2294. }
  2295. }, {
  2296. /**
  2297. * Custom CSS class name for the widget.
  2298. * @property CSS_PREFIX
  2299. * @type String
  2300. * @protected
  2301. * @static
  2302. */
  2303. CSS_PREFIX: 'fl-slideshow-image',
  2304. /**
  2305. * Static property used to define the default attribute configuration of
  2306. * the Widget.
  2307. *
  2308. * @property ATTRS
  2309. * @type Object
  2310. * @protected
  2311. * @static
  2312. */
  2313. ATTRS: {
  2314. /**
  2315. * @attribute loadGroup
  2316. * @type String
  2317. * @default none
  2318. */
  2319. loadGroup: {
  2320. value: 'none'
  2321. },
  2322. /**
  2323. * @attribute loadPriority
  2324. * @type Boolean
  2325. * @default false
  2326. */
  2327. loadPriority: {
  2328. value: false
  2329. },
  2330. /**
  2331. * Whether to crop the image.
  2332. *
  2333. * @attribute crop
  2334. * @type Boolean
  2335. * @default false
  2336. */
  2337. crop: {
  2338. value: false
  2339. },
  2340. /**
  2341. * Checks whether the filename has nocrop in it or not.
  2342. * If it does, the image will not be cropped.
  2343. *
  2344. * @attribute checkFilenamesForNoCrop
  2345. * @type Boolean
  2346. * @default true
  2347. */
  2348. checkFilenamesForNoCrop: {
  2349. value: true
  2350. },
  2351. /**
  2352. * Whether to only crop horizontal images or not.
  2353. *
  2354. * @attribute cropHorizontalsOnly
  2355. * @type Boolean
  2356. * @default false
  2357. */
  2358. cropHorizontalsOnly: {
  2359. value: false
  2360. },
  2361. /**
  2362. * The x and y position of the image
  2363. * within the bounding box.
  2364. *
  2365. * @attribute position
  2366. * @type String
  2367. * @default center center
  2368. */
  2369. position: {
  2370. value: 'center center'
  2371. },
  2372. /**
  2373. * Whether to right click protect the image.
  2374. *
  2375. * @attribute protect
  2376. * @type Boolean
  2377. * @default true
  2378. */
  2379. protect: {
  2380. value: true
  2381. },
  2382. /**
  2383. * Whether to resize the image past
  2384. * its original width and height.
  2385. *
  2386. * @attribute upsize
  2387. * @type Boolean
  2388. * @default true
  2389. */
  2390. upsize: {
  2391. value: true
  2392. },
  2393. /**
  2394. * Whether to load thumb sizes. Defaults
  2395. * to false since thumb sizes are square.
  2396. *
  2397. * @attribute useThumbSizes
  2398. * @type Boolean
  2399. * @default false
  2400. */
  2401. useThumbSizes: {
  2402. value: false
  2403. },
  2404. /**
  2405. * Whether to constrain the width of the
  2406. * bounding box to the width of the image.
  2407. *
  2408. * @attribute constrainWidth
  2409. * @type Boolean
  2410. * @default false
  2411. */
  2412. constrainWidth: {
  2413. value: false
  2414. },
  2415. /**
  2416. * Whether to constrain the height of the
  2417. * bounding box to the height of the image.
  2418. *
  2419. * @attribute constrainHeight
  2420. * @type Boolean
  2421. * @default false
  2422. */
  2423. constrainHeight: {
  2424. value: false
  2425. },
  2426. /**
  2427. * Whether to load videos or not. The poster
  2428. * image will be loaded if set to false.
  2429. *
  2430. * @attribute loadVideos
  2431. * @type Boolean
  2432. * @default true
  2433. */
  2434. loadVideos: {
  2435. value: true
  2436. },
  2437. /**
  2438. * Whether to show the video play button or not.
  2439. * When clicked, videos will be displayed in a
  2440. * lightbox instead of the slideshow itself.
  2441. *
  2442. * @attribute showVideoButton
  2443. * @type Boolean
  2444. * @default true
  2445. */
  2446. showVideoButton: {
  2447. value: true
  2448. }
  2449. }
  2450. });
  2451. /**
  2452. * A plugin that turns the cursor into a prev or next arrow when
  2453. * it is over the left or right side of the slideshow.
  2454. *
  2455. * @namespace FL
  2456. * @class SlideshowMouseNav
  2457. * @constructor
  2458. * @param config {Object} Configuration object
  2459. * @extends Plugin.Base
  2460. */
  2461. Y.namespace('FL').SlideshowMouseNav = Y.Base.create('fl-slideshow-mouse-nav', Y.Plugin.Base, [], {
  2462. /**
  2463. * @method initializer
  2464. * @protected
  2465. */
  2466. initializer: function()
  2467. {
  2468. var trigger = this.get('trigger');
  2469. trigger.on('click', this._triggerClick, this);
  2470. trigger.on('mousemove', this._showArrow, this);
  2471. trigger.on('mouseleave', this._hideArrow, this);
  2472. },
  2473. /**
  2474. * @method _triggerClick
  2475. * @protected
  2476. */
  2477. _triggerClick: function(e)
  2478. {
  2479. var host = this.get('host'),
  2480. trigger = this.get('trigger'),
  2481. triggerWidth = parseInt(trigger.getStyle('width'), 10),
  2482. triggerRegion = trigger.get('region'),
  2483. layerX = e.pageX - triggerRegion.left + 5;
  2484. if(layerX >= triggerWidth/2) {
  2485. host.nextImage();
  2486. }
  2487. else {
  2488. host.prevImage();
  2489. }
  2490. },
  2491. /**
  2492. * @method _showArrow
  2493. * @protected
  2494. */
  2495. _showArrow: function(e)
  2496. {
  2497. var host = this.get('host'),
  2498. trigger = this.get('trigger'),
  2499. triggerWidth = parseInt(trigger.getStyle('width'), 10),
  2500. triggerRegion = trigger.get('region'),
  2501. layerX = e.pageX - triggerRegion.left + 5;
  2502. if(host.albumInfo !== null && host.albumInfo.images.length > 1) {
  2503. if(layerX >= triggerWidth/2) {
  2504. trigger.removeClass('fl-slideshow-mouse-nav-prev');
  2505. trigger.addClass('fl-slideshow-mouse-nav-next');
  2506. }
  2507. else {
  2508. trigger.removeClass('fl-slideshow-mouse-nav-next');
  2509. trigger.addClass('fl-slideshow-mouse-nav-prev');
  2510. }
  2511. }
  2512. },
  2513. /**
  2514. * @method _hideArrow
  2515. * @protected
  2516. */
  2517. _hideArrow: function()
  2518. {
  2519. var trigger = this.get('trigger');
  2520. trigger.removeClass('fl-slideshow-mouse-nav-next');
  2521. trigger.removeClass('fl-slideshow-mouse-nav-prev');
  2522. }
  2523. }, {
  2524. /**
  2525. * Namespace for the plugin.
  2526. *
  2527. * @property NS
  2528. * @type String
  2529. * @protected
  2530. * @static
  2531. */
  2532. NS: 'mouseNav',
  2533. /**
  2534. * Static property used to define the default attribute configuration of
  2535. * the Plugin.
  2536. *
  2537. * @property ATTRS
  2538. * @type Object
  2539. * @protected
  2540. * @static
  2541. */
  2542. ATTRS: {
  2543. /**
  2544. * A Node that triggers the arrows.
  2545. *
  2546. * @attribute trigger
  2547. * @type Node
  2548. * @default null
  2549. */
  2550. trigger: {
  2551. value: null
  2552. }
  2553. }
  2554. });
  2555. /**
  2556. * Ken Burns effect for slideshow images.
  2557. *
  2558. * @namespace FL
  2559. * @class SlideshowKenBurns
  2560. * @constructor
  2561. * @param config {Object} Configuration object
  2562. * @extends Base
  2563. */
  2564. Y.namespace('FL').SlideshowKenBurns = Y.Base.create('fl-slideshow-ken-burns', Y.Base, [], {
  2565. /**
  2566. * Runs the Ken Burns effect.
  2567. *
  2568. * @method run
  2569. */
  2570. run: function()
  2571. {
  2572. var imageNode = null,
  2573. transform = null;
  2574. if(Y.FL.Utils.cssSupport('transform')) {
  2575. // Image node
  2576. imageNode = this.get('image').one('img');
  2577. // Transform object
  2578. transform = this._getTransform();
  2579. // Apply the start transform
  2580. imageNode.setStyles({
  2581. '-webkit-transform-origin': transform.origin,
  2582. '-moz-transform-origin': transform.origin,
  2583. '-ms-transform-origin': transform.origin,
  2584. 'transform-origin': transform.origin,
  2585. 'transform': transform.start
  2586. });
  2587. // Transition to the end transform
  2588. imageNode.transition({
  2589. easing: 'ease-out',
  2590. duration : this.get('duration'),
  2591. 'transform' : transform.end
  2592. });
  2593. }
  2594. },
  2595. /**
  2596. * @method _getTransform
  2597. * @protected
  2598. */
  2599. _getTransform: function()
  2600. {
  2601. var zoom = this.get('zoom'),
  2602. image = this.get('image'),
  2603. i = 0,
  2604. zoomDirection = null,
  2605. transform = null;
  2606. // Random zoom direction
  2607. i = Math.floor(Math.random() * Y.FL.SlideshowKenBurns.ZOOM_DIRECTIONS.length);
  2608. zoomDirection = Y.FL.SlideshowKenBurns.ZOOM_DIRECTIONS[i];
  2609. // Random transform
  2610. i = Math.floor(Math.random() * Y.FL.SlideshowKenBurns.TRANSFORMS.length);
  2611. transform = Y.FL.SlideshowKenBurns.TRANSFORMS[i];
  2612. // Get the start and end transforms
  2613. if(!image.hasClass('fl-slideshow-image-cropped') && zoomDirection == 'in') {
  2614. i = Math.floor(Math.random() * 2);
  2615. transform.start = i === 0 ? 'scale(1) translate(100px, 0)' : 'scale(1) translate(-100px, 0)';
  2616. transform.end = 'scale(' + zoom + ') translate(0, 0)';
  2617. transform.origin = 'center center';
  2618. }
  2619. else if(zoomDirection == 'out') {
  2620. transform.start = 'scale(' + zoom + ') ' + transform.translate;
  2621. transform.end = 'scale(1) translate(0, 0)';
  2622. }
  2623. else {
  2624. transform.start = 'scale(1) translate(0, 0)';
  2625. transform.end = 'scale(' + zoom + ') ' + transform.translate;
  2626. }
  2627. return transform;
  2628. }
  2629. }, {
  2630. /**
  2631. * Static property used to define the default attribute configuration of
  2632. * the Widget.
  2633. *
  2634. * @property ATTRS
  2635. * @type Object
  2636. * @protected
  2637. * @static
  2638. */
  2639. ATTRS: {
  2640. /**
  2641. * An instance of FL.Slideshow image to apply the
  2642. * Ken Burns effect on.
  2643. *
  2644. * @attribute image
  2645. * @type FL.Slideshow
  2646. * @default null
  2647. */
  2648. image: {
  2649. value: null
  2650. },
  2651. /**
  2652. * The amount to zoom the image. Zooming
  2653. * in our out is done randomly by this class.
  2654. *
  2655. * @attribute scale
  2656. * @type Number
  2657. * @default 1.2
  2658. */
  2659. zoom: {
  2660. value: 1.2
  2661. },
  2662. /**
  2663. * The duration of the effect in seconds.
  2664. *
  2665. * @attribute duration
  2666. * @type Number
  2667. * @default 2
  2668. */
  2669. duration: {
  2670. value: 2
  2671. }
  2672. },
  2673. /**
  2674. * The zoom directions that can be applied to an image.
  2675. *
  2676. * @property ZOOM_DIRECTIONS
  2677. * @type Object
  2678. * @readOnly
  2679. * @protected
  2680. * @static
  2681. */
  2682. ZOOM_DIRECTIONS: [
  2683. 'in',
  2684. 'out'
  2685. ],
  2686. /**
  2687. * The types of transforms that can be applied to an image.
  2688. *
  2689. * @property TRANSFORMS
  2690. * @type Object
  2691. * @readOnly
  2692. * @protected
  2693. * @static
  2694. */
  2695. TRANSFORMS: [
  2696. {
  2697. origin : 'left top',
  2698. translate : 'translate(-30px, -15px)'
  2699. },{
  2700. origin : 'left center',
  2701. translate : 'translate(-30px, 0)'
  2702. },{
  2703. origin : 'left bottom',
  2704. translate : 'translate(-30px, 15px)'
  2705. },{
  2706. origin : 'right top',
  2707. translate : 'translate(30px, -15px)'
  2708. },{
  2709. origin : 'right center',
  2710. translate : 'translate(30px, 0)'
  2711. },{
  2712. origin : 'right bottom',
  2713. translate : 'translate(30px, 15px)'
  2714. }
  2715. ]
  2716. });
  2717. /**
  2718. * Navigation buttons widget for controlling a slideshow instance
  2719. * and its child widgets.
  2720. *
  2721. * @namespace FL
  2722. * @class SlideshowNav
  2723. * @constructor
  2724. * @param config {Object} Configuration object
  2725. * @extends Widget
  2726. */
  2727. Y.namespace('FL').SlideshowNav = Y.Base.create('fl-slideshow-nav', Y.Widget, [Y.WidgetChild], {
  2728. /**
  2729. * An object containing the anchor nodes for all buttons.
  2730. *
  2731. * @property _buttons
  2732. * @type Object
  2733. * @default null
  2734. * @protected
  2735. */
  2736. _buttons: null,
  2737. /**
  2738. * An div node containing the anchor nodes for the main buttons.
  2739. *
  2740. * @property _buttonsContainer
  2741. * @type Object
  2742. * @default null
  2743. * @protected
  2744. */
  2745. _buttonsContainer: null,
  2746. /**
  2747. * An div node containing the anchor nodes for the left buttons.
  2748. *
  2749. * @property _buttonsLeftContainer
  2750. * @type Object
  2751. * @default null
  2752. * @protected
  2753. */
  2754. _buttonsLeftContainer: null,
  2755. /**
  2756. * An div node containing the anchor nodes for the right buttons.
  2757. *
  2758. * @property _buttonsRightContainer
  2759. * @type Object
  2760. * @default null
  2761. * @protected
  2762. */
  2763. _buttonsRightContainer: null,
  2764. /**
  2765. * Property map for rendering SmugMug font icons.
  2766. *
  2767. * @property _fontIcons
  2768. * @type Object
  2769. * @protected
  2770. */
  2771. _fontIcons: {
  2772. buy: 'Cart',
  2773. caption: 'InfoEncircled',
  2774. close: 'XCrossEncircled',
  2775. fullscreen: 'ScreenExpand',
  2776. next: 'ArrowRight',
  2777. nextPage: 'ArrowRight',
  2778. pause: 'PlayerPause',
  2779. play: 'PlayerPlay',
  2780. prev: 'ArrowLeft',
  2781. prevPage: 'ArrowLeft',
  2782. social: 'Heart',
  2783. thumbs: 'ViewThumbGrid'
  2784. },
  2785. /**
  2786. * The default content template for the nav
  2787. * inherited from Y.Widget. Set to null since
  2788. * only the bounding box is needed.
  2789. *
  2790. * @property CONTENT_TEMPLATE
  2791. * @type String
  2792. * @default null
  2793. * @protected
  2794. */
  2795. CONTENT_TEMPLATE: null,
  2796. /**
  2797. * Renders the buttons.
  2798. *
  2799. * @method renderUI
  2800. * @protected
  2801. */
  2802. renderUI: function()
  2803. {
  2804. this._renderContainers();
  2805. this._renderButtons();
  2806. this._renderFontIcons();
  2807. },
  2808. /**
  2809. * Binds events to the root slideshow for each button.
  2810. *
  2811. * @method bindUI
  2812. * @protected
  2813. */
  2814. bindUI: function()
  2815. {
  2816. var root = this.get('root'),
  2817. id = this.get('id');
  2818. if(this._buttons.prev) {
  2819. this._buttons.prev.on('click', root.prevImage, root);
  2820. }
  2821. if(this._buttons.next) {
  2822. this._buttons.next.on('click', root.nextImage, root);
  2823. }
  2824. if(this._buttons.play) {
  2825. this._buttons.play.on('click', this._playClicked, this);
  2826. root.on(id + '|played', this._showPauseButton, this);
  2827. root.on(id + '|paused', this._showPlayButton, this);
  2828. if(root._playing) {
  2829. this._showPauseButton();
  2830. }
  2831. else {
  2832. this._showPlayButton();
  2833. }
  2834. }
  2835. if(this._buttons.buy) {
  2836. root.on(id + '|albumLoadComplete', this._updateBuy, this);
  2837. if(root.albumInfo !== null) {
  2838. this._updateBuy();
  2839. }
  2840. }
  2841. if(this._buttons.count) {
  2842. root.on(id + '|imageLoadComplete', this._updateCount, this);
  2843. }
  2844. if(this._buttons.thumbs) {
  2845. this._buttons.thumbs.on('click', root._toggleThumbs, root);
  2846. }
  2847. if(this._buttons.caption) {
  2848. root.on(id + '|imageLoadComplete', this._updateCaption, this);
  2849. this._updateCaption();
  2850. }
  2851. if(this._buttons.social) {
  2852. this._buttons.social.on('click', root._toggleSocial, root);
  2853. }
  2854. if(this._buttons.fullscreen && root.fullscreen) {
  2855. this._buttons.fullscreen.on('click', root.fullscreen.toggle, root.fullscreen);
  2856. }
  2857. if(this._buttons.close) {
  2858. this._buttons.close.on('click', root.hide, root);
  2859. }
  2860. },
  2861. /**
  2862. * @method destructor
  2863. * @protected
  2864. */
  2865. destructor: function()
  2866. {
  2867. var root = this.get('root'),
  2868. id = this.get('id');
  2869. root.detach(id + '|*');
  2870. },
  2871. /**
  2872. * Renders the button left, right and main button containers.
  2873. *
  2874. * @method _renderContainers
  2875. * @protected
  2876. */
  2877. _renderContainers: function()
  2878. {
  2879. var cb = this.get('contentBox'),
  2880. buttonsLeft = this.get('buttonsLeft'),
  2881. buttonsRight = this.get('buttonsRight');
  2882. this._buttonsContainer = Y.Node.create('<div></div>');
  2883. this._buttonsContainer.addClass('fl-slideshow-nav-buttons');
  2884. cb.appendChild(this._buttonsContainer);
  2885. if(buttonsLeft.length > 0) {
  2886. this._buttonsLeftContainer = Y.Node.create('<div></div>');
  2887. this._buttonsLeftContainer.addClass('fl-slideshow-nav-buttons-left');
  2888. cb.appendChild(this._buttonsLeftContainer);
  2889. }
  2890. if(buttonsRight.length > 0) {
  2891. this._buttonsRightContainer = Y.Node.create('<div></div>');
  2892. this._buttonsRightContainer.addClass('fl-slideshow-nav-buttons-right');
  2893. cb.appendChild(this._buttonsRightContainer);
  2894. }
  2895. },
  2896. /**
  2897. * Renders the buttons based on the buttons array
  2898. * passed in the configuration object.
  2899. *
  2900. * @method _renderButtons
  2901. * @protected
  2902. */
  2903. _renderButtons: function()
  2904. {
  2905. var name = '',
  2906. i = 0,
  2907. k = 0,
  2908. b = [
  2909. {
  2910. names: this.get('buttons'),
  2911. container: this._buttonsContainer
  2912. },
  2913. {
  2914. names: this.get('buttonsLeft'),
  2915. container: this._buttonsLeftContainer
  2916. },
  2917. {
  2918. names: this.get('buttonsRight'),
  2919. container: this._buttonsRightContainer
  2920. }
  2921. ];
  2922. this._buttons = {};
  2923. for( ; i < b.length; i++) {
  2924. for(k = 0; k < b[i].names.length; k++) {
  2925. name = b[i].names[k];
  2926. if(name.indexOf('count') > -1) {
  2927. this._buttons[name] = Y.Node.create('<span></span>');
  2928. this._updateCount();
  2929. }
  2930. else {
  2931. this._buttons[name] = Y.Node.create('<a href="javascript:void(0);"></a>');
  2932. }
  2933. if(name.indexOf('buy') > -1) {
  2934. this._buttons[name].setStyle('display', 'none');
  2935. }
  2936. this._buttons[name].set('name', name);
  2937. this._buttons[name].set('aria-label', name);
  2938. this._buttons[name].addClass('fl-slideshow-nav-' + name);
  2939. b[i].container.appendChild(this._buttons[name]);
  2940. }
  2941. }
  2942. },
  2943. /**
  2944. * Renders SmugMug font icons for each button.
  2945. *
  2946. * @method _renderFontIcons
  2947. * @protected
  2948. */
  2949. _renderFontIcons: function()
  2950. {
  2951. var name = null;
  2952. if(this.get('useFontIcons') && typeof YUI.Env.mods['sm-fonticon'] !== 'undefined') {
  2953. for(name in this._buttons) {
  2954. if(typeof this._buttons[name] !== 'undefined' && typeof this._fontIcons[name] !== 'undefined') {
  2955. this._buttons[name].addClass('sm-fonticon-' + this._fontIcons[name]);
  2956. this._buttons[name].addClass('sm-fonticon sm-button-skin-default sm-button-nochrome');
  2957. }
  2958. else if(name.indexOf('count') > -1) {
  2959. this._buttons[name].addClass('fonticons-enabled');
  2960. }
  2961. }
  2962. }
  2963. },
  2964. /**
  2965. * Updates the image count.
  2966. *
  2967. * @method _updateCount
  2968. * @protected
  2969. */
  2970. _updateCount: function()
  2971. {
  2972. var html = '',
  2973. countText = Y.FL.SlideshowNav.COUNT_TEXT,
  2974. current = 1,
  2975. total = 1;
  2976. if(this.get('root').albumInfo) {
  2977. current = this.get('root').imageInfo.index + 1;
  2978. total = this.get('root').albumInfo.images.length;
  2979. }
  2980. html = countText.replace('{current}', current).replace('{total}', total);
  2981. this._buttons.count.set('innerHTML', html);
  2982. },
  2983. /**
  2984. * Shows the caption button if the current image
  2985. * has a caption, hides it if the image does not
  2986. * have a caption.
  2987. *
  2988. * @method _updateCaption
  2989. * @protected
  2990. */
  2991. _updateCaption: function()
  2992. {
  2993. var root = this.get('root'),
  2994. imageInfo = root.imageInfo;
  2995. if(imageInfo && imageInfo.caption === '') {
  2996. root.caption.slideshowOverlay.enable();
  2997. root.caption.slideshowOverlay.hide();
  2998. this._buttons.caption.detach('click');
  2999. this._buttons.caption.addClass('fl-slideshow-nav-caption-disabled');
  3000. }
  3001. else {
  3002. this._buttons.caption.on('click', root._toggleCaption, root);
  3003. this._buttons.caption.removeClass('fl-slideshow-nav-caption-disabled');
  3004. }
  3005. },
  3006. /**
  3007. * Checks if buying has been enabled for the current album.
  3008. *
  3009. * @method _updateBuy
  3010. * @protected
  3011. */
  3012. _updateBuy: function()
  3013. {
  3014. var sm = null,
  3015. root = this.get('root'),
  3016. rootSource = root.get('source')[root.albumIndex],
  3017. albumIndex = root.albumIndex,
  3018. source = root.get('source')[albumIndex];
  3019. if(rootSource && rootSource.type == 'smugmug') {
  3020. if(typeof root.albumInfo.printable !== 'undefined') {
  3021. this._updateBuyComplete();
  3022. }
  3023. else {
  3024. sm = new Y.FL.SmugMugAPI();
  3025. sm.addParam('method', 'smugmug.albums.getInfo');
  3026. sm.addParam('AlbumID', source.id);
  3027. sm.addParam('AlbumKey', source.key);
  3028. sm.on('complete', this._updateBuyComplete, this);
  3029. sm.request();
  3030. }
  3031. }
  3032. },
  3033. /**
  3034. * Shows the buy button and updates the buy url
  3035. * if buying has been enabled.
  3036. *
  3037. * @method _updateBuyComplete
  3038. * @param e {Object} The custom event object passed to this function.
  3039. * @protected
  3040. */
  3041. _updateBuyComplete: function(e)
  3042. {
  3043. var root = this.get('root'),
  3044. printable = typeof e == 'undefined' ? root.albumInfo.printable : e.Album.Printable,
  3045. link = root.albumInfo.link;
  3046. if(printable) {
  3047. root.albumInfo.printable = true;
  3048. this._buttons.buy.set('href', 'https://secure.smugmug.com/cart/batchadd/?url=' + encodeURIComponent(link));
  3049. this._buttons.buy.setStyle('display', 'inline-block');
  3050. }
  3051. else {
  3052. root.albumInfo.printable = false;
  3053. this._buttons.buy.setStyle('display', 'none');
  3054. }
  3055. this.fire('resize');
  3056. },
  3057. /**
  3058. * Pauses the slideshow if it is playing and
  3059. * plays the slideshow if it is paused.
  3060. *
  3061. * @method _playClicked
  3062. * @protected
  3063. */
  3064. _playClicked: function()
  3065. {
  3066. var root = this.get('root');
  3067. if(root._playing) {
  3068. root.pause();
  3069. }
  3070. else {
  3071. root.play();
  3072. }
  3073. },
  3074. /**
  3075. * Toggles the button class for the play button
  3076. * so pause is hidden and play is shown.
  3077. *
  3078. * @method _showPlayButton
  3079. * @protected
  3080. */
  3081. _showPlayButton: function()
  3082. {
  3083. this._buttons.play.removeClass('fl-slideshow-nav-pause');
  3084. this._buttons.play.addClass('fl-slideshow-nav-play');
  3085. if(this.get('useFontIcons') && typeof YUI.Env.mods['sm-fonticon'] !== 'undefined') {
  3086. this._buttons.play.removeClass('sm-fonticon-PlayerPause');
  3087. this._buttons.play.addClass('sm-fonticon-PlayerPlay');
  3088. }
  3089. },
  3090. /**
  3091. * Toggles the button class for the play button
  3092. * so pause is shown and play is hidden.
  3093. *
  3094. * @method _showPauseButton
  3095. * @protected
  3096. */
  3097. _showPauseButton: function()
  3098. {
  3099. this._buttons.play.removeClass('fl-slideshow-nav-play');
  3100. this._buttons.play.addClass('fl-slideshow-nav-pause');
  3101. if(this.get('useFontIcons') && typeof YUI.Env.mods['sm-fonticon'] !== 'undefined') {
  3102. this._buttons.play.removeClass('sm-fonticon-PlayerPlay');
  3103. this._buttons.play.addClass('sm-fonticon-PlayerPause');
  3104. }
  3105. }
  3106. }, {
  3107. /**
  3108. * Custom CSS class name for the widget.
  3109. *
  3110. * @property CSS_PREFIX
  3111. * @type String
  3112. * @protected
  3113. * @static
  3114. */
  3115. CSS_PREFIX: 'fl-slideshow-nav',
  3116. /**
  3117. * Static string used for displaying the image count. Use {current}
  3118. * for the current image and {total} for the total number of images.
  3119. * Those placeholders will be replaced when the count node is created.
  3120. *
  3121. * @property COUNT_TEXT
  3122. * @type String
  3123. * @protected
  3124. * @static
  3125. */
  3126. COUNT_TEXT: '{current} of {total}',
  3127. /**
  3128. * Static property used to define the default attribute configuration of
  3129. * the Widget.
  3130. *
  3131. * @property ATTRS
  3132. * @type Object
  3133. * @protected
  3134. * @static
  3135. */
  3136. ATTRS: {
  3137. /**
  3138. * An array of button names that is used to render the main buttons.
  3139. *
  3140. * @attribute buttons
  3141. * @type Array
  3142. * @default []
  3143. * @writeOnce
  3144. */
  3145. buttons: {
  3146. value: [],
  3147. writeOnce: true
  3148. },
  3149. /**
  3150. * An array of button names that is used to render the left buttons.
  3151. *
  3152. * @attribute buttonsLeft
  3153. * @type Array
  3154. * @default []
  3155. * @writeOnce
  3156. */
  3157. buttonsLeft: {
  3158. value: [],
  3159. writeOnce: true
  3160. },
  3161. /**
  3162. * An array of button names that is used to render the right buttons.
  3163. *
  3164. * @attribute buttonsRight
  3165. * @type Array
  3166. * @default []
  3167. * @writeOnce
  3168. */
  3169. buttonsRight: {
  3170. value: [],
  3171. writeOnce: true
  3172. },
  3173. /**
  3174. * Whether to use font icons when available.
  3175. *
  3176. * @attribute useFontIcons
  3177. * @type Boolean
  3178. * @default true
  3179. * @writeOnce
  3180. */
  3181. useFontIcons: {
  3182. value: true,
  3183. writeOnce: true
  3184. }
  3185. }
  3186. });
  3187. /**
  3188. * A plugin for overlaying widgets in a slideshow
  3189. * with specialized show and hide functionality.
  3190. *
  3191. * @namespace FL
  3192. * @class SlideshowOverlay
  3193. * @constructor
  3194. * @param config {Object} Configuration object
  3195. * @extends Plugin.Base
  3196. */
  3197. Y.namespace('FL').SlideshowOverlay = Y.Base.create('fl-slideshow-overlay', Y.Plugin.Base, [], {
  3198. /**
  3199. * Flag for whether the mouse has entered
  3200. * the host's bounding box.
  3201. *
  3202. * @property _focus
  3203. * @type Boolean
  3204. * @default false
  3205. * @protected
  3206. */
  3207. _focus: false,
  3208. /**
  3209. * Flag for whether the host's bounding box is visible.
  3210. *
  3211. * @property _visible
  3212. * @type Boolean
  3213. * @default true
  3214. * @protected
  3215. */
  3216. _visible: true,
  3217. /**
  3218. * Flag for whether show and hide functionality
  3219. * has been disabled.
  3220. *
  3221. * @property _disabled
  3222. * @type Boolean
  3223. * @default false
  3224. * @protected
  3225. */
  3226. _disabled: false,
  3227. /**
  3228. * An object containing properties for the show transition.
  3229. *
  3230. * @property _showProps
  3231. * @type Object
  3232. * @protected
  3233. */
  3234. _showProps: {
  3235. duration: 0.5,
  3236. easing: 'ease-out',
  3237. opacity: 1
  3238. },
  3239. /**
  3240. * An object containing properties for the hide transition.
  3241. *
  3242. * @property _hideProps
  3243. * @type Object
  3244. * @protected
  3245. */
  3246. _hideProps: {
  3247. duration: 0.5,
  3248. easing: 'ease-out',
  3249. opacity: 0
  3250. },
  3251. /**
  3252. * A timer object for delaying the hide transition.
  3253. *
  3254. * @property _hideTimer
  3255. * @type Object
  3256. * @default null
  3257. * @protected
  3258. */
  3259. _hideTimer: null,
  3260. /**
  3261. * @method initializer
  3262. * @protected
  3263. */
  3264. initializer: function()
  3265. {
  3266. var bb = this.get('host').get('boundingBox');
  3267. this.afterHostEvent('render', this._initFocus);
  3268. this.afterHostEvent('render', this._initVisibility);
  3269. if(this.get('closeButton')) {
  3270. this._initCloseButton();
  3271. }
  3272. bb.addClass('fl-slideshow-overlay');
  3273. },
  3274. /**
  3275. * @method destructor
  3276. * @protected
  3277. */
  3278. destructor: function()
  3279. {
  3280. this._hideTimerCancel();
  3281. },
  3282. /**
  3283. * Binds the mouseenter and mouseleave events for setting focus.
  3284. *
  3285. * @method _initFocus
  3286. * @protected
  3287. */
  3288. _initFocus: function()
  3289. {
  3290. var bb = this.get('host').get('boundingBox');
  3291. bb.on('mouseenter', Y.bind(this._setFocusOnMouseenter, this));
  3292. bb.on('mouseleave', Y.bind(this._setFocusOnMouseleave, this));
  3293. },
  3294. /**
  3295. * Sets the initial visibility of the host's bounding box.
  3296. *
  3297. * @method _initVisibility
  3298. * @protected
  3299. */
  3300. _initVisibility: function()
  3301. {
  3302. var bb = this.get('host').get('boundingBox'),
  3303. hideStyle = this.get('hideStyle');
  3304. if(!this.get('visible')) {
  3305. if(hideStyle == 'display') {
  3306. bb.setStyle('display', 'none');
  3307. }
  3308. else if(hideStyle == 'left') {
  3309. bb.setStyle('left', '-99999px');
  3310. }
  3311. bb.setStyle('opacity', '0');
  3312. this._visible = false;
  3313. }
  3314. },
  3315. /**
  3316. * Creates and inserts the close button.
  3317. *
  3318. * @method _initCloseButton
  3319. * @protected
  3320. */
  3321. _initCloseButton: function()
  3322. {
  3323. var bb = this.get('host').get('boundingBox'),
  3324. closeButton = null;
  3325. closeButton = Y.Node.create('<a class="fl-slideshow-overlay-close" href="javascript:void(0);"></a>');
  3326. closeButton.on('click', Y.bind(this._closeButtonClick, this));
  3327. if(typeof YUI.Env.mods['sm-fonticon'] !== 'undefined') {
  3328. closeButton.addClass('sm-fonticon sm-fonticon-XCrossEncircled sm-button-skin-default sm-button-nochrome');
  3329. }
  3330. bb.insert(closeButton);
  3331. },
  3332. /**
  3333. * Hides the overlay when the close button is clicked.
  3334. *
  3335. * @method _closeButtonClick
  3336. * @protected
  3337. */
  3338. _closeButtonClick: function()
  3339. {
  3340. var bb = this.get('host').get('boundingBox');
  3341. bb.transition(this._hideProps, Y.bind(this._hideComplete, this));
  3342. },
  3343. /**
  3344. * Sets the focus flag to true.
  3345. *
  3346. * @method _setFocusOnMouseenter
  3347. * @protected
  3348. */
  3349. _setFocusOnMouseenter: function()
  3350. {
  3351. this._focus = true;
  3352. },
  3353. /**
  3354. * Sets the focus flag to false.
  3355. *
  3356. * @method _setFocusOnMouseleave
  3357. * @protected
  3358. */
  3359. _setFocusOnMouseleave: function()
  3360. {
  3361. this._focus = false;
  3362. },
  3363. /**
  3364. * Disables show and hide functionality.
  3365. *
  3366. * @method disable
  3367. * @public
  3368. */
  3369. disable: function()
  3370. {
  3371. this._disabled = true;
  3372. },
  3373. /**
  3374. * Enables show and hide functionality.
  3375. *
  3376. * @method enable
  3377. * @public
  3378. */
  3379. enable: function()
  3380. {
  3381. this._disabled = false;
  3382. },
  3383. /**
  3384. * Shows the host's bounding box with a fade in transition.
  3385. *
  3386. * @method show
  3387. * @public
  3388. */
  3389. show: function()
  3390. {
  3391. var bb = this.get('host').get('boundingBox'),
  3392. hideStyle = this.get('hideStyle');
  3393. if(this._disabled) {
  3394. return;
  3395. }
  3396. if(hideStyle == 'display') {
  3397. bb.setStyle('display', 'block');
  3398. }
  3399. else if(hideStyle == 'left') {
  3400. bb.setStyle('left', 'auto');
  3401. }
  3402. bb.transition(this._showProps, Y.bind(this._showComplete, this));
  3403. /**
  3404. * @event hideStart
  3405. */
  3406. this.fire('showStart');
  3407. },
  3408. /**
  3409. * @method _showComplete
  3410. * @protected
  3411. */
  3412. _showComplete: function()
  3413. {
  3414. this._visible = true;
  3415. this.hideWithTimer();
  3416. /**
  3417. * @event showComplete
  3418. */
  3419. this.fire('showComplete');
  3420. },
  3421. /**
  3422. * Hides the host's bounding box with a fade out transition.
  3423. *
  3424. * @method hide
  3425. * @public
  3426. */
  3427. hide: function()
  3428. {
  3429. if(this._focus || this._disabled) {
  3430. return;
  3431. }
  3432. var bb = this.get('host').get('boundingBox');
  3433. bb.transition(this._hideProps, Y.bind(this._hideComplete, this));
  3434. /**
  3435. * @event hideStart
  3436. */
  3437. this.fire('hideStart');
  3438. },
  3439. /**
  3440. * Hides the host's bounding box with a fade out transition
  3441. * after a timer completes.
  3442. *
  3443. * @method hideWithTimer
  3444. * @public
  3445. */
  3446. hideWithTimer: function()
  3447. {
  3448. this._hideTimerCancel();
  3449. this._hideTimer = Y.later(this.get('hideDelay'), this, this.hide);
  3450. },
  3451. /**
  3452. * Cancels the hide timer.
  3453. *
  3454. * @method _hideTimerCancel
  3455. * @protected
  3456. */
  3457. _hideTimerCancel: function()
  3458. {
  3459. if(this._hideTimer) {
  3460. this._hideTimer.cancel();
  3461. this._hideTimer = null;
  3462. }
  3463. },
  3464. /**
  3465. * @method _hideComplete
  3466. * @protected
  3467. */
  3468. _hideComplete: function()
  3469. {
  3470. var bb = this.get('host').get('boundingBox'),
  3471. hideStyle = this.get('hideStyle');
  3472. if(hideStyle == 'display') {
  3473. bb.setStyle('display', 'none');
  3474. }
  3475. else if(hideStyle == 'left') {
  3476. bb.setStyle('left', '-99999px');
  3477. }
  3478. this._visible = false;
  3479. /**
  3480. * @event hideComplete
  3481. */
  3482. this.fire('hideComplete');
  3483. }
  3484. }, {
  3485. /**
  3486. * Namespace for the plugin.
  3487. *
  3488. * @property NS
  3489. * @type String
  3490. * @protected
  3491. * @static
  3492. */
  3493. NS: 'slideshowOverlay',
  3494. /**
  3495. * Static property used to define the default attribute configuration of
  3496. * the plugin.
  3497. *
  3498. * @property ATTRS
  3499. * @type Object
  3500. * @protected
  3501. * @static
  3502. */
  3503. ATTRS: {
  3504. /**
  3505. * Whether to use the close button or not.
  3506. *
  3507. * @attribute closeButton
  3508. * @type Boolean
  3509. * @default false
  3510. * @writeOnce
  3511. */
  3512. closeButton: {
  3513. value: false,
  3514. writeOnce: true
  3515. },
  3516. /**
  3517. * The time to wait before hiding the host's bounding box.
  3518. * Measured in milliseconds.
  3519. *
  3520. * @attribute hideDelay
  3521. * @type Number
  3522. * @default 3000
  3523. * @writeOnce
  3524. */
  3525. hideDelay: {
  3526. value: 3000,
  3527. writeOnce: true
  3528. },
  3529. /**
  3530. * The style to use for hiding the image. Possible
  3531. * values are display and left.
  3532. *
  3533. * @attribute hideStyle
  3534. * @type String
  3535. * @default display
  3536. * @writeOnce
  3537. */
  3538. hideStyle: {
  3539. value: 'display',
  3540. writeOnce: true
  3541. },
  3542. /**
  3543. * Sets the initial visibility of the host's boudning box.
  3544. *
  3545. * @attribute visible
  3546. * @type Boolean
  3547. * @default true
  3548. * @writeOnce
  3549. */
  3550. visible: {
  3551. value: true,
  3552. writeOnce: true
  3553. }
  3554. }
  3555. });
  3556. /**
  3557. * Social buttons widget used in slideshows.
  3558. *
  3559. * @namespace FL
  3560. * @class SlideshowSocial
  3561. * @constructor
  3562. * @param config {Object} Configuration object
  3563. * @extends Widget
  3564. */
  3565. Y.namespace('FL').SlideshowSocial = Y.Base.create('fl-slideshow-social', Y.Widget, [Y.WidgetChild], {
  3566. /**
  3567. * An object containing the social button nodes.
  3568. *
  3569. * @property _buttons
  3570. * @type Object
  3571. * @default null
  3572. * @protected
  3573. */
  3574. _buttons: null,
  3575. /**
  3576. * @method renderUI
  3577. * @protected
  3578. */
  3579. renderUI: function()
  3580. {
  3581. this._buttons = {};
  3582. },
  3583. /**
  3584. * @method bindUI
  3585. * @protected
  3586. */
  3587. bindUI: function()
  3588. {
  3589. var root = this.get('root');
  3590. if(root.get('likeButtonEnabled')) {
  3591. root.on('imageLoadComplete', Y.bind(this._updateLikeButton, this));
  3592. }
  3593. if(root.get('tweetButtonEnabled')) {
  3594. root.on('imageLoadComplete', Y.bind(this._updateTweetButton, this));
  3595. }
  3596. if(root.get('pinterestButtonEnabled')) {
  3597. root.on('imageLoadComplete', Y.bind(this._updatePinterestButton, this));
  3598. }
  3599. },
  3600. /**
  3601. * @method _updateLikeButton
  3602. * @protected
  3603. */
  3604. _updateLikeButton: function()
  3605. {
  3606. var src = null,
  3607. cb = this.get('contentBox'),
  3608. root = this.get('root'),
  3609. albumIndex = root.albumIndex,
  3610. rootSource = root.get('source')[albumIndex],
  3611. imageInfo = root.imageInfo;
  3612. if(this._buttons.like) {
  3613. this._buttons.like.remove();
  3614. this._buttons.like = null;
  3615. }
  3616. if(rootSource.type == 'smugmug') {
  3617. src = 'https://www.facebook.com/plugins/like.php?';
  3618. src += 'href=' + 'https://www.smugmug.com/services/graph/gallery/';
  3619. src += rootSource.id + '_' + rootSource.key +'/' + imageInfo.id + '_' + imageInfo.key;
  3620. }
  3621. else {
  3622. src = 'https://www.facebook.com/plugins/like.php?';
  3623. src += 'href=' + encodeURIComponent(imageInfo.largeURL);
  3624. }
  3625. src += '&send=false';
  3626. src += '&layout=button_count';
  3627. src += '&width=90';
  3628. src += '&show_faces=false';
  3629. src += '&action=like';
  3630. src += '&colorscheme=light';
  3631. src += '&height=21';
  3632. this._buttons.like = Y.Node.create('<iframe src="'+ src +'" scrolling="no" allowTransparency="true"></iframe>');
  3633. this._buttons.like.setStyles({
  3634. overflow: 'hidden',
  3635. width: '90px',
  3636. height: '21px'
  3637. });
  3638. cb.appendChild(this._buttons.like);
  3639. },
  3640. /**
  3641. * @method _updateTweetButton
  3642. * @protected
  3643. */
  3644. _updateTweetButton: function()
  3645. {
  3646. var src = null,
  3647. imageInfo = this.get('root').imageInfo,
  3648. cb = this.get('contentBox');
  3649. if(this._buttons.tweet) {
  3650. this._buttons.tweet.remove();
  3651. this._buttons.tweet = null;
  3652. }
  3653. src = 'https://platform.twitter.com/widgets/tweet_button.html?';
  3654. src += 'url=' + encodeURIComponent(imageInfo.largeURL);
  3655. src += '&count=none';
  3656. this._buttons.tweet = Y.Node.create('<iframe src="'+ src +'" scrolling="no" allowTransparency="true"></iframe>');
  3657. this._buttons.tweet.setStyles({
  3658. overflow: 'hidden',
  3659. width: '90px',
  3660. height: '21px'
  3661. });
  3662. cb.appendChild(this._buttons.tweet);
  3663. },
  3664. /**
  3665. * @method _updatePinterestButton
  3666. * @protected
  3667. */
  3668. _updatePinterestButton: function()
  3669. {
  3670. var href = 'https://pinterest.com/pin/create/button/',
  3671. imageInfo = this.get('root').imageInfo,
  3672. cb = this.get('contentBox');
  3673. if(this._buttons.pin) {
  3674. this._buttons.pin.remove();
  3675. this._buttons.pin = null;
  3676. }
  3677. href += '?url=' + encodeURIComponent(window.location.href);
  3678. href += '&media='+ encodeURIComponent(imageInfo.mediumURL);
  3679. href += '&description='+ encodeURIComponent(imageInfo.caption);
  3680. this._buttons.pin = Y.Node.create('<a></a>');
  3681. this._buttons.pin.setAttribute('data-pin-config', 'none');
  3682. this._buttons.pin.setAttribute('data-pin-do', 'buttonPin');
  3683. this._buttons.pin.setAttribute('href', href);
  3684. this._buttons.pin.setAttribute('target', '_blank');
  3685. this._buttons.pin.set('innerHTML', '<img src="https://assets.pinterest.com/images/pidgets/pin_it_button.png" border="0" />');
  3686. cb.appendChild(this._buttons.pin);
  3687. }
  3688. }, {
  3689. /**
  3690. * Custom CSS class name for the widget.
  3691. *
  3692. * @property CSS_PREFIX
  3693. * @type String
  3694. * @protected
  3695. * @static
  3696. */
  3697. CSS_PREFIX: 'fl-slideshow-social',
  3698. /**
  3699. * Static property used to define the default attribute configuration of
  3700. * the Widget.
  3701. *
  3702. * @property ATTRS
  3703. * @type Object
  3704. * @protected
  3705. * @static
  3706. */
  3707. ATTRS: {
  3708. }
  3709. });
  3710. /**
  3711. * Creates a grid of FL.SlideshowImage instances.
  3712. *
  3713. * @namespace FL
  3714. * @class SlideshowThumbs
  3715. * @constructor
  3716. * @param config {Object} Configuration object
  3717. * @extends Widget
  3718. */
  3719. Y.namespace('FL').SlideshowThumbs = Y.Base.create('fl-slideshow-thumbs', Y.Widget, [Y.WidgetParent, Y.WidgetChild], {
  3720. /**
  3721. * A div node used to hide the overflow when
  3722. * transitioning between pages.
  3723. *
  3724. * @property _clipBox
  3725. * @type Object
  3726. * @default null
  3727. * @protected
  3728. */
  3729. _clipBox: null,
  3730. /**
  3731. * A div node used to hold the pages.
  3732. *
  3733. * @property _pagesBox
  3734. * @type Object
  3735. * @default null
  3736. * @protected
  3737. */
  3738. _pagesBox: null,
  3739. /**
  3740. * A reference to the active page div node. Holds a grid
  3741. * of FL.SlideshowImage instances.
  3742. *
  3743. * @property _activePageBox
  3744. * @type Object
  3745. * @default null
  3746. * @protected
  3747. */
  3748. _activePageBox: null,
  3749. /**
  3750. * The index of the active page of thumbs.
  3751. *
  3752. * @property _activePageIndex
  3753. * @type Number
  3754. * @default 0
  3755. * @protected
  3756. */
  3757. _activePageIndex: 0,
  3758. /**
  3759. * A reference to the next page div node. Holds a grid
  3760. * of FL.SlideshowImage instances.
  3761. *
  3762. * @property _nextPageBox
  3763. * @type Object
  3764. * @default null
  3765. * @protected
  3766. */
  3767. _nextPageBox: null,
  3768. /**
  3769. * An array of FL.SlideshowImage instances in the active page.
  3770. *
  3771. * @property _activeImages
  3772. * @type Array
  3773. * @default null
  3774. * @protected
  3775. */
  3776. _activeImages: null,
  3777. /**
  3778. * An array of FL.SlideshowImage instances used to
  3779. * preload the next page of images.
  3780. *
  3781. * @property _nextImages
  3782. * @type Array
  3783. * @default null
  3784. * @protected
  3785. */
  3786. _nextImages: null,
  3787. /**
  3788. * An array of FL.SlideshowImage instances used to
  3789. * preload the previous page of images.
  3790. *
  3791. * @property _prevImages
  3792. * @type Array
  3793. * @default null
  3794. * @protected
  3795. */
  3796. _prevImages: null,
  3797. /**
  3798. * An instance of FL.SlideshowNav used for the left nav.
  3799. *
  3800. * @property _leftNav
  3801. * @type Object
  3802. * @default null
  3803. * @protected
  3804. */
  3805. _leftNav: null,
  3806. /**
  3807. * An instance of FL.SlideshowNav used for the right nav.
  3808. *
  3809. * @property _rightNav
  3810. * @type Object
  3811. * @default null
  3812. * @protected
  3813. */
  3814. _rightNav: null,
  3815. /**
  3816. * An instance of FL.SlideshowNav used for the top nav.
  3817. *
  3818. * @property _topNav
  3819. * @type Object
  3820. * @default null
  3821. * @protected
  3822. */
  3823. _topNav: null,
  3824. /**
  3825. * An instance of FL.SlideshowNav used for the bottom nav.
  3826. *
  3827. * @property _bottomNav
  3828. * @type Object
  3829. * @default null
  3830. * @protected
  3831. */
  3832. _bottomNav: null,
  3833. /**
  3834. * Height of the bounding box.
  3835. *
  3836. * @property _bbHeight
  3837. * @type Number
  3838. * @default 0
  3839. * @protected
  3840. */
  3841. _bbHeight: 0,
  3842. /**
  3843. * Width of the bounding box.
  3844. *
  3845. * @property _bbWidth
  3846. * @type Number
  3847. * @default 0
  3848. * @protected
  3849. */
  3850. _bbWidth: 0,
  3851. /**
  3852. * Width of the content box.
  3853. *
  3854. * @property _cbWidth
  3855. * @type Number
  3856. * @default 0
  3857. * @protected
  3858. */
  3859. _cbWidth: 0,
  3860. /**
  3861. * Left margin of the clip box.
  3862. *
  3863. * @property _clipBoxMarginLeft
  3864. * @type Number
  3865. * @default 0
  3866. * @protected
  3867. */
  3868. _clipBoxMarginLeft: 0,
  3869. /**
  3870. * Top position of the clip box.
  3871. *
  3872. * @property _clipBoxTop
  3873. * @type Number
  3874. * @default 0
  3875. * @protected
  3876. */
  3877. _clipBoxTop: 0,
  3878. /**
  3879. * The number of columns per page.
  3880. *
  3881. * @property _colsPerPage
  3882. * @type Number
  3883. * @default 0
  3884. * @protected
  3885. */
  3886. _colsPerPage: 0,
  3887. /**
  3888. * The number of rows per page.
  3889. *
  3890. * @property _rowsPerPage
  3891. * @type Number
  3892. * @default 0
  3893. * @protected
  3894. */
  3895. _rowsPerPage: 0,
  3896. /**
  3897. * The number of images per page.
  3898. *
  3899. * @property _imagesPerPage
  3900. * @type Number
  3901. * @default 0
  3902. * @protected
  3903. */
  3904. _imagesPerPage: 0,
  3905. /**
  3906. * The number of pages.
  3907. *
  3908. * @property _numPages
  3909. * @type Number
  3910. * @default 0
  3911. * @protected
  3912. */
  3913. _numPages: 0,
  3914. /**
  3915. * Height of the pages.
  3916. *
  3917. * @property _pageHeight
  3918. * @type Number
  3919. * @default 0
  3920. * @protected
  3921. */
  3922. _pageHeight: 0,
  3923. /**
  3924. * Width of the pages.
  3925. *
  3926. * @property _pageWidth
  3927. * @type Number
  3928. * @default 0
  3929. * @protected
  3930. */
  3931. _pageWidth: 0,
  3932. /**
  3933. * The horizontal spacing between thumbs.
  3934. *
  3935. * @property _horizontalSpacing
  3936. * @type Number
  3937. * @default 0
  3938. * @protected
  3939. */
  3940. _horizontalSpacing: 0,
  3941. /**
  3942. * The vertical spacing between thumbs.
  3943. *
  3944. * @property _verticalSpacing
  3945. * @type Number
  3946. * @default 0
  3947. * @protected
  3948. */
  3949. _verticalSpacing: 0,
  3950. /**
  3951. * Width of the left nav.
  3952. *
  3953. * @property _leftNavWidth
  3954. * @type Number
  3955. * @default 0
  3956. * @protected
  3957. */
  3958. _leftNavWidth: 0,
  3959. /**
  3960. * Width of the right nav.
  3961. *
  3962. * @property _rightNavWidth
  3963. * @type Number
  3964. * @default 0
  3965. * @protected
  3966. */
  3967. _rightNavWidth: 0,
  3968. /**
  3969. * An instance of FL.SlideshowTransition for the current transition.
  3970. *
  3971. * @property _transition
  3972. * @type FL.SlideshowTransition
  3973. * @default null
  3974. * @protected
  3975. */
  3976. _transition: null,
  3977. /**
  3978. * Whether the pages are currently transitioning or not.
  3979. *
  3980. * @property _verticalSpacing
  3981. * @type Boolean
  3982. * @default false
  3983. * @protected
  3984. */
  3985. _transitioning: false,
  3986. /**
  3987. * Direction of the current transition.
  3988. *
  3989. * @property _transitionDirection
  3990. * @type String
  3991. * @default next
  3992. * @protected
  3993. */
  3994. _transitionDirection: 'next',
  3995. /**
  3996. * Provides functionality for gesture based transitions
  3997. * between the active and next pages.
  3998. *
  3999. * @property _gestures
  4000. * @type FL.SlideshowGestures
  4001. * @default null
  4002. * @protected
  4003. */
  4004. _gestures: null,
  4005. /**
  4006. * Initialize image vars.
  4007. *
  4008. * @method initializer
  4009. * @protected
  4010. */
  4011. initializer: function()
  4012. {
  4013. this._activeImages = [];
  4014. this._nextImages = [];
  4015. this._prevImages = [];
  4016. },
  4017. /**
  4018. * Renders the UI boxes.
  4019. *
  4020. * @method renderUI
  4021. * @protected
  4022. */
  4023. renderUI: function()
  4024. {
  4025. this._renderBoxes();
  4026. this._renderNavs();
  4027. },
  4028. /**
  4029. * Binds the UI events.
  4030. *
  4031. * @method bindUI
  4032. * @protected
  4033. */
  4034. bindUI: function()
  4035. {
  4036. var root = this.get('root'),
  4037. id = this.get('id'),
  4038. transition = this.get('transition');
  4039. root.on(id + '|albumLoadComplete', this._albumLoadComplete, this);
  4040. if('ontouchstart' in window && this.get('touchSupport')) {
  4041. this._gestures = new Y.FL.SlideshowGestures({
  4042. direction: transition == 'slideVertical' ? 'vertical' : 'horizontal',
  4043. activeItem: this._activePageBox,
  4044. nextItem: this._nextPageBox
  4045. });
  4046. this._gestures.on('moveStart', this._gesturesMoveStart, this);
  4047. this._gestures.on('endComplete', this._gesturesEndComplete, this);
  4048. }
  4049. },
  4050. /**
  4051. * Syncs the UI boxes.
  4052. *
  4053. * @method syncUI
  4054. * @protected
  4055. */
  4056. syncUI: function()
  4057. {
  4058. this._syncBoxes();
  4059. this._syncNavs();
  4060. },
  4061. /**
  4062. * @method destructor
  4063. * @protected
  4064. */
  4065. destructor: function()
  4066. {
  4067. var root = this.get('root'),
  4068. id = this.get('id');
  4069. root.detach(id + '|*');
  4070. Y.FL.SlideshowImageLoader.removeGroup('thumbs');
  4071. },
  4072. /**
  4073. * Unload all images.
  4074. *
  4075. * @method unload
  4076. */
  4077. unload: function()
  4078. {
  4079. var root = this.get('root'),
  4080. id = this.get('id'),
  4081. i = 0;
  4082. root.detach(id + '|imageLoadComplete');
  4083. Y.FL.SlideshowImageLoader.removeGroup('thumbs');
  4084. for( ; i < this._activeImages.length; i++) {
  4085. this._activeImages[i].unload();
  4086. }
  4087. },
  4088. /**
  4089. * Resizes the UI boxes.
  4090. *
  4091. * @method resize
  4092. */
  4093. resize: function()
  4094. {
  4095. this._setSizeInfo();
  4096. this._togglePageButtons();
  4097. this._resizeBoxes();
  4098. this._resizeNavs();
  4099. if(this.get('root').albumInfo) {
  4100. Y.FL.SlideshowImageLoader.removeGroup('thumbs');
  4101. this._renderActivePage();
  4102. this._preloadNextPage();
  4103. this._preloadPrevPage();
  4104. }
  4105. // Enable or disable gestures.
  4106. if(this._gestures && this._numPages < 2) {
  4107. this._gestures.disable();
  4108. }
  4109. else if(this._gestures) {
  4110. this._gestures.enable();
  4111. }
  4112. },
  4113. /**
  4114. * Transitions to the previous page.
  4115. *
  4116. * @method prevPage
  4117. * @protected
  4118. */
  4119. prevPage: function()
  4120. {
  4121. if(this._transitioning) {
  4122. return;
  4123. }
  4124. this._transitionStart('prev');
  4125. },
  4126. /**
  4127. * Transitions to the next page.
  4128. *
  4129. * @method nextPage
  4130. * @protected
  4131. */
  4132. nextPage: function()
  4133. {
  4134. if(this._transitioning) {
  4135. return;
  4136. }
  4137. this._transitionStart('next');
  4138. },
  4139. /**
  4140. * Called when an album is loaded into the root slideshow widget.
  4141. *
  4142. * @method _albumLoadComplete
  4143. * @protected
  4144. */
  4145. _albumLoadComplete: function()
  4146. {
  4147. var root = this.get('root'),
  4148. id = this.get('id');
  4149. root.once(id + '|imageLoadComplete', this.resize, this);
  4150. root.on(id + '|imageLoadComplete', this._imageLoadComplete, this);
  4151. },
  4152. /**
  4153. * Called when an image is loaded into the root slideshow widget.
  4154. *
  4155. * @method _imageLoadComplete
  4156. * @protected
  4157. */
  4158. _imageLoadComplete: function()
  4159. {
  4160. var albumInfo = this.get('root').albumInfo,
  4161. lastActive = Y.one('.fl-slideshow-image-active'),
  4162. lastInfo = lastActive ? lastActive._imageInfo : null,
  4163. nextActive = null,
  4164. nextInfo = this.get('root').imageInfo;
  4165. this._setActiveImage(this._activeImages);
  4166. nextActive = Y.one('.fl-slideshow-image-active');
  4167. if(lastActive && !nextActive) {
  4168. if(nextInfo.index === 0 && lastInfo.index === albumInfo.images.length - 1) {
  4169. this.nextPage();
  4170. }
  4171. else if(lastInfo.index === 0 && nextInfo.index === albumInfo.images.length - 1) {
  4172. this.prevPage();
  4173. }
  4174. else if(lastInfo.index < nextInfo.index) {
  4175. this.nextPage();
  4176. }
  4177. else if(lastInfo.index > nextInfo.index) {
  4178. this.prevPage();
  4179. }
  4180. }
  4181. },
  4182. /**
  4183. * Renders the boxes.
  4184. *
  4185. * @method _renderBoxes
  4186. * @protected
  4187. */
  4188. _renderBoxes: function()
  4189. {
  4190. // Clip box
  4191. this._clipBox = Y.Node.create('<div></div>');
  4192. this._clipBox.addClass('fl-slideshow-thumbs-clip');
  4193. this.get('contentBox').insert(this._clipBox);
  4194. // Pages box
  4195. this._pagesBox = Y.Node.create('<div></div>');
  4196. this._pagesBox.addClass('fl-slideshow-thumbs-pages');
  4197. this._clipBox.insert(this._pagesBox);
  4198. // Active page box
  4199. this._activePageBox = Y.Node.create('<div></div>');
  4200. this._activePageBox.addClass('fl-slideshow-thumbs-page');
  4201. this._pagesBox.insert(this._activePageBox);
  4202. // Next page box
  4203. this._nextPageBox = Y.Node.create('<div></div>');
  4204. this._nextPageBox.addClass('fl-slideshow-thumbs-page');
  4205. this._pagesBox.insert(this._nextPageBox);
  4206. },
  4207. /**
  4208. * Syncs the boxes.
  4209. *
  4210. * @method _syncBoxes
  4211. * @protected
  4212. */
  4213. _syncBoxes: function()
  4214. {
  4215. // Active page box
  4216. this._activePageBox.setStyle('left', '0');
  4217. // Next page box
  4218. this._nextPageBox.setStyle('left', '-9999px');
  4219. },
  4220. /**
  4221. * Resizes the boxes.
  4222. *
  4223. * @method _resizeBoxes
  4224. * @protected
  4225. */
  4226. _resizeBoxes: function()
  4227. {
  4228. this.set('width', this._bbWidth);
  4229. this.set('height', this._bbHeight);
  4230. this.get('contentBox').setStyle('width', this._cbWidth + 'px');
  4231. this._clipBox.setStyle('width', this._pageWidth + 'px');
  4232. this._clipBox.setStyle('height', this._pageHeight + 'px');
  4233. this._clipBox.setStyle('padding', this._verticalSpacing + 'px 0 0 ' + this._horizontalSpacing + 'px ');
  4234. this._clipBox.setStyle('margin', '0 0 0 ' + this._clipBoxMarginLeft + 'px');
  4235. this._clipBox.setStyle('top', this._clipBoxTop);
  4236. this._pagesBox.setStyle('width', this._pageWidth + 'px');
  4237. this._pagesBox.setStyle('height', this._pageHeight + 'px');
  4238. this._activePageBox.setStyle('width', this._pageWidth + 'px');
  4239. this._activePageBox.setStyle('height', this._pageHeight + 'px');
  4240. this._nextPageBox.setStyle('width', this._pageWidth + 'px');
  4241. this._nextPageBox.setStyle('height', this._pageHeight + 'px');
  4242. },
  4243. /**
  4244. * Renders the active page of images.
  4245. *
  4246. * @method _renderActivePage
  4247. * @protected
  4248. */
  4249. _renderActivePage: function()
  4250. {
  4251. var i = 0,
  4252. root = this.get('root'),
  4253. imageIndex = this._imagesPerPage * this._activePageIndex,
  4254. endIndex = imageIndex + this._imagesPerPage,
  4255. images = root.albumInfo.images;
  4256. this._clearActiveImage();
  4257. // Remove current images
  4258. for( ; i < this._activeImages.length; i++) {
  4259. this._activeImages[i].remove();
  4260. this._activeImages[i].unload();
  4261. this._activeImages[i].get('boundingBox')._imageInfo = null;
  4262. this._activeImages[i].get('boundingBox').remove();
  4263. }
  4264. // Draw images
  4265. for(i = 0; imageIndex < endIndex; imageIndex++) {
  4266. if(!images[imageIndex]) {
  4267. break;
  4268. }
  4269. this._renderImage(this._activeImages, i, this._activePageBox, images[imageIndex]);
  4270. i++;
  4271. }
  4272. this._setActiveImage(this._activeImages);
  4273. },
  4274. /**
  4275. * Renders the next page of images.
  4276. *
  4277. * @method _renderNextPage
  4278. * @protected
  4279. */
  4280. _renderNextPage: function()
  4281. {
  4282. var i = 0,
  4283. imageArray = this._transitionDirection == 'next' ? this._nextImages : this._prevImages;
  4284. this._nextPageBox.get('children').remove();
  4285. for( ; i < imageArray.length; i++) {
  4286. if(imageArray[i]._imageInfo) {
  4287. this._renderImage(imageArray, i, this._nextPageBox, imageArray[i]._imageInfo);
  4288. }
  4289. else {
  4290. break;
  4291. }
  4292. }
  4293. this._setActiveImage(imageArray);
  4294. },
  4295. /**
  4296. * Preloads the next page of images.
  4297. *
  4298. * @method _preloadNextPage
  4299. * @protected
  4300. */
  4301. _preloadNextPage: function()
  4302. {
  4303. var pageIndex = this._activePageIndex + 1 >= this._numPages ? 0 : this._activePageIndex + 1;
  4304. this._preloadPage(pageIndex, this._nextImages);
  4305. },
  4306. /**
  4307. * Preloads the previous page of images.
  4308. *
  4309. * @method _preloadPrevPage
  4310. * @protected
  4311. */
  4312. _preloadPrevPage: function()
  4313. {
  4314. var pageIndex = this._activePageIndex - 1 < 0 ? this._numPages - 1 : this._activePageIndex - 1;
  4315. this._preloadPage(pageIndex, this._prevImages);
  4316. },
  4317. /**
  4318. * Preloads a page of images.
  4319. *
  4320. * @method _preloadPage
  4321. * @param imageIndex {Number} The image index to start preloading from.
  4322. * @param imageArray {Array} The array to store the preloaded images.
  4323. * @protected
  4324. */
  4325. _preloadPage: function(pageIndex, imageArray)
  4326. {
  4327. var i = 0,
  4328. root = this.get('root'),
  4329. images = root.albumInfo.images,
  4330. imageIndex = pageIndex * this._imagesPerPage,
  4331. endIndex = imageIndex + this._imagesPerPage,
  4332. imageConfig = this.get('imageConfig'),
  4333. width = imageConfig.width,
  4334. height = imageConfig.height;
  4335. if(this._numPages > 1) {
  4336. // Unload existing images
  4337. for( ; i < imageArray.length; i++) {
  4338. imageArray[i].remove();
  4339. imageArray[i].unload();
  4340. }
  4341. // Preload the images
  4342. for(i = 0; imageIndex < endIndex; imageIndex++) {
  4343. if(!images[imageIndex]) {
  4344. continue;
  4345. }
  4346. this._renderImage(imageArray, i);
  4347. imageArray[i].preload(images[imageIndex], width, height);
  4348. i++;
  4349. }
  4350. }
  4351. },
  4352. /**
  4353. * Renders an image.
  4354. *
  4355. * @method _renderImage
  4356. * @protected
  4357. */
  4358. _renderImage: function(imageArray, i, page, imageInfo)
  4359. {
  4360. var imageBB = null,
  4361. imageConfig = this.get('imageConfig');
  4362. // Create the image?
  4363. if(typeof imageArray[i] == 'undefined') {
  4364. imageConfig.loadGroup = 'thumbs';
  4365. imageConfig.useThumbSizes = true;
  4366. imageConfig.loadVideos = false;
  4367. imageArray[i] = new Y.FL.SlideshowImage(imageConfig);
  4368. imageBB = imageArray[i].get('boundingBox');
  4369. imageBB.on('click', this._imageClick, this);
  4370. imageBB.on('mouseover', this._imageMouseover, this);
  4371. imageBB.on('mouseout', this._imageMouseout, this);
  4372. }
  4373. // Image bounding box
  4374. imageBB = imageArray[i].get('boundingBox');
  4375. imageBB.setStyle('margin', '0 ' + this._horizontalSpacing + 'px ' + this._verticalSpacing + 'px 0');
  4376. // Add the image to a page?
  4377. if(page) {
  4378. this._childrenContainer = page;
  4379. this.add(imageArray[i]);
  4380. imageArray[i].resize(imageConfig.width, imageConfig.height);
  4381. }
  4382. // Load the image?
  4383. if(imageInfo) {
  4384. imageArray[i].load(imageInfo);
  4385. imageBB._imageInfo = imageInfo;
  4386. }
  4387. },
  4388. /**
  4389. * Overrides the WidgetParent _uiAddChild method so _renderImage
  4390. * will render to the appropriate page.
  4391. *
  4392. * @method _uiAddChild
  4393. * @protected
  4394. * @param child {Widget} The child Widget instance to render.
  4395. * @param parentNode {Object} The Node under which the
  4396. * child Widget is to be rendered. Set to the appropriate page
  4397. * in the _renderImage method by setting _childrenContainer.
  4398. */
  4399. _uiAddChild: function (child, parentNode)
  4400. {
  4401. child.render(parentNode);
  4402. parentNode.appendChild(child.get('boundingBox'));
  4403. },
  4404. /**
  4405. * Called when an image is clicked.
  4406. *
  4407. * @method _imageClick
  4408. * @protected
  4409. */
  4410. _imageClick: function(e)
  4411. {
  4412. var root = this.get('root');
  4413. if(this.get('pauseOnClick')) {
  4414. root.pause();
  4415. }
  4416. root.loadImage(e.currentTarget._imageInfo.index);
  4417. /**
  4418. * Fires when an image is clicked.
  4419. *
  4420. * @event imageClick
  4421. */
  4422. this.fire('imageClick');
  4423. },
  4424. /**
  4425. * Sets the active image.
  4426. *
  4427. * @method _setActiveImage
  4428. * @param imageArray {Array} The image array to check for the active image.
  4429. * @protected
  4430. */
  4431. _setActiveImage: function(imageArray)
  4432. {
  4433. var i = 0;
  4434. this._clearActiveImage();
  4435. for( ; i < imageArray.length; i++) {
  4436. if(imageArray[i]._imageInfo) {
  4437. if(imageArray[i]._imageInfo.index == this.get('root').imageInfo.index) {
  4438. imageArray[i].get('boundingBox').addClass('fl-slideshow-image-active');
  4439. break;
  4440. }
  4441. }
  4442. }
  4443. },
  4444. /**
  4445. * Removes the class name 'fl-slideshow-image-active'
  4446. * from the active image.
  4447. *
  4448. * @method _clearActiveImage
  4449. * @protected
  4450. */
  4451. _clearActiveImage: function()
  4452. {
  4453. var active = Y.one('.fl-slideshow-image-active');
  4454. if(active) {
  4455. active.removeClass('fl-slideshow-image-active');
  4456. }
  4457. },
  4458. /**
  4459. * Gets the transition type.
  4460. *
  4461. * @method _getTransition
  4462. * @protected
  4463. */
  4464. _getTransition: function()
  4465. {
  4466. var transition = this.get('transition');
  4467. if(transition == 'slideHorizontal' && this._transitionDirection == 'next') {
  4468. return 'slideLeft';
  4469. }
  4470. else if(transition == 'slideHorizontal' && this._transitionDirection == 'prev') {
  4471. return 'slideRight';
  4472. }
  4473. else if(transition == 'slideVertical' && this._transitionDirection == 'next') {
  4474. return 'slideUp';
  4475. }
  4476. else if(transition == 'slideVertical' && this._transitionDirection == 'prev') {
  4477. return 'slideDown';
  4478. }
  4479. return transition;
  4480. },
  4481. /**
  4482. * Starts the transition, moving in the provided direction.
  4483. *
  4484. * @method _transitionStart
  4485. * @param direction {String} The direction to transition.
  4486. * @protected
  4487. */
  4488. _transitionStart: function(direction)
  4489. {
  4490. if(this._numPages > 1) {
  4491. Y.FL.SlideshowImageLoader.removeGroup('thumbs');
  4492. this._transitionDirection = direction;
  4493. this._transitioning = true;
  4494. this._nextPageBox.setStyle('left', '0px');
  4495. this._renderNextPage();
  4496. this._transition = new Y.FL.SlideshowTransition({
  4497. itemIn: this._nextPageBox,
  4498. itemOut: this._activePageBox,
  4499. type: this._getTransition(),
  4500. duration: this.get('transitionDuration'),
  4501. easing: this.get('transitionEasing')
  4502. });
  4503. this._transition.once('complete', this._transitionComplete, this);
  4504. this._transition.run();
  4505. // Disable gestures if set.
  4506. if(this._gestures) {
  4507. this._gestures.disable();
  4508. }
  4509. }
  4510. },
  4511. /**
  4512. * Transition cleanup called when the current transition ends.
  4513. *
  4514. * @method _transitionComplete
  4515. * @protected
  4516. */
  4517. _transitionComplete: function()
  4518. {
  4519. this._swapPageRefs();
  4520. this._transitioning = false;
  4521. this._transitionDirection = '';
  4522. this._transition = null;
  4523. // Enable gestures if set.
  4524. if(this._gestures) {
  4525. this._gestures.enable();
  4526. }
  4527. /**
  4528. * Fires when a page transition completes.
  4529. *
  4530. * @event transitionComplete
  4531. */
  4532. this.fire('transitionComplete');
  4533. },
  4534. /**
  4535. * @method _gesturesMoveStart
  4536. * @param e {Object} The event object.
  4537. * @protected
  4538. */
  4539. _gesturesMoveStart: function(e)
  4540. {
  4541. Y.FL.SlideshowImageLoader.removeGroup('thumbs');
  4542. this._transitionDirection = e.direction;
  4543. this._renderNextPage();
  4544. },
  4545. /**
  4546. * @method _gesturesEndComplete
  4547. * @protected
  4548. */
  4549. _gesturesEndComplete: function()
  4550. {
  4551. this._swapPageRefs();
  4552. this._transitionDirection = '';
  4553. this.fire('transitionComplete');
  4554. },
  4555. /**
  4556. * Swaps the active page and next page references when
  4557. * a transition completes and sets the active page index.
  4558. *
  4559. * @method _swapPageRefs
  4560. * @protected
  4561. */
  4562. _swapPageRefs: function()
  4563. {
  4564. var lastBox = this._activePageBox,
  4565. lastImages = this._activeImages;
  4566. this._activePageBox = this._nextPageBox;
  4567. this._nextPageBox = lastBox;
  4568. this._nextPageBox.setStyle('left', '-9999px');
  4569. if(this._transitionDirection == 'next') {
  4570. this._activeImages = this._nextImages;
  4571. this._nextImages = lastImages;
  4572. }
  4573. else {
  4574. this._activeImages = this._prevImages;
  4575. this._prevImages = lastImages;
  4576. }
  4577. // Active page index
  4578. if(this._transitionDirection == 'next' && this._activePageIndex + 1 < this._numPages) {
  4579. this._activePageIndex++;
  4580. }
  4581. else if(this._transitionDirection == 'next') {
  4582. this._activePageIndex = 0;
  4583. }
  4584. else if(this._transitionDirection == 'prev' && this._activePageIndex - 1 > -1) {
  4585. this._activePageIndex--;
  4586. }
  4587. else if(this._transitionDirection == 'prev') {
  4588. this._activePageIndex = this._numPages - 1;
  4589. }
  4590. // Swap gesture refs
  4591. if(this._gestures) {
  4592. this._gestures.set('activeItem', this._activePageBox);
  4593. this._gestures.set('nextItem', this._nextPageBox);
  4594. }
  4595. this._preloadNextPage();
  4596. this._preloadPrevPage();
  4597. },
  4598. /**
  4599. * Renders the enabled navs.
  4600. *
  4601. * @method _renderNavs
  4602. * @protected
  4603. */
  4604. _renderNavs: function()
  4605. {
  4606. var topNavButtons = this.get('topNavButtons'),
  4607. rightNavButtons = this.get('rightNavButtons'),
  4608. bottomNavButtons = this.get('bottomNavButtons'),
  4609. leftNavButtons = this.get('leftNavButtons');
  4610. if(this.get('topNavEnabled') && topNavButtons.length > 0) {
  4611. this._topNav = new Y.FL.SlideshowNav({ buttons: topNavButtons });
  4612. this._topNav.get('boundingBox').addClass('fl-slideshow-thumbs-top-nav');
  4613. this.add(this._topNav);
  4614. this._topNav.render(this.get('contentBox'));
  4615. this._clipBox.insert(this._topNav.get('boundingBox'), 'before');
  4616. this._bindNavEvents(this._topNav);
  4617. }
  4618. if(this.get('rightNavEnabled') && rightNavButtons.length > 0) {
  4619. this._rightNav = new Y.FL.SlideshowNav({ buttons: rightNavButtons });
  4620. this._rightNav.get('boundingBox').addClass('fl-slideshow-thumbs-right-nav');
  4621. this.add(this._rightNav);
  4622. this._rightNav.render(this.get('contentBox'));
  4623. this._bindNavEvents(this._rightNav);
  4624. }
  4625. if(this.get('bottomNavEnabled') && bottomNavButtons.length > 0) {
  4626. this._bottomNav = new Y.FL.SlideshowNav({ buttons: bottomNavButtons });
  4627. this._bottomNav.get('boundingBox').addClass('fl-slideshow-thumbs-bottom-nav');
  4628. this.add(this._bottomNav);
  4629. this._bottomNav.render(this.get('contentBox'));
  4630. this._bindNavEvents(this._bottomNav);
  4631. }
  4632. if(this.get('leftNavEnabled') && leftNavButtons.length > 0) {
  4633. this._leftNav = new Y.FL.SlideshowNav({ buttons: leftNavButtons });
  4634. this._leftNav.get('boundingBox').addClass('fl-slideshow-thumbs-left-nav');
  4635. this.add(this._leftNav);
  4636. this._leftNav.render(this.get('contentBox'));
  4637. this._bindNavEvents(this._leftNav);
  4638. }
  4639. },
  4640. /**
  4641. * Syncs the navs.
  4642. *
  4643. * @method _syncNavs
  4644. * @protected
  4645. */
  4646. _syncNavs: function()
  4647. {
  4648. var rightNavBB, bottomNavBB, leftNavBB;
  4649. if(this._rightNav) {
  4650. rightNavBB = this._rightNav.get('boundingBox');
  4651. rightNavBB.setStyle('position', 'absolute');
  4652. rightNavBB.setStyle('top', '0px');
  4653. rightNavBB.setStyle('right', '0px');
  4654. }
  4655. if(this._bottomNav) {
  4656. bottomNavBB = this._bottomNav.get('boundingBox');
  4657. bottomNavBB.setStyle('position', 'absolute');
  4658. bottomNavBB.setStyle('bottom', '0px');
  4659. bottomNavBB.setStyle('width', '100%');
  4660. }
  4661. if(this._leftNav) {
  4662. leftNavBB = this._leftNav.get('boundingBox');
  4663. leftNavBB.setStyle('position', 'absolute');
  4664. leftNavBB.setStyle('top', '0px');
  4665. leftNavBB.setStyle('left', '0px');
  4666. }
  4667. },
  4668. /**
  4669. * Resizes the navs.
  4670. *
  4671. * @method _resizeNavs
  4672. * @protected
  4673. */
  4674. _resizeNavs: function()
  4675. {
  4676. var rightNavBB,
  4677. leftNavBB,
  4678. marginTop;
  4679. if(this._rightNav) {
  4680. rightNavBB = this._rightNav.get('boundingBox');
  4681. marginTop = this._bbHeight/2 - parseInt(rightNavBB.getComputedStyle('height'), 10)/2;
  4682. rightNavBB.setStyle('marginTop', marginTop + 'px');
  4683. }
  4684. if(this._leftNav) {
  4685. leftNavBB = this._leftNav.get('boundingBox');
  4686. marginTop = this._bbHeight/2 - parseInt(leftNavBB.getComputedStyle('height'), 10)/2;
  4687. leftNavBB.setStyle('marginTop', marginTop + 'px');
  4688. }
  4689. },
  4690. /**
  4691. * Binds events to the provided nav.
  4692. *
  4693. * @method _bindNavEvents
  4694. * @param nav {Object} The nav to bind to.
  4695. * @protected
  4696. */
  4697. _bindNavEvents: function(nav)
  4698. {
  4699. if(nav._buttons.prevPage) {
  4700. nav._buttons.prevPage.on('click', this.prevPage, this);
  4701. }
  4702. if(nav._buttons.nextPage) {
  4703. nav._buttons.nextPage.on('click', this.nextPage, this);
  4704. }
  4705. nav.on('resize', this.resize, this);
  4706. },
  4707. /**
  4708. * Hides the prev page and next page buttons
  4709. * if there is only one page of thumbs.
  4710. *
  4711. * @method _togglePageButtons
  4712. * @protected
  4713. */
  4714. _togglePageButtons: function()
  4715. {
  4716. var buttons = this.get('boundingBox').all('.fl-slideshow-nav-prevPage, .fl-slideshow-nav-nextPage'),
  4717. display = buttons.getStyle('display')[0];
  4718. if(this._numPages == 1 && display == 'inline-block') {
  4719. buttons.setStyle('display', 'none');
  4720. this._setSizeInfo();
  4721. }
  4722. else if(this._numPages > 1 && display == 'none') {
  4723. buttons.setStyle('display', 'inline-block');
  4724. this._setSizeInfo();
  4725. }
  4726. },
  4727. /**
  4728. * Sets the size info used when resizing and loading pages.
  4729. *
  4730. * @method _setSizeInfo
  4731. * @protected
  4732. */
  4733. _setSizeInfo: function()
  4734. {
  4735. var root = this.get('root'),
  4736. bb = this.get('boundingBox'),
  4737. bbPosition = bb.getStyle('position'),
  4738. bbLeftMargin = parseInt(bb.getStyle('marginLeft'), 10),
  4739. bbRightMargin = parseInt(bb.getStyle('marginRight'), 10),
  4740. bbTopMargin = parseInt(bb.getStyle('marginTop'), 10),
  4741. bbBottomMargin = parseInt(bb.getStyle('marginBottom'), 10),
  4742. bbLeftPadding = parseInt(bb.getStyle('paddingLeft'), 10),
  4743. bbRightPadding = parseInt(bb.getStyle('paddingRight'), 10),
  4744. bbTopPadding = parseInt(bb.getStyle('paddingTop'), 10),
  4745. bbBottomPadding = parseInt(bb.getStyle('paddingBottom'), 10),
  4746. parent = bb.get('parentNode'),
  4747. parentWidth = parseInt(parent.getComputedStyle('width'), 10),
  4748. parentHeight = parseInt(parent.getComputedStyle('height'), 10),
  4749. bbWidth = parentWidth - bbLeftPadding - bbRightPadding - bbLeftMargin - bbRightMargin,
  4750. bbHeight = parentHeight - bbTopPadding - bbBottomPadding - bbTopMargin - bbBottomMargin,
  4751. cbWidth = bbWidth,
  4752. pageWidth = bbWidth,
  4753. pageHeight = bbHeight,
  4754. columns = this.get('columns'),
  4755. rows = this.get('rows'),
  4756. imageConfig = this.get('imageConfig'),
  4757. horizontalSpacing = this.get('horizontalSpacing'),
  4758. verticalSpacing = this.get('verticalSpacing'),
  4759. spaceEvenly = this.get('spaceEvenly'),
  4760. centerSinglePage = this.get('centerSinglePage'),
  4761. leftNavWidth = 0,
  4762. rightNavWidth = 0,
  4763. topNavHeight = 0,
  4764. bottomNavHeight = 0,
  4765. colsPerPage = columns,
  4766. rowsPerPage = rows,
  4767. imagesPerPage = 0,
  4768. numPages = 1,
  4769. clipBoxMarginLeft = 0,
  4770. clipBoxTop = 0,
  4771. availHorizSpace = 0,
  4772. availVerticalSpace = 0;
  4773. // Position absolute causes some resizing bugs.
  4774. bb.setStyle('position', 'relative');
  4775. // Bounding box width
  4776. if(!isNaN(columns)) {
  4777. bbWidth = pageWidth = columns * (imageConfig.width + horizontalSpacing) + horizontalSpacing;
  4778. }
  4779. // Bounding box height
  4780. if(!isNaN(rows)) {
  4781. bbHeight = pageHeight = rows * (imageConfig.height + verticalSpacing) + verticalSpacing;
  4782. }
  4783. // Compensate for the navs
  4784. if(this._leftNav) {
  4785. leftNavWidth = parseInt(this._leftNav.get('boundingBox').getComputedStyle('width'), 10);
  4786. if(isNaN(columns)) {
  4787. pageWidth -= leftNavWidth;
  4788. }
  4789. else {
  4790. bbWidth += leftNavWidth;
  4791. }
  4792. }
  4793. if(this._rightNav) {
  4794. rightNavWidth = parseInt(this._rightNav.get('boundingBox').getComputedStyle('width'), 10);
  4795. if(isNaN(columns)) {
  4796. pageWidth -= rightNavWidth;
  4797. }
  4798. else {
  4799. bbWidth += rightNavWidth;
  4800. }
  4801. }
  4802. if(this._topNav) {
  4803. topNavHeight = parseInt(this._topNav.get('boundingBox').getComputedStyle('height'), 10);
  4804. if(isNaN(rows)) {
  4805. pageHeight -= topNavHeight;
  4806. }
  4807. else {
  4808. bbHeight += topNavHeight;
  4809. }
  4810. }
  4811. if(this._bottomNav) {
  4812. bottomNavHeight = parseInt(this._bottomNav.get('boundingBox').getComputedStyle('height'), 10);
  4813. if(isNaN(rows)) {
  4814. pageHeight -= bottomNavHeight;
  4815. }
  4816. else {
  4817. bbHeight += bottomNavHeight;
  4818. }
  4819. }
  4820. // Columns per page
  4821. if(isNaN(columns)) {
  4822. colsPerPage = Math.floor(pageWidth/(imageConfig.width + horizontalSpacing));
  4823. colsPerPage = colsPerPage < 1 ? 1 : colsPerPage;
  4824. }
  4825. // Rows per page
  4826. if(isNaN(rows)) {
  4827. rowsPerPage = Math.floor(pageHeight/(imageConfig.height + verticalSpacing));
  4828. rowsPerPage = rowsPerPage < 1 ? 1 : rowsPerPage;
  4829. }
  4830. // Images per page
  4831. imagesPerPage = colsPerPage * rowsPerPage;
  4832. // Number of pages
  4833. if(root.albumInfo) {
  4834. numPages = Math.ceil(root.albumInfo.images.length/imagesPerPage);
  4835. }
  4836. // Horizontal spacing
  4837. if(isNaN(columns) && spaceEvenly) {
  4838. horizontalSpacing = Math.floor((pageWidth - (imageConfig.width * colsPerPage))/(colsPerPage + 1));
  4839. }
  4840. // Vertical spacing
  4841. if(isNaN(rows) && spaceEvenly) {
  4842. verticalSpacing = Math.floor((pageHeight - (imageConfig.height * rowsPerPage))/(rowsPerPage + 1));
  4843. }
  4844. // Content container width
  4845. if(root.albumInfo && centerSinglePage && numPages == 1 && rowsPerPage == 1) {
  4846. cbWidth = root.albumInfo.images.length * imageConfig.width;
  4847. cbWidth += horizontalSpacing * (root.albumInfo.images.length + 1);
  4848. if(this._leftNav) {
  4849. cbWidth += leftNavWidth;
  4850. }
  4851. if(this._rightNav) {
  4852. cbWidth += rightNavWidth;
  4853. }
  4854. }
  4855. else {
  4856. cbWidth = bbWidth;
  4857. }
  4858. // Final page width and height
  4859. if(root.albumInfo && centerSinglePage && numPages == 1 && rowsPerPage == 1) {
  4860. pageWidth = root.albumInfo.images.length * imageConfig.width;
  4861. pageWidth += horizontalSpacing * root.albumInfo.images.length;
  4862. }
  4863. else {
  4864. pageWidth = colsPerPage * (imageConfig.width + horizontalSpacing);
  4865. }
  4866. pageHeight = rowsPerPage * (imageConfig.height + verticalSpacing);
  4867. // Clip box margin left
  4868. if(numPages < 2) {
  4869. clipBoxMarginLeft = leftNavWidth;
  4870. }
  4871. else {
  4872. availHorizSpace = bbWidth;
  4873. if(this._rightNav) {
  4874. availHorizSpace -= rightNavWidth;
  4875. }
  4876. if(this._leftNav) {
  4877. availHorizSpace -= leftNavWidth;
  4878. clipBoxMarginLeft = leftNavWidth + (availHorizSpace - pageWidth - horizontalSpacing)/2;
  4879. }
  4880. else {
  4881. clipBoxMarginLeft = (availHorizSpace - pageWidth - horizontalSpacing)/2;
  4882. }
  4883. }
  4884. // Clip box margin top
  4885. if(numPages > 1 && !spaceEvenly) {
  4886. availVerticalSpace = bbHeight;
  4887. if(this._topNav) {
  4888. availVerticalSpace -= topNavHeight;
  4889. }
  4890. if(this._bottomNav) {
  4891. availVerticalSpace -= bottomNavHeight;
  4892. }
  4893. clipBoxTop = (availVerticalSpace - (verticalSpacing + pageHeight))/2;
  4894. }
  4895. // Set the info
  4896. this._bbHeight = bbHeight;
  4897. this._bbWidth = bbWidth;
  4898. this._cbWidth = cbWidth;
  4899. this._clipBoxMarginLeft = clipBoxMarginLeft;
  4900. this._clipBoxTop = clipBoxTop;
  4901. this._colsPerPage = colsPerPage;
  4902. this._rowsPerPage = rowsPerPage;
  4903. this._imagesPerPage = imagesPerPage;
  4904. this._numPages = numPages;
  4905. this._pageHeight = pageHeight;
  4906. this._pageWidth = pageWidth;
  4907. this._leftNavWidth = leftNavWidth;
  4908. this._rightNavWidth = rightNavWidth;
  4909. this._horizontalSpacing = horizontalSpacing;
  4910. this._verticalSpacing = verticalSpacing;
  4911. this._activePageIndex = Math.floor(root.imageIndex/this._imagesPerPage);
  4912. // Set back to the initial position.
  4913. bb.setStyle('position', bbPosition);
  4914. }
  4915. }, {
  4916. /**
  4917. * Custom CSS class name for the widget.
  4918. *
  4919. * @property CSS_PREFIX
  4920. * @type String
  4921. * @protected
  4922. * @static
  4923. */
  4924. CSS_PREFIX: 'fl-slideshow-thumbs',
  4925. /**
  4926. * Static property used to define the default attribute configuration of
  4927. * the Widget.
  4928. *
  4929. * @property ATTRS
  4930. * @type Object
  4931. * @protected
  4932. * @static
  4933. */
  4934. ATTRS: {
  4935. /**
  4936. * The number of thumbnail columns. If set to auto, the number of
  4937. * columns will be calculated based on the width of the parent node.
  4938. *
  4939. * @attribute columns
  4940. * @type String or Number
  4941. * @default auto
  4942. */
  4943. columns: {
  4944. value: 'auto'
  4945. },
  4946. /**
  4947. * The number of thumbnail rows. If set to auto, the number of
  4948. * rows will be calculated based on the height of the parent node.
  4949. *
  4950. * @attribute rows
  4951. * @type String or Number
  4952. * @default auto
  4953. */
  4954. rows: {
  4955. value: 'auto'
  4956. },
  4957. /**
  4958. * The horizontal spacing between thumbs.
  4959. *
  4960. * @attribute horizontalSpacing
  4961. * @type Number
  4962. * @default 15
  4963. */
  4964. horizontalSpacing: {
  4965. value: 15
  4966. },
  4967. /**
  4968. * The vertical spacing between thumbs.
  4969. *
  4970. * @attribute verticalSpacing
  4971. * @type Number
  4972. * @default 15
  4973. */
  4974. verticalSpacing: {
  4975. value: 15
  4976. },
  4977. /**
  4978. * Whether to space the thumbs evenly within a page.
  4979. *
  4980. * @attribute spaceEvenly
  4981. * @type Boolean
  4982. * @default true
  4983. */
  4984. spaceEvenly: {
  4985. value: true
  4986. },
  4987. /**
  4988. * Whether to center single pages of thumbs.
  4989. *
  4990. * @attribute centerSinglePage
  4991. * @type Boolean
  4992. * @default false
  4993. */
  4994. centerSinglePage: {
  4995. value: true
  4996. },
  4997. /**
  4998. * Whether to pause the parent slideshow when a thumb is clicked.
  4999. *
  5000. * @attribute pauseOnClick
  5001. * @type Boolean
  5002. * @default false
  5003. */
  5004. pauseOnClick: {
  5005. value: false
  5006. },
  5007. /**
  5008. * The type of transition to use between pages.
  5009. *
  5010. * @attribute transition
  5011. * @type String
  5012. * @default slideHorizontal
  5013. */
  5014. transition: {
  5015. value: 'slideHorizontal'
  5016. },
  5017. /**
  5018. * The duration of the transition between pages.
  5019. *
  5020. * @attribute transitionDuration
  5021. * @type Number
  5022. * @default 0.8
  5023. */
  5024. transitionDuration: {
  5025. value: 0.8
  5026. },
  5027. /**
  5028. * The type of transition easing to use between pages.
  5029. *
  5030. * @attribute transitionEasing
  5031. * @type String
  5032. * @default ease-out
  5033. */
  5034. transitionEasing: {
  5035. value: 'ease-out'
  5036. },
  5037. /**
  5038. * The configuration object used to create new instances of
  5039. * FL.SlideshowImage. See the API docs for {@link FL.SlideshowImage}
  5040. * for a complete list of configuration attributes.
  5041. *
  5042. * @attribute imageConfig
  5043. * @type Object
  5044. * @default {}
  5045. */
  5046. imageConfig: {
  5047. value: {
  5048. crop: true,
  5049. width: 50,
  5050. height: 50
  5051. }
  5052. },
  5053. /**
  5054. * Whether to use the top nav or not.
  5055. *
  5056. * @attribute topNavEnabled
  5057. * @type Boolean
  5058. * @default false
  5059. */
  5060. topNavEnabled: {
  5061. value: false
  5062. },
  5063. /**
  5064. * An array of button names used to render the top nav buttons.
  5065. *
  5066. * @attribute topNavButtons
  5067. * @type Array
  5068. * @default prevPage, nextPage
  5069. */
  5070. topNavButtons: {
  5071. value: ['prevPage', 'nextPage']
  5072. },
  5073. /**
  5074. * Whether to use the right nav or not.
  5075. *
  5076. * @attribute rightNavEnabled
  5077. * @type Boolean
  5078. * @default true
  5079. */
  5080. rightNavEnabled: {
  5081. value: true
  5082. },
  5083. /**
  5084. * An array of button names used to render the right nav buttons.
  5085. *
  5086. * @attribute rightNavButtons
  5087. * @type Array
  5088. * @default nextPage
  5089. */
  5090. rightNavButtons: {
  5091. value: ['nextPage']
  5092. },
  5093. /**
  5094. * Whether to use the bottom nav or not.
  5095. *
  5096. * @attribute bottomNavEnabled
  5097. * @type Boolean
  5098. * @default false
  5099. */
  5100. bottomNavEnabled: {
  5101. value: false
  5102. },
  5103. /**
  5104. * An array of button names used to render the bottom nav buttons.
  5105. *
  5106. * @attribute bottomNavButtons
  5107. * @type Array
  5108. * @default prevPage, nextPage
  5109. */
  5110. bottomNavButtons:{
  5111. value: ['prevPage', 'nextPage']
  5112. },
  5113. /**
  5114. * Whether to use the left nav or not.
  5115. *
  5116. * @attribute leftNavEnabled
  5117. * @type Boolean
  5118. * @default true
  5119. */
  5120. leftNavEnabled: {
  5121. value: true
  5122. },
  5123. /**
  5124. * An array of button names used to render the left nav buttons.
  5125. *
  5126. * @attribute leftNavButtons
  5127. * @type Array
  5128. * @default prevPage
  5129. */
  5130. leftNavButtons:{
  5131. value: ['prevPage']
  5132. },
  5133. /**
  5134. * Whether to use touch gestures, when available,
  5135. * to transition between pages or not.
  5136. *
  5137. * @attribute touchSupport
  5138. * @type Boolean
  5139. * @default false
  5140. */
  5141. touchSupport: {
  5142. value: false
  5143. }
  5144. }
  5145. });
  5146. /**
  5147. * Provides functionality for transitions between slideshow components.
  5148. *
  5149. * @namespace FL
  5150. * @class SlideshowTransition
  5151. * @constructor
  5152. * @param config {Object} Configuration object
  5153. * @extends Base
  5154. */
  5155. Y.namespace('FL').SlideshowTransition = Y.Base.create('fl-slideshow-transition', Y.Base, [], {
  5156. /**
  5157. * The transition function to use when run is called.
  5158. *
  5159. * @property _transitionFunction
  5160. * @type String
  5161. * @default _transitionFade
  5162. * @protected
  5163. */
  5164. _transitionFunction: '_transitionFade',
  5165. /**
  5166. * The current transition type.
  5167. *
  5168. * @property _type
  5169. * @type String
  5170. * @default fade
  5171. * @protected
  5172. */
  5173. _type: 'fade',
  5174. /**
  5175. * Parses the transition type and sets the _transitionFunction
  5176. * used when run is called.
  5177. *
  5178. * @method initializer
  5179. * @protected
  5180. */
  5181. initializer: function()
  5182. {
  5183. var type = this.get('type'),
  5184. typeArray = [],
  5185. types = Y.FL.SlideshowTransition.TYPES,
  5186. slideshowImageTypes = Y.FL.SlideshowTransition.SLIDESHOW_IMAGE_TYPES,
  5187. isSlideshowImageTransition = Y.Array.indexOf(slideshowImageTypes, type) > -1,
  5188. isSlideshowImage = this._isSlideshowImage(),
  5189. itemIn = this.get('itemIn'),
  5190. itemOut = this.get('itemOut');
  5191. // Check for random transitions.
  5192. if(type.indexOf(',') > -1) {
  5193. typeArray = type.split(',');
  5194. typeArray.sort(function() { return 0.5 - Math.random(); });
  5195. type = typeArray[0];
  5196. }
  5197. // Make sure we can run this transition, otherwise set a fallback.
  5198. if(!isSlideshowImage && isSlideshowImageTransition) {
  5199. type = 'fade';
  5200. }
  5201. else if(isSlideshowImage) {
  5202. if((itemIn && itemIn.one('img') === null) || (itemOut && itemOut.one('img') === null)) {
  5203. type = 'none';
  5204. }
  5205. else if(isSlideshowImageTransition) {
  5206. if((Y.UA.gecko && Y.UA.gecko < 5) || Y.UA.opera > 0 || (Y.UA.ie > 0 && Y.UA.ie < 9)) {
  5207. type = 'fade';
  5208. }
  5209. }
  5210. }
  5211. // Set the transition function and type.
  5212. if(Y.FL.SlideshowTransition.TYPES[type]) {
  5213. this._transitionFunction = types[type];
  5214. this._type = type;
  5215. }
  5216. // Setup the items.
  5217. this._setupItems();
  5218. },
  5219. /**
  5220. * Fires the start event and calls the transition function.
  5221. *
  5222. * @method run
  5223. */
  5224. run: function()
  5225. {
  5226. /**
  5227. * Fires when the transition starts.
  5228. *
  5229. * @event start
  5230. */
  5231. this.fire('start');
  5232. this[this._transitionFunction].call(this);
  5233. },
  5234. /**
  5235. * Set initial styles for the items.
  5236. *
  5237. * @method _setupItems
  5238. * @protected
  5239. */
  5240. _setupItems: function()
  5241. {
  5242. var itemIn = this.get('itemIn'),
  5243. itemOut = this.get('itemOut');
  5244. if(itemIn) {
  5245. itemIn.setStyle('zIndex', 2);
  5246. itemIn.setStyle('opacity', 1);
  5247. if(Y.FL.Utils.cssSupport('transform')) {
  5248. itemIn.setStyle('transform', 'translate(0, 0)');
  5249. }
  5250. else {
  5251. itemIn.setStyle('top', '0');
  5252. itemIn.setStyle('left', '0');
  5253. }
  5254. }
  5255. if(itemOut) {
  5256. itemOut.setStyle('zIndex', 1);
  5257. }
  5258. },
  5259. /**
  5260. * Checks if the transition is being run
  5261. * on an instance of FL.SlideshowImage or not.
  5262. *
  5263. * @method _isSlideshowImage
  5264. * @protected
  5265. */
  5266. _isSlideshowImage: function()
  5267. {
  5268. var itemIn = this.get('itemIn'),
  5269. itemOut = this.get('itemOut');
  5270. if(itemIn && itemIn.hasClass('fl-slideshow-image')) {
  5271. return true;
  5272. }
  5273. else if(itemOut && itemOut.hasClass('fl-slideshow-image')) {
  5274. return true;
  5275. }
  5276. return false;
  5277. },
  5278. /**
  5279. * Starts the transtion using the provided property objects.
  5280. *
  5281. * @method _transitionStart
  5282. * @param propsIn {Object} The properties to animate in.
  5283. * @param propsOut {Object} The properties to animate out.
  5284. * @protected
  5285. */
  5286. _transitionStart: function(propsIn, propsOut)
  5287. {
  5288. var itemIn = this.get('itemIn'),
  5289. itemOut = this.get('itemOut'),
  5290. itemInCallback = Y.bind(this._transitionComplete, this),
  5291. itemOutCallback = !itemIn ? itemInCallback : null,
  5292. duration = this.get('duration'),
  5293. easing = this.get('easing');
  5294. if(itemIn) {
  5295. propsIn.duration = propsIn.duration || duration;
  5296. propsIn.easing = propsIn.easing || easing;
  5297. itemIn.transition(propsIn);
  5298. }
  5299. if(itemOut) {
  5300. propsOut.duration = propsOut.duration || duration;
  5301. propsOut.easing = propsOut.easing || easing;
  5302. itemOut.transition(propsOut);
  5303. }
  5304. if(itemInCallback) {
  5305. Y.later(propsIn.duration * 1000 + 100, null, itemInCallback);
  5306. }
  5307. else if(itemOutCallback) {
  5308. Y.later(propsOut.duration * 1000 + 100, null, itemOutCallback);
  5309. }
  5310. },
  5311. /**
  5312. * Clean up method called when the transition completes.
  5313. *
  5314. * @method _transitionComplete
  5315. * @protected
  5316. */
  5317. _transitionComplete: function()
  5318. {
  5319. this._set('itemIn', null);
  5320. this._set('itemOut', null);
  5321. /**
  5322. * Fires when the transition completes.
  5323. *
  5324. * @event complete
  5325. */
  5326. this.fire('complete');
  5327. },
  5328. /**
  5329. * No transition.
  5330. *
  5331. * @method _transitionNone
  5332. * @protected
  5333. */
  5334. _transitionNone: function()
  5335. {
  5336. var itemIn = this.get('itemIn'),
  5337. itemOut = this.get('itemOut');
  5338. if(itemIn) {
  5339. itemIn.setStyle('opacity', 1);
  5340. }
  5341. if(itemOut) {
  5342. itemOut.setStyle('opacity', 0);
  5343. }
  5344. this._transitionComplete();
  5345. },
  5346. /**
  5347. * Fade transition.
  5348. *
  5349. * @method _transitionFade
  5350. * @protected
  5351. */
  5352. _transitionFade: function()
  5353. {
  5354. var itemIn = this.get('itemIn');
  5355. if(itemIn) {
  5356. itemIn.setStyle('opacity', 0);
  5357. }
  5358. this._transitionStart({ opacity: 1 },{ opacity: 0 });
  5359. },
  5360. /**
  5361. * Slide left transition.
  5362. *
  5363. * @method _transitionSlideLeft
  5364. * @protected
  5365. */
  5366. _transitionSlideLeft: function()
  5367. {
  5368. if(Y.FL.Utils.cssSupport('transform')) {
  5369. this._cssTransitionSlide({
  5370. inStart: 'translate(100%, 0)',
  5371. inEnd: 'translate(0, 0)',
  5372. outStart: 'translate(0, 0)',
  5373. outEnd: 'translate(-100%, 0)'
  5374. });
  5375. }
  5376. else {
  5377. this._jsTransitionSlide('left');
  5378. }
  5379. },
  5380. /**
  5381. * Slide right transition.
  5382. *
  5383. * @method _transitionSlideRight
  5384. * @protected
  5385. */
  5386. _transitionSlideRight: function()
  5387. {
  5388. if(Y.FL.Utils.cssSupport('transform')) {
  5389. this._cssTransitionSlide({
  5390. inStart: 'translate(-100%, 0)',
  5391. inEnd: 'translate(0, 0)',
  5392. outStart: 'translate(0, 0)',
  5393. outEnd: 'translate(100%, 0)'
  5394. });
  5395. }
  5396. else {
  5397. this._jsTransitionSlide('right');
  5398. }
  5399. },
  5400. /**
  5401. * Slide up transition.
  5402. *
  5403. * @method _transitionSlideUp
  5404. * @protected
  5405. */
  5406. _transitionSlideUp: function()
  5407. {
  5408. if(Y.FL.Utils.cssSupport('transform')) {
  5409. this._cssTransitionSlide({
  5410. inStart: 'translate(0, 100%)',
  5411. inEnd: 'translate(0, 0)',
  5412. outStart: 'translate(0, 0)',
  5413. outEnd: 'translate(0, -100%)'
  5414. });
  5415. }
  5416. else {
  5417. this._jsTransitionSlide('up');
  5418. }
  5419. },
  5420. /**
  5421. * Slide down transition.
  5422. *
  5423. * @method _transitionSlideDown
  5424. * @protected
  5425. */
  5426. _transitionSlideDown: function()
  5427. {
  5428. if(Y.FL.Utils.cssSupport('transform')) {
  5429. this._cssTransitionSlide({
  5430. inStart: 'translate(0, -100%)',
  5431. inEnd: 'translate(0, 0)',
  5432. outStart: 'translate(0, 0)',
  5433. outEnd: 'translate(0, 100%)'
  5434. });
  5435. }
  5436. else {
  5437. this._jsTransitionSlide('down');
  5438. }
  5439. },
  5440. /**
  5441. * JavaScript slide transition.
  5442. *
  5443. * @method _jsTransitionSlide
  5444. * @protected
  5445. */
  5446. _jsTransitionSlide: function(direction)
  5447. {
  5448. var itemIn = this.get('itemIn'),
  5449. itemOut = this.get('itemOut'),
  5450. itemOutEnd = 0;
  5451. // Item Out
  5452. if(itemOut && direction == 'left') {
  5453. itemOutEnd = -parseInt(itemOut.getStyle('width'), 10);
  5454. }
  5455. if(itemOut && direction == 'right') {
  5456. itemOutEnd = parseInt(itemOut.getStyle('width'), 10);
  5457. }
  5458. if(itemOut && direction == 'up') {
  5459. itemOutEnd = -parseInt(itemOut.getStyle('height'), 10);
  5460. }
  5461. if(itemOut && direction == 'down') {
  5462. itemOutEnd = parseInt(itemOut.getStyle('height'), 10);
  5463. }
  5464. // Item In
  5465. if(itemIn) {
  5466. itemIn.setStyle('opacity', 1);
  5467. }
  5468. if(itemIn && direction == 'left') {
  5469. itemIn.setStyle('left', itemIn.getStyle('width'));
  5470. }
  5471. if(itemIn && direction == 'right') {
  5472. itemIn.setStyle('left', '-' + itemIn.getStyle('width'));
  5473. }
  5474. if(itemIn && direction == 'up') {
  5475. itemIn.setStyle('top', itemIn.getStyle('height'));
  5476. }
  5477. if(itemIn && direction == 'down') {
  5478. itemIn.setStyle('top', '-' + itemIn.getStyle('height'));
  5479. }
  5480. // Transition Start
  5481. if(direction == 'left' || direction == 'right') {
  5482. this._transitionStart({ left: 0 },{ left: itemOutEnd });
  5483. }
  5484. else {
  5485. this._transitionStart({ top: 0 },{ top: itemOutEnd });
  5486. }
  5487. },
  5488. /**
  5489. * CSS slide transition.
  5490. *
  5491. * @method _cssTransitionSlide
  5492. * @protected
  5493. */
  5494. _cssTransitionSlide: function(props)
  5495. {
  5496. var itemIn = this.get('itemIn'),
  5497. itemOut = this.get('itemOut'),
  5498. transformProp = Y.UA.chrome < 36 ? 'transform' : '-webkit-transform',
  5499. inProps = {},
  5500. outProps = {};
  5501. inProps[transformProp] = props.inEnd;
  5502. outProps[transformProp] = props.outEnd;
  5503. if(itemIn) {
  5504. itemIn.setStyle('transition', '');
  5505. itemIn.setStyle('opacity', 1);
  5506. itemIn.setStyle(transformProp, props.inStart);
  5507. }
  5508. if(itemOut) {
  5509. itemOut.setStyle('transition', '');
  5510. itemOut.setStyle(transformProp, props.outStart);
  5511. }
  5512. this._transitionStart(inProps, outProps);
  5513. },
  5514. /**
  5515. * Bars and blinds transition.
  5516. *
  5517. * @method _transitionBars
  5518. * @protected
  5519. */
  5520. _transitionBars: function()
  5521. {
  5522. // Hide the image until the slices have transitioned in.
  5523. this.get('itemIn').one('.fl-slideshow-image-img').setStyle('opacity', 0);
  5524. var numBars = this.get('bars'),
  5525. slices = this._renderSlices(1, numBars),
  5526. duration = this.get('duration'),
  5527. delay = 0,
  5528. increment = 100,
  5529. last = false,
  5530. i = 0,
  5531. clone = null,
  5532. props = {
  5533. duration: duration,
  5534. opacity: 1
  5535. };
  5536. // barsRandom
  5537. if(this._type == 'barsRandom') {
  5538. slices = this._randomizeSlices(slices);
  5539. }
  5540. // Transition the slices.
  5541. for( ; i < slices.length; i++) {
  5542. // Make a clone of our transition properties.
  5543. clone = Y.clone(props);
  5544. // blinds
  5545. if(this._type == 'blinds') {
  5546. clone.width = parseFloat(slices[i].getComputedStyle('width'), 10) + 'px';
  5547. slices[i].setStyle('width', '0px');
  5548. increment = 50;
  5549. }
  5550. // Run the transition.
  5551. last = i == slices.length - 1 ? true : false;
  5552. Y.later(delay, this, this._transitionSlice, [slices[i], clone, last]);
  5553. delay += increment;
  5554. }
  5555. this._transitionSlicesFadeLast(delay);
  5556. },
  5557. /**
  5558. * Boxes transition.
  5559. *
  5560. * @method _transitionBoxes
  5561. * @protected
  5562. */
  5563. _transitionBoxes: function()
  5564. {
  5565. // Hide the image until the slices have transitioned in.
  5566. this.get('itemIn').one('.fl-slideshow-image-img').setStyle('opacity', 0);
  5567. var numCols = this.get('boxCols'),
  5568. numRows = this.get('boxRows'),
  5569. numSlices = numCols * numRows,
  5570. multi = this._type != 'boxesRandom',
  5571. slices = this._renderSlices(numRows, numCols, multi),
  5572. duration = this.get('duration'),
  5573. delay = 0,
  5574. increment = 150,
  5575. last = false,
  5576. i = 0,
  5577. row = 0,
  5578. col = 0,
  5579. startCol = -1,
  5580. clone = null,
  5581. props = {
  5582. duration: duration,
  5583. opacity: 1
  5584. };
  5585. // boxesRandom
  5586. if(!multi) {
  5587. slices = this._randomizeSlices(slices);
  5588. increment = 30;
  5589. for( ; i < slices.length; i++) {
  5590. clone = Y.clone(props);
  5591. last = i == slices.length - 1 ? true : false;
  5592. Y.later(delay, this, this._transitionSlice, [slices[i], clone, last]);
  5593. delay += increment;
  5594. }
  5595. }
  5596. // boxes
  5597. else {
  5598. while(i < numSlices) {
  5599. for(row = 0; row < numRows; row++) {
  5600. if(row === 0) {
  5601. startCol++;
  5602. col = startCol;
  5603. }
  5604. if(col > -1 && col < numCols) {
  5605. i++;
  5606. clone = Y.clone(props);
  5607. // boxesGrow
  5608. if(this._type == 'boxesGrow') {
  5609. clone.height = parseFloat(slices[row][col].getComputedStyle('height'), 10) + 'px';
  5610. clone.width = parseFloat(slices[row][col].getComputedStyle('width'), 10) + 'px';
  5611. slices[row][col].setStyle('height', '0px');
  5612. slices[row][col].setStyle('width', '0px');
  5613. increment = 50;
  5614. }
  5615. last = i == numSlices - 1 ? true : false;
  5616. Y.later(delay, this, this._transitionSlice, [slices[row][col], clone, last]);
  5617. }
  5618. col--;
  5619. }
  5620. delay += increment;
  5621. }
  5622. }
  5623. this._transitionSlicesFadeLast(delay);
  5624. },
  5625. /**
  5626. * Renders the divs for slice based transitions.
  5627. *
  5628. * @method _renderSlices
  5629. * @protected
  5630. */
  5631. _renderSlices: function(numRows, numCols, multidimensional)
  5632. {
  5633. var itemIn = this.get('itemIn'),
  5634. itemHeight = parseFloat(itemIn.getComputedStyle('height'), 10),
  5635. itemWidth = parseFloat(itemIn.getComputedStyle('width'), 10),
  5636. img = itemIn.one('img'),
  5637. imgSrc = img.get('src'),
  5638. imgHeight = parseFloat(img.getComputedStyle('height'), 10),
  5639. imgWidth = parseFloat(img.getComputedStyle('width'), 10),
  5640. imgLeft = parseFloat(img.getComputedStyle('left'), 10),
  5641. imgTop = parseFloat(img.getComputedStyle('top'), 10),
  5642. col = 0,
  5643. row = 0,
  5644. sliceHeight = Math.round(itemHeight/numRows),
  5645. sliceWidth = Math.round(itemWidth/numCols),
  5646. slice = null,
  5647. sliceImg = null,
  5648. slices = [];
  5649. for( ; row < numRows; row++) {
  5650. if(typeof multidimensional !== 'undefined' && multidimensional) {
  5651. slices[row] = [];
  5652. }
  5653. for(col = 0; col < numCols; col++) {
  5654. slice = Y.Node.create('<div class="fl-slideshow-transition-slice"></div>');
  5655. sliceImg = Y.Node.create('<img src="'+ imgSrc +'" />');
  5656. slice.setStyles({
  5657. left: (sliceWidth * col) + 'px',
  5658. top: (sliceHeight * row) + 'px',
  5659. width: col == numCols - 1 ? (itemWidth - (sliceWidth * col)) + 'px' : sliceWidth + 'px',
  5660. height: row == numRows - 1 ? (itemHeight - (sliceHeight * row)) + 'px' : sliceHeight + 'px',
  5661. opacity: 0
  5662. });
  5663. sliceImg.setStyles({
  5664. height: imgHeight + 'px',
  5665. width: imgWidth + 'px',
  5666. top: imgTop - ((sliceHeight + (row * sliceHeight)) - sliceHeight) + 'px',
  5667. left: imgLeft - ((sliceWidth + (col * sliceWidth)) - sliceWidth) + 'px'
  5668. });
  5669. slice.append(sliceImg);
  5670. itemIn.append(slice);
  5671. if(typeof multidimensional !== 'undefined' && multidimensional) {
  5672. slices[row].push(slice);
  5673. }
  5674. else {
  5675. slices.push(slice);
  5676. }
  5677. }
  5678. }
  5679. return slices;
  5680. },
  5681. /**
  5682. * Fade the itemOut node.
  5683. *
  5684. * @method _transitionSlicesFadeLast
  5685. * @protected
  5686. */
  5687. _transitionSlicesFadeLast: function(delay)
  5688. {
  5689. var itemOut = this.get('itemOut');
  5690. if(itemOut && !itemOut.hasClass('fl-slideshow-image-cropped')) {
  5691. itemOut.transition({
  5692. duration: delay/1000 + this.get('duration'),
  5693. opacity: 0
  5694. });
  5695. }
  5696. },
  5697. /**
  5698. * Transitions a single slice.
  5699. *
  5700. * @method _transitionSlice
  5701. * @protected
  5702. */
  5703. _transitionSlice: function(slice, props, last)
  5704. {
  5705. var callback = last ? Y.bind(this._transitionSlicesComplete, this) : null;
  5706. slice.transition(props, callback);
  5707. },
  5708. /**
  5709. * Complete callback for slice based transitions.
  5710. *
  5711. * @method _transitionSlicesComplete
  5712. * @protected
  5713. */
  5714. _transitionSlicesComplete: function()
  5715. {
  5716. var itemIn = this.get('itemIn');
  5717. itemIn.all('.fl-slideshow-transition-slice').remove();
  5718. itemIn.one('.fl-slideshow-image-img').setStyle('opacity', 1);
  5719. this._transitionComplete();
  5720. },
  5721. /**
  5722. * Randomizes a slices array.
  5723. *
  5724. * @method _radomizeSlices
  5725. * @protected
  5726. */
  5727. _randomizeSlices: function(slices)
  5728. {
  5729. var i = slices.length, j, temp;
  5730. if(i === 0) {
  5731. return;
  5732. }
  5733. while(--i) {
  5734. j = Math.floor( Math.random() * ( i + 1 ) );
  5735. temp = slices[i];
  5736. slices[i] = slices[j];
  5737. slices[j] = temp;
  5738. }
  5739. return slices;
  5740. },
  5741. _transitionKenBurns: function()
  5742. {
  5743. var kbDuration = this.get('kenBurnsDuration'),
  5744. duration = this.get('duration'),
  5745. itemIn = this.get('itemIn'),
  5746. zoom = this.get('kenBurnsZoom');
  5747. this._transitionFade();
  5748. (new Y.FL.SlideshowKenBurns({
  5749. duration: kbDuration + duration + 4,
  5750. image: itemIn,
  5751. zoom: zoom
  5752. })).run();
  5753. }
  5754. }, {
  5755. /**
  5756. * Static property used to define the default attribute configuration of
  5757. * the Widget.
  5758. *
  5759. * @property ATTRS
  5760. * @type Object
  5761. * @protected
  5762. * @static
  5763. */
  5764. ATTRS: {
  5765. /**
  5766. * The Node to transition in.
  5767. *
  5768. * @attribute itemIn
  5769. * @type Node
  5770. * @default null
  5771. */
  5772. itemIn: {
  5773. value: null
  5774. },
  5775. /**
  5776. * The Node to transition out.
  5777. *
  5778. * @attribute itemOut
  5779. * @type Node
  5780. * @default null
  5781. */
  5782. itemOut: {
  5783. value: null
  5784. },
  5785. /**
  5786. * The duration of the transition in seconds.
  5787. *
  5788. * @attribute duration
  5789. * @type Number
  5790. * @default 0.5
  5791. */
  5792. duration: {
  5793. value: 0.5
  5794. },
  5795. /**
  5796. * The type of easing to use.
  5797. *
  5798. * @attribute easing
  5799. * @type String
  5800. * @default ease-out
  5801. */
  5802. easing: {
  5803. value: 'ease-out'
  5804. },
  5805. /**
  5806. * The type of transition to use.
  5807. *
  5808. * @attribute type
  5809. * @type String
  5810. * @default fade
  5811. */
  5812. type: {
  5813. value: 'fade'
  5814. },
  5815. /**
  5816. * The number of bars to use for
  5817. * transitions such as blinds.
  5818. *
  5819. * @attribute bars
  5820. * @type Number
  5821. * @default 15
  5822. */
  5823. bars: {
  5824. value: 15
  5825. },
  5826. /**
  5827. * The number of columns to use for
  5828. * transitions such as boxes.
  5829. *
  5830. * @attribute boxCols
  5831. * @type Number
  5832. * @default 8
  5833. */
  5834. boxCols: {
  5835. value: 8
  5836. },
  5837. /**
  5838. * The number of rows to use for
  5839. * transitions such as boxes.
  5840. *
  5841. * @attribute boxRows
  5842. * @type Number
  5843. * @default 4
  5844. */
  5845. boxRows: {
  5846. value: 4
  5847. },
  5848. /**
  5849. * The duration the ken burns effect will
  5850. * last, measured in seconds.
  5851. *
  5852. * @attribute kenBurnsDuration
  5853. * @type Number
  5854. * @default 4
  5855. */
  5856. kenBurnsDuration: {
  5857. value: 4
  5858. },
  5859. /**
  5860. * The amount of zoom to use for the Ken Burns effect.
  5861. *
  5862. * @attribute kenBurnsZoom
  5863. * @type Number
  5864. * @default 1.2
  5865. */
  5866. kenBurnsZoom: {
  5867. value: 1.2
  5868. }
  5869. },
  5870. /**
  5871. * The types of transitions and associated functions.
  5872. *
  5873. * @property TYPES
  5874. * @type Object
  5875. * @readOnly
  5876. * @protected
  5877. * @static
  5878. */
  5879. TYPES: {
  5880. fade: '_transitionFade',
  5881. none: '_transitionNone',
  5882. slideLeft: '_transitionSlideLeft',
  5883. slideRight: '_transitionSlideRight',
  5884. slideUp: '_transitionSlideUp',
  5885. slideDown: '_transitionSlideDown',
  5886. blinds: '_transitionBars',
  5887. bars: '_transitionBars',
  5888. barsRandom: '_transitionBars',
  5889. boxes: '_transitionBoxes',
  5890. boxesRandom: '_transitionBoxes',
  5891. boxesGrow: '_transitionBoxes',
  5892. kenBurns: '_transitionKenBurns'
  5893. },
  5894. /**
  5895. * The types of transitions that can only be
  5896. * run on FL.SlideshowImage widgets.
  5897. *
  5898. * @property SLIDESHOW_IMAGE_TYPES
  5899. * @type Object
  5900. * @readOnly
  5901. * @protected
  5902. * @static
  5903. */
  5904. SLIDESHOW_IMAGE_TYPES: [
  5905. 'blinds',
  5906. 'bars',
  5907. 'barsRandom',
  5908. 'boxes',
  5909. 'boxesRandom',
  5910. 'boxesGrow',
  5911. 'kenBurns'
  5912. ]
  5913. });
  5914. /**
  5915. * A highly configurable slideshow widget.
  5916. *
  5917. * @namespace FL
  5918. * @class Slideshow
  5919. * @constructor
  5920. * @param config {Object} Configuration object
  5921. * @extends FL.SlideshowBase
  5922. */
  5923. Y.namespace('FL').Slideshow = Y.Base.create('fl-slideshow', Y.FL.SlideshowBase, [], {
  5924. /**
  5925. * A FL.SlideshowFrame instance used for the main image.
  5926. *
  5927. * @property frame
  5928. * @type FL.SlideshowFrame
  5929. * @default null
  5930. */
  5931. frame: null,
  5932. /**
  5933. * A FL.SlideshowNav instance used for the main nav.
  5934. *
  5935. * @property nav
  5936. * @type FL.SlideshowNav
  5937. * @default null
  5938. */
  5939. nav: null,
  5940. /**
  5941. * A FL.SlideshowNav instance used for the image nav's left button.
  5942. *
  5943. * @property imageNavLeft
  5944. * @type FL.SlideshowNav
  5945. * @default null
  5946. */
  5947. imageNavLeft: null,
  5948. /**
  5949. * A FL.SlideshowNav instance used for the image nav's right button.
  5950. *
  5951. * @property imageNavRight
  5952. * @type FL.SlideshowNav
  5953. * @default null
  5954. */
  5955. imageNavRight: null,
  5956. /**
  5957. * A FL.SlideshowThumbs instance used for the thumbnail grid.
  5958. *
  5959. * @property thumbs
  5960. * @type FL.SlideshowThumbs
  5961. * @default null
  5962. */
  5963. thumbs: null,
  5964. /**
  5965. * A FL.SlideshowThumbs instance used for the vertical thumbnail grid.
  5966. *
  5967. * @property verticalThumbs
  5968. * @type FL.SlideshowThumbs
  5969. * @default null
  5970. */
  5971. verticalThumbs: null,
  5972. /**
  5973. * A FL.SlideshowCaption instance.
  5974. *
  5975. * @property caption
  5976. * @type FL.SlideshowCaption
  5977. * @default null
  5978. */
  5979. caption: null,
  5980. /**
  5981. * A FL.SlideshowSocial instance.
  5982. *
  5983. * @property social
  5984. * @type FL.SlideshowSocial
  5985. * @default null
  5986. */
  5987. social: null,
  5988. /**
  5989. * A FL.SlideshowImage instance used to preload
  5990. * the next image.
  5991. *
  5992. * @property _nextImagePreloader
  5993. * @type FL.SlideshowImage
  5994. * @default null
  5995. * @protected
  5996. */
  5997. _nextImagePreloader: null,
  5998. /**
  5999. * An object that holds the initial nav settings
  6000. * when the mini nav has been enabled for a responsive layout.
  6001. *
  6002. * @property _initialNavSettings
  6003. * @type Object
  6004. * @default null
  6005. * @protected
  6006. */
  6007. _initialNavSettings: null,
  6008. /**
  6009. * Initializes the preloaders, nav buttons, fullscreen and captions.
  6010. *
  6011. * @method initializer
  6012. * @protected
  6013. */
  6014. initializer: function()
  6015. {
  6016. // Preloader config
  6017. var imageConfig = {
  6018. loadGroup: 'main-preload',
  6019. crop: this.get('crop'),
  6020. position: this.get('position'),
  6021. protect: this.get('protect'),
  6022. upsize: this.get('upsize')
  6023. };
  6024. // Preloader
  6025. this._nextImagePreloader = new Y.FL.SlideshowImage(imageConfig);
  6026. // Nav buttons not needed for touch
  6027. if(this._isMobile()) {
  6028. this._removeNavButton('prevPage');
  6029. this._removeNavButton('nextPage');
  6030. this._removeNavButton('fullscreen');
  6031. }
  6032. // Fullscreen
  6033. if(this._hasNavButton('fullscreen')) {
  6034. if(Y.FL.SlideshowFullscreen.OS_SUPPORT) {
  6035. this.plug(Y.FL.SlideshowFullscreen);
  6036. }
  6037. else {
  6038. this._removeNavButton('fullscreen');
  6039. }
  6040. }
  6041. },
  6042. /**
  6043. * Calls the FL.SlideshowBase superclass renderUI method
  6044. * and renders the child widgets.
  6045. *
  6046. * @method renderUI
  6047. * @protected
  6048. */
  6049. renderUI: function()
  6050. {
  6051. Y.FL.Slideshow.superclass.renderUI.apply(this, arguments);
  6052. this._renderFrame();
  6053. this._renderVerticalThumbs();
  6054. this._renderNavAndThumbs();
  6055. this._renderImageNav();
  6056. this._renderMouseNav();
  6057. this._renderCaption();
  6058. this._renderSocial();
  6059. },
  6060. /**
  6061. * Calls the FL.SlideshowBase superclass bindUI method, binds
  6062. * _resizeChildWidgets to fire after the resize method inherited
  6063. * from FL.SlideshowBase, shows the loading image, binds overlay events
  6064. * and binds an event to load an image into the frame.
  6065. *
  6066. * @method bindUI
  6067. * @protected
  6068. */
  6069. bindUI: function()
  6070. {
  6071. var ssBB = this.get('boundingBox'),
  6072. frameBB = this.frame.get('boundingBox'),
  6073. navOverlay = this.get('navOverlay'),
  6074. navType = this.get('navType'),
  6075. nav = this._getNav(),
  6076. clickAction = this.get('clickAction');
  6077. // Call superclass bindUI
  6078. Y.FL.Slideshow.superclass.bindUI.apply(this, arguments);
  6079. // Resize child widgets after the superclass resize method.
  6080. Y.Do.after(this._resizeChildWidgets, this, 'resize');
  6081. // Loading events
  6082. this.on('albumLoadStart', this._albumLoadStart, this);
  6083. this.on('albumLoadComplete', this._albumLoadComplete, this);
  6084. this.on('imageLoadComplete', this._loadFrame, this);
  6085. // Loading image
  6086. if(this.get('loadingImageAlwaysEnabled')) {
  6087. this.frame.on('transitionInit', Y.bind(this._showLoadingImageWithDelay, this));
  6088. this.frame.on('transitionStart', Y.bind(this._hideLoadingImage, this));
  6089. }
  6090. // Overlay events
  6091. if(this.get('overlayHideOnMousemove')) {
  6092. if(nav && navOverlay) {
  6093. this.frame.once('transitionComplete', nav.slideshowOverlay.hideWithTimer, nav.slideshowOverlay);
  6094. ssBB.on('mousemove', Y.bind(this._toggleNav, this));
  6095. }
  6096. if(navType == 'buttons' || navType == 'thumbs' || navType == 'custom') {
  6097. ssBB.on('mouseenter', Y.bind(this._checkOverlaysOnMouseenter, this));
  6098. ssBB.on('mouseleave', Y.bind(this._hideAllOverlays, this));
  6099. }
  6100. }
  6101. ssBB.delegate('click', Y.bind(this._overlayCloseClick, this), '.fl-slideshow-overlay-close');
  6102. // Click action
  6103. if(clickAction == 'gallery' || clickAction == 'url') {
  6104. frameBB.delegate('click', Y.bind(this._frameClick, this), '.fl-slideshow-image-img');
  6105. }
  6106. },
  6107. /**
  6108. * Calls the FL.SlideshowBase superclass syncUI method
  6109. * and makes the bounding box unselectable.
  6110. *
  6111. * @method syncUI
  6112. * @protected
  6113. */
  6114. syncUI: function()
  6115. {
  6116. var bb = this.get('boundingBox');
  6117. Y.FL.Slideshow.superclass.syncUI.apply(this, arguments);
  6118. bb._node.onselectstart = function() { return false; };
  6119. bb._node.unselectable = "on";
  6120. bb._node.style.MozUserSelect = "none";
  6121. if(this.get('clickAction') != 'none') {
  6122. this.frame.get('boundingBox').addClass('fl-click-action-enabled');
  6123. }
  6124. },
  6125. /**
  6126. * Checks to see if the current device is mobile.
  6127. *
  6128. * @since 1.9.3
  6129. * @access private
  6130. * @method _isMobile
  6131. * @return {Boolean}
  6132. */
  6133. _isMobile: function()
  6134. {
  6135. return /Mobile|Android|Silk\/|Kindle|BlackBerry|Opera Mini|Opera Mobi|webOS/i.test( navigator.userAgent );
  6136. },
  6137. /**
  6138. * Unload all slideshow images and pause
  6139. * the slideshow.
  6140. *
  6141. * @method unload
  6142. */
  6143. unload: function()
  6144. {
  6145. this.pause();
  6146. this.frame.unload();
  6147. if(this.thumbs !== null) {
  6148. this.thumbs.unload();
  6149. }
  6150. },
  6151. /**
  6152. * @method _albumLoadStart
  6153. * @protected
  6154. */
  6155. _albumLoadStart: function()
  6156. {
  6157. this._showLoadingImage();
  6158. },
  6159. /**
  6160. * @method _albumLoadComplete
  6161. * @protected
  6162. */
  6163. _albumLoadComplete: function()
  6164. {
  6165. this.frame.once('transitionStart', Y.bind(this._hideLoadingImage, this));
  6166. },
  6167. /**
  6168. * Resizes all enabled child widgets.
  6169. *
  6170. * @method _resizeChildWidgets
  6171. * @protected
  6172. */
  6173. _resizeChildWidgets: function()
  6174. {
  6175. var bb = this.get('boundingBox'),
  6176. cb = this.get('contentBox'),
  6177. imageNavEnabled = this.get('imageNavEnabled');
  6178. this._renderNavAndThumbs();
  6179. if(this.get('verticalThumbsOverlay')) {
  6180. this._resizeFrame(cb.get('offsetWidth'), bb.get('offsetHeight'));
  6181. this._resizeVerticalThumbs();
  6182. }
  6183. else {
  6184. this._resizeVerticalThumbs();
  6185. this._resizeFrame(cb.get('offsetWidth'), bb.get('offsetHeight'));
  6186. }
  6187. if(imageNavEnabled) {
  6188. this._positionImageNav();
  6189. }
  6190. this._positionLoadingImage();
  6191. },
  6192. /**
  6193. * @method _renderVerticalThumbs
  6194. * @protected
  6195. */
  6196. _renderVerticalThumbs: function()
  6197. {
  6198. var threshold = this.get('responsiveThreshold'),
  6199. ssBB = this.get('boundingBox'),
  6200. bbWidth = ssBB.get('offsetWidth'),
  6201. vtBB;
  6202. if(this.get('verticalThumbsEnabled') && bbWidth > threshold) {
  6203. this.verticalThumbs = new Y.FL.SlideshowThumbs(this._getVerticalThumbsConfig());
  6204. this.add(this.verticalThumbs);
  6205. this.verticalThumbs.render(ssBB);
  6206. vtBB = this.verticalThumbs.get('boundingBox');
  6207. vtBB.addClass('fl-slideshow-vertical-thumbs');
  6208. vtBB.setStyle(this.get('verticalThumbsPosition'), 0);
  6209. ssBB.append(vtBB);
  6210. if(this.get('verticalThumbsOverlay')) {
  6211. this.verticalThumbs.plug(Y.FL.SlideshowOverlay, {
  6212. hideDelay: this.get('overlayHideDelay'),
  6213. hideStyle: 'left'
  6214. });
  6215. this.frame.get('boundingBox').append(vtBB);
  6216. this.verticalThumbs.resize();
  6217. }
  6218. else {
  6219. this.verticalThumbs.resize();
  6220. this._adjustContentForVerticalThumbs();
  6221. }
  6222. this._bindVerticalThumbs();
  6223. }
  6224. },
  6225. /**
  6226. * Prepares and returns the vertical thumbs config object.
  6227. *
  6228. * @method _getVerticalThumbsConfig
  6229. * @protected
  6230. * @returns Object
  6231. */
  6232. _getVerticalThumbsConfig: function()
  6233. {
  6234. var attrs = this.getAttrs(),
  6235. config = {
  6236. columns: attrs.verticalThumbsColumns,
  6237. rows: 'auto',
  6238. centerSinglePage: false,
  6239. horizontalSpacing: attrs.verticalThumbsHorizontalSpacing,
  6240. verticalSpacing: attrs.verticalThumbsVerticalSpacing,
  6241. spaceEvenly: attrs.verticalThumbsSpaceEvenly,
  6242. rightNavEnabled: false,
  6243. leftNavEnabled: false,
  6244. topNavEnabled: attrs.verticalThumbsTopNavEnabled,
  6245. topNavButtons: attrs.verticalThumbsTopNavButtons,
  6246. bottomNavEnabled: attrs.verticalThumbsBottomNavEnabled,
  6247. bottomNavButtons: attrs.verticalThumbsBottomNavButtons,
  6248. pauseOnClick: attrs.verticalThumbsPauseOnClick,
  6249. transition: attrs.verticalThumbsTransition,
  6250. transitionDirection: attrs.verticalThumbsTransitionDirection,
  6251. transitionEasing: attrs.verticalThumbsTransitionEasing,
  6252. touchSupport: true,
  6253. imageConfig: {
  6254. crop: attrs.verticalThumbsImageCrop,
  6255. width: attrs.verticalThumbsImageWidth,
  6256. height: attrs.verticalThumbsImageHeight
  6257. }
  6258. };
  6259. return config;
  6260. },
  6261. _bindVerticalThumbs: function()
  6262. {
  6263. var ssBB = this.get('boundingBox'),
  6264. hideOnMouse = this.get('overlayHideOnMousemove'),
  6265. vtOverlay = this.get('verticalThumbsOverlay'),
  6266. vt = this.verticalThumbs;
  6267. if(vt && hideOnMouse && vtOverlay) {
  6268. this.frame.once('transitionComplete', vt.slideshowOverlay.hideWithTimer, vt.slideshowOverlay);
  6269. ssBB.on('mousemove', Y.bind(this._toggleVerticalThumbs, this));
  6270. ssBB.on('mouseenter', Y.bind(this._toggleVerticalThumbs, this));
  6271. }
  6272. },
  6273. /**
  6274. * Resizes the vertical thumbs.
  6275. *
  6276. * @method _resizeVerticalThumbs
  6277. * @protected
  6278. */
  6279. _resizeVerticalThumbs: function()
  6280. {
  6281. var vtEnabled = this.get('verticalThumbsEnabled'),
  6282. vtOverlay,
  6283. threshold,
  6284. ssBB,
  6285. bbWidth,
  6286. navOverlay,
  6287. navType,
  6288. nav,
  6289. navBB;
  6290. if(vtEnabled) {
  6291. vtOverlay = this.get('verticalThumbsOverlay');
  6292. threshold = this.get('responsiveThreshold');
  6293. ssBB = this.get('boundingBox');
  6294. bbWidth = ssBB.get('offsetWidth');
  6295. navOverlay = this.get('navOverlay');
  6296. navType = this.get('navType');
  6297. nav = this._getNav();
  6298. if(this.verticalThumbs && bbWidth > threshold) {
  6299. this.verticalThumbs.get('boundingBox').setStyle('display', 'block');
  6300. this.verticalThumbs.resize();
  6301. if(!vtOverlay) {
  6302. this._adjustContentForVerticalThumbs();
  6303. }
  6304. else if(nav && navOverlay) {
  6305. navBB = nav.get('boundingBox');
  6306. if(navType == 'thumbs') {
  6307. this._adjustOverlayForVerticalThumbs(navBB, true);
  6308. this.thumbs.resize();
  6309. }
  6310. else {
  6311. this._adjustOverlayForVerticalThumbs(navBB);
  6312. }
  6313. }
  6314. }
  6315. else if(!this.verticalThumbs && bbWidth > threshold) {
  6316. this._renderVerticalThumbs();
  6317. }
  6318. else if(this.verticalThumbs && bbWidth <= threshold) {
  6319. this.verticalThumbs.get('boundingBox').setStyle('display', 'none');
  6320. if(!vtOverlay) {
  6321. this.get('contentBox').setStyles({
  6322. left: 'auto',
  6323. position: 'relative',
  6324. right: 'auto',
  6325. width: 'auto'
  6326. });
  6327. }
  6328. }
  6329. }
  6330. },
  6331. /**
  6332. * Toggles the visibility of the vertical thumbs.
  6333. *
  6334. * @method _toggleVerticalThumbs
  6335. * @protected
  6336. */
  6337. _toggleVerticalThumbs: function()
  6338. {
  6339. if(this.verticalThumbs) {
  6340. if(this.verticalThumbs.slideshowOverlay._visible) {
  6341. this.verticalThumbs.slideshowOverlay.hideWithTimer();
  6342. }
  6343. else {
  6344. this.verticalThumbs.slideshowOverlay.show();
  6345. }
  6346. }
  6347. },
  6348. /**
  6349. * Adjusts the content position and width
  6350. * for the vertical thumbs.
  6351. *
  6352. * @method _adjustContentForVerticalThumbs
  6353. * @protected
  6354. */
  6355. _adjustContentForVerticalThumbs: function()
  6356. {
  6357. var ssBB = this.get('boundingBox'),
  6358. vtBB = this.verticalThumbs.get('boundingBox'),
  6359. vtPos = this.get('verticalThumbsPosition'),
  6360. ssCB = this.get('contentBox'),
  6361. cbPos = vtPos == 'left' ? 'right' : 'left',
  6362. cbWidth = ssBB.get('offsetWidth') - vtBB.get('offsetWidth');
  6363. ssCB.setStyle('position', 'absolute');
  6364. ssCB.setStyle(cbPos, 0);
  6365. ssCB.setStyle('width', cbWidth);
  6366. },
  6367. /**
  6368. * Adjusts an overlay's position for the vertical
  6369. * thumbs when they are overlaid as well.
  6370. *
  6371. * @method _adjustOverlayForVerticalThumbs
  6372. * @protected
  6373. */
  6374. _adjustOverlayForVerticalThumbs: function(node, useMargin)
  6375. {
  6376. var vtEnabled = this.get('verticalThumbsEnabled'),
  6377. vtOverlay = this.get('verticalThumbsOverlay'),
  6378. vtBB = null,
  6379. vtPos = null,
  6380. margin = typeof useMargin === 'undefined' ? '' : 'margin-',
  6381. vtWidth = 0;
  6382. if(this.verticalThumbs && vtEnabled && vtOverlay) {
  6383. vtBB = this.verticalThumbs.get('boundingBox');
  6384. vtWidth = vtBB.get('offsetWidth');
  6385. vtPos = this.get('verticalThumbsPosition');
  6386. if(vtPos == 'left') {
  6387. node.setStyle(margin + 'left', vtWidth + 'px');
  6388. }
  6389. else {
  6390. node.setStyle(margin + 'right', vtWidth + 'px');
  6391. }
  6392. }
  6393. },
  6394. /**
  6395. * Creates and renders a new instance of FL.SlideshowFrame
  6396. * used for the main image.
  6397. *
  6398. * @method _renderFrame
  6399. * @protected
  6400. */
  6401. _renderFrame: function()
  6402. {
  6403. this.frame = new Y.FL.SlideshowFrame({
  6404. imageConfig: {
  6405. loadGroup: 'main',
  6406. loadPriority: true,
  6407. crop: this.get('crop'),
  6408. cropHorizontalsOnly: this.get('cropHorizontalsOnly'),
  6409. position: this.get('position'),
  6410. protect: this.get('protect'),
  6411. upsize: this.get('upsize'),
  6412. showVideoButton: this.get('navOverlay')
  6413. },
  6414. touchSupport: this.get('touchSupport')
  6415. });
  6416. this.add(this.frame);
  6417. this.frame.render(this.get('contentBox'));
  6418. this.frame.get('boundingBox').addClass('fl-slideshow-main-image');
  6419. this._setPlayingTimerEvent(this.frame, 'transitionComplete');
  6420. this._loadingImageContainer = this.frame.get('contentBox');
  6421. },
  6422. /**
  6423. * Resizes the frame used for the main image.
  6424. *
  6425. * @method _resizeMainImage
  6426. * @param width {Number} The width to resize to.
  6427. * @param height {Number} The height to resize to.
  6428. * @protected
  6429. */
  6430. _resizeFrame: function(width, height)
  6431. {
  6432. var navOverlay = this.get('navOverlay'),
  6433. nav = this._getNav();
  6434. if(nav && !navOverlay) {
  6435. height -= parseInt(nav.get('boundingBox').getComputedStyle('height'), 10);
  6436. }
  6437. this.frame.resize(width, height);
  6438. },
  6439. /**
  6440. * Called when the imageLoadComplete event fires.
  6441. * Loads an image into the frame and preloads the next image.
  6442. *
  6443. * @method _loadFrame
  6444. * @param e {Object} Event object containing the image info.
  6445. * @protected
  6446. */
  6447. _loadFrame: function(e)
  6448. {
  6449. var activeIndex = this.imageInfo.index,
  6450. images = this.albumInfo.images,
  6451. nextIndex = activeIndex + 1 >= images.length ? 0 : activeIndex + 1,
  6452. width = this.frame.get('width'),
  6453. height = this.frame.get('height');
  6454. // Load the frame.
  6455. this.frame.load(e.imageInfo);
  6456. // Remove main preload images from the load queue.
  6457. Y.FL.SlideshowImageLoader.removeGroup('main-preload');
  6458. // Preload the next image.
  6459. this._nextImagePreloader.preload(images[nextIndex], width, height);
  6460. },
  6461. /**
  6462. * Fired when the frame img tag is clicked.
  6463. *
  6464. * @method _frameClick
  6465. * @protected
  6466. */
  6467. _frameClick: function()
  6468. {
  6469. var clickAction = this.get('clickAction'),
  6470. clickActionUrl = this.get('clickActionUrl');
  6471. if(clickAction == 'url') {
  6472. window.location.href = clickActionUrl;
  6473. }
  6474. else if(clickAction == 'gallery') {
  6475. window.location.href = this.imageInfo.link;
  6476. }
  6477. },
  6478. /**
  6479. * Sets attributes to display a compact nav
  6480. * for responsive layouts.
  6481. *
  6482. * @method _initMiniNav
  6483. * @protected
  6484. */
  6485. _initMiniNav: function()
  6486. {
  6487. var buttons = [];
  6488. if(this._hasNavButton('prev')) {
  6489. buttons.push('prev');
  6490. }
  6491. if(this._hasNavButton('thumbs') || this.get('navType') == 'thumbs') {
  6492. buttons.push('thumbs');
  6493. }
  6494. if(this._hasNavButton('caption')) {
  6495. buttons.push('caption');
  6496. }
  6497. if(this._hasNavButton('social')) {
  6498. buttons.push('social');
  6499. }
  6500. if(this._hasNavButton('buy')) {
  6501. buttons.push('buy');
  6502. }
  6503. if(this._hasNavButton('play')) {
  6504. buttons.push('play');
  6505. }
  6506. if(this._hasNavButton('fullscreen') && !('ontouchstart' in window)) {
  6507. buttons.push('fullscreen');
  6508. }
  6509. if(this._hasNavButton('next')) {
  6510. buttons.push('next');
  6511. }
  6512. this._initialNavSettings = {
  6513. buttons: this.get('navButtons'),
  6514. buttonsLeft: this.get('navButtonsLeft'),
  6515. buttonsRight: this.get('navButtonsRight'),
  6516. type: this.get('navType')
  6517. };
  6518. this._set('navButtons', buttons);
  6519. this._set('navButtonsLeft', []);
  6520. this._set('navButtonsRight', []);
  6521. this._set('navType', 'buttons');
  6522. },
  6523. /**
  6524. * Renders the nav and thumbs layout based on the
  6525. * current window size.
  6526. *
  6527. * @method _renderNavAndThumbs
  6528. * @protected
  6529. */
  6530. _renderNavAndThumbs: function()
  6531. {
  6532. var navType = this.get('navType'),
  6533. renderNav = false,
  6534. bbWidth,
  6535. threshold;
  6536. if(navType == 'buttons' || navType == 'thumbs') {
  6537. bbWidth = this.get('boundingBox').get('offsetWidth');
  6538. threshold = this.get('responsiveThreshold');
  6539. if(bbWidth <= threshold && this._initialNavSettings === null) {
  6540. this._initMiniNav();
  6541. renderNav = true;
  6542. }
  6543. else if(bbWidth > threshold && this._initialNavSettings !== null) {
  6544. this._set('navButtons', this._initialNavSettings.buttons);
  6545. this._set('navButtonsLeft', this._initialNavSettings.buttonsLeft);
  6546. this._set('navButtonsRight', this._initialNavSettings.buttonsRight);
  6547. this._set('navType', this._initialNavSettings.type);
  6548. this._initialNavSettings = null;
  6549. renderNav = true;
  6550. }
  6551. // Button nav
  6552. if(renderNav || this.nav === null) {
  6553. this._renderNav();
  6554. }
  6555. // Thumbs nav
  6556. if(renderNav || this.thumbs === null) {
  6557. this._renderThumbs();
  6558. }
  6559. else if(this._thumbsEnabled()) {
  6560. this._resizeThumbs();
  6561. }
  6562. // Caption
  6563. if(renderNav && this.caption !== null) {
  6564. this._syncCaption();
  6565. }
  6566. // Social
  6567. if(renderNav && this.social !== null) {
  6568. this._syncSocial();
  6569. }
  6570. }
  6571. },
  6572. /**
  6573. * Creates and renders a new instance of FL.SlideshowNav
  6574. * used for the main nav.
  6575. *
  6576. * @method _renderNav
  6577. * @protected
  6578. */
  6579. _renderNav: function()
  6580. {
  6581. var frameBB = this.frame.get('boundingBox'),
  6582. navBB = null,
  6583. navOverlay = this.get('navOverlay'),
  6584. navPosition = this.get('navPosition');
  6585. // Destroy old instances
  6586. this._destroyNav();
  6587. // Create a new instance
  6588. if(this.get('navType') == 'buttons') {
  6589. // Create the nav
  6590. this.nav = new Y.FL.SlideshowNav({
  6591. buttons: this.get('navButtons'),
  6592. buttonsLeft: this.get('navButtonsLeft'),
  6593. buttonsRight: this.get('navButtonsRight')
  6594. });
  6595. // Add to widget parent and render
  6596. this.add(this.nav);
  6597. this.nav.render(this.get('contentBox'));
  6598. navBB = this.nav.get('boundingBox');
  6599. // Plug overlay?
  6600. if(navOverlay) {
  6601. this.nav.plug(Y.FL.SlideshowOverlay, {
  6602. hideDelay: this.get('overlayHideDelay')
  6603. });
  6604. navBB.setStyle('position', 'absolute');
  6605. navBB.setStyle(navPosition, '0px');
  6606. }
  6607. // Insert
  6608. if(navPosition == 'top') {
  6609. frameBB.insert(navBB, 'before');
  6610. }
  6611. else {
  6612. frameBB.insert(navBB, 'after');
  6613. }
  6614. // CSS class name
  6615. navBB.addClass('fl-slideshow-main-nav');
  6616. }
  6617. },
  6618. /**
  6619. * Destroy the current nav instance.
  6620. *
  6621. * @method _destroyNav
  6622. * @protected
  6623. */
  6624. _destroyNav: function()
  6625. {
  6626. if(this.nav !== null) {
  6627. if(this.nav.slideshowOverlay) {
  6628. this.nav.slideshowOverlay.destroy();
  6629. }
  6630. this.nav.get('boundingBox').remove();
  6631. this.remove(this.nav);
  6632. try { this.nav.destroy(true); } catch(e) {}
  6633. this.nav = null;
  6634. }
  6635. },
  6636. /**
  6637. * Returns the nav object or null if navType is
  6638. * set to none or custom.
  6639. *
  6640. * @method _getNav
  6641. * @protected
  6642. */
  6643. _getNav: function()
  6644. {
  6645. var navType = this.get('navType');
  6646. if(navType == 'buttons') {
  6647. return this.nav;
  6648. }
  6649. else if(navType == 'thumbs') {
  6650. return this.thumbs;
  6651. }
  6652. else {
  6653. return null;
  6654. }
  6655. },
  6656. /**
  6657. * Toggles the visibility of the nav or thumbs nav
  6658. * if navOverlay is set to true.
  6659. *
  6660. * @method _toggleNav
  6661. * @protected
  6662. */
  6663. _toggleNav: function()
  6664. {
  6665. var nav = this._getNav();
  6666. if(nav.slideshowOverlay) {
  6667. if(nav.slideshowOverlay._visible) {
  6668. nav.slideshowOverlay.hideWithTimer();
  6669. }
  6670. else {
  6671. nav.slideshowOverlay.show();
  6672. }
  6673. }
  6674. },
  6675. /**
  6676. * Creates and renders two instances of FL.SlideshowNav for the
  6677. * prev and next button that will be overlaid on the main image.
  6678. *
  6679. * @method _renderImageNav
  6680. * @protected
  6681. */
  6682. _renderImageNav: function()
  6683. {
  6684. var ssBB;
  6685. if(this.get('imageNavEnabled')) {
  6686. if(this._isMobile()) {
  6687. this._set('imageNavEnabled', false);
  6688. }
  6689. else {
  6690. ssBB = this.get('boundingBox');
  6691. this.imageNavLeft = new Y.FL.SlideshowNav({
  6692. buttons: ['prev'],
  6693. useFontIcons: false
  6694. });
  6695. this.imageNavRight = new Y.FL.SlideshowNav({
  6696. buttons: ['next'],
  6697. useFontIcons: false
  6698. });
  6699. this.add(this.imageNavLeft);
  6700. this.add(this.imageNavRight);
  6701. this.imageNavLeft.render(this.frame.get('boundingBox'));
  6702. this.imageNavRight.render(this.frame.get('boundingBox'));
  6703. this.imageNavLeft.plug(Y.FL.SlideshowOverlay, { hideDelay: this.get('overlayHideDelay') });
  6704. this.imageNavRight.plug(Y.FL.SlideshowOverlay, { hideDelay: this.get('overlayHideDelay') });
  6705. if(this.get('overlayHideOnMousemove')) {
  6706. this.frame.once('transitionComplete', this.imageNavLeft.slideshowOverlay.hideWithTimer, this.imageNavLeft.slideshowOverlay);
  6707. this.frame.once('transitionComplete', this.imageNavRight.slideshowOverlay.hideWithTimer, this.imageNavRight.slideshowOverlay);
  6708. ssBB.on('mousemove', Y.bind(this._toggleImageNav, this));
  6709. ssBB.on('mouseenter', Y.bind(this._toggleImageNav, this));
  6710. }
  6711. this.imageNavLeft.get('boundingBox').addClass('fl-slideshow-image-nav-left');
  6712. this.imageNavRight.get('boundingBox').addClass('fl-slideshow-image-nav-right');
  6713. }
  6714. }
  6715. },
  6716. /**
  6717. * @method _positionImageNav
  6718. * @protected
  6719. */
  6720. _positionImageNav: function()
  6721. {
  6722. var leftBB = this.imageNavLeft.get('boundingBox'),
  6723. rightBB = this.imageNavRight.get('boundingBox'),
  6724. imageNavHeight = leftBB.get('offsetHeight'),
  6725. frameHeight = this.frame.get('boundingBox').get('offsetHeight'),
  6726. top = frameHeight/2 - imageNavHeight/2,
  6727. styles = {
  6728. top: top + 'px',
  6729. display: 'block'
  6730. };
  6731. leftBB.setStyles(styles);
  6732. rightBB.setStyles(styles);
  6733. this._adjustOverlayForVerticalThumbs(leftBB);
  6734. this._adjustOverlayForVerticalThumbs(rightBB);
  6735. },
  6736. /**
  6737. * Toggles the visibility of the image nav buttons.
  6738. *
  6739. * @method _toggleImageNav
  6740. * @protected
  6741. */
  6742. _toggleImageNav: function()
  6743. {
  6744. if(this.imageNavLeft.slideshowOverlay._visible) {
  6745. this.imageNavLeft.slideshowOverlay.hideWithTimer();
  6746. }
  6747. else {
  6748. this.imageNavLeft.slideshowOverlay.show();
  6749. }
  6750. if(this.imageNavRight.slideshowOverlay._visible) {
  6751. this.imageNavRight.slideshowOverlay.hideWithTimer();
  6752. }
  6753. else {
  6754. this.imageNavRight.slideshowOverlay.show();
  6755. }
  6756. },
  6757. /**
  6758. * @method _renderMouseNav
  6759. * @protected
  6760. */
  6761. _renderMouseNav: function()
  6762. {
  6763. if(this.get('mouseNavEnabled') && !('ontouchstart' in window) && !window.navigator.msPointerEnabled) {
  6764. this.plug(Y.FL.SlideshowMouseNav, {
  6765. trigger: this.frame.get('boundingBox')
  6766. });
  6767. }
  6768. },
  6769. /**
  6770. * Checks whether the thumbs are enabled.
  6771. *
  6772. * @method _thumbsEnabled
  6773. * @protected
  6774. * @returns Boolean
  6775. */
  6776. _thumbsEnabled: function()
  6777. {
  6778. var navType = this.get('navType');
  6779. if(navType == 'thumbs') {
  6780. return true;
  6781. }
  6782. if((navType == 'buttons' || navType == 'custom') && this._hasNavButton('thumbs')) {
  6783. return true;
  6784. }
  6785. else {
  6786. return false;
  6787. }
  6788. },
  6789. /**
  6790. * Creates and renders a new instance of FL.SlideshowThumbs.
  6791. *
  6792. * @method _renderThumbs
  6793. * @protected
  6794. */
  6795. _renderThumbs: function()
  6796. {
  6797. var frameBB, navOverlay, navPosition, navType;
  6798. // Destroy old instances
  6799. this._destroyThumbs();
  6800. // Create a new instance
  6801. if(this._thumbsEnabled()) {
  6802. frameBB = this.frame.get('boundingBox');
  6803. navOverlay = this.get('navOverlay');
  6804. navPosition = this.get('navPosition');
  6805. navType = this.get('navType');
  6806. // Create the thumbs
  6807. this.thumbs = new Y.FL.SlideshowThumbs(this._getThumbsConfig());
  6808. // This breaks sometimes on SM Next. Try/catch bandaid for now.
  6809. try { this.add(this.thumbs); } catch(e) {}
  6810. // Overlay setup
  6811. if(navType == 'buttons' || navType == 'custom') {
  6812. this.thumbs.plug(Y.FL.SlideshowOverlay, {
  6813. hideDelay: this.get('overlayHideDelay'),
  6814. hideStyle: 'left',
  6815. visible: false
  6816. });
  6817. }
  6818. else if(navType == 'thumbs' && navOverlay) {
  6819. this.thumbs.plug(Y.FL.SlideshowOverlay, {
  6820. hideDelay: this.get('overlayHideDelay'),
  6821. hideStyle: 'left'
  6822. });
  6823. }
  6824. // Insert
  6825. this.thumbs.render(this.get('contentBox'));
  6826. if(navPosition == 'top') {
  6827. frameBB.insert(this.thumbs.get('boundingBox'), 'before');
  6828. }
  6829. else {
  6830. frameBB.insert(this.thumbs.get('boundingBox'), 'after');
  6831. }
  6832. // Hide overlay thumbs on click
  6833. if(this.get('thumbsHideOnClick') && navType != 'thumbs') {
  6834. this.thumbs.on('imageClick', Y.bind(this._hideThumbsOnImageClick, this));
  6835. }
  6836. this._syncThumbs();
  6837. }
  6838. },
  6839. /**
  6840. * Destroy the current thumbs instance.
  6841. *
  6842. * @method _destroyThumbs
  6843. * @protected
  6844. */
  6845. _destroyThumbs: function()
  6846. {
  6847. if(this.thumbs !== null) {
  6848. if(this.thumbs.slideshowOverlay) {
  6849. this.thumbs.slideshowOverlay.destroy();
  6850. }
  6851. this.thumbs.get('boundingBox').remove();
  6852. this.remove(this.thumbs);
  6853. try { this.thumbs.destroy(true); } catch(e) {}
  6854. this.thumbs = null;
  6855. }
  6856. },
  6857. /**
  6858. * Syncs the thumbs UI styles.
  6859. *
  6860. * @method _syncThumbs
  6861. * @protected
  6862. */
  6863. _syncThumbs: function()
  6864. {
  6865. var thumbsBB = this.thumbs.get('boundingBox'),
  6866. navOverlay = this.get('navOverlay'),
  6867. navPosition = this.get('navPosition'),
  6868. navType = this.get('navType'),
  6869. paddingType = 'padding' + navPosition.charAt(0).toUpperCase() + navPosition.slice(1),
  6870. navHeight = 0;
  6871. if(navType == 'buttons') {
  6872. navHeight = parseInt(this.nav.get('boundingBox').getComputedStyle('height'), 10);
  6873. thumbsBB.setStyle('position', 'absolute');
  6874. if(navOverlay) {
  6875. thumbsBB.setStyle(paddingType, navHeight + 'px');
  6876. thumbsBB.setStyle(navPosition, '0px');
  6877. }
  6878. else {
  6879. thumbsBB.setStyle(navPosition, navHeight + 'px');
  6880. }
  6881. }
  6882. if(navType == 'custom' || (navType == 'thumbs' && navOverlay)) {
  6883. thumbsBB.setStyle('position', 'absolute');
  6884. thumbsBB.setStyle(navPosition, '0px');
  6885. }
  6886. this.thumbs.resize();
  6887. },
  6888. /**
  6889. * Prepares and returns the thumbs config object.
  6890. *
  6891. * @method _getThumbsConfig
  6892. * @protected
  6893. * @returns Object
  6894. */
  6895. _getThumbsConfig: function()
  6896. {
  6897. var attrs = this.getAttrs(),
  6898. navType = this.get('navType'),
  6899. imageConfig = {
  6900. crop: attrs.thumbsImageCrop,
  6901. width: attrs.thumbsImageWidth,
  6902. height: attrs.thumbsImageHeight
  6903. },
  6904. config = {
  6905. columns: 'auto',
  6906. rows: 1,
  6907. horizontalSpacing: attrs.thumbsHorizontalSpacing,
  6908. verticalSpacing: attrs.thumbsVerticalSpacing,
  6909. spaceEvenly: attrs.thumbsSpaceEvenly,
  6910. centerSinglePage: attrs.thumbsCenterSinglePage,
  6911. pauseOnClick: attrs.thumbsPauseOnClick,
  6912. transition: attrs.thumbsTransition,
  6913. transitionDirection: attrs.thumbsTransitionDirection,
  6914. transitionEasing: attrs.thumbsTransitionEasing,
  6915. leftNavButtons: attrs.navButtonsLeft,
  6916. rightNavButtons: attrs.navButtonsRight,
  6917. imageConfig: imageConfig,
  6918. touchSupport: true
  6919. };
  6920. if(navType == 'buttons' || navType == 'custom') {
  6921. if('ontouchstart' in window) {
  6922. config.leftNavEnabled = false;
  6923. config.rightNavEnabled = false;
  6924. }
  6925. else {
  6926. config.centerSinglePage = false;
  6927. config.leftNavButtons = ['prevPage'];
  6928. config.rightNavButtons = ['nextPage'];
  6929. }
  6930. }
  6931. return config;
  6932. },
  6933. /**
  6934. * Resizes the thumbs.
  6935. *
  6936. * @method _resizeThumbs
  6937. * @protected
  6938. */
  6939. _resizeThumbs: function()
  6940. {
  6941. if(this.thumbs) {
  6942. this.thumbs.resize();
  6943. }
  6944. },
  6945. /**
  6946. * Shows or hides the thumbs.
  6947. *
  6948. * @method _toggleThumbs
  6949. * @protected
  6950. */
  6951. _toggleThumbs: function()
  6952. {
  6953. this._toggleOverlay(this.thumbs.slideshowOverlay);
  6954. },
  6955. /**
  6956. * Hides the thumbs when a thumb image is clicked.
  6957. *
  6958. * @method _hideThumbsOnImageClick
  6959. * @protected
  6960. */
  6961. _hideThumbsOnImageClick: function()
  6962. {
  6963. if(this.thumbs.slideshowOverlay) {
  6964. this.thumbs.slideshowOverlay._focus = false;
  6965. this.thumbs.slideshowOverlay.enable();
  6966. this.thumbs.slideshowOverlay.hide();
  6967. if(this.nav && this.nav.slideshowOverlay) {
  6968. this.nav.slideshowOverlay.enable();
  6969. }
  6970. }
  6971. },
  6972. /**
  6973. * Creates and renders a new instance of FL.SlideshowCaption.
  6974. *
  6975. * @method _renderCaption
  6976. * @protected
  6977. */
  6978. _renderCaption: function()
  6979. {
  6980. if(this._hasNavButton('caption')) {
  6981. this.caption = new Y.FL.SlideshowCaption({
  6982. lessLinkText: this.get('captionLessLinkText'),
  6983. moreLinkText: this.get('captionMoreLinkText'),
  6984. textLength: this.get('captionTextLength'),
  6985. stripTags: this.get('captionStripTags')
  6986. });
  6987. this.add(this.caption);
  6988. this.caption.plug(Y.FL.SlideshowOverlay, {
  6989. hideDelay: this.get('overlayHideDelay'),
  6990. visible: false,
  6991. closeButton: true
  6992. });
  6993. this._syncCaption();
  6994. }
  6995. },
  6996. /**
  6997. * Syncs the caption UI styles.
  6998. *
  6999. * @method _syncCaption
  7000. * @protected
  7001. */
  7002. _syncCaption: function()
  7003. {
  7004. var captionBB = this.caption.get('boundingBox'),
  7005. navOverlay = this.get('navOverlay'),
  7006. navPosition = this.get('navPosition'),
  7007. nav = this._getNav(),
  7008. paddingType = 'padding' + navPosition.charAt(0).toUpperCase() + navPosition.slice(1),
  7009. navHeight = 0;
  7010. captionBB.setStyle('position', 'absolute');
  7011. if(nav) {
  7012. navHeight = parseInt(nav.get('boundingBox').getComputedStyle('height'), 10);
  7013. }
  7014. if(nav && navOverlay) {
  7015. captionBB.setStyle(paddingType, navHeight + 'px');
  7016. captionBB.setStyle(navPosition, '0px');
  7017. }
  7018. else {
  7019. captionBB.setStyle(navPosition, navHeight + 'px');
  7020. }
  7021. },
  7022. /**
  7023. * Shows or hides the caption.
  7024. *
  7025. * @method _toggleCaption
  7026. * @protected
  7027. */
  7028. _toggleCaption: function()
  7029. {
  7030. this._toggleOverlay(this.caption.slideshowOverlay);
  7031. },
  7032. /**
  7033. * Creates and renders a new instance of FL.SlideshowSocial.
  7034. *
  7035. * @method _renderSocial
  7036. * @protected
  7037. */
  7038. _renderSocial: function()
  7039. {
  7040. if(this._hasNavButton('social')) {
  7041. this.social = new Y.FL.SlideshowSocial();
  7042. this.add(this.social);
  7043. this.social.plug(Y.FL.SlideshowOverlay, {
  7044. hideDelay: this.get('overlayHideDelay'),
  7045. visible: false,
  7046. closeButton: true
  7047. });
  7048. this._syncSocial();
  7049. }
  7050. },
  7051. /**
  7052. * Syncs the social UI styles.
  7053. *
  7054. * @method _syncSocial
  7055. * @protected
  7056. */
  7057. _syncSocial: function()
  7058. {
  7059. var socialBB = this.social.get('boundingBox'),
  7060. navOverlay = this.get('navOverlay'),
  7061. navPosition = this.get('navPosition'),
  7062. nav = this._getNav(),
  7063. paddingType = 'padding' + navPosition.charAt(0).toUpperCase() + navPosition.slice(1),
  7064. navHeight = 0;
  7065. socialBB.setStyle('position', 'absolute');
  7066. if(nav) {
  7067. navHeight = parseInt(nav.get('boundingBox').getComputedStyle('height'), 10);
  7068. }
  7069. if(nav && navOverlay) {
  7070. socialBB.setStyle(paddingType, navHeight + 'px');
  7071. socialBB.setStyle(navPosition, '0px');
  7072. }
  7073. else {
  7074. socialBB.setStyle(navPosition, navHeight + 'px');
  7075. }
  7076. },
  7077. /**
  7078. * Shows or hides the social buttons.
  7079. *
  7080. * @method _toggleSocial
  7081. * @protected
  7082. */
  7083. _toggleSocial: function()
  7084. {
  7085. this._toggleOverlay(this.social.slideshowOverlay);
  7086. // Refresh iframe to fix tweet button issue visibility inside hidden elements
  7087. var iFrame = jQuery('.fl-slideshow-social-content').find('iframe');
  7088. iFrame.remove();
  7089. jQuery('.fl-slideshow-social-content').prepend(iFrame);
  7090. },
  7091. /**
  7092. * Shows or hides an overlaid widget based
  7093. * on its current visibility.
  7094. *
  7095. * @method _toggleOverlay
  7096. * @param overlay {Object} The overlay to toggle.
  7097. * @protected
  7098. */
  7099. _toggleOverlay: function(overlay)
  7100. {
  7101. var navType = this.get('navType'),
  7102. nav = this._getNav();
  7103. if(overlay._visible) {
  7104. if(nav && nav.slideshowOverlay) {
  7105. nav.slideshowOverlay.enable();
  7106. }
  7107. overlay.enable();
  7108. overlay.hide();
  7109. }
  7110. else {
  7111. if(nav && nav.slideshowOverlay) {
  7112. nav.slideshowOverlay.disable();
  7113. }
  7114. overlay.show();
  7115. overlay.disable();
  7116. }
  7117. if(this.thumbs && navType != 'thumbs' && this.thumbs.slideshowOverlay !== overlay) {
  7118. this.thumbs.slideshowOverlay.enable();
  7119. this.thumbs.slideshowOverlay.hide();
  7120. }
  7121. if(this.caption && this.caption.slideshowOverlay !== overlay) {
  7122. this.caption.slideshowOverlay.enable();
  7123. this.caption.slideshowOverlay.hide();
  7124. }
  7125. if(this.social && this.social.slideshowOverlay !== overlay) {
  7126. this.social.slideshowOverlay.enable();
  7127. this.social.slideshowOverlay.hide();
  7128. }
  7129. },
  7130. /**
  7131. * Called when an overlay's close button is clicked.
  7132. *
  7133. * @method _overlayCloseClick
  7134. * @protected
  7135. */
  7136. _overlayCloseClick: function()
  7137. {
  7138. if(this.nav && this.nav.slideshowOverlay) {
  7139. this.nav.slideshowOverlay.enable();
  7140. }
  7141. if(this.thumbs && this.thumbs.slideshowOverlay) {
  7142. this.thumbs.slideshowOverlay.enable();
  7143. }
  7144. if(this.caption) {
  7145. this.caption.slideshowOverlay.enable();
  7146. }
  7147. if(this.social) {
  7148. this.social.slideshowOverlay.enable();
  7149. }
  7150. if(this.imageNavLeft) {
  7151. this.imageNavLeft.slideshowOverlay.enable();
  7152. this.imageNavRight.slideshowOverlay.enable();
  7153. }
  7154. },
  7155. /**
  7156. * Hides all overlaid widgets.
  7157. *
  7158. * @method _hideAllOverlays
  7159. * @protected
  7160. */
  7161. _hideAllOverlays: function()
  7162. {
  7163. if(this.nav && this.nav.slideshowOverlay && this.nav.slideshowOverlay._visible) {
  7164. this.nav.slideshowOverlay.enable();
  7165. this.nav.slideshowOverlay.hideWithTimer();
  7166. }
  7167. if(this.thumbs && this.thumbs.slideshowOverlay && this.thumbs.slideshowOverlay._visible) {
  7168. this.thumbs.slideshowOverlay.enable();
  7169. this.thumbs.slideshowOverlay.hideWithTimer();
  7170. }
  7171. if(this.caption && this.caption.slideshowOverlay._visible) {
  7172. this.caption.slideshowOverlay.enable();
  7173. this.caption.slideshowOverlay.hideWithTimer();
  7174. }
  7175. if(this.social && this.social.slideshowOverlay._visible) {
  7176. this.social.slideshowOverlay.enable();
  7177. this.social.slideshowOverlay.hideWithTimer();
  7178. }
  7179. if(this.imageNavLeft) {
  7180. this.imageNavLeft.slideshowOverlay.enable();
  7181. this.imageNavLeft.slideshowOverlay.hideWithTimer();
  7182. this.imageNavRight.slideshowOverlay.enable();
  7183. this.imageNavRight.slideshowOverlay.hideWithTimer();
  7184. }
  7185. },
  7186. /**
  7187. * Checks if overlays are still visible when the mouse enters
  7188. * the bounding box. If they are, overlay functionality is disabled
  7189. * until the overlays are closed by a button or the mouse leaves
  7190. * the bounding box. If only the nav overlay is visible, this
  7191. * function does nothing.
  7192. *
  7193. * @method _checkOverlaysOnMouseenter
  7194. * @protected
  7195. */
  7196. _checkOverlaysOnMouseenter: function()
  7197. {
  7198. var navType = this.get('navType'),
  7199. navOverlay = this.get('navOverlay'),
  7200. nav = this._getNav(),
  7201. overlayVisible = false;
  7202. if(this.thumbs && navType != 'thumbs' && this.thumbs.slideshowOverlay._visible) {
  7203. overlayVisible = true;
  7204. this.thumbs.slideshowOverlay.disable();
  7205. }
  7206. else if(this.caption && this.caption.slideshowOverlay._visible) {
  7207. overlayVisible = true;
  7208. this.caption.slideshowOverlay.disable();
  7209. }
  7210. else if(this.social && this.social.slideshowOverlay._visible) {
  7211. overlayVisible = true;
  7212. this.social.slideshowOverlay.disable();
  7213. }
  7214. if(nav && overlayVisible && navOverlay) {
  7215. nav.slideshowOverlay.disable();
  7216. }
  7217. },
  7218. /**
  7219. * Checks whether a nav button is set or not.
  7220. *
  7221. * @method _hasNavButton
  7222. * @protected
  7223. * @param button {String} The button to look for.
  7224. * @returns Boolean
  7225. */
  7226. _hasNavButton: function(button)
  7227. {
  7228. var navType = this.get('navType');
  7229. if(navType == 'buttons' || navType == 'thumbs' || navType == 'custom') {
  7230. if(Y.Array.indexOf(this.get('navButtons'), button) > -1) {
  7231. return true;
  7232. }
  7233. else if(Y.Array.indexOf(this.get('navButtonsLeft'), button) > -1) {
  7234. return true;
  7235. }
  7236. else if(Y.Array.indexOf(this.get('navButtonsRight'), button) > -1) {
  7237. return true;
  7238. }
  7239. else {
  7240. return false;
  7241. }
  7242. }
  7243. else {
  7244. return false;
  7245. }
  7246. },
  7247. /**
  7248. * @method _removeNavButton
  7249. * @param button {String} The name of the button to remove.
  7250. * @protected
  7251. */
  7252. _removeNavButton: function(button)
  7253. {
  7254. var buttons = this.get('navButtons'),
  7255. buttonsLeft = this.get('navButtonsLeft'),
  7256. buttonsRight = this.get('navButtonsRight'),
  7257. vtTopNavButtons = this.get('verticalThumbsTopNavButtons'),
  7258. vtBottomNavButtons = this.get('verticalThumbsBottomNavButtons');
  7259. if(Y.Array.indexOf(buttons, button) > -1) {
  7260. buttons.splice(Y.Array.indexOf(buttons, button), 1);
  7261. }
  7262. if(Y.Array.indexOf(buttonsLeft, button) > -1) {
  7263. buttonsLeft.splice(Y.Array.indexOf(buttonsLeft, button), 1);
  7264. }
  7265. if(Y.Array.indexOf(buttonsRight, button) > -1) {
  7266. buttonsRight.splice(Y.Array.indexOf(buttonsRight, button), 1);
  7267. }
  7268. if(Y.Array.indexOf(vtTopNavButtons, button) > -1) {
  7269. vtTopNavButtons.splice(Y.Array.indexOf(vtTopNavButtons, button), 1);
  7270. }
  7271. if(Y.Array.indexOf(vtBottomNavButtons, button) > -1) {
  7272. vtBottomNavButtons.splice(Y.Array.indexOf(vtBottomNavButtons, button), 1);
  7273. }
  7274. this._set('navButtons', buttons);
  7275. this._set('navButtonsLeft', buttonsLeft);
  7276. this._set('navButtonsRight', buttonsRight);
  7277. this._set('verticalThumbsTopNavButtons', vtTopNavButtons);
  7278. this._set('verticalThumbsBottomNavButtons', vtBottomNavButtons);
  7279. }
  7280. }, {
  7281. /**
  7282. * Custom CSS class name for the widget.
  7283. *
  7284. * @property CSS_PREFIX
  7285. * @type String
  7286. * @protected
  7287. * @static
  7288. */
  7289. CSS_PREFIX: 'fl-slideshow',
  7290. /**
  7291. * Static property used to define the default attribute configuration of
  7292. * the Widget.
  7293. *
  7294. * @property ATTRS
  7295. * @type Object
  7296. * @protected
  7297. * @static
  7298. */
  7299. ATTRS: {
  7300. /**
  7301. * What should happen when the main image is clicked.
  7302. * Options are none, gallery and url. If url is chosen,
  7303. * clickActionUrl must be set.
  7304. *
  7305. * @attribute clickAction
  7306. * @type String
  7307. * @default none
  7308. */
  7309. clickAction: {
  7310. value: 'none'
  7311. },
  7312. /**
  7313. * The redirect url to use when clickAction is set to url.
  7314. *
  7315. * @attribute clickActionUrl
  7316. * @type String
  7317. * @default none
  7318. */
  7319. clickActionUrl: {
  7320. value: ''
  7321. },
  7322. /**
  7323. * Whether to crop the main image.
  7324. *
  7325. * @attribute crop
  7326. * @type Boolean
  7327. * @default false
  7328. */
  7329. crop: {
  7330. value: false
  7331. },
  7332. /**
  7333. * Whether to only crop horizontal images or not.
  7334. *
  7335. * @attribute cropHorizontalsOnly
  7336. * @type Boolean
  7337. * @default false
  7338. */
  7339. cropHorizontalsOnly: {
  7340. value: false
  7341. },
  7342. /**
  7343. * Whether to always use the loading image between images
  7344. * or to only use it between albums.
  7345. *
  7346. * @attribute loadingImageAlwaysEnabled
  7347. * @type Boolean
  7348. * @default true
  7349. */
  7350. loadingImageAlwaysEnabled: {
  7351. value: true
  7352. },
  7353. /**
  7354. * The x and y position of the main image
  7355. * within the bounding box.
  7356. *
  7357. * @attribute position
  7358. * @type String
  7359. * @default center center
  7360. */
  7361. position: {
  7362. value: 'center center'
  7363. },
  7364. /**
  7365. * Whether to right click protect the main image.
  7366. *
  7367. * @attribute protect
  7368. * @type Boolean
  7369. * @default true
  7370. */
  7371. protect: {
  7372. value: true
  7373. },
  7374. /**
  7375. * Whether to resize the main image past
  7376. * its original width and height.
  7377. *
  7378. * @attribute upsize
  7379. * @type Boolean
  7380. * @default true
  7381. */
  7382. upsize: {
  7383. value: true
  7384. },
  7385. /**
  7386. * The type of transition to use. Possible values are
  7387. * none, fade, slideHorizontal and slideVertical. The
  7388. * value can also be a common seperated string of transitions
  7389. * that will be randomly chosen for each image.
  7390. *
  7391. * @attribute transition
  7392. * @type String
  7393. * @default fade
  7394. */
  7395. transition: {
  7396. value: 'fade'
  7397. },
  7398. /**
  7399. * The duration of the transition, measured in seconds.
  7400. *
  7401. * @attribute transitionDuration
  7402. * @type Number
  7403. * @default 1
  7404. */
  7405. transitionDuration: {
  7406. value: 1
  7407. },
  7408. /**
  7409. * The type of transition easing to use.
  7410. *
  7411. * @attribute transitionEasing
  7412. * @type String
  7413. * @default ease-out
  7414. */
  7415. transitionEasing: {
  7416. value: 'ease-out'
  7417. },
  7418. /**
  7419. * The amount of zoom to use for the Ken Burns effect.
  7420. *
  7421. * @attribute kenBurnsZoom
  7422. * @type Number
  7423. * @default 1.2
  7424. */
  7425. kenBurnsZoom: {
  7426. value: 1.2
  7427. },
  7428. /**
  7429. * The type of navigation to use. Possible values are
  7430. * buttons, thumbs, custon and none.
  7431. *
  7432. * @attribute navType
  7433. * @type String
  7434. * @default none
  7435. */
  7436. navType: {
  7437. value: 'none'
  7438. },
  7439. /**
  7440. * The position of the main nav. Possible values are top and bottom.
  7441. *
  7442. * @attribute navPosition
  7443. * @type String
  7444. * @default bottom
  7445. */
  7446. navPosition: {
  7447. value: 'bottom'
  7448. },
  7449. /**
  7450. * Whether to overlay the nav on top of the main image.
  7451. *
  7452. * @attribute navOverlay
  7453. * @type Boolean
  7454. * @default false
  7455. */
  7456. navOverlay: {
  7457. value: false
  7458. },
  7459. /**
  7460. * An array of button names used to render the main nav's buttons.
  7461. *
  7462. * @attribute navButtons
  7463. * @type Array
  7464. * @default []
  7465. */
  7466. navButtons: {
  7467. value: []
  7468. },
  7469. /**
  7470. * An array of button names used to render the main nav's left buttons.
  7471. *
  7472. * @attribute navButtonsLeft
  7473. * @type Array
  7474. * @default []
  7475. */
  7476. navButtonsLeft: {
  7477. value: []
  7478. },
  7479. /**
  7480. * An array of button names used to render the main nav's right buttons.
  7481. *
  7482. * @attribute navButtonsRight
  7483. * @type Array
  7484. * @default []
  7485. */
  7486. navButtonsRight: {
  7487. value: []
  7488. },
  7489. /**
  7490. * Whether to hide the overlays when the mouse moves or not.
  7491. *
  7492. * @attribute overlayHideOnMousemove
  7493. * @type String
  7494. * @default mouseover
  7495. */
  7496. overlayHideOnMousemove: {
  7497. value: true
  7498. },
  7499. /**
  7500. * How long to wait before hiding the overlays.
  7501. * Measured in milliseconds.
  7502. *
  7503. * @attribute overlayHideDelay
  7504. * @type Number
  7505. * @default false
  7506. */
  7507. overlayHideDelay: {
  7508. value: 3000
  7509. },
  7510. /**
  7511. * Whether to use the image nav or not. If true, a prev
  7512. * and next button will be overlaid on the main image.
  7513. *
  7514. * @attribute imageNavEnabled
  7515. * @type Boolean
  7516. * @default false
  7517. */
  7518. imageNavEnabled: {
  7519. value: false
  7520. },
  7521. /**
  7522. * Whether to use the mouse nav or not. If true, the cursor
  7523. * will turn into a prev or next button when over the slideshow.
  7524. *
  7525. * @attribute mouseNavEnabled
  7526. * @type Boolean
  7527. * @default false
  7528. */
  7529. mouseNavEnabled: {
  7530. value: false
  7531. },
  7532. /**
  7533. * Whether to hide the thumbs when clicking on a thumbnail
  7534. * image or not. Thumbs always hide navType is set to buttons.
  7535. *
  7536. * @attribute thumbsHideOnClick
  7537. * @type Boolean
  7538. * @default false
  7539. */
  7540. thumbsHideOnClick: {
  7541. value: true
  7542. },
  7543. /**
  7544. * The horizontal spacing between thumbs.
  7545. *
  7546. * @attribute thumbsHorizontalSpacing
  7547. * @type Number
  7548. * @default 15
  7549. */
  7550. thumbsHorizontalSpacing: {
  7551. value: 15
  7552. },
  7553. /**
  7554. * The vertical spacing between thumbs.
  7555. *
  7556. * @attribute thumbsVerticalSpacing
  7557. * @type Number
  7558. * @default 15
  7559. */
  7560. thumbsVerticalSpacing: {
  7561. value: 15
  7562. },
  7563. /**
  7564. * Whether to space the thumbs evenly within a page.
  7565. *
  7566. * @attribute thumbsSpaceEvenly
  7567. * @type Boolean
  7568. * @default true
  7569. */
  7570. thumbsSpaceEvenly: {
  7571. value: true
  7572. },
  7573. /**
  7574. * Whether to center single pages of thumbs.
  7575. *
  7576. * @attribute thumbsCenterSinglePage
  7577. * @type Boolean
  7578. * @default false
  7579. */
  7580. thumbsCenterSinglePage: {
  7581. value: true
  7582. },
  7583. /**
  7584. * Whether to pause the slideshow when a thumb is clicked.
  7585. *
  7586. * @attribute thumbsPauseOnClick
  7587. * @type Boolean
  7588. * @default false
  7589. */
  7590. thumbsPauseOnClick: {
  7591. value: false
  7592. },
  7593. /**
  7594. * The type of transition to use between pages of thumbs.
  7595. *
  7596. * @attribute thumbsTransition
  7597. * @type String
  7598. * @default slideHorizontal
  7599. */
  7600. thumbsTransition: {
  7601. value: 'slideHorizontal'
  7602. },
  7603. /**
  7604. * The duration of the transition between pages of thumbs.
  7605. *
  7606. * @attribute thumbsTransitionDuration
  7607. * @type Number
  7608. * @default 0.8
  7609. */
  7610. thumbsTransitionDuration: {
  7611. value: 0.8
  7612. },
  7613. /**
  7614. * The type of transition easing to use between pages of thumbs.
  7615. *
  7616. * @attribute thumbsTransitionEasing
  7617. * @type String
  7618. * @default ease-out
  7619. */
  7620. thumbsTransitionEasing: {
  7621. value: 'ease-out'
  7622. },
  7623. /**
  7624. * Whether to crop the thumbnails.
  7625. *
  7626. * @attribute thumbsImageCrop
  7627. * @type Boolean
  7628. * @default true
  7629. */
  7630. thumbsImageCrop: {
  7631. value: true
  7632. },
  7633. /**
  7634. * The width of each thumbnail.
  7635. *
  7636. * @attribute thumbsImageWidth
  7637. * @type Number
  7638. * @default 50
  7639. */
  7640. thumbsImageWidth: {
  7641. value: 50
  7642. },
  7643. /**
  7644. * The height of each thumbnail.
  7645. *
  7646. * @attribute thumbsImageHeight
  7647. * @type Number
  7648. * @default 50
  7649. */
  7650. thumbsImageHeight: {
  7651. value: 50
  7652. },
  7653. /**
  7654. * The text to use for the "read less" toggle link.
  7655. *
  7656. * @attribute captionLessLinkText
  7657. * @type String
  7658. * @default Read Less
  7659. */
  7660. captionLessLinkText: {
  7661. value: 'Read Less'
  7662. },
  7663. /**
  7664. * The text to use for the "read more" toggle link.
  7665. *
  7666. * @attribute captionMoreLinkText
  7667. * @type String
  7668. * @default Read More
  7669. */
  7670. captionMoreLinkText: {
  7671. value: 'Read More'
  7672. },
  7673. /**
  7674. * The length of the caption to show. If greater than -1,
  7675. * the text will be truncated and a read more link will
  7676. * be displayed. If set to -1, the entire caption will be shown.
  7677. *
  7678. * @attribute captionTextLength
  7679. * @type Number
  7680. * @default 200
  7681. */
  7682. captionTextLength: {
  7683. value: 200
  7684. },
  7685. /**
  7686. * Whether to strip out HTML tags in the caption
  7687. * text or not.
  7688. *
  7689. * @attribute captionStripTags
  7690. * @type Boolean
  7691. * @default false
  7692. */
  7693. captionStripTags: {
  7694. value: false
  7695. },
  7696. /**
  7697. * Whether to use the vertical thumbs or not.
  7698. *
  7699. * @attribute verticalThumbsEnabled
  7700. * @type Boolean
  7701. * @default false
  7702. */
  7703. verticalThumbsEnabled: {
  7704. value: false
  7705. },
  7706. /**
  7707. * Position of the vertical thumbs. Possible values
  7708. * are either left or right.
  7709. *
  7710. * @attribute verticalThumbsPosition
  7711. * @type String
  7712. * @default left
  7713. */
  7714. verticalThumbsPosition: {
  7715. value: 'left'
  7716. },
  7717. /**
  7718. * Whether to overlay the vertical thumbs
  7719. * on the main image or not.
  7720. *
  7721. * @attribute verticalThumbsOverlay
  7722. * @type Boolean
  7723. * @default false
  7724. */
  7725. verticalThumbsOverlay: {
  7726. value: false
  7727. },
  7728. /**
  7729. * The number of columns for the vertical thumbs.
  7730. *
  7731. * @attribute verticalThumbsColumns
  7732. * @type Number
  7733. * @default 1
  7734. */
  7735. verticalThumbsColumns: {
  7736. value: 1
  7737. },
  7738. /**
  7739. * Whether to use the vertical thumbs top nav or not.
  7740. *
  7741. * @attribute verticalThumbsTopNavEnabled
  7742. * @type Boolean
  7743. * @default false
  7744. */
  7745. verticalThumbsTopNavEnabled: {
  7746. value: false
  7747. },
  7748. /**
  7749. * An array of button names used to render
  7750. * the vertical thumbs top nav buttons.
  7751. *
  7752. * @attribute verticalThumbsTopNavButtons
  7753. * @type Array
  7754. * @default prevPage, nextPage
  7755. */
  7756. verticalThumbsTopNavButtons: {
  7757. value: ['prevPage', 'nextPage']
  7758. },
  7759. /**
  7760. * Whether to use the vertical thumbs bottom nav or not.
  7761. *
  7762. * @attribute verticalThumbsBottomNavEnabled
  7763. * @type Boolean
  7764. * @default false
  7765. */
  7766. verticalThumbsBottomNavEnabled: {
  7767. value: true
  7768. },
  7769. /**
  7770. * An array of button names used to render
  7771. * the vertical thumbs top nav buttons.
  7772. *
  7773. * @attribute verticalThumbsBottomNavButtons
  7774. * @type Array
  7775. * @default prevPage, nextPage
  7776. */
  7777. verticalThumbsBottomNavButtons: {
  7778. value: ['prevPage', 'nextPage']
  7779. },
  7780. /**
  7781. * The horizontal spacing between vertical thumbs.
  7782. *
  7783. * @attribute verticalThumbsHorizontalSpacing
  7784. * @type Number
  7785. * @default 15
  7786. */
  7787. verticalThumbsHorizontalSpacing: {
  7788. value: 15
  7789. },
  7790. /**
  7791. * The vertical spacing between vertical thumbs.
  7792. *
  7793. * @attribute verticalThumbsVerticalSpacing
  7794. * @type Number
  7795. * @default 15
  7796. */
  7797. verticalThumbsVerticalSpacing: {
  7798. value: 15
  7799. },
  7800. /**
  7801. * Whether to space the vertical thumbs evenly within a page.
  7802. *
  7803. * @attribute verticalThumbsSpaceEvenly
  7804. * @type Boolean
  7805. * @default false
  7806. */
  7807. verticalThumbsSpaceEvenly: {
  7808. value: false
  7809. },
  7810. /**
  7811. * Whether to pause the slideshow when a vertical thumb is clicked.
  7812. *
  7813. * @attribute verticalThumbsPauseOnClick
  7814. * @type Boolean
  7815. * @default false
  7816. */
  7817. verticalThumbsPauseOnClick: {
  7818. value: false
  7819. },
  7820. /**
  7821. * Whether to crop the vertical thumbs or not.
  7822. *
  7823. * @attribute verticalThumbsImageCrop
  7824. * @type Boolean
  7825. * @default true
  7826. */
  7827. verticalThumbsImageCrop: {
  7828. value: true
  7829. },
  7830. /**
  7831. * The width of each vertical thumbnail.
  7832. *
  7833. * @attribute verticalThumbsImageWidth
  7834. * @type Number
  7835. * @default 75
  7836. */
  7837. verticalThumbsImageWidth: {
  7838. value: 75
  7839. },
  7840. /**
  7841. * The height of each vertical thumbnail.
  7842. *
  7843. * @attribute verticalThumbsImageHeight
  7844. * @type Number
  7845. * @default 75
  7846. */
  7847. verticalThumbsImageHeight: {
  7848. value: 75
  7849. },
  7850. /**
  7851. * The type of transition to use between pages of vertical thumbs.
  7852. *
  7853. * @attribute verticalThumbsTransition
  7854. * @type String
  7855. * @default slideVertical
  7856. */
  7857. verticalThumbsTransition: {
  7858. value: 'slideVertical'
  7859. },
  7860. /**
  7861. * The duration of the transition between pages of vertical thumbs.
  7862. *
  7863. * @attribute verticalThumbsTransitionDuration
  7864. * @type Number
  7865. * @default 0.8
  7866. */
  7867. verticalThumbsTransitionDuration: {
  7868. value: 0.8
  7869. },
  7870. /**
  7871. * The type of transition easing to use between pages of vertical thumbs.
  7872. *
  7873. * @attribute verticalThumbsTransitionEasing
  7874. * @type String
  7875. * @default ease-out
  7876. */
  7877. verticalThumbsTransitionEasing: {
  7878. value: 'ease-out'
  7879. },
  7880. /**
  7881. * Whether to use the Facebook like button or not.
  7882. *
  7883. * @attribute likeButtonEnabled
  7884. * @type Boolean
  7885. * @default true
  7886. */
  7887. likeButtonEnabled: {
  7888. value: true
  7889. },
  7890. /**
  7891. * Whether to use the Pinterest button or not.
  7892. *
  7893. * @attribute pinterestButtonEnabled
  7894. * @type Boolean
  7895. * @default true
  7896. */
  7897. pinterestButtonEnabled: {
  7898. value: true
  7899. },
  7900. /**
  7901. * Whether to use the Tweet button or not.
  7902. *
  7903. * @attribute tweetButtonEnabled
  7904. * @type Boolean
  7905. * @default true
  7906. */
  7907. tweetButtonEnabled: {
  7908. value: true
  7909. },
  7910. /**
  7911. * Whether to use touch gestures, when available,
  7912. * to transition between images or not.
  7913. *
  7914. * @attribute touchSupport
  7915. * @type Boolean
  7916. * @default true
  7917. */
  7918. touchSupport: {
  7919. value: true
  7920. }
  7921. }
  7922. });
  7923. }, '2.0.0' ,{requires:['anim', 'event-mouseenter', 'plugin', 'transition', 'fl-event-move', 'fl-slideshow-css', 'fl-slideshow-base', 'fl-utils', 'sm-fonticon']});
  7924. YUI.add('fl-slideshow-album-loader', function(Y) {
  7925. /**
  7926. * @module fl-slideshow-album-loader
  7927. */
  7928. /**
  7929. * Loads slideshow albums using a provided source object.
  7930. *
  7931. * @namespace FL
  7932. * @class SlideshowAlbumLoader
  7933. * @constructor
  7934. * @param config {Object} Configuration object
  7935. * @extends Base
  7936. */
  7937. Y.namespace('FL').SlideshowAlbumLoader = Y.Base.create('fl-slideshow-album-loader', Y.Base, [], {
  7938. /**
  7939. * The source object used for loading.
  7940. *
  7941. * @property _source
  7942. * @type Object
  7943. * @default null
  7944. * @protected
  7945. */
  7946. _source: null,
  7947. /**
  7948. * Loads slideshow album data using the provided source object.
  7949. *
  7950. * @method load
  7951. * @param source {Object} The source object to use for loading.
  7952. */
  7953. load: function(source)
  7954. {
  7955. this._source = source;
  7956. /**
  7957. * Fires before a new load request is made.
  7958. *
  7959. * @event start
  7960. */
  7961. this.fire('start');
  7962. this[Y.FL.SlideshowAlbumLoader.TYPES[source.type]].call(this);
  7963. },
  7964. /**
  7965. * Called when a source type completes loading
  7966. * and fires the complete event.
  7967. *
  7968. * @method _loadComplete
  7969. * @param o {Object} Passed to complete event subscribers.
  7970. * @protected
  7971. */
  7972. _loadComplete: function(o)
  7973. {
  7974. o = this._randomize(o);
  7975. /**
  7976. * Fires after a new load request is made.
  7977. *
  7978. * @event complete
  7979. */
  7980. this.fire('complete', o);
  7981. },
  7982. /**
  7983. * Randomizes images in an album.
  7984. *
  7985. * @method _randomize
  7986. * @param album {Object} The album to randomize.
  7987. * @protected
  7988. */
  7989. _randomize: function(o)
  7990. {
  7991. var i;
  7992. if(this.get('randomize')) {
  7993. o.albumInfo.images.sort(function() { return 0.5 - Math.random(); });
  7994. for(i = 0; i < o.albumInfo.images.length; i++) {
  7995. o.albumInfo.images[i].index = i;
  7996. }
  7997. }
  7998. return o;
  7999. },
  8000. /**
  8001. * Loads slideshow album data from SmugMug.
  8002. *
  8003. * @method _loadSmugMug
  8004. * @protected
  8005. */
  8006. _loadSmugMug: function()
  8007. {
  8008. var sm = new Y.FL.SmugMugAPI();
  8009. sm.on('complete', this._loadSmugMugSuccess, this);
  8010. sm.addParam('method', 'smugmug.images.get');
  8011. sm.addParam('AlbumID', this._source.id);
  8012. sm.addParam('AlbumKey', this._source.key);
  8013. sm.addParam('Extras', 'Caption,Format,FileName');
  8014. // Gallery password
  8015. if(this._source.password) {
  8016. sm.addParam('Password', this._source.password);
  8017. }
  8018. // Site-wide password
  8019. if(this._source.sp) {
  8020. sm.addParam('SitePassword', this._source.sp);
  8021. }
  8022. sm.request();
  8023. },
  8024. /**
  8025. * Processes slideshow album data loaded from SmugMug.
  8026. *
  8027. * @method _loadSmugMugSuccess
  8028. * @param e {Object} The custom event object passed to this function.
  8029. * @protected
  8030. */
  8031. _loadSmugMugSuccess: function(e)
  8032. {
  8033. var images = e.Album.Images,
  8034. album = {},
  8035. proxy = typeof this._source.proxy !== 'undefined' ? this._source.proxy : '',
  8036. buyBase = '',
  8037. baseURL = '',
  8038. ext = '',
  8039. format = '',
  8040. i = 0,
  8041. temp = null,
  8042. iframe = null;
  8043. album.index = this._source.index;
  8044. album.id = e.Album.id;
  8045. album.key = e.Album.Key;
  8046. album.link = e.Album.URL;
  8047. album.title = this._source.title ? this._source.title : '';
  8048. album.images = [];
  8049. buyBase = album.link.replace('https://', '').split('/').shift();
  8050. buyBase = 'https://' + buyBase + '/buy/' + e.Album.id + '_' + e.Album.Key + '/';
  8051. for(i = 0; i < images.length; i++)
  8052. {
  8053. baseURL = proxy + e.Album.URL + '/' + images[i].id + '_' + images[i].Key;
  8054. format = images[i].Format.toLowerCase();
  8055. ext = format == 'mp4' ? '.jpg' : '.' + format;
  8056. album.images[i] = {};
  8057. album.images[i].index = i;
  8058. album.images[i].sourceType = 'smugmug';
  8059. album.images[i].albumId = e.Album.id;
  8060. album.images[i].albumKey = e.Album.Key;
  8061. album.images[i].id = images[i].id;
  8062. album.images[i].key = images[i].Key;
  8063. album.images[i].filename = images[i].FileName;
  8064. album.images[i].format = format;
  8065. album.images[i].caption = images[i].Caption || '';
  8066. album.images[i].link = e.Album.URL + '#' + images[i].id + '_' + images[i].Key;
  8067. album.images[i].tinyURL = baseURL + '-Ti' + ext;
  8068. album.images[i].thumbURL = baseURL + '-Th' + ext;
  8069. album.images[i].smallURL = baseURL + '-S' + ext;
  8070. album.images[i].mediumURL = baseURL + '-M' + ext;
  8071. album.images[i].largeURL = baseURL + '-L' + ext;
  8072. album.images[i].xlargeURL = baseURL + '-XL' + ext;
  8073. album.images[i].x2largeURL = baseURL + '-X2' + ext;
  8074. album.images[i].x3largeURL = baseURL + '-X3' + ext;
  8075. album.images[i].buyURL = buyBase + images[i].id + '_' + images[i].Key;
  8076. album.images[i].iframe = '';
  8077. if(album.images[i].caption.indexOf('iframe')) {
  8078. temp = Y.Node.create('<div>'+ album.images[i].caption +'</div>');
  8079. iframe = temp.one('iframe');
  8080. if(iframe) {
  8081. album.images[i].iframe = iframe.getAttribute('src');
  8082. album.images[i].caption = album.images[i].caption.replace(/<iframe.*>.*<\/iframe>/gi, '');
  8083. }
  8084. }
  8085. }
  8086. this._loadComplete({ 'albumInfo': album });
  8087. },
  8088. /**
  8089. * Loads slideshow album data from an array of urls.
  8090. *
  8091. * NOTE: You must have a large URL.
  8092. *
  8093. * @method _loadUrls
  8094. * @protected
  8095. */
  8096. _loadUrls: function()
  8097. {
  8098. var album = {},
  8099. i = 0;
  8100. album.index = this._source.index;
  8101. album.title = this._source.title ? this._source.title : '';
  8102. album.images = [];
  8103. for( ; i < this._source.urls.length; i++)
  8104. {
  8105. album.images[i] = {};
  8106. album.images[i].index = i;
  8107. album.images[i].sourceType = 'urls';
  8108. album.images[i].filename = this._source.urls[i].largeURL.split('/').pop();
  8109. album.images[i].format = '';
  8110. album.images[i].caption = this._source.urls[i].caption || '';
  8111. album.images[i].alt = this._source.urls[i].alt || '';
  8112. album.images[i].link = this._source.urls[i].largeURL;
  8113. album.images[i].thumbURL = this._source.urls[i].thumbURL || this._source.urls[i].largeURL;
  8114. album.images[i].smallURL = this._source.urls[i].smallURL || this._source.urls[i].largeURL;
  8115. album.images[i].mediumURL = this._source.urls[i].mediumURL || this._source.urls[i].largeURL;
  8116. album.images[i].largeURL = this._source.urls[i].largeURL; // Must have a large URL
  8117. album.images[i].xlargeURL = this._source.urls[i].xlargeURL || this._source.urls[i].largeURL;
  8118. album.images[i].x2largeURL = this._source.urls[i].x2largeURL || this._source.urls[i].largeURL;
  8119. album.images[i].x3largeURL = this._source.urls[i].x3largeURL || this._source.urls[i].largeURL;
  8120. album.images[i].buyURL = this._source.urls[i].buyURL || '';
  8121. album.images[i].iframe = this._source.urls[i].iframe || '';
  8122. }
  8123. this._loadComplete({ 'albumInfo': album });
  8124. }
  8125. }, {
  8126. /**
  8127. * Static property used to define the default attribute configuration of
  8128. * the Widget.
  8129. *
  8130. * @property ATTRS
  8131. * @type Object
  8132. * @protected
  8133. * @static
  8134. */
  8135. ATTRS: {
  8136. /**
  8137. * If true, the images will be randomized after loading.
  8138. *
  8139. * @attribute randomize
  8140. * @type Boolean
  8141. * @default false
  8142. */
  8143. randomize: {
  8144. value: false
  8145. }
  8146. },
  8147. /**
  8148. * The types of source data that can be loaded
  8149. * and associated functions.
  8150. *
  8151. * @property TYPES
  8152. * @type Object
  8153. * @readOnly
  8154. * @protected
  8155. * @static
  8156. */
  8157. TYPES: {
  8158. 'smugmug': '_loadSmugMug',
  8159. 'flickr': '_loadFlickr',
  8160. 'picasa': '_loadPicasa',
  8161. 'urls': '_loadUrls',
  8162. 'html': '_loadHtml'
  8163. }
  8164. });
  8165. }, '2.0.0' ,{requires:['base', 'fl-smugmug-api']});
  8166. YUI.add('fl-slideshow-base', function(Y) {
  8167. /**
  8168. * @module fl-slideshow-base
  8169. */
  8170. /**
  8171. * The base class that gets extended when creating new
  8172. * slideshow widgets. Manages loading, playing, and resizing.
  8173. * <p>
  8174. * While SlideshowBase can be instantiated, it is only meant to
  8175. * be extended and does not display any images.
  8176. *
  8177. * @namespace FL
  8178. * @class SlideshowBase
  8179. * @constructor
  8180. * @param config {Object} Configuration object
  8181. * @extends Widget
  8182. */
  8183. Y.namespace('FL').SlideshowBase = Y.Base.create('fl-slideshow-base', Y.Widget, [Y.WidgetParent], {
  8184. /**
  8185. * FL.SlideshowAlbumLoader instance used to load albums.
  8186. *
  8187. * @property _loader
  8188. * @type FL.SlideshowAlbumLoader
  8189. * @default null
  8190. * @protected
  8191. */
  8192. _albumLoader: null,
  8193. /**
  8194. * An array of albums loaded from the source attribute.
  8195. * Each album is an array of objects containing image info.
  8196. *
  8197. * @property albums
  8198. * @type Array
  8199. * @default []
  8200. */
  8201. albums: [],
  8202. /**
  8203. * Info for the active album.
  8204. *
  8205. * @property albumInfo
  8206. * @type Object
  8207. * @default null
  8208. */
  8209. albumInfo: null,
  8210. /**
  8211. * A number that represents the index of the active
  8212. * album in the albums array.
  8213. *
  8214. * @property albumIndex
  8215. * @type Number
  8216. * @default null
  8217. */
  8218. albumIndex: null,
  8219. /**
  8220. * Info for the active image.
  8221. *
  8222. * @property imageInfo
  8223. * @type Object
  8224. * @default null
  8225. */
  8226. imageInfo: null,
  8227. /**
  8228. * A number that represents the index of the active
  8229. * image in the albumInfo array.
  8230. *
  8231. * @property imageIndex
  8232. * @type Number
  8233. * @default null
  8234. */
  8235. imageIndex: null,
  8236. /**
  8237. * A number that represents the index of the last
  8238. * image that was loaded in the albumInfo array.
  8239. *
  8240. * @property lastImageIndex
  8241. * @type Number
  8242. * @default null
  8243. */
  8244. lastImageIndex: null,
  8245. /**
  8246. * Timer for the delay before resizing if one is set.
  8247. *
  8248. * @property _resizeTimer
  8249. * @type Object
  8250. * @default null
  8251. * @protected
  8252. */
  8253. _resizeTimer: null,
  8254. /**
  8255. * Flag for whether the slideshow is currently playing or not.
  8256. *
  8257. * @property playing
  8258. * @type Boolean
  8259. * @default false
  8260. * @protected
  8261. */
  8262. _playing: false,
  8263. /**
  8264. * Timer for the break in between images when
  8265. * the slideshow is playing.
  8266. *
  8267. * @property _playingTimer
  8268. * @type Object
  8269. * @default null
  8270. * @protected
  8271. */
  8272. _playingTimer: null,
  8273. /**
  8274. * If set, the slideshow will only auto start when
  8275. * this event is fired.
  8276. *
  8277. * @property _playingTimerEvent
  8278. * @type Object
  8279. * @default null
  8280. * @protected
  8281. */
  8282. _playingTimerEvent: null,
  8283. /**
  8284. * An instance of FL.Spinner that is shown and hidden
  8285. * using _showLoadingImage and _hideLoadingImage when
  8286. * a loading activity occurs.
  8287. *
  8288. * @property _loadingImage
  8289. * @type FL.Spinner
  8290. * @default null
  8291. * @protected
  8292. */
  8293. _loadingImage: null,
  8294. /**
  8295. * An div node that wraps the loading image.
  8296. *
  8297. * @property _loadingImageWrap
  8298. * @type Node
  8299. * @default null
  8300. * @protected
  8301. */
  8302. _loadingImageWrap: null,
  8303. /**
  8304. * Whether the loading image is visible or not.
  8305. *
  8306. * @property _loadingImageVisible
  8307. * @type Boolean
  8308. * @default false
  8309. * @protected
  8310. */
  8311. _loadingImageVisible: false,
  8312. /**
  8313. * A timer to delay the display of the loading image.
  8314. *
  8315. * @property _loadingImageTimer
  8316. * @type Object
  8317. * @default null
  8318. * @protected
  8319. */
  8320. _loadingImageTimer: null,
  8321. /**
  8322. * The container to insert the loading image into. If
  8323. * no container is set, the loading image will be inserted
  8324. * into the widget's bounding box.
  8325. *
  8326. * @property _loadingImageContainer
  8327. * @type Object
  8328. * @default null
  8329. * @protected
  8330. */
  8331. _loadingImageContainer: null,
  8332. /**
  8333. * The intial height of the slideshow. Used to resize
  8334. * back to the starting height when exiting stretchy.
  8335. *
  8336. * @property _initialHeight
  8337. * @type Number
  8338. * @default null
  8339. * @protected
  8340. */
  8341. _initialHeight: null,
  8342. /**
  8343. * The intial width of the slideshow. Used to resize
  8344. * back to the starting width when exiting stretchy.
  8345. *
  8346. * @property _initialWidth
  8347. * @type Number
  8348. * @default null
  8349. * @protected
  8350. */
  8351. _initialWidth: null,
  8352. /**
  8353. * @method initializer
  8354. * @protected
  8355. */
  8356. initializer: function()
  8357. {
  8358. // Loader
  8359. this._albumLoader = new Y.FL.SlideshowAlbumLoader({
  8360. randomize: this.get('randomize')
  8361. });
  8362. },
  8363. /**
  8364. * @method renderUI
  8365. * @protected
  8366. */
  8367. renderUI: function()
  8368. {
  8369. this._renderLoadingImage();
  8370. },
  8371. /**
  8372. * @method bindUI
  8373. * @protected
  8374. */
  8375. bindUI: function()
  8376. {
  8377. // Album load complete
  8378. this._albumLoader.on('complete', this._loadAlbumComplete, this);
  8379. // Resize Events
  8380. Y.one(window).on('fl-slideshow-base|resize', this._delayResize, this);
  8381. Y.one(window).on('fl-slideshow-base|orientationchange', this._delayResize, this);
  8382. // Key Events
  8383. Y.Node.one('body').on('keydown', Y.bind(this._onKey, this));
  8384. },
  8385. /**
  8386. * @method syncUI
  8387. * @protected
  8388. */
  8389. syncUI: function()
  8390. {
  8391. this.get('boundingBox').addClass('fl-slideshow-' + this.get('color'));
  8392. this.resize();
  8393. if(this.get('loadOnRender')) {
  8394. this.loadAlbum(this.get('defaultAlbum'), this.get('defaultImage'));
  8395. }
  8396. },
  8397. /**
  8398. * Add album data to the source object.
  8399. *
  8400. * @method addAlbum
  8401. * @protected
  8402. */
  8403. addAlbum: function(data)
  8404. {
  8405. var source = this.get('source'),
  8406. i = source.length;
  8407. source[i] = data;
  8408. source[i].index = i;
  8409. this.set('source', source);
  8410. },
  8411. /**
  8412. * Loads an album from the source array with the provided albumIndex.
  8413. * If no albumIndex is provided, the first album in the array will be loaded.
  8414. * An image to load can also be specified using imageIndex.
  8415. *
  8416. * @method loadAlbum
  8417. * @param albumIndex {Number} The album index to load from the source array.
  8418. * @param imageIndex {Number} The image index to load from the album array.
  8419. */
  8420. loadAlbum: function(albumIndex, imageIndex)
  8421. {
  8422. var source = this.get('source'),
  8423. loadImageIndex = typeof imageIndex == 'undefined' ? 0 : imageIndex;
  8424. // Reset internal image indexes.
  8425. this.imageIndex = null;
  8426. this.lastImageIndex = null;
  8427. /**
  8428. * Fires before a new album request is made.
  8429. *
  8430. * @event albumLoadStart
  8431. */
  8432. this.fire('albumLoadStart');
  8433. // Load an image after the album.
  8434. this.once('albumLoadComplete', Y.bind(this.loadImage, this, loadImageIndex));
  8435. // Load data passed from another slideshow instance.
  8436. if(source[albumIndex] && source[albumIndex].type == 'album-data') {
  8437. this.albums[albumIndex] = source[albumIndex].data;
  8438. this._loadAlbumComplete({albumInfo: this.albums[albumIndex]});
  8439. }
  8440. // Load the album from the albums array.
  8441. else if(source[albumIndex] && this.albums[albumIndex]) {
  8442. this._loadAlbumComplete({albumInfo: this.albums[albumIndex]});
  8443. }
  8444. // Load the album using the album loader.
  8445. else {
  8446. this._albumLoader.load(source[albumIndex] || source[0]);
  8447. }
  8448. },
  8449. /**
  8450. * Processes the loaded album and fires the albumLoadComplete event.
  8451. *
  8452. * @method _loadAlbumComplete
  8453. * @param o {Object} The custom event object passed to this method.
  8454. * @protected
  8455. */
  8456. _loadAlbumComplete: function(o)
  8457. {
  8458. this.albums[o.albumInfo.index] = o.albumInfo;
  8459. this.albumInfo = o.albumInfo;
  8460. this.albumIndex = o.albumInfo.index;
  8461. /**
  8462. * Fires after a new album request is made.
  8463. *
  8464. * @event albumLoadComplete
  8465. */
  8466. this.fire('albumLoadComplete');
  8467. // Auto Play
  8468. if(this.get('autoPlay')) {
  8469. this._playingTimerStart();
  8470. this.fire('played');
  8471. this._playing = true;
  8472. }
  8473. },
  8474. /**
  8475. * Sets the active image index and fires the imageLoadComplete event.
  8476. *
  8477. * @method loadImage
  8478. * @param index {Number} The image index to load.
  8479. */
  8480. loadImage: function(index)
  8481. {
  8482. if(this._playing) {
  8483. this._playingTimerStart();
  8484. }
  8485. index = index < 0 ? this.albumInfo.images.length - 1 : index;
  8486. index = index >= this.albumInfo.images.length ? 0 : index;
  8487. this.lastImageIndex = this.imageIndex;
  8488. this.imageIndex = index;
  8489. this.imageInfo = this.albumInfo.images[index];
  8490. /**
  8491. * Fires after a new image index is set.
  8492. *
  8493. * @event imageLoadComplete
  8494. */
  8495. this.fire('imageLoadComplete', { 'imageInfo': this.imageInfo });
  8496. },
  8497. /**
  8498. * Loads the previous image.
  8499. *
  8500. * @method prevImage
  8501. */
  8502. prevImage: function()
  8503. {
  8504. if(this.get('pauseOnNextOrPrev')) {
  8505. this.pause();
  8506. }
  8507. this.loadImage(this.imageIndex - 1);
  8508. /**
  8509. * Fires when the previous image is loaded.
  8510. *
  8511. * @event prevImage
  8512. */
  8513. this.fire('prevImage');
  8514. },
  8515. /**
  8516. * Loads the next image.
  8517. *
  8518. * @method nextImage
  8519. */
  8520. nextImage: function()
  8521. {
  8522. if(this.get('pauseOnNextOrPrev')) {
  8523. this.pause();
  8524. }
  8525. this.loadImage(this.imageIndex + 1);
  8526. /**
  8527. * Fires when the next image is loaded.
  8528. *
  8529. * @event nextImage
  8530. */
  8531. this.fire('nextImage');
  8532. },
  8533. /**
  8534. * Keyboard navigation for the next and prev images.
  8535. *
  8536. * @method _onKey
  8537. * @protected
  8538. */
  8539. _onKey: function(e)
  8540. {
  8541. switch(e.keyCode) {
  8542. case 37:
  8543. this.prevImage();
  8544. break;
  8545. case 39:
  8546. this.nextImage();
  8547. break;
  8548. }
  8549. },
  8550. /**
  8551. * Resizes the slideshow using either the
  8552. * stretchy or standard functions.
  8553. *
  8554. * @method resize
  8555. */
  8556. resize: function()
  8557. {
  8558. var stretchy = this.get('stretchy'),
  8559. stretchyType = this.get('stretchyType'),
  8560. width = parseInt(Y.one('body').get('winWidth'), 10),
  8561. threshold = this.get('responsiveThreshold');
  8562. // Stretchy resize to the window only if the parent width is greater
  8563. // than the responsive threshold and stretchyType is set to window.
  8564. if(width > threshold && stretchy && stretchyType == 'window') {
  8565. this._stretchyWindowResize();
  8566. }
  8567. // Ratio resize if the parent width is less than the responsive
  8568. // threshold or if stretchyType is set to ratio.
  8569. else if((width <= threshold) || (stretchy && stretchyType == 'ratio')) {
  8570. this._stretchyRatioResize();
  8571. }
  8572. // Do a standard resize based on the height and
  8573. // width passed to the constructor function.
  8574. else {
  8575. this._standardResize();
  8576. }
  8577. /**
  8578. * Fires when the slideshow is resized.
  8579. *
  8580. * @event resize
  8581. */
  8582. this.fire('resize');
  8583. },
  8584. /**
  8585. * @method _standardResize
  8586. * @protected
  8587. */
  8588. _standardResize: function()
  8589. {
  8590. var stretchy = this.get('stretchy'),
  8591. stretchyType = this.get('stretchyType'),
  8592. bb = this.get('boundingBox'),
  8593. parent = bb.get('parentNode'),
  8594. parentHeight = parseInt(parent.getComputedStyle('height'), 10),
  8595. parentWidth = parseInt(parent.getComputedStyle('width'), 10),
  8596. height = this.get('height'),
  8597. width = this.get('width');
  8598. // Window resize if we are in fullscreen.
  8599. if(bb.hasClass('fl-fullscreen-active')) {
  8600. this._stretchyWindowResize();
  8601. return;
  8602. }
  8603. // Resize to the width and height of the parent.
  8604. else if(stretchy && stretchyType == 'contain') {
  8605. bb.setStyle('height', parentHeight + 'px');
  8606. bb.setStyle('width', parentWidth + 'px');
  8607. }
  8608. // Ratio resize if we don't have a height defined.
  8609. else if(!Y.Lang.isNumber(height)) {
  8610. this._stretchyRatioResize();
  8611. return;
  8612. }
  8613. // Resize to the defined width and height.
  8614. else {
  8615. bb.setStyle('height', height + 'px');
  8616. if(width) {
  8617. bb.setStyle('width', width + 'px');
  8618. }
  8619. else {
  8620. bb.setStyle('width', parentWidth + 'px');
  8621. }
  8622. }
  8623. },
  8624. /**
  8625. * Resizes to the height of the window, compensating
  8626. * for any padding.
  8627. *
  8628. * @method _stretchyWindowResize
  8629. * @protected
  8630. */
  8631. _stretchyWindowResize: function()
  8632. {
  8633. var bb = this.get('boundingBox'),
  8634. verticalSpace = this.get('stretchyVerticalSpace'),
  8635. paddingTop = parseInt(bb.getStyle('paddingTop'), 10),
  8636. paddingBottom = parseInt(bb.getStyle('paddingBottom'), 10),
  8637. height = parseInt(Y.one('body').get('winHeight'), 10),
  8638. width = '';
  8639. // Set the vertical space to 0 and width to the
  8640. // window's width if we are in fullscreen mode.
  8641. if(bb.hasClass('fl-fullscreen-active')) {
  8642. verticalSpace = 0;
  8643. width = parseInt(Y.one('body').get('winWidth'), 10) + 'px';
  8644. }
  8645. height = (height - paddingTop - paddingBottom - verticalSpace) + 'px';
  8646. bb.setStyle('height', height);
  8647. bb.setStyle('width', width);
  8648. },
  8649. /**
  8650. * Resizes the height by multiplying the width and stretchyRatio value.
  8651. *
  8652. * @method _stretchyRatioResize
  8653. * @protected
  8654. */
  8655. _stretchyRatioResize: function()
  8656. {
  8657. var bb = this.get('boundingBox'),
  8658. parent = bb.get('parentNode'),
  8659. verticalSpace = 0,
  8660. stretchyRatio = this.get('stretchyRatio'),
  8661. paddingTop = parseInt(bb.getStyle('paddingTop'), 10),
  8662. paddingBottom = parseInt(bb.getStyle('paddingBottom'), 10),
  8663. computedWidth = parseInt(parent.getComputedStyle('width'), 10),
  8664. winHeight = parseInt(Y.one('body').get('winHeight'), 10),
  8665. winWidth = parseInt(Y.one('body').get('winWidth'), 10),
  8666. height = computedWidth * stretchyRatio,
  8667. width = '';
  8668. // Use the window's height and width if we are in fullscreen mode.
  8669. if(bb.hasClass('fl-fullscreen-active')) {
  8670. height = winHeight;
  8671. width = winWidth;
  8672. }
  8673. height = (height - paddingTop - paddingBottom - verticalSpace) + 'px';
  8674. bb.setStyle('height', height);
  8675. bb.setStyle('width', width);
  8676. },
  8677. /**
  8678. * Resizes the slideshow after the resize timer completes.
  8679. *
  8680. * @method _delayResize
  8681. * @protected
  8682. */
  8683. _delayResize: function()
  8684. {
  8685. if(this._resizeTimer) {
  8686. this._resizeTimer.cancel();
  8687. }
  8688. this._resizeTimer = Y.later(300, this, this.resize);
  8689. },
  8690. /**
  8691. * Starts a new playing timer and fires the played event.
  8692. *
  8693. * @method play
  8694. */
  8695. play: function()
  8696. {
  8697. this._playingTimer = Y.later(this.get('speed'), this, this._playingTimerComplete);
  8698. /**
  8699. * Fires when the playing timer starts.
  8700. *
  8701. * @event played
  8702. */
  8703. this.fire('played');
  8704. this._playing = true;
  8705. },
  8706. /**
  8707. * Cancels the current playing timer and fires the paused event.
  8708. *
  8709. * @method pause
  8710. */
  8711. pause: function()
  8712. {
  8713. this._playingTimerCancel();
  8714. /**
  8715. * Fires when the playing timer is canceled.
  8716. *
  8717. * @event paused
  8718. */
  8719. this.fire('paused');
  8720. this._playing = false;
  8721. },
  8722. /**
  8723. * A new playing timer will start when this event is fired.
  8724. *
  8725. * @method _setPlayingTimerEvent
  8726. * @param obj {Object} The event's host object.
  8727. * @param e {String} The event to fire on the host object.
  8728. * @protected
  8729. */
  8730. _setPlayingTimerEvent: function(obj, e)
  8731. {
  8732. this._playingTimerEvent = {
  8733. 'obj': obj,
  8734. 'e': e
  8735. };
  8736. },
  8737. /**
  8738. * Cancels the playing timer if it is running and starts a new one.
  8739. * The next image is loaded when the timer completes.
  8740. *
  8741. * @method _playingTimerStart
  8742. * @protected
  8743. */
  8744. _playingTimerStart: function(e)
  8745. {
  8746. this._playingTimerCancel();
  8747. if(!e && this._playingTimerEvent !== null) {
  8748. this._playingTimerEvent.obj.once('fl-slideshow-base|' + this._playingTimerEvent.e, Y.bind(this._playingTimerStart, this));
  8749. }
  8750. else {
  8751. this._playingTimer = Y.later(this.get('speed'), this, this._playingTimerComplete);
  8752. }
  8753. },
  8754. /**
  8755. * Fires when the playing timer completes, starts a
  8756. * new timer and loads the next image.
  8757. *
  8758. * @method _playingTimerComplete
  8759. * @protected
  8760. */
  8761. _playingTimerComplete: function()
  8762. {
  8763. this.loadImage(this.imageIndex + 1);
  8764. /**
  8765. * Fires when the playing timer completes.
  8766. *
  8767. * @event albumLoadStart
  8768. */
  8769. this.fire('playingTimerComplete');
  8770. },
  8771. /**
  8772. * Cancels the playing timer.
  8773. *
  8774. * @method _playingTimerCancel
  8775. * @protected
  8776. */
  8777. _playingTimerCancel: function()
  8778. {
  8779. if(this._playingTimer) {
  8780. this._playingTimer.cancel();
  8781. }
  8782. if(this._playingTimerEvent) {
  8783. this._playingTimerEvent.obj.detach('fl-slideshow-base|' + this._playingTimerEvent.e);
  8784. }
  8785. },
  8786. /**
  8787. * Creates the loading image.
  8788. *
  8789. * @method _renderLoadingImage
  8790. * @protected
  8791. */
  8792. _renderLoadingImage: function()
  8793. {
  8794. var defaults = {
  8795. lines: 11, // The number of lines to draw
  8796. length: 6, // The length of each line
  8797. width: 2, // The line thickness
  8798. radius: 7, // The radius of the inner circle
  8799. color: '', // #rbg or #rrggbb
  8800. speed: 1, // Rounds per second
  8801. trail: 60, // Afterglow percentage
  8802. shadow: false // Whether to render a shadow
  8803. },
  8804. settings = Y.merge(defaults, this.get('loadingImageSettings'));
  8805. if(this.get('loadingImageEnabled')) {
  8806. // Loading image
  8807. if(settings.color === '') {
  8808. settings.color = this._colorToHex(Y.one('body').getStyle('color'));
  8809. }
  8810. this._loadingImage = new Y.FL.Spinner(settings);
  8811. // Loading image wrap
  8812. this._loadingImageWrap = Y.Node.create('<div class="fl-loading-image"></div>');
  8813. this._loadingImageWrap.setStyles({
  8814. position : 'absolute',
  8815. 'z-index' : '1000'
  8816. });
  8817. }
  8818. },
  8819. /**
  8820. * Inserts the loading image.
  8821. *
  8822. * @method _showLoadingImage
  8823. * @protected
  8824. */
  8825. _showLoadingImage: function()
  8826. {
  8827. if(this._loadingImage && !this._loadingImageVisible) {
  8828. this._loadingImageVisible = true;
  8829. this._loadingImage.spin();
  8830. this._loadingImageWrap.insert(this._loadingImage.el);
  8831. if(this._loadingImageContainer !== null) {
  8832. this._loadingImageContainer.insert(this._loadingImageWrap);
  8833. }
  8834. else {
  8835. this.get('contentBox').insert(this._loadingImageWrap);
  8836. }
  8837. this._positionLoadingImage();
  8838. }
  8839. },
  8840. /**
  8841. * Inserts the loading image div node after
  8842. * a timer completes.
  8843. *
  8844. * @method _showLoadingImageWithDelay
  8845. * @protected
  8846. */
  8847. _showLoadingImageWithDelay: function()
  8848. {
  8849. if(this._loadingImage) {
  8850. this._loadingImageTimer = Y.later(1000, this, this._showLoadingImage);
  8851. }
  8852. },
  8853. /**
  8854. * Removes the loading image div node.
  8855. *
  8856. * @method _hideLoadingImage
  8857. * @protected
  8858. */
  8859. _hideLoadingImage: function()
  8860. {
  8861. if(this._loadingImageTimer) {
  8862. this._loadingImageTimer.cancel();
  8863. this._loadingImageTimer = null;
  8864. }
  8865. if(this._loadingImage && this._loadingImageVisible) {
  8866. this._loadingImageVisible = false;
  8867. this._loadingImage.stop();
  8868. this._loadingImageWrap.remove();
  8869. }
  8870. },
  8871. /**
  8872. * Centers the loading image in the content box.
  8873. *
  8874. * @method _positionLoadingImage
  8875. * @protected
  8876. */
  8877. _positionLoadingImage: function()
  8878. {
  8879. if(this._loadingImage && this._loadingImageVisible) {
  8880. var wrap = this._loadingImageWrap,
  8881. wrapHeight = parseInt(wrap.getComputedStyle('height'), 10),
  8882. wrapWidth = parseInt(wrap.getComputedStyle('width'), 10),
  8883. parent = wrap.get('parentNode'),
  8884. parentHeight = parseInt(parent.getComputedStyle('height'), 10),
  8885. parentWidth = parseInt(parent.getComputedStyle('width'), 10),
  8886. left = (parentWidth - wrapWidth)/2,
  8887. top = (parentHeight - wrapHeight)/2;
  8888. wrap.setStyles({
  8889. left : left + 'px',
  8890. top : top + 'px'
  8891. });
  8892. Y.one(this._loadingImage.el).setStyles({
  8893. left : '50%',
  8894. top : '50%'
  8895. });
  8896. }
  8897. },
  8898. /**
  8899. * Convert RGB color value to a hex value.
  8900. *
  8901. * @method _colorToHex
  8902. * @protected
  8903. */
  8904. _colorToHex: function(color)
  8905. {
  8906. var digits, red, green, blue, rgb;
  8907. if(color.substr(0, 1) === '#') {
  8908. return color;
  8909. }
  8910. digits = /(.*?)rgb\((\d+), (\d+), (\d+)\)/.exec(color);
  8911. if ( null === digits ) {
  8912. return '#000';
  8913. }
  8914. red = parseInt(digits[2], 10);
  8915. green = parseInt(digits[3], 10);
  8916. blue = parseInt(digits[4], 10);
  8917. rgb = blue | (green << 8) | (red << 16);
  8918. rgb = rgb.toString(16);
  8919. if(rgb === '0') {
  8920. rgb = '000';
  8921. }
  8922. return digits[1] + '#' + rgb;
  8923. }
  8924. }, {
  8925. /**
  8926. * Custom CSS class name for the widget.
  8927. *
  8928. * @property CSS_PREFIX
  8929. * @type String
  8930. * @protected
  8931. * @static
  8932. */
  8933. CSS_PREFIX: 'fl-slideshow-base',
  8934. /**
  8935. * Static property used to define the default attribute configuration of
  8936. * the Widget.
  8937. *
  8938. * @property ATTRS
  8939. * @type Object
  8940. * @protected
  8941. * @static
  8942. */
  8943. ATTRS: {
  8944. /**
  8945. * Used to create the color class that gets added to the bounding box
  8946. * when the widget is rendered. The color class is used to create new
  8947. * CSS color themes. The default CSS provided includes dark and light themes.
  8948. *
  8949. * @attribute color
  8950. * @type String
  8951. * @default dark
  8952. * @writeOnce
  8953. */
  8954. color: {
  8955. value: 'dark',
  8956. writeOnce: true
  8957. },
  8958. /**
  8959. * An array of source objects used to load albums. Each object must have
  8960. * a type property and can have a title property as well.
  8961. * <p>
  8962. * In addition to those properties, each object has additional required
  8963. * properties specific to its type. The types currently supported are
  8964. * smugmug and urls with planned support for flickr and picasa.
  8965. * See the user guide for information on loading different types.
  8966. *
  8967. * @attribute source
  8968. * @type Array
  8969. * @default []
  8970. * @writeOnce
  8971. */
  8972. source: {
  8973. value: [],
  8974. setter: function(source) {
  8975. if(source.constructor == Object) {
  8976. source = [source];
  8977. }
  8978. for(var i = 0; i < source.length; i++) {
  8979. source[i].index = i;
  8980. }
  8981. return source;
  8982. }
  8983. },
  8984. /**
  8985. * The default album index to load.
  8986. *
  8987. * @attribute defaultAlbum
  8988. * @type Number
  8989. * @default 0
  8990. */
  8991. defaultAlbum: {
  8992. value: 0
  8993. },
  8994. /**
  8995. * The default image index to load.
  8996. *
  8997. * @attribute defaultImage
  8998. * @type Number
  8999. * @default 0
  9000. */
  9001. defaultImage: {
  9002. value: 0
  9003. },
  9004. /**
  9005. * If true, the slideshow will be loaded after rendering.
  9006. *
  9007. * @attribute loadOnRender
  9008. * @type Boolean
  9009. * @default true
  9010. */
  9011. loadOnRender: {
  9012. value: true
  9013. },
  9014. /**
  9015. * If true, the slideshow will start playing after loading.
  9016. *
  9017. * @attribute autoPlay
  9018. * @type Boolean
  9019. * @default true
  9020. */
  9021. autoPlay: {
  9022. value: true
  9023. },
  9024. /**
  9025. * Whether to pause when the next or previous image is loaded
  9026. * using nextImage or prevImage. The slideshow will not be paused
  9027. * if the next or previous image is loaded using loadImage as is the
  9028. * case when the slideshow is playing.
  9029. *
  9030. * @attribute pauseOnNextOrPrev
  9031. * @type Boolean
  9032. * @default true
  9033. */
  9034. pauseOnNextOrPrev: {
  9035. value: true
  9036. },
  9037. /**
  9038. * If true, the images will be randomized after loading.
  9039. *
  9040. * @attribute randomize
  9041. * @type Boolean
  9042. * @default false
  9043. */
  9044. randomize: {
  9045. value: false
  9046. },
  9047. /**
  9048. * The time between images when playing, measured in milliseconds.
  9049. *
  9050. * @attribute speed
  9051. * @type Number
  9052. * @default 4000
  9053. */
  9054. speed: {
  9055. value: 4000
  9056. },
  9057. /**
  9058. * The minimum width of the parent node at which
  9059. * responsive features are enabled. Set to 0 to
  9060. * disable responsive features as they are enabled
  9061. * whether stretchy is set to true or not.
  9062. *
  9063. * @attribute responsiveThreshold
  9064. * @type Number
  9065. * @default 600
  9066. */
  9067. responsiveThreshold: {
  9068. value: 600
  9069. },
  9070. /**
  9071. * Whether stretchy resizing should be enabled.
  9072. *
  9073. * @attribute stretchy
  9074. * @type Boolean
  9075. * @default false
  9076. */
  9077. stretchy: {
  9078. value: false
  9079. },
  9080. /**
  9081. * The type of stretchy logic to use. Possible values are
  9082. * window and ratio. Both types resize the width of the
  9083. * slideshow to the width of its parent node. With window, the
  9084. * height of the slideshow is resized to the height of the window.
  9085. * With ratio, the height of the slideshow is resized based
  9086. * on the ratio set with stretchyRatio or the height of the window
  9087. * if the ratio height is greater than the window height.
  9088. *
  9089. * @attribute stretchyType
  9090. * @type String
  9091. * @default ratio
  9092. */
  9093. stretchyType: {
  9094. value: 'ratio'
  9095. },
  9096. /**
  9097. * The number of pixels to subtract from the height of
  9098. * the slideshow when stretchy is set to true.
  9099. *
  9100. * @attribute stretchyVerticalSpace
  9101. * @type Number
  9102. * @default 0
  9103. */
  9104. stretchyVerticalSpace: {
  9105. value: 0
  9106. },
  9107. /**
  9108. * Used to calculate the height of the slideshow when stretchyType
  9109. * is set to ratio.
  9110. *
  9111. * @attribute stretchyRatio
  9112. * @type Number
  9113. * @default 0.7
  9114. */
  9115. stretchyRatio: {
  9116. value: 0.7
  9117. },
  9118. /**
  9119. * Whether to use the loading image or not.
  9120. *
  9121. * @attribute loadingImageEnabled
  9122. * @type Boolean
  9123. * @default true
  9124. */
  9125. loadingImageEnabled: {
  9126. value: true
  9127. },
  9128. /**
  9129. * Property object for setting up the spin.js loading image.
  9130. * For a complete list of properties see:
  9131. * http://effinroot.eiremedia.netdna-cdn.com/repo/plugins/misc/spin.js/index.html
  9132. *
  9133. * @attribute loadingImageSettings
  9134. * @type Object
  9135. */
  9136. loadingImageSettings: {
  9137. value: {}
  9138. }
  9139. }
  9140. });
  9141. }, '2.0.0' ,{requires:['node', 'base', 'widget', 'widget-parent', 'widget-child', 'fl-slideshow-album-loader', 'fl-spinner']});
  9142. YUI.add('fl-smugmug-api', function(Y) {
  9143. /**
  9144. * @module fl-smugmug-api
  9145. */
  9146. /**
  9147. * SmugMug API wrapper.
  9148. *
  9149. * NOTE: Only anonymous logins are currently supported.
  9150. *
  9151. * @namespace FL
  9152. * @class SmugMugAPI
  9153. * @constructor
  9154. * @param config {Object} Configuration object
  9155. * @extends Base
  9156. */
  9157. Y.namespace('FL').SmugMugAPI = Y.Base.create('fl-smugmug-api', Y.Base, [], {
  9158. /**
  9159. * ID for the current session.
  9160. *
  9161. * @property _sessionID
  9162. * @type String
  9163. * @default null
  9164. * @protected
  9165. */
  9166. _sessionID: null,
  9167. /**
  9168. * URL with parameters for the next API request.
  9169. * Reset after each request.
  9170. *
  9171. * @property _requestURL
  9172. * @type String
  9173. * @default null
  9174. * @protected
  9175. */
  9176. _requestURL: null,
  9177. /**
  9178. * Lifecycle method. Initializes the request url.
  9179. *
  9180. * @method initializer
  9181. * @protected
  9182. */
  9183. initializer: function()
  9184. {
  9185. this._resetRequestURL();
  9186. },
  9187. /**
  9188. * Adds a key/value pair to the request url.
  9189. *
  9190. * @method addParam
  9191. * @param key {String} The name of the parameter (example: key=val).
  9192. * @param val {String} The value of the parameter (example: key=val).
  9193. */
  9194. addParam: function(key, val)
  9195. {
  9196. this._requestURL = this._requestURL + '&' + key + '=' + val;
  9197. },
  9198. /**
  9199. * Requests an anonymous login session.
  9200. *
  9201. * @method loginAnon
  9202. */
  9203. loginAnon: function()
  9204. {
  9205. this.addParam('method', 'smugmug.login.anonymously');
  9206. this.once('complete', this._loginAnonComplete);
  9207. this.request();
  9208. },
  9209. /**
  9210. * Anonymous login success handler.
  9211. *
  9212. * @method _loginAnonComplete
  9213. * @param data {Object} A jsonp data object.
  9214. * @protected
  9215. */
  9216. _loginAnonComplete: function(data)
  9217. {
  9218. if(data.Login) {
  9219. this._sessionID = data.Login.Session.id;
  9220. }
  9221. },
  9222. /**
  9223. * Sends an API request using the request url.
  9224. *
  9225. * @method request
  9226. */
  9227. request: function()
  9228. {
  9229. this.addParam('Callback', '{callback}');
  9230. Y.jsonp(this._requestURL, {
  9231. on: {
  9232. success: this._requestComplete,
  9233. timeout: function(){} // TODO: Handle timeouts
  9234. },
  9235. context: this,
  9236. timeout: 60000,
  9237. args: []
  9238. });
  9239. },
  9240. /**
  9241. * API request complete handler.
  9242. *
  9243. * @method _requestComplete
  9244. * @param data {Object} A jsonp data object.
  9245. * @protected
  9246. */
  9247. _requestComplete: function(data)
  9248. {
  9249. this._resetRequestURL();
  9250. /**
  9251. * Fires when a request is complete.
  9252. *
  9253. * @event complete
  9254. */
  9255. this.fire('complete', data);
  9256. },
  9257. /**
  9258. * Clears all parameters on the request url except
  9259. * the API key and session ID.
  9260. *
  9261. * @method _resetRequestURL
  9262. * @protected
  9263. */
  9264. _resetRequestURL: function()
  9265. {
  9266. this._requestURL = this.get('apiURL') + '?APIKey=' + this.get('apiKey');
  9267. if(this._sessionID) {
  9268. this.addParam('SessionID', this._sessionID);
  9269. }
  9270. }
  9271. }, {
  9272. /**
  9273. * Static property used to define the default attribute configuration of
  9274. * the Widget.
  9275. *
  9276. * @property ATTRS
  9277. * @type Object
  9278. * @protected
  9279. * @static
  9280. */
  9281. ATTRS: {
  9282. /**
  9283. * SmugMug API url to use for requests.
  9284. *
  9285. * @attribute apiUrl
  9286. * @type String
  9287. * @default https://api.smugmug.com/services/api/json/1.3.0/
  9288. */
  9289. apiURL: {
  9290. value: 'https://api.smugmug.com/services/api/json/1.3.0/'
  9291. },
  9292. /**
  9293. * SmugMug API key.
  9294. *
  9295. * @attribute apiKey
  9296. * @type String
  9297. * @default 7w6kuU5Ee6KSgRRExf2KLgppdkez9JD2
  9298. */
  9299. apiKey: {
  9300. value: '7w6kuU5Ee6KSgRRExf2KLgppdkez9JD2'
  9301. }
  9302. }
  9303. });
  9304. }, '2.0.0' ,{requires:['base', 'jsonp']});
  9305. YUI.add('fl-spinner', function(Y) {
  9306. (function(window,document,undefined){var width="width",length="length",radius="radius",lines="lines",trail="trail",color="color",opacity="opacity",speed="speed",shadow="shadow",style="style",height="height",left="left",top="top",px="px",childNodes="childNodes",firstChild="firstChild",parentNode="parentNode",position="position",relative="relative",absolute="absolute",animation="animation",transform="transform",Origin="Origin",Timeout="Timeout",coord="coord",black="#000",styleSheets=style+"Sheets",prefixes="webkit0Moz0ms0O".split(0),animations={},useCssAnimations;function eachPair(args,it){var end=~~((args[length]-1)/2);for(var i=1;i<=end;i++){it(args[i*2-1],args[i*2])}}function createEl(tag){var el=document.createElement(tag||"div");eachPair(arguments,function(prop,val){el[prop]=val});return el}function ins(parent,child1,child2){if(child2&&!child2[parentNode]){ins(parent,child2)}parent.insertBefore(child1,child2||null);return parent}ins(document.getElementsByTagName("head")[0],createEl(style));var sheet=document[styleSheets][document[styleSheets][length]-1];function addAnimation(to,end){var name=[opacity,end,~~(to*100)].join("-"),dest="{"+opacity+":"+to+"}",i;if(!animations[name]){for(i=0;i<prefixes[length];i++){try{sheet.insertRule("@"+(prefixes[i]&&"-"+prefixes[i].toLowerCase()+"-"||"")+"keyframes "+name+"{0%{"+opacity+":1}"+end+"%"+dest+"to"+dest+"}",sheet.cssRules[length])}catch(err){}}animations[name]=1}return name}function vendor(el,prop){var s=el[style],pp,i;if(s[prop]!==undefined){return prop}prop=prop.charAt(0).toUpperCase()+prop.slice(1);for(i=0;i<prefixes[length];i++){pp=prefixes[i]+prop;if(s[pp]!==undefined){return pp}}}function css(el){eachPair(arguments,function(n,val){el[style][vendor(el,n)||n]=val});return el}function defaults(obj){eachPair(arguments,function(prop,val){if(obj[prop]===undefined){obj[prop]=val}});return obj}var Spinner=function Spinner(o){this.opts=defaults(o||{},lines,12,trail,100,length,7,width,5,radius,10,color,black,opacity,1/4,speed,1)},proto=Spinner.prototype={spin:function(target){var self=this,el=self.el=self[lines](self.opts);if(target){ins(target,css(el,left,~~(target.offsetWidth/2)+px,top,~~(target.offsetHeight/2)+px),target[firstChild])}if(!useCssAnimations){var o=self.opts,i=0,f=20/o[speed],ostep=(1-o[opacity])/(f*o[trail]/100),astep=f/o[lines];(function anim(){i++;for(var s=o[lines];s;s--){var alpha=Math.max(1-(i+s*astep)%f*ostep,o[opacity]);self[opacity](el,o[lines]-s,alpha,o)}self[Timeout]=self.el&&window["set"+Timeout](anim,50)})()}return self},stop:function(){var self=this,el=self.el;window["clear"+Timeout](self[Timeout]);if(el&&el[parentNode]){el[parentNode].removeChild(el)}self.el=undefined;return self}};proto[lines]=function(o){var el=css(createEl(),position,relative),animationName=addAnimation(o[opacity],o[trail]),i=0,seg;function fill(color,shadow){return css(createEl(),position,absolute,width,(o[length]+o[width])+px,height,o[width]+px,"background",color,"boxShadow",shadow,transform+Origin,left,transform,"rotate("+~~(360/o[lines]*i)+"deg) translate("+o[radius]+px+",0)","borderRadius","100em")}for(;i<o[lines];i++){seg=css(createEl(),position,absolute,top,1+~(o[width]/2)+px,transform,"translate3d(0,0,0)",animation,animationName+" "+1/o[speed]+"s linear infinite "+(1/o[lines]/o[speed]*i-1/o[speed])+"s");if(o[shadow]){ins(seg,css(fill(black,"0 0 4px "+black),top,2+px))}ins(el,ins(seg,fill(o[color],"0 0 1px rgba(0,0,0,.1)")))}return el};proto[opacity]=function(el,i,val){el[childNodes][i][style][opacity]=val};var behavior="behavior",URL_VML="url(#default#VML)",tag="group0roundrect0fill0stroke".split(0);(function(){var s=css(createEl(tag[0]),behavior,URL_VML),i;if(!vendor(s,transform)&&s.adj){for(i=0;i<tag[length];i++){sheet.addRule(tag[i],behavior+":"+URL_VML)}proto[lines]=function(){var o=this.opts,r=o[length]+o[width],s=2*r;function grp(){return css(createEl(tag[0],coord+"size",s+" "+s,coord+Origin,-r+" "+-r),width,s,height,s)}var g=grp(),margin=~(o[length]+o[radius]+o[width])+px,i;function seg(i,dx,filter){ins(g,ins(css(grp(),"rotation",360/o[lines]*i+"deg",left,~~dx),ins(css(createEl(tag[1],"arcsize",1),width,r,height,o[width],left,o[radius],top,-o[width]/2,"filter",filter),createEl(tag[2],color,o[color],opacity,o[opacity]),createEl(tag[3],opacity,0))))}if(o[shadow]){for(i=1;i<=o[lines];i++){seg(i,-2,"progid:DXImage"+transform+".Microsoft.Blur(pixel"+radius+"=2,make"+shadow+"=1,"+shadow+opacity+"=.3)")}}for(i=1;i<=o[lines];i++){seg(i)}return ins(css(createEl(),"margin",margin+" 0 0 "+margin,position,relative),g)};proto[opacity]=function(el,i,val,o){o=o[shadow]&&o[lines]||0;el[firstChild][childNodes][i+o][firstChild][firstChild][opacity]=val}}else{useCssAnimations=vendor(s,animation)}})();Y.namespace('FL').Spinner=Spinner})(window,document);
  9307. }, '2.0.0' );
  9308. YUI.add('fl-utils', function(Y) {
  9309. /**
  9310. * @module fl-utils
  9311. */
  9312. /**
  9313. * General helper functions for all FastLine modules.
  9314. *
  9315. * @namespace FL
  9316. * @class Utils
  9317. * @constructor
  9318. * @static
  9319. */
  9320. Y.namespace('FL').Utils = {
  9321. /**
  9322. * Checks for support of the provided CSS property.
  9323. * Method adapted from: https://gist.github.com/556448
  9324. *
  9325. * @method cssSupport
  9326. * @param p {String} The property to check.
  9327. * @returns Boolean
  9328. */
  9329. cssSupport: function(p)
  9330. {
  9331. var b = document.body || document.documentElement,
  9332. s = b.style,
  9333. v = ['Moz', 'Webkit', 'Khtml', 'O', 'ms', 'Icab'],
  9334. i = 0;
  9335. // Transform not working well in these browsers
  9336. if(p == 'transform' && Y.UA.gecko && Y.UA.gecko < 4) { return false; }
  9337. if(p == 'transform' && Y.UA.opera > 0) { return false; }
  9338. if(p == 'transform' && Y.UA.ie > 0 && Y.UA.ie < 10) { return false; }
  9339. if(p == 'transform' && navigator.userAgent.match(/Trident/)) { return false; }
  9340. // No css support detected
  9341. if(typeof s == 'undefined') { return false; }
  9342. // Tests for standard prop
  9343. if(typeof s[p] == 'string') { return true; }
  9344. // Tests for vendor specific prop
  9345. p = p.charAt(0).toUpperCase() + p.substr(1);
  9346. for( ; i < v.length; i++) {
  9347. if(typeof s[v[i] + p] == 'string') { return true; }
  9348. }
  9349. }
  9350. };
  9351. }, '2.0.0' );