main.js 200 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279
  1. /*! jQuery v2.1.1 | (c) 2005, 2014 jQuery Foundation, Inc. | jquery.org/license */
  2. !function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=[],d=c.slice,e=c.concat,f=c.push,g=c.indexOf,h={},i=h.toString,j=h.hasOwnProperty,k={},l=a.document,m="2.1.1",n=function(a,b){return new n.fn.init(a,b)},o=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,p=/^-ms-/,q=/-([\da-z])/gi,r=function(a,b){return b.toUpperCase()};n.fn=n.prototype={jquery:m,constructor:n,selector:"",length:0,toArray:function(){return d.call(this)},get:function(a){return null!=a?0>a?this[a+this.length]:this[a]:d.call(this)},pushStack:function(a){var b=n.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a,b){return n.each(this,a,b)},map:function(a){return this.pushStack(n.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(d.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(0>a?b:0);return this.pushStack(c>=0&&b>c?[this[c]]:[])},end:function(){return this.prevObject||this.constructor(null)},push:f,sort:c.sort,splice:c.splice},n.extend=n.fn.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=1,i=arguments.length,j=!1;for("boolean"==typeof g&&(j=g,g=arguments[h]||{},h++),"object"==typeof g||n.isFunction(g)||(g={}),h===i&&(g=this,h--);i>h;h++)if(null!=(a=arguments[h]))for(b in a)c=g[b],d=a[b],g!==d&&(j&&d&&(n.isPlainObject(d)||(e=n.isArray(d)))?(e?(e=!1,f=c&&n.isArray(c)?c:[]):f=c&&n.isPlainObject(c)?c:{},g[b]=n.extend(j,f,d)):void 0!==d&&(g[b]=d));return g},n.extend({expando:"jQuery"+(m+Math.random()).replace(/\D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunction:function(a){return"function"===n.type(a)},isArray:Array.isArray,isWindow:function(a){return null!=a&&a===a.window},isNumeric:function(a){return!n.isArray(a)&&a-parseFloat(a)>=0},isPlainObject:function(a){return"object"!==n.type(a)||a.nodeType||n.isWindow(a)?!1:a.constructor&&!j.call(a.constructor.prototype,"isPrototypeOf")?!1:!0},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},type:function(a){return null==a?a+"":"object"==typeof a||"function"==typeof a?h[i.call(a)]||"object":typeof a},globalEval:function(a){var b,c=eval;a=n.trim(a),a&&(1===a.indexOf("use strict")?(b=l.createElement("script"),b.text=a,l.head.appendChild(b).parentNode.removeChild(b)):c(a))},camelCase:function(a){return a.replace(p,"ms-").replace(q,r)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()},each:function(a,b,c){var d,e=0,f=a.length,g=s(a);if(c){if(g){for(;f>e;e++)if(d=b.apply(a[e],c),d===!1)break}else for(e in a)if(d=b.apply(a[e],c),d===!1)break}else if(g){for(;f>e;e++)if(d=b.call(a[e],e,a[e]),d===!1)break}else for(e in a)if(d=b.call(a[e],e,a[e]),d===!1)break;return a},trim:function(a){return null==a?"":(a+"").replace(o,"")},makeArray:function(a,b){var c=b||[];return null!=a&&(s(Object(a))?n.merge(c,"string"==typeof a?[a]:a):f.call(c,a)),c},inArray:function(a,b,c){return null==b?-1:g.call(b,a,c)},merge:function(a,b){for(var c=+b.length,d=0,e=a.length;c>d;d++)a[e++]=b[d];return a.length=e,a},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;g>f;f++)d=!b(a[f],f),d!==h&&e.push(a[f]);return e},map:function(a,b,c){var d,f=0,g=a.length,h=s(a),i=[];if(h)for(;g>f;f++)d=b(a[f],f,c),null!=d&&i.push(d);else for(f in a)d=b(a[f],f,c),null!=d&&i.push(d);return e.apply([],i)},guid:1,proxy:function(a,b){var c,e,f;return"string"==typeof b&&(c=a[b],b=a,a=c),n.isFunction(a)?(e=d.call(arguments,2),f=function(){return a.apply(b||this,e.concat(d.call(arguments)))},f.guid=a.guid=a.guid||n.guid++,f):void 0},now:Date.now,support:k}),n.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(a,b){h["[object "+b+"]"]=b.toLowerCase()});function s(a){var b=a.length,c=n.type(a);return"function"===c||n.isWindow(a)?!1:1===a.nodeType&&b?!0:"array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a}var t=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u="sizzle"+-new Date,v=a.document,w=0,x=0,y=gb(),z=gb(),A=gb(),B=function(a,b){return a===b&&(l=!0),0},C="undefined",D=1<<31,E={}.hasOwnProperty,F=[],G=F.pop,H=F.push,I=F.push,J=F.slice,K=F.indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(this[b]===a)return b;return-1},L="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",M="[\\x20\\t\\r\\n\\f]",N="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",O=N.replace("w","w#"),P="\\["+M+"*("+N+")(?:"+M+"*([*^$|!~]?=)"+M+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+O+"))|)"+M+"*\\]",Q=":("+N+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+P+")*)|.*)\\)|)",R=new RegExp("^"+M+"+|((?:^|[^\\\\])(?:\\\\.)*)"+M+"+$","g"),S=new RegExp("^"+M+"*,"+M+"*"),T=new RegExp("^"+M+"*([>+~]|"+M+")"+M+"*"),U=new RegExp("="+M+"*([^\\]'\"]*?)"+M+"*\\]","g"),V=new RegExp(Q),W=new RegExp("^"+O+"$"),X={ID:new RegExp("^#("+N+")"),CLASS:new RegExp("^\\.("+N+")"),TAG:new RegExp("^("+N.replace("w","w*")+")"),ATTR:new RegExp("^"+P),PSEUDO:new RegExp("^"+Q),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+M+"*(even|odd|(([+-]|)(\\d*)n|)"+M+"*(?:([+-]|)"+M+"*(\\d+)|))"+M+"*\\)|)","i"),bool:new RegExp("^(?:"+L+")$","i"),needsContext:new RegExp("^"+M+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+M+"*((?:-\\d)?\\d*)"+M+"*\\)|)(?=[^-]|$)","i")},Y=/^(?:input|select|textarea|button)$/i,Z=/^h\d$/i,$=/^[^{]+\{\s*\[native \w/,_=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ab=/[+~]/,bb=/'|\\/g,cb=new RegExp("\\\\([\\da-f]{1,6}"+M+"?|("+M+")|.)","ig"),db=function(a,b,c){var d="0x"+b-65536;return d!==d||c?b:0>d?String.fromCharCode(d+65536):String.fromCharCode(d>>10|55296,1023&d|56320)};try{I.apply(F=J.call(v.childNodes),v.childNodes),F[v.childNodes.length].nodeType}catch(eb){I={apply:F.length?function(a,b){H.apply(a,J.call(b))}:function(a,b){var c=a.length,d=0;while(a[c++]=b[d++]);a.length=c-1}}}function fb(a,b,d,e){var f,h,j,k,l,o,r,s,w,x;if((b?b.ownerDocument||b:v)!==n&&m(b),b=b||n,d=d||[],!a||"string"!=typeof a)return d;if(1!==(k=b.nodeType)&&9!==k)return[];if(p&&!e){if(f=_.exec(a))if(j=f[1]){if(9===k){if(h=b.getElementById(j),!h||!h.parentNode)return d;if(h.id===j)return d.push(h),d}else if(b.ownerDocument&&(h=b.ownerDocument.getElementById(j))&&t(b,h)&&h.id===j)return d.push(h),d}else{if(f[2])return I.apply(d,b.getElementsByTagName(a)),d;if((j=f[3])&&c.getElementsByClassName&&b.getElementsByClassName)return I.apply(d,b.getElementsByClassName(j)),d}if(c.qsa&&(!q||!q.test(a))){if(s=r=u,w=b,x=9===k&&a,1===k&&"object"!==b.nodeName.toLowerCase()){o=g(a),(r=b.getAttribute("id"))?s=r.replace(bb,"\\$&"):b.setAttribute("id",s),s="[id='"+s+"'] ",l=o.length;while(l--)o[l]=s+qb(o[l]);w=ab.test(a)&&ob(b.parentNode)||b,x=o.join(",")}if(x)try{return I.apply(d,w.querySelectorAll(x)),d}catch(y){}finally{r||b.removeAttribute("id")}}}return i(a.replace(R,"$1"),b,d,e)}function gb(){var a=[];function b(c,e){return a.push(c+" ")>d.cacheLength&&delete b[a.shift()],b[c+" "]=e}return b}function hb(a){return a[u]=!0,a}function ib(a){var b=n.createElement("div");try{return!!a(b)}catch(c){return!1}finally{b.parentNode&&b.parentNode.removeChild(b),b=null}}function jb(a,b){var c=a.split("|"),e=a.length;while(e--)d.attrHandle[c[e]]=b}function kb(a,b){var c=b&&a,d=c&&1===a.nodeType&&1===b.nodeType&&(~b.sourceIndex||D)-(~a.sourceIndex||D);if(d)return d;if(c)while(c=c.nextSibling)if(c===b)return-1;return a?1:-1}function lb(a){return function(b){var c=b.nodeName.toLowerCase();return"input"===c&&b.type===a}}function mb(a){return function(b){var c=b.nodeName.toLowerCase();return("input"===c||"button"===c)&&b.type===a}}function nb(a){return hb(function(b){return b=+b,hb(function(c,d){var e,f=a([],c.length,b),g=f.length;while(g--)c[e=f[g]]&&(c[e]=!(d[e]=c[e]))})})}function ob(a){return a&&typeof a.getElementsByTagName!==C&&a}c=fb.support={},f=fb.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return b?"HTML"!==b.nodeName:!1},m=fb.setDocument=function(a){var b,e=a?a.ownerDocument||a:v,g=e.defaultView;return e!==n&&9===e.nodeType&&e.documentElement?(n=e,o=e.documentElement,p=!f(e),g&&g!==g.top&&(g.addEventListener?g.addEventListener("unload",function(){m()},!1):g.attachEvent&&g.attachEvent("onunload",function(){m()})),c.attributes=ib(function(a){return a.className="i",!a.getAttribute("className")}),c.getElementsByTagName=ib(function(a){return a.appendChild(e.createComment("")),!a.getElementsByTagName("*").length}),c.getElementsByClassName=$.test(e.getElementsByClassName)&&ib(function(a){return a.innerHTML="<div class='a'></div><div class='a i'></div>",a.firstChild.className="i",2===a.getElementsByClassName("i").length}),c.getById=ib(function(a){return o.appendChild(a).id=u,!e.getElementsByName||!e.getElementsByName(u).length}),c.getById?(d.find.ID=function(a,b){if(typeof b.getElementById!==C&&p){var c=b.getElementById(a);return c&&c.parentNode?[c]:[]}},d.filter.ID=function(a){var b=a.replace(cb,db);return function(a){return a.getAttribute("id")===b}}):(delete d.find.ID,d.filter.ID=function(a){var b=a.replace(cb,db);return function(a){var c=typeof a.getAttributeNode!==C&&a.getAttributeNode("id");return c&&c.value===b}}),d.find.TAG=c.getElementsByTagName?function(a,b){return typeof b.getElementsByTagName!==C?b.getElementsByTagName(a):void 0}:function(a,b){var c,d=[],e=0,f=b.getElementsByTagName(a);if("*"===a){while(c=f[e++])1===c.nodeType&&d.push(c);return d}return f},d.find.CLASS=c.getElementsByClassName&&function(a,b){return typeof b.getElementsByClassName!==C&&p?b.getElementsByClassName(a):void 0},r=[],q=[],(c.qsa=$.test(e.querySelectorAll))&&(ib(function(a){a.innerHTML="<select msallowclip=''><option selected=''></option></select>",a.querySelectorAll("[msallowclip^='']").length&&q.push("[*^$]="+M+"*(?:''|\"\")"),a.querySelectorAll("[selected]").length||q.push("\\["+M+"*(?:value|"+L+")"),a.querySelectorAll(":checked").length||q.push(":checked")}),ib(function(a){var b=e.createElement("input");b.setAttribute("type","hidden"),a.appendChild(b).setAttribute("name","D"),a.querySelectorAll("[name=d]").length&&q.push("name"+M+"*[*^$|!~]?="),a.querySelectorAll(":enabled").length||q.push(":enabled",":disabled"),a.querySelectorAll("*,:x"),q.push(",.*:")})),(c.matchesSelector=$.test(s=o.matches||o.webkitMatchesSelector||o.mozMatchesSelector||o.oMatchesSelector||o.msMatchesSelector))&&ib(function(a){c.disconnectedMatch=s.call(a,"div"),s.call(a,"[s!='']:x"),r.push("!=",Q)}),q=q.length&&new RegExp(q.join("|")),r=r.length&&new RegExp(r.join("|")),b=$.test(o.compareDocumentPosition),t=b||$.test(o.contains)?function(a,b){var c=9===a.nodeType?a.documentElement:a,d=b&&b.parentNode;return a===d||!(!d||1!==d.nodeType||!(c.contains?c.contains(d):a.compareDocumentPosition&&16&a.compareDocumentPosition(d)))}:function(a,b){if(b)while(b=b.parentNode)if(b===a)return!0;return!1},B=b?function(a,b){if(a===b)return l=!0,0;var d=!a.compareDocumentPosition-!b.compareDocumentPosition;return d?d:(d=(a.ownerDocument||a)===(b.ownerDocument||b)?a.compareDocumentPosition(b):1,1&d||!c.sortDetached&&b.compareDocumentPosition(a)===d?a===e||a.ownerDocument===v&&t(v,a)?-1:b===e||b.ownerDocument===v&&t(v,b)?1:k?K.call(k,a)-K.call(k,b):0:4&d?-1:1)}:function(a,b){if(a===b)return l=!0,0;var c,d=0,f=a.parentNode,g=b.parentNode,h=[a],i=[b];if(!f||!g)return a===e?-1:b===e?1:f?-1:g?1:k?K.call(k,a)-K.call(k,b):0;if(f===g)return kb(a,b);c=a;while(c=c.parentNode)h.unshift(c);c=b;while(c=c.parentNode)i.unshift(c);while(h[d]===i[d])d++;return d?kb(h[d],i[d]):h[d]===v?-1:i[d]===v?1:0},e):n},fb.matches=function(a,b){return fb(a,null,null,b)},fb.matchesSelector=function(a,b){if((a.ownerDocument||a)!==n&&m(a),b=b.replace(U,"='$1']"),!(!c.matchesSelector||!p||r&&r.test(b)||q&&q.test(b)))try{var d=s.call(a,b);if(d||c.disconnectedMatch||a.document&&11!==a.document.nodeType)return d}catch(e){}return fb(b,n,null,[a]).length>0},fb.contains=function(a,b){return(a.ownerDocument||a)!==n&&m(a),t(a,b)},fb.attr=function(a,b){(a.ownerDocument||a)!==n&&m(a);var e=d.attrHandle[b.toLowerCase()],f=e&&E.call(d.attrHandle,b.toLowerCase())?e(a,b,!p):void 0;return void 0!==f?f:c.attributes||!p?a.getAttribute(b):(f=a.getAttributeNode(b))&&f.specified?f.value:null},fb.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)},fb.uniqueSort=function(a){var b,d=[],e=0,f=0;if(l=!c.detectDuplicates,k=!c.sortStable&&a.slice(0),a.sort(B),l){while(b=a[f++])b===a[f]&&(e=d.push(f));while(e--)a.splice(d[e],1)}return k=null,a},e=fb.getText=function(a){var b,c="",d=0,f=a.nodeType;if(f){if(1===f||9===f||11===f){if("string"==typeof a.textContent)return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)c+=e(a)}else if(3===f||4===f)return a.nodeValue}else while(b=a[d++])c+=e(b);return c},d=fb.selectors={cacheLength:50,createPseudo:hb,match:X,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(cb,db),a[3]=(a[3]||a[4]||a[5]||"").replace(cb,db),"~="===a[2]&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(a){return a[1]=a[1].toLowerCase(),"nth"===a[1].slice(0,3)?(a[3]||fb.error(a[0]),a[4]=+(a[4]?a[5]+(a[6]||1):2*("even"===a[3]||"odd"===a[3])),a[5]=+(a[7]+a[8]||"odd"===a[3])):a[3]&&fb.error(a[0]),a},PSEUDO:function(a){var b,c=!a[6]&&a[2];return X.CHILD.test(a[0])?null:(a[3]?a[2]=a[4]||a[5]||"":c&&V.test(c)&&(b=g(c,!0))&&(b=c.indexOf(")",c.length-b)-c.length)&&(a[0]=a[0].slice(0,b),a[2]=c.slice(0,b)),a.slice(0,3))}},filter:{TAG:function(a){var b=a.replace(cb,db).toLowerCase();return"*"===a?function(){return!0}:function(a){return a.nodeName&&a.nodeName.toLowerCase()===b}},CLASS:function(a){var b=y[a+" "];return b||(b=new RegExp("(^|"+M+")"+a+"("+M+"|$)"))&&y(a,function(a){return b.test("string"==typeof a.className&&a.className||typeof a.getAttribute!==C&&a.getAttribute("class")||"")})},ATTR:function(a,b,c){return function(d){var e=fb.attr(d,a);return null==e?"!="===b:b?(e+="","="===b?e===c:"!="===b?e!==c:"^="===b?c&&0===e.indexOf(c):"*="===b?c&&e.indexOf(c)>-1:"$="===b?c&&e.slice(-c.length)===c:"~="===b?(" "+e+" ").indexOf(c)>-1:"|="===b?e===c||e.slice(0,c.length+1)===c+"-":!1):!0}},CHILD:function(a,b,c,d,e){var f="nth"!==a.slice(0,3),g="last"!==a.slice(-4),h="of-type"===b;return 1===d&&0===e?function(a){return!!a.parentNode}:function(b,c,i){var j,k,l,m,n,o,p=f!==g?"nextSibling":"previousSibling",q=b.parentNode,r=h&&b.nodeName.toLowerCase(),s=!i&&!h;if(q){if(f){while(p){l=b;while(l=l[p])if(h?l.nodeName.toLowerCase()===r:1===l.nodeType)return!1;o=p="only"===a&&!o&&"nextSibling"}return!0}if(o=[g?q.firstChild:q.lastChild],g&&s){k=q[u]||(q[u]={}),j=k[a]||[],n=j[0]===w&&j[1],m=j[0]===w&&j[2],l=n&&q.childNodes[n];while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if(1===l.nodeType&&++m&&l===b){k[a]=[w,n,m];break}}else if(s&&(j=(b[u]||(b[u]={}))[a])&&j[0]===w)m=j[1];else while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if((h?l.nodeName.toLowerCase()===r:1===l.nodeType)&&++m&&(s&&((l[u]||(l[u]={}))[a]=[w,m]),l===b))break;return m-=e,m===d||m%d===0&&m/d>=0}}},PSEUDO:function(a,b){var c,e=d.pseudos[a]||d.setFilters[a.toLowerCase()]||fb.error("unsupported pseudo: "+a);return e[u]?e(b):e.length>1?(c=[a,a,"",b],d.setFilters.hasOwnProperty(a.toLowerCase())?hb(function(a,c){var d,f=e(a,b),g=f.length;while(g--)d=K.call(a,f[g]),a[d]=!(c[d]=f[g])}):function(a){return e(a,0,c)}):e}},pseudos:{not:hb(function(a){var b=[],c=[],d=h(a.replace(R,"$1"));return d[u]?hb(function(a,b,c,e){var f,g=d(a,null,e,[]),h=a.length;while(h--)(f=g[h])&&(a[h]=!(b[h]=f))}):function(a,e,f){return b[0]=a,d(b,null,f,c),!c.pop()}}),has:hb(function(a){return function(b){return fb(a,b).length>0}}),contains:hb(function(a){return function(b){return(b.textContent||b.innerText||e(b)).indexOf(a)>-1}}),lang:hb(function(a){return W.test(a||"")||fb.error("unsupported lang: "+a),a=a.replace(cb,db).toLowerCase(),function(b){var c;do if(c=p?b.lang:b.getAttribute("xml:lang")||b.getAttribute("lang"))return c=c.toLowerCase(),c===a||0===c.indexOf(a+"-");while((b=b.parentNode)&&1===b.nodeType);return!1}}),target:function(b){var c=a.location&&a.location.hash;return c&&c.slice(1)===b.id},root:function(a){return a===o},focus:function(a){return a===n.activeElement&&(!n.hasFocus||n.hasFocus())&&!!(a.type||a.href||~a.tabIndex)},enabled:function(a){return a.disabled===!1},disabled:function(a){return a.disabled===!0},checked:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&!!a.checked||"option"===b&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},empty:function(a){for(a=a.firstChild;a;a=a.nextSibling)if(a.nodeType<6)return!1;return!0},parent:function(a){return!d.pseudos.empty(a)},header:function(a){return Z.test(a.nodeName)},input:function(a){return Y.test(a.nodeName)},button:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&"button"===a.type||"button"===b},text:function(a){var b;return"input"===a.nodeName.toLowerCase()&&"text"===a.type&&(null==(b=a.getAttribute("type"))||"text"===b.toLowerCase())},first:nb(function(){return[0]}),last:nb(function(a,b){return[b-1]}),eq:nb(function(a,b,c){return[0>c?c+b:c]}),even:nb(function(a,b){for(var c=0;b>c;c+=2)a.push(c);return a}),odd:nb(function(a,b){for(var c=1;b>c;c+=2)a.push(c);return a}),lt:nb(function(a,b,c){for(var d=0>c?c+b:c;--d>=0;)a.push(d);return a}),gt:nb(function(a,b,c){for(var d=0>c?c+b:c;++d<b;)a.push(d);return a})}},d.pseudos.nth=d.pseudos.eq;for(b in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})d.pseudos[b]=lb(b);for(b in{submit:!0,reset:!0})d.pseudos[b]=mb(b);function pb(){}pb.prototype=d.filters=d.pseudos,d.setFilters=new pb,g=fb.tokenize=function(a,b){var c,e,f,g,h,i,j,k=z[a+" "];if(k)return b?0:k.slice(0);h=a,i=[],j=d.preFilter;while(h){(!c||(e=S.exec(h)))&&(e&&(h=h.slice(e[0].length)||h),i.push(f=[])),c=!1,(e=T.exec(h))&&(c=e.shift(),f.push({value:c,type:e[0].replace(R," ")}),h=h.slice(c.length));for(g in d.filter)!(e=X[g].exec(h))||j[g]&&!(e=j[g](e))||(c=e.shift(),f.push({value:c,type:g,matches:e}),h=h.slice(c.length));if(!c)break}return b?h.length:h?fb.error(a):z(a,i).slice(0)};function qb(a){for(var b=0,c=a.length,d="";c>b;b++)d+=a[b].value;return d}function rb(a,b,c){var d=b.dir,e=c&&"parentNode"===d,f=x++;return b.first?function(b,c,f){while(b=b[d])if(1===b.nodeType||e)return a(b,c,f)}:function(b,c,g){var h,i,j=[w,f];if(g){while(b=b[d])if((1===b.nodeType||e)&&a(b,c,g))return!0}else while(b=b[d])if(1===b.nodeType||e){if(i=b[u]||(b[u]={}),(h=i[d])&&h[0]===w&&h[1]===f)return j[2]=h[2];if(i[d]=j,j[2]=a(b,c,g))return!0}}}function sb(a){return a.length>1?function(b,c,d){var e=a.length;while(e--)if(!a[e](b,c,d))return!1;return!0}:a[0]}function tb(a,b,c){for(var d=0,e=b.length;e>d;d++)fb(a,b[d],c);return c}function ub(a,b,c,d,e){for(var f,g=[],h=0,i=a.length,j=null!=b;i>h;h++)(f=a[h])&&(!c||c(f,d,e))&&(g.push(f),j&&b.push(h));return g}function vb(a,b,c,d,e,f){return d&&!d[u]&&(d=vb(d)),e&&!e[u]&&(e=vb(e,f)),hb(function(f,g,h,i){var j,k,l,m=[],n=[],o=g.length,p=f||tb(b||"*",h.nodeType?[h]:h,[]),q=!a||!f&&b?p:ub(p,m,a,h,i),r=c?e||(f?a:o||d)?[]:g:q;if(c&&c(q,r,h,i),d){j=ub(r,n),d(j,[],h,i),k=j.length;while(k--)(l=j[k])&&(r[n[k]]=!(q[n[k]]=l))}if(f){if(e||a){if(e){j=[],k=r.length;while(k--)(l=r[k])&&j.push(q[k]=l);e(null,r=[],j,i)}k=r.length;while(k--)(l=r[k])&&(j=e?K.call(f,l):m[k])>-1&&(f[j]=!(g[j]=l))}}else r=ub(r===g?r.splice(o,r.length):r),e?e(null,g,r,i):I.apply(g,r)})}function wb(a){for(var b,c,e,f=a.length,g=d.relative[a[0].type],h=g||d.relative[" "],i=g?1:0,k=rb(function(a){return a===b},h,!0),l=rb(function(a){return K.call(b,a)>-1},h,!0),m=[function(a,c,d){return!g&&(d||c!==j)||((b=c).nodeType?k(a,c,d):l(a,c,d))}];f>i;i++)if(c=d.relative[a[i].type])m=[rb(sb(m),c)];else{if(c=d.filter[a[i].type].apply(null,a[i].matches),c[u]){for(e=++i;f>e;e++)if(d.relative[a[e].type])break;return vb(i>1&&sb(m),i>1&&qb(a.slice(0,i-1).concat({value:" "===a[i-2].type?"*":""})).replace(R,"$1"),c,e>i&&wb(a.slice(i,e)),f>e&&wb(a=a.slice(e)),f>e&&qb(a))}m.push(c)}return sb(m)}function xb(a,b){var c=b.length>0,e=a.length>0,f=function(f,g,h,i,k){var l,m,o,p=0,q="0",r=f&&[],s=[],t=j,u=f||e&&d.find.TAG("*",k),v=w+=null==t?1:Math.random()||.1,x=u.length;for(k&&(j=g!==n&&g);q!==x&&null!=(l=u[q]);q++){if(e&&l){m=0;while(o=a[m++])if(o(l,g,h)){i.push(l);break}k&&(w=v)}c&&((l=!o&&l)&&p--,f&&r.push(l))}if(p+=q,c&&q!==p){m=0;while(o=b[m++])o(r,s,g,h);if(f){if(p>0)while(q--)r[q]||s[q]||(s[q]=G.call(i));s=ub(s)}I.apply(i,s),k&&!f&&s.length>0&&p+b.length>1&&fb.uniqueSort(i)}return k&&(w=v,j=t),r};return c?hb(f):f}return h=fb.compile=function(a,b){var c,d=[],e=[],f=A[a+" "];if(!f){b||(b=g(a)),c=b.length;while(c--)f=wb(b[c]),f[u]?d.push(f):e.push(f);f=A(a,xb(e,d)),f.selector=a}return f},i=fb.select=function(a,b,e,f){var i,j,k,l,m,n="function"==typeof a&&a,o=!f&&g(a=n.selector||a);if(e=e||[],1===o.length){if(j=o[0]=o[0].slice(0),j.length>2&&"ID"===(k=j[0]).type&&c.getById&&9===b.nodeType&&p&&d.relative[j[1].type]){if(b=(d.find.ID(k.matches[0].replace(cb,db),b)||[])[0],!b)return e;n&&(b=b.parentNode),a=a.slice(j.shift().value.length)}i=X.needsContext.test(a)?0:j.length;while(i--){if(k=j[i],d.relative[l=k.type])break;if((m=d.find[l])&&(f=m(k.matches[0].replace(cb,db),ab.test(j[0].type)&&ob(b.parentNode)||b))){if(j.splice(i,1),a=f.length&&qb(j),!a)return I.apply(e,f),e;break}}}return(n||h(a,o))(f,b,!p,e,ab.test(a)&&ob(b.parentNode)||b),e},c.sortStable=u.split("").sort(B).join("")===u,c.detectDuplicates=!!l,m(),c.sortDetached=ib(function(a){return 1&a.compareDocumentPosition(n.createElement("div"))}),ib(function(a){return a.innerHTML="<a href='#'></a>","#"===a.firstChild.getAttribute("href")})||jb("type|href|height|width",function(a,b,c){return c?void 0:a.getAttribute(b,"type"===b.toLowerCase()?1:2)}),c.attributes&&ib(function(a){return a.innerHTML="<input/>",a.firstChild.setAttribute("value",""),""===a.firstChild.getAttribute("value")})||jb("value",function(a,b,c){return c||"input"!==a.nodeName.toLowerCase()?void 0:a.defaultValue}),ib(function(a){return null==a.getAttribute("disabled")})||jb(L,function(a,b,c){var d;return c?void 0:a[b]===!0?b.toLowerCase():(d=a.getAttributeNode(b))&&d.specified?d.value:null}),fb}(a);n.find=t,n.expr=t.selectors,n.expr[":"]=n.expr.pseudos,n.unique=t.uniqueSort,n.text=t.getText,n.isXMLDoc=t.isXML,n.contains=t.contains;var u=n.expr.match.needsContext,v=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,w=/^.[^:#\[\.,]*$/;function x(a,b,c){if(n.isFunction(b))return n.grep(a,function(a,d){return!!b.call(a,d,a)!==c});if(b.nodeType)return n.grep(a,function(a){return a===b!==c});if("string"==typeof b){if(w.test(b))return n.filter(b,a,c);b=n.filter(b,a)}return n.grep(a,function(a){return g.call(b,a)>=0!==c})}n.filter=function(a,b,c){var d=b[0];return c&&(a=":not("+a+")"),1===b.length&&1===d.nodeType?n.find.matchesSelector(d,a)?[d]:[]:n.find.matches(a,n.grep(b,function(a){return 1===a.nodeType}))},n.fn.extend({find:function(a){var b,c=this.length,d=[],e=this;if("string"!=typeof a)return this.pushStack(n(a).filter(function(){for(b=0;c>b;b++)if(n.contains(e[b],this))return!0}));for(b=0;c>b;b++)n.find(a,e[b],d);return d=this.pushStack(c>1?n.unique(d):d),d.selector=this.selector?this.selector+" "+a:a,d},filter:function(a){return this.pushStack(x(this,a||[],!1))},not:function(a){return this.pushStack(x(this,a||[],!0))},is:function(a){return!!x(this,"string"==typeof a&&u.test(a)?n(a):a||[],!1).length}});var y,z=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,A=n.fn.init=function(a,b){var c,d;if(!a)return this;if("string"==typeof a){if(c="<"===a[0]&&">"===a[a.length-1]&&a.length>=3?[null,a,null]:z.exec(a),!c||!c[1]&&b)return!b||b.jquery?(b||y).find(a):this.constructor(b).find(a);if(c[1]){if(b=b instanceof n?b[0]:b,n.merge(this,n.parseHTML(c[1],b&&b.nodeType?b.ownerDocument||b:l,!0)),v.test(c[1])&&n.isPlainObject(b))for(c in b)n.isFunction(this[c])?this[c](b[c]):this.attr(c,b[c]);return this}return d=l.getElementById(c[2]),d&&d.parentNode&&(this.length=1,this[0]=d),this.context=l,this.selector=a,this}return a.nodeType?(this.context=this[0]=a,this.length=1,this):n.isFunction(a)?"undefined"!=typeof y.ready?y.ready(a):a(n):(void 0!==a.selector&&(this.selector=a.selector,this.context=a.context),n.makeArray(a,this))};A.prototype=n.fn,y=n(l);var B=/^(?:parents|prev(?:Until|All))/,C={children:!0,contents:!0,next:!0,prev:!0};n.extend({dir:function(a,b,c){var d=[],e=void 0!==c;while((a=a[b])&&9!==a.nodeType)if(1===a.nodeType){if(e&&n(a).is(c))break;d.push(a)}return d},sibling:function(a,b){for(var c=[];a;a=a.nextSibling)1===a.nodeType&&a!==b&&c.push(a);return c}}),n.fn.extend({has:function(a){var b=n(a,this),c=b.length;return this.filter(function(){for(var a=0;c>a;a++)if(n.contains(this,b[a]))return!0})},closest:function(a,b){for(var c,d=0,e=this.length,f=[],g=u.test(a)||"string"!=typeof a?n(a,b||this.context):0;e>d;d++)for(c=this[d];c&&c!==b;c=c.parentNode)if(c.nodeType<11&&(g?g.index(c)>-1:1===c.nodeType&&n.find.matchesSelector(c,a))){f.push(c);break}return this.pushStack(f.length>1?n.unique(f):f)},index:function(a){return a?"string"==typeof a?g.call(n(a),this[0]):g.call(this,a.jquery?a[0]:a):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(a,b){return this.pushStack(n.unique(n.merge(this.get(),n(a,b))))},addBack:function(a){return this.add(null==a?this.prevObject:this.prevObject.filter(a))}});function D(a,b){while((a=a[b])&&1!==a.nodeType);return a}n.each({parent:function(a){var b=a.parentNode;return b&&11!==b.nodeType?b:null},parents:function(a){return n.dir(a,"parentNode")},parentsUntil:function(a,b,c){return n.dir(a,"parentNode",c)},next:function(a){return D(a,"nextSibling")},prev:function(a){return D(a,"previousSibling")},nextAll:function(a){return n.dir(a,"nextSibling")},prevAll:function(a){return n.dir(a,"previousSibling")},nextUntil:function(a,b,c){return n.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return n.dir(a,"previousSibling",c)},siblings:function(a){return n.sibling((a.parentNode||{}).firstChild,a)},children:function(a){return n.sibling(a.firstChild)},contents:function(a){return a.contentDocument||n.merge([],a.childNodes)}},function(a,b){n.fn[a]=function(c,d){var e=n.map(this,b,c);return"Until"!==a.slice(-5)&&(d=c),d&&"string"==typeof d&&(e=n.filter(d,e)),this.length>1&&(C[a]||n.unique(e),B.test(a)&&e.reverse()),this.pushStack(e)}});var E=/\S+/g,F={};function G(a){var b=F[a]={};return n.each(a.match(E)||[],function(a,c){b[c]=!0}),b}n.Callbacks=function(a){a="string"==typeof a?F[a]||G(a):n.extend({},a);var b,c,d,e,f,g,h=[],i=!a.once&&[],j=function(l){for(b=a.memory&&l,c=!0,g=e||0,e=0,f=h.length,d=!0;h&&f>g;g++)if(h[g].apply(l[0],l[1])===!1&&a.stopOnFalse){b=!1;break}d=!1,h&&(i?i.length&&j(i.shift()):b?h=[]:k.disable())},k={add:function(){if(h){var c=h.length;!function g(b){n.each(b,function(b,c){var d=n.type(c);"function"===d?a.unique&&k.has(c)||h.push(c):c&&c.length&&"string"!==d&&g(c)})}(arguments),d?f=h.length:b&&(e=c,j(b))}return this},remove:function(){return h&&n.each(arguments,function(a,b){var c;while((c=n.inArray(b,h,c))>-1)h.splice(c,1),d&&(f>=c&&f--,g>=c&&g--)}),this},has:function(a){return a?n.inArray(a,h)>-1:!(!h||!h.length)},empty:function(){return h=[],f=0,this},disable:function(){return h=i=b=void 0,this},disabled:function(){return!h},lock:function(){return i=void 0,b||k.disable(),this},locked:function(){return!i},fireWith:function(a,b){return!h||c&&!i||(b=b||[],b=[a,b.slice?b.slice():b],d?i.push(b):j(b)),this},fire:function(){return k.fireWith(this,arguments),this},fired:function(){return!!c}};return k},n.extend({Deferred:function(a){var b=[["resolve","done",n.Callbacks("once memory"),"resolved"],["reject","fail",n.Callbacks("once memory"),"rejected"],["notify","progress",n.Callbacks("memory")]],c="pending",d={state:function(){return c},always:function(){return e.done(arguments).fail(arguments),this},then:function(){var a=arguments;return n.Deferred(function(c){n.each(b,function(b,f){var g=n.isFunction(a[b])&&a[b];e[f[1]](function(){var a=g&&g.apply(this,arguments);a&&n.isFunction(a.promise)?a.promise().done(c.resolve).fail(c.reject).progress(c.notify):c[f[0]+"With"](this===d?c.promise():this,g?[a]:arguments)})}),a=null}).promise()},promise:function(a){return null!=a?n.extend(a,d):d}},e={};return d.pipe=d.then,n.each(b,function(a,f){var g=f[2],h=f[3];d[f[1]]=g.add,h&&g.add(function(){c=h},b[1^a][2].disable,b[2][2].lock),e[f[0]]=function(){return e[f[0]+"With"](this===e?d:this,arguments),this},e[f[0]+"With"]=g.fireWith}),d.promise(e),a&&a.call(e,e),e},when:function(a){var b=0,c=d.call(arguments),e=c.length,f=1!==e||a&&n.isFunction(a.promise)?e:0,g=1===f?a:n.Deferred(),h=function(a,b,c){return function(e){b[a]=this,c[a]=arguments.length>1?d.call(arguments):e,c===i?g.notifyWith(b,c):--f||g.resolveWith(b,c)}},i,j,k;if(e>1)for(i=new Array(e),j=new Array(e),k=new Array(e);e>b;b++)c[b]&&n.isFunction(c[b].promise)?c[b].promise().done(h(b,k,c)).fail(g.reject).progress(h(b,j,i)):--f;return f||g.resolveWith(k,c),g.promise()}});var H;n.fn.ready=function(a){return n.ready.promise().done(a),this},n.extend({isReady:!1,readyWait:1,holdReady:function(a){a?n.readyWait++:n.ready(!0)},ready:function(a){(a===!0?--n.readyWait:n.isReady)||(n.isReady=!0,a!==!0&&--n.readyWait>0||(H.resolveWith(l,[n]),n.fn.triggerHandler&&(n(l).triggerHandler("ready"),n(l).off("ready"))))}});function I(){l.removeEventListener("DOMContentLoaded",I,!1),a.removeEventListener("load",I,!1),n.ready()}n.ready.promise=function(b){return H||(H=n.Deferred(),"complete"===l.readyState?setTimeout(n.ready):(l.addEventListener("DOMContentLoaded",I,!1),a.addEventListener("load",I,!1))),H.promise(b)},n.ready.promise();var J=n.access=function(a,b,c,d,e,f,g){var h=0,i=a.length,j=null==c;if("object"===n.type(c)){e=!0;for(h in c)n.access(a,b,h,c[h],!0,f,g)}else if(void 0!==d&&(e=!0,n.isFunction(d)||(g=!0),j&&(g?(b.call(a,d),b=null):(j=b,b=function(a,b,c){return j.call(n(a),c)})),b))for(;i>h;h++)b(a[h],c,g?d:d.call(a[h],h,b(a[h],c)));return e?a:j?b.call(a):i?b(a[0],c):f};n.acceptData=function(a){return 1===a.nodeType||9===a.nodeType||!+a.nodeType};function K(){Object.defineProperty(this.cache={},0,{get:function(){return{}}}),this.expando=n.expando+Math.random()}K.uid=1,K.accepts=n.acceptData,K.prototype={key:function(a){if(!K.accepts(a))return 0;var b={},c=a[this.expando];if(!c){c=K.uid++;try{b[this.expando]={value:c},Object.defineProperties(a,b)}catch(d){b[this.expando]=c,n.extend(a,b)}}return this.cache[c]||(this.cache[c]={}),c},set:function(a,b,c){var d,e=this.key(a),f=this.cache[e];if("string"==typeof b)f[b]=c;else if(n.isEmptyObject(f))n.extend(this.cache[e],b);else for(d in b)f[d]=b[d];return f},get:function(a,b){var c=this.cache[this.key(a)];return void 0===b?c:c[b]},access:function(a,b,c){var d;return void 0===b||b&&"string"==typeof b&&void 0===c?(d=this.get(a,b),void 0!==d?d:this.get(a,n.camelCase(b))):(this.set(a,b,c),void 0!==c?c:b)},remove:function(a,b){var c,d,e,f=this.key(a),g=this.cache[f];if(void 0===b)this.cache[f]={};else{n.isArray(b)?d=b.concat(b.map(n.camelCase)):(e=n.camelCase(b),b in g?d=[b,e]:(d=e,d=d in g?[d]:d.match(E)||[])),c=d.length;while(c--)delete g[d[c]]}},hasData:function(a){return!n.isEmptyObject(this.cache[a[this.expando]]||{})},discard:function(a){a[this.expando]&&delete this.cache[a[this.expando]]}};var L=new K,M=new K,N=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,O=/([A-Z])/g;function P(a,b,c){var d;if(void 0===c&&1===a.nodeType)if(d="data-"+b.replace(O,"-$1").toLowerCase(),c=a.getAttribute(d),"string"==typeof c){try{c="true"===c?!0:"false"===c?!1:"null"===c?null:+c+""===c?+c:N.test(c)?n.parseJSON(c):c}catch(e){}M.set(a,b,c)}else c=void 0;return c}n.extend({hasData:function(a){return M.hasData(a)||L.hasData(a)},data:function(a,b,c){return M.access(a,b,c)},removeData:function(a,b){M.remove(a,b)
  3. },_data:function(a,b,c){return L.access(a,b,c)},_removeData:function(a,b){L.remove(a,b)}}),n.fn.extend({data:function(a,b){var c,d,e,f=this[0],g=f&&f.attributes;if(void 0===a){if(this.length&&(e=M.get(f),1===f.nodeType&&!L.get(f,"hasDataAttrs"))){c=g.length;while(c--)g[c]&&(d=g[c].name,0===d.indexOf("data-")&&(d=n.camelCase(d.slice(5)),P(f,d,e[d])));L.set(f,"hasDataAttrs",!0)}return e}return"object"==typeof a?this.each(function(){M.set(this,a)}):J(this,function(b){var c,d=n.camelCase(a);if(f&&void 0===b){if(c=M.get(f,a),void 0!==c)return c;if(c=M.get(f,d),void 0!==c)return c;if(c=P(f,d,void 0),void 0!==c)return c}else this.each(function(){var c=M.get(this,d);M.set(this,d,b),-1!==a.indexOf("-")&&void 0!==c&&M.set(this,a,b)})},null,b,arguments.length>1,null,!0)},removeData:function(a){return this.each(function(){M.remove(this,a)})}}),n.extend({queue:function(a,b,c){var d;return a?(b=(b||"fx")+"queue",d=L.get(a,b),c&&(!d||n.isArray(c)?d=L.access(a,b,n.makeArray(c)):d.push(c)),d||[]):void 0},dequeue:function(a,b){b=b||"fx";var c=n.queue(a,b),d=c.length,e=c.shift(),f=n._queueHooks(a,b),g=function(){n.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return L.get(a,c)||L.access(a,c,{empty:n.Callbacks("once memory").add(function(){L.remove(a,[b+"queue",c])})})}}),n.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.length<c?n.queue(this[0],a):void 0===b?this:this.each(function(){var c=n.queue(this,a,b);n._queueHooks(this,a),"fx"===a&&"inprogress"!==c[0]&&n.dequeue(this,a)})},dequeue:function(a){return this.each(function(){n.dequeue(this,a)})},clearQueue:function(a){return this.queue(a||"fx",[])},promise:function(a,b){var c,d=1,e=n.Deferred(),f=this,g=this.length,h=function(){--d||e.resolveWith(f,[f])};"string"!=typeof a&&(b=a,a=void 0),a=a||"fx";while(g--)c=L.get(f[g],a+"queueHooks"),c&&c.empty&&(d++,c.empty.add(h));return h(),e.promise(b)}});var Q=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,R=["Top","Right","Bottom","Left"],S=function(a,b){return a=b||a,"none"===n.css(a,"display")||!n.contains(a.ownerDocument,a)},T=/^(?:checkbox|radio)$/i;!function(){var a=l.createDocumentFragment(),b=a.appendChild(l.createElement("div")),c=l.createElement("input");c.setAttribute("type","radio"),c.setAttribute("checked","checked"),c.setAttribute("name","t"),b.appendChild(c),k.checkClone=b.cloneNode(!0).cloneNode(!0).lastChild.checked,b.innerHTML="<textarea>x</textarea>",k.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue}();var U="undefined";k.focusinBubbles="onfocusin"in a;var V=/^key/,W=/^(?:mouse|pointer|contextmenu)|click/,X=/^(?:focusinfocus|focusoutblur)$/,Y=/^([^.]*)(?:\.(.+)|)$/;function Z(){return!0}function $(){return!1}function _(){try{return l.activeElement}catch(a){}}n.event={global:{},add:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,o,p,q,r=L.get(a);if(r){c.handler&&(f=c,c=f.handler,e=f.selector),c.guid||(c.guid=n.guid++),(i=r.events)||(i=r.events={}),(g=r.handle)||(g=r.handle=function(b){return typeof n!==U&&n.event.triggered!==b.type?n.event.dispatch.apply(a,arguments):void 0}),b=(b||"").match(E)||[""],j=b.length;while(j--)h=Y.exec(b[j])||[],o=q=h[1],p=(h[2]||"").split(".").sort(),o&&(l=n.event.special[o]||{},o=(e?l.delegateType:l.bindType)||o,l=n.event.special[o]||{},k=n.extend({type:o,origType:q,data:d,handler:c,guid:c.guid,selector:e,needsContext:e&&n.expr.match.needsContext.test(e),namespace:p.join(".")},f),(m=i[o])||(m=i[o]=[],m.delegateCount=0,l.setup&&l.setup.call(a,d,p,g)!==!1||a.addEventListener&&a.addEventListener(o,g,!1)),l.add&&(l.add.call(a,k),k.handler.guid||(k.handler.guid=c.guid)),e?m.splice(m.delegateCount++,0,k):m.push(k),n.event.global[o]=!0)}},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,o,p,q,r=L.hasData(a)&&L.get(a);if(r&&(i=r.events)){b=(b||"").match(E)||[""],j=b.length;while(j--)if(h=Y.exec(b[j])||[],o=q=h[1],p=(h[2]||"").split(".").sort(),o){l=n.event.special[o]||{},o=(d?l.delegateType:l.bindType)||o,m=i[o]||[],h=h[2]&&new RegExp("(^|\\.)"+p.join("\\.(?:.*\\.|)")+"(\\.|$)"),g=f=m.length;while(f--)k=m[f],!e&&q!==k.origType||c&&c.guid!==k.guid||h&&!h.test(k.namespace)||d&&d!==k.selector&&("**"!==d||!k.selector)||(m.splice(f,1),k.selector&&m.delegateCount--,l.remove&&l.remove.call(a,k));g&&!m.length&&(l.teardown&&l.teardown.call(a,p,r.handle)!==!1||n.removeEvent(a,o,r.handle),delete i[o])}else for(o in i)n.event.remove(a,o+b[j],c,d,!0);n.isEmptyObject(i)&&(delete r.handle,L.remove(a,"events"))}},trigger:function(b,c,d,e){var f,g,h,i,k,m,o,p=[d||l],q=j.call(b,"type")?b.type:b,r=j.call(b,"namespace")?b.namespace.split("."):[];if(g=h=d=d||l,3!==d.nodeType&&8!==d.nodeType&&!X.test(q+n.event.triggered)&&(q.indexOf(".")>=0&&(r=q.split("."),q=r.shift(),r.sort()),k=q.indexOf(":")<0&&"on"+q,b=b[n.expando]?b:new n.Event(q,"object"==typeof b&&b),b.isTrigger=e?2:3,b.namespace=r.join("."),b.namespace_re=b.namespace?new RegExp("(^|\\.)"+r.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,b.result=void 0,b.target||(b.target=d),c=null==c?[b]:n.makeArray(c,[b]),o=n.event.special[q]||{},e||!o.trigger||o.trigger.apply(d,c)!==!1)){if(!e&&!o.noBubble&&!n.isWindow(d)){for(i=o.delegateType||q,X.test(i+q)||(g=g.parentNode);g;g=g.parentNode)p.push(g),h=g;h===(d.ownerDocument||l)&&p.push(h.defaultView||h.parentWindow||a)}f=0;while((g=p[f++])&&!b.isPropagationStopped())b.type=f>1?i:o.bindType||q,m=(L.get(g,"events")||{})[b.type]&&L.get(g,"handle"),m&&m.apply(g,c),m=k&&g[k],m&&m.apply&&n.acceptData(g)&&(b.result=m.apply(g,c),b.result===!1&&b.preventDefault());return b.type=q,e||b.isDefaultPrevented()||o._default&&o._default.apply(p.pop(),c)!==!1||!n.acceptData(d)||k&&n.isFunction(d[q])&&!n.isWindow(d)&&(h=d[k],h&&(d[k]=null),n.event.triggered=q,d[q](),n.event.triggered=void 0,h&&(d[k]=h)),b.result}},dispatch:function(a){a=n.event.fix(a);var b,c,e,f,g,h=[],i=d.call(arguments),j=(L.get(this,"events")||{})[a.type]||[],k=n.event.special[a.type]||{};if(i[0]=a,a.delegateTarget=this,!k.preDispatch||k.preDispatch.call(this,a)!==!1){h=n.event.handlers.call(this,a,j),b=0;while((f=h[b++])&&!a.isPropagationStopped()){a.currentTarget=f.elem,c=0;while((g=f.handlers[c++])&&!a.isImmediatePropagationStopped())(!a.namespace_re||a.namespace_re.test(g.namespace))&&(a.handleObj=g,a.data=g.data,e=((n.event.special[g.origType]||{}).handle||g.handler).apply(f.elem,i),void 0!==e&&(a.result=e)===!1&&(a.preventDefault(),a.stopPropagation()))}return k.postDispatch&&k.postDispatch.call(this,a),a.result}},handlers:function(a,b){var c,d,e,f,g=[],h=b.delegateCount,i=a.target;if(h&&i.nodeType&&(!a.button||"click"!==a.type))for(;i!==this;i=i.parentNode||this)if(i.disabled!==!0||"click"!==a.type){for(d=[],c=0;h>c;c++)f=b[c],e=f.selector+" ",void 0===d[e]&&(d[e]=f.needsContext?n(e,this).index(i)>=0:n.find(e,this,null,[i]).length),d[e]&&d.push(f);d.length&&g.push({elem:i,handlers:d})}return h<b.length&&g.push({elem:this,handlers:b.slice(h)}),g},props:"altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),fixHooks:{},keyHooks:{props:"char charCode key keyCode".split(" "),filter:function(a,b){return null==a.which&&(a.which=null!=b.charCode?b.charCode:b.keyCode),a}},mouseHooks:{props:"button buttons clientX clientY offsetX offsetY pageX pageY screenX screenY toElement".split(" "),filter:function(a,b){var c,d,e,f=b.button;return null==a.pageX&&null!=b.clientX&&(c=a.target.ownerDocument||l,d=c.documentElement,e=c.body,a.pageX=b.clientX+(d&&d.scrollLeft||e&&e.scrollLeft||0)-(d&&d.clientLeft||e&&e.clientLeft||0),a.pageY=b.clientY+(d&&d.scrollTop||e&&e.scrollTop||0)-(d&&d.clientTop||e&&e.clientTop||0)),a.which||void 0===f||(a.which=1&f?1:2&f?3:4&f?2:0),a}},fix:function(a){if(a[n.expando])return a;var b,c,d,e=a.type,f=a,g=this.fixHooks[e];g||(this.fixHooks[e]=g=W.test(e)?this.mouseHooks:V.test(e)?this.keyHooks:{}),d=g.props?this.props.concat(g.props):this.props,a=new n.Event(f),b=d.length;while(b--)c=d[b],a[c]=f[c];return a.target||(a.target=l),3===a.target.nodeType&&(a.target=a.target.parentNode),g.filter?g.filter(a,f):a},special:{load:{noBubble:!0},focus:{trigger:function(){return this!==_()&&this.focus?(this.focus(),!1):void 0},delegateType:"focusin"},blur:{trigger:function(){return this===_()&&this.blur?(this.blur(),!1):void 0},delegateType:"focusout"},click:{trigger:function(){return"checkbox"===this.type&&this.click&&n.nodeName(this,"input")?(this.click(),!1):void 0},_default:function(a){return n.nodeName(a.target,"a")}},beforeunload:{postDispatch:function(a){void 0!==a.result&&a.originalEvent&&(a.originalEvent.returnValue=a.result)}}},simulate:function(a,b,c,d){var e=n.extend(new n.Event,c,{type:a,isSimulated:!0,originalEvent:{}});d?n.event.trigger(e,null,b):n.event.dispatch.call(b,e),e.isDefaultPrevented()&&c.preventDefault()}},n.removeEvent=function(a,b,c){a.removeEventListener&&a.removeEventListener(b,c,!1)},n.Event=function(a,b){return this instanceof n.Event?(a&&a.type?(this.originalEvent=a,this.type=a.type,this.isDefaultPrevented=a.defaultPrevented||void 0===a.defaultPrevented&&a.returnValue===!1?Z:$):this.type=a,b&&n.extend(this,b),this.timeStamp=a&&a.timeStamp||n.now(),void(this[n.expando]=!0)):new n.Event(a,b)},n.Event.prototype={isDefaultPrevented:$,isPropagationStopped:$,isImmediatePropagationStopped:$,preventDefault:function(){var a=this.originalEvent;this.isDefaultPrevented=Z,a&&a.preventDefault&&a.preventDefault()},stopPropagation:function(){var a=this.originalEvent;this.isPropagationStopped=Z,a&&a.stopPropagation&&a.stopPropagation()},stopImmediatePropagation:function(){var a=this.originalEvent;this.isImmediatePropagationStopped=Z,a&&a.stopImmediatePropagation&&a.stopImmediatePropagation(),this.stopPropagation()}},n.each({mouseenter:"mouseover",mouseleave:"mouseout",pointerenter:"pointerover",pointerleave:"pointerout"},function(a,b){n.event.special[a]={delegateType:b,bindType:b,handle:function(a){var c,d=this,e=a.relatedTarget,f=a.handleObj;return(!e||e!==d&&!n.contains(d,e))&&(a.type=f.origType,c=f.handler.apply(this,arguments),a.type=b),c}}}),k.focusinBubbles||n.each({focus:"focusin",blur:"focusout"},function(a,b){var c=function(a){n.event.simulate(b,a.target,n.event.fix(a),!0)};n.event.special[b]={setup:function(){var d=this.ownerDocument||this,e=L.access(d,b);e||d.addEventListener(a,c,!0),L.access(d,b,(e||0)+1)},teardown:function(){var d=this.ownerDocument||this,e=L.access(d,b)-1;e?L.access(d,b,e):(d.removeEventListener(a,c,!0),L.remove(d,b))}}}),n.fn.extend({on:function(a,b,c,d,e){var f,g;if("object"==typeof a){"string"!=typeof b&&(c=c||b,b=void 0);for(g in a)this.on(g,b,c,a[g],e);return this}if(null==c&&null==d?(d=b,c=b=void 0):null==d&&("string"==typeof b?(d=c,c=void 0):(d=c,c=b,b=void 0)),d===!1)d=$;else if(!d)return this;return 1===e&&(f=d,d=function(a){return n().off(a),f.apply(this,arguments)},d.guid=f.guid||(f.guid=n.guid++)),this.each(function(){n.event.add(this,a,d,c,b)})},one:function(a,b,c,d){return this.on(a,b,c,d,1)},off:function(a,b,c){var d,e;if(a&&a.preventDefault&&a.handleObj)return d=a.handleObj,n(a.delegateTarget).off(d.namespace?d.origType+"."+d.namespace:d.origType,d.selector,d.handler),this;if("object"==typeof a){for(e in a)this.off(e,b,a[e]);return this}return(b===!1||"function"==typeof b)&&(c=b,b=void 0),c===!1&&(c=$),this.each(function(){n.event.remove(this,a,c,b)})},trigger:function(a,b){return this.each(function(){n.event.trigger(a,b,this)})},triggerHandler:function(a,b){var c=this[0];return c?n.event.trigger(a,b,c,!0):void 0}});var ab=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,bb=/<([\w:]+)/,cb=/<|&#?\w+;/,db=/<(?:script|style|link)/i,eb=/checked\s*(?:[^=]|=\s*.checked.)/i,fb=/^$|\/(?:java|ecma)script/i,gb=/^true\/(.*)/,hb=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,ib={option:[1,"<select multiple='multiple'>","</select>"],thead:[1,"<table>","</table>"],col:[2,"<table><colgroup>","</colgroup></table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],_default:[0,"",""]};ib.optgroup=ib.option,ib.tbody=ib.tfoot=ib.colgroup=ib.caption=ib.thead,ib.th=ib.td;function jb(a,b){return n.nodeName(a,"table")&&n.nodeName(11!==b.nodeType?b:b.firstChild,"tr")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function kb(a){return a.type=(null!==a.getAttribute("type"))+"/"+a.type,a}function lb(a){var b=gb.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function mb(a,b){for(var c=0,d=a.length;d>c;c++)L.set(a[c],"globalEval",!b||L.get(b[c],"globalEval"))}function nb(a,b){var c,d,e,f,g,h,i,j;if(1===b.nodeType){if(L.hasData(a)&&(f=L.access(a),g=L.set(b,f),j=f.events)){delete g.handle,g.events={};for(e in j)for(c=0,d=j[e].length;d>c;c++)n.event.add(b,e,j[e][c])}M.hasData(a)&&(h=M.access(a),i=n.extend({},h),M.set(b,i))}}function ob(a,b){var c=a.getElementsByTagName?a.getElementsByTagName(b||"*"):a.querySelectorAll?a.querySelectorAll(b||"*"):[];return void 0===b||b&&n.nodeName(a,b)?n.merge([a],c):c}function pb(a,b){var c=b.nodeName.toLowerCase();"input"===c&&T.test(a.type)?b.checked=a.checked:("input"===c||"textarea"===c)&&(b.defaultValue=a.defaultValue)}n.extend({clone:function(a,b,c){var d,e,f,g,h=a.cloneNode(!0),i=n.contains(a.ownerDocument,a);if(!(k.noCloneChecked||1!==a.nodeType&&11!==a.nodeType||n.isXMLDoc(a)))for(g=ob(h),f=ob(a),d=0,e=f.length;e>d;d++)pb(f[d],g[d]);if(b)if(c)for(f=f||ob(a),g=g||ob(h),d=0,e=f.length;e>d;d++)nb(f[d],g[d]);else nb(a,h);return g=ob(h,"script"),g.length>0&&mb(g,!i&&ob(a,"script")),h},buildFragment:function(a,b,c,d){for(var e,f,g,h,i,j,k=b.createDocumentFragment(),l=[],m=0,o=a.length;o>m;m++)if(e=a[m],e||0===e)if("object"===n.type(e))n.merge(l,e.nodeType?[e]:e);else if(cb.test(e)){f=f||k.appendChild(b.createElement("div")),g=(bb.exec(e)||["",""])[1].toLowerCase(),h=ib[g]||ib._default,f.innerHTML=h[1]+e.replace(ab,"<$1></$2>")+h[2],j=h[0];while(j--)f=f.lastChild;n.merge(l,f.childNodes),f=k.firstChild,f.textContent=""}else l.push(b.createTextNode(e));k.textContent="",m=0;while(e=l[m++])if((!d||-1===n.inArray(e,d))&&(i=n.contains(e.ownerDocument,e),f=ob(k.appendChild(e),"script"),i&&mb(f),c)){j=0;while(e=f[j++])fb.test(e.type||"")&&c.push(e)}return k},cleanData:function(a){for(var b,c,d,e,f=n.event.special,g=0;void 0!==(c=a[g]);g++){if(n.acceptData(c)&&(e=c[L.expando],e&&(b=L.cache[e]))){if(b.events)for(d in b.events)f[d]?n.event.remove(c,d):n.removeEvent(c,d,b.handle);L.cache[e]&&delete L.cache[e]}delete M.cache[c[M.expando]]}}}),n.fn.extend({text:function(a){return J(this,function(a){return void 0===a?n.text(this):this.empty().each(function(){(1===this.nodeType||11===this.nodeType||9===this.nodeType)&&(this.textContent=a)})},null,a,arguments.length)},append:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=jb(this,a);b.appendChild(a)}})},prepend:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=jb(this,a);b.insertBefore(a,b.firstChild)}})},before:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this)})},after:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this.nextSibling)})},remove:function(a,b){for(var c,d=a?n.filter(a,this):this,e=0;null!=(c=d[e]);e++)b||1!==c.nodeType||n.cleanData(ob(c)),c.parentNode&&(b&&n.contains(c.ownerDocument,c)&&mb(ob(c,"script")),c.parentNode.removeChild(c));return this},empty:function(){for(var a,b=0;null!=(a=this[b]);b++)1===a.nodeType&&(n.cleanData(ob(a,!1)),a.textContent="");return this},clone:function(a,b){return a=null==a?!1:a,b=null==b?a:b,this.map(function(){return n.clone(this,a,b)})},html:function(a){return J(this,function(a){var b=this[0]||{},c=0,d=this.length;if(void 0===a&&1===b.nodeType)return b.innerHTML;if("string"==typeof a&&!db.test(a)&&!ib[(bb.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(ab,"<$1></$2>");try{for(;d>c;c++)b=this[c]||{},1===b.nodeType&&(n.cleanData(ob(b,!1)),b.innerHTML=a);b=0}catch(e){}}b&&this.empty().append(a)},null,a,arguments.length)},replaceWith:function(){var a=arguments[0];return this.domManip(arguments,function(b){a=this.parentNode,n.cleanData(ob(this)),a&&a.replaceChild(b,this)}),a&&(a.length||a.nodeType)?this:this.remove()},detach:function(a){return this.remove(a,!0)},domManip:function(a,b){a=e.apply([],a);var c,d,f,g,h,i,j=0,l=this.length,m=this,o=l-1,p=a[0],q=n.isFunction(p);if(q||l>1&&"string"==typeof p&&!k.checkClone&&eb.test(p))return this.each(function(c){var d=m.eq(c);q&&(a[0]=p.call(this,c,d.html())),d.domManip(a,b)});if(l&&(c=n.buildFragment(a,this[0].ownerDocument,!1,this),d=c.firstChild,1===c.childNodes.length&&(c=d),d)){for(f=n.map(ob(c,"script"),kb),g=f.length;l>j;j++)h=c,j!==o&&(h=n.clone(h,!0,!0),g&&n.merge(f,ob(h,"script"))),b.call(this[j],h,j);if(g)for(i=f[f.length-1].ownerDocument,n.map(f,lb),j=0;g>j;j++)h=f[j],fb.test(h.type||"")&&!L.access(h,"globalEval")&&n.contains(i,h)&&(h.src?n._evalUrl&&n._evalUrl(h.src):n.globalEval(h.textContent.replace(hb,"")))}return this}}),n.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){n.fn[a]=function(a){for(var c,d=[],e=n(a),g=e.length-1,h=0;g>=h;h++)c=h===g?this:this.clone(!0),n(e[h])[b](c),f.apply(d,c.get());return this.pushStack(d)}});var qb,rb={};function sb(b,c){var d,e=n(c.createElement(b)).appendTo(c.body),f=a.getDefaultComputedStyle&&(d=a.getDefaultComputedStyle(e[0]))?d.display:n.css(e[0],"display");return e.detach(),f}function tb(a){var b=l,c=rb[a];return c||(c=sb(a,b),"none"!==c&&c||(qb=(qb||n("<iframe frameborder='0' width='0' height='0'/>")).appendTo(b.documentElement),b=qb[0].contentDocument,b.write(),b.close(),c=sb(a,b),qb.detach()),rb[a]=c),c}var ub=/^margin/,vb=new RegExp("^("+Q+")(?!px)[a-z%]+$","i"),wb=function(a){return a.ownerDocument.defaultView.getComputedStyle(a,null)};function xb(a,b,c){var d,e,f,g,h=a.style;return c=c||wb(a),c&&(g=c.getPropertyValue(b)||c[b]),c&&(""!==g||n.contains(a.ownerDocument,a)||(g=n.style(a,b)),vb.test(g)&&ub.test(b)&&(d=h.width,e=h.minWidth,f=h.maxWidth,h.minWidth=h.maxWidth=h.width=g,g=c.width,h.width=d,h.minWidth=e,h.maxWidth=f)),void 0!==g?g+"":g}function yb(a,b){return{get:function(){return a()?void delete this.get:(this.get=b).apply(this,arguments)}}}!function(){var b,c,d=l.documentElement,e=l.createElement("div"),f=l.createElement("div");if(f.style){f.style.backgroundClip="content-box",f.cloneNode(!0).style.backgroundClip="",k.clearCloneStyle="content-box"===f.style.backgroundClip,e.style.cssText="border:0;width:0;height:0;top:0;left:-9999px;margin-top:1px;position:absolute",e.appendChild(f);function g(){f.style.cssText="-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;display:block;margin-top:1%;top:1%;border:1px;padding:1px;width:4px;position:absolute",f.innerHTML="",d.appendChild(e);var g=a.getComputedStyle(f,null);b="1%"!==g.top,c="4px"===g.width,d.removeChild(e)}a.getComputedStyle&&n.extend(k,{pixelPosition:function(){return g(),b},boxSizingReliable:function(){return null==c&&g(),c},reliableMarginRight:function(){var b,c=f.appendChild(l.createElement("div"));return c.style.cssText=f.style.cssText="-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;display:block;margin:0;border:0;padding:0",c.style.marginRight=c.style.width="0",f.style.width="1px",d.appendChild(e),b=!parseFloat(a.getComputedStyle(c,null).marginRight),d.removeChild(e),b}})}}(),n.swap=function(a,b,c,d){var e,f,g={};for(f in b)g[f]=a.style[f],a.style[f]=b[f];e=c.apply(a,d||[]);for(f in b)a.style[f]=g[f];return e};var zb=/^(none|table(?!-c[ea]).+)/,Ab=new RegExp("^("+Q+")(.*)$","i"),Bb=new RegExp("^([+-])=("+Q+")","i"),Cb={position:"absolute",visibility:"hidden",display:"block"},Db={letterSpacing:"0",fontWeight:"400"},Eb=["Webkit","O","Moz","ms"];function Fb(a,b){if(b in a)return b;var c=b[0].toUpperCase()+b.slice(1),d=b,e=Eb.length;while(e--)if(b=Eb[e]+c,b in a)return b;return d}function Gb(a,b,c){var d=Ab.exec(b);return d?Math.max(0,d[1]-(c||0))+(d[2]||"px"):b}function Hb(a,b,c,d,e){for(var f=c===(d?"border":"content")?4:"width"===b?1:0,g=0;4>f;f+=2)"margin"===c&&(g+=n.css(a,c+R[f],!0,e)),d?("content"===c&&(g-=n.css(a,"padding"+R[f],!0,e)),"margin"!==c&&(g-=n.css(a,"border"+R[f]+"Width",!0,e))):(g+=n.css(a,"padding"+R[f],!0,e),"padding"!==c&&(g+=n.css(a,"border"+R[f]+"Width",!0,e)));return g}function Ib(a,b,c){var d=!0,e="width"===b?a.offsetWidth:a.offsetHeight,f=wb(a),g="border-box"===n.css(a,"boxSizing",!1,f);if(0>=e||null==e){if(e=xb(a,b,f),(0>e||null==e)&&(e=a.style[b]),vb.test(e))return e;d=g&&(k.boxSizingReliable()||e===a.style[b]),e=parseFloat(e)||0}return e+Hb(a,b,c||(g?"border":"content"),d,f)+"px"}function Jb(a,b){for(var c,d,e,f=[],g=0,h=a.length;h>g;g++)d=a[g],d.style&&(f[g]=L.get(d,"olddisplay"),c=d.style.display,b?(f[g]||"none"!==c||(d.style.display=""),""===d.style.display&&S(d)&&(f[g]=L.access(d,"olddisplay",tb(d.nodeName)))):(e=S(d),"none"===c&&e||L.set(d,"olddisplay",e?c:n.css(d,"display"))));for(g=0;h>g;g++)d=a[g],d.style&&(b&&"none"!==d.style.display&&""!==d.style.display||(d.style.display=b?f[g]||"":"none"));return a}n.extend({cssHooks:{opacity:{get:function(a,b){if(b){var c=xb(a,"opacity");return""===c?"1":c}}}},cssNumber:{columnCount:!0,fillOpacity:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":"cssFloat"},style:function(a,b,c,d){if(a&&3!==a.nodeType&&8!==a.nodeType&&a.style){var e,f,g,h=n.camelCase(b),i=a.style;return b=n.cssProps[h]||(n.cssProps[h]=Fb(i,h)),g=n.cssHooks[b]||n.cssHooks[h],void 0===c?g&&"get"in g&&void 0!==(e=g.get(a,!1,d))?e:i[b]:(f=typeof c,"string"===f&&(e=Bb.exec(c))&&(c=(e[1]+1)*e[2]+parseFloat(n.css(a,b)),f="number"),null!=c&&c===c&&("number"!==f||n.cssNumber[h]||(c+="px"),k.clearCloneStyle||""!==c||0!==b.indexOf("background")||(i[b]="inherit"),g&&"set"in g&&void 0===(c=g.set(a,c,d))||(i[b]=c)),void 0)}},css:function(a,b,c,d){var e,f,g,h=n.camelCase(b);return b=n.cssProps[h]||(n.cssProps[h]=Fb(a.style,h)),g=n.cssHooks[b]||n.cssHooks[h],g&&"get"in g&&(e=g.get(a,!0,c)),void 0===e&&(e=xb(a,b,d)),"normal"===e&&b in Db&&(e=Db[b]),""===c||c?(f=parseFloat(e),c===!0||n.isNumeric(f)?f||0:e):e}}),n.each(["height","width"],function(a,b){n.cssHooks[b]={get:function(a,c,d){return c?zb.test(n.css(a,"display"))&&0===a.offsetWidth?n.swap(a,Cb,function(){return Ib(a,b,d)}):Ib(a,b,d):void 0},set:function(a,c,d){var e=d&&wb(a);return Gb(a,c,d?Hb(a,b,d,"border-box"===n.css(a,"boxSizing",!1,e),e):0)}}}),n.cssHooks.marginRight=yb(k.reliableMarginRight,function(a,b){return b?n.swap(a,{display:"inline-block"},xb,[a,"marginRight"]):void 0}),n.each({margin:"",padding:"",border:"Width"},function(a,b){n.cssHooks[a+b]={expand:function(c){for(var d=0,e={},f="string"==typeof c?c.split(" "):[c];4>d;d++)e[a+R[d]+b]=f[d]||f[d-2]||f[0];return e}},ub.test(a)||(n.cssHooks[a+b].set=Gb)}),n.fn.extend({css:function(a,b){return J(this,function(a,b,c){var d,e,f={},g=0;if(n.isArray(b)){for(d=wb(a),e=b.length;e>g;g++)f[b[g]]=n.css(a,b[g],!1,d);return f}return void 0!==c?n.style(a,b,c):n.css(a,b)},a,b,arguments.length>1)},show:function(){return Jb(this,!0)},hide:function(){return Jb(this)},toggle:function(a){return"boolean"==typeof a?a?this.show():this.hide():this.each(function(){S(this)?n(this).show():n(this).hide()})}});function Kb(a,b,c,d,e){return new Kb.prototype.init(a,b,c,d,e)}n.Tween=Kb,Kb.prototype={constructor:Kb,init:function(a,b,c,d,e,f){this.elem=a,this.prop=c,this.easing=e||"swing",this.options=b,this.start=this.now=this.cur(),this.end=d,this.unit=f||(n.cssNumber[c]?"":"px")},cur:function(){var a=Kb.propHooks[this.prop];return a&&a.get?a.get(this):Kb.propHooks._default.get(this)},run:function(a){var b,c=Kb.propHooks[this.prop];return this.pos=b=this.options.duration?n.easing[this.easing](a,this.options.duration*a,0,1,this.options.duration):a,this.now=(this.end-this.start)*b+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),c&&c.set?c.set(this):Kb.propHooks._default.set(this),this}},Kb.prototype.init.prototype=Kb.prototype,Kb.propHooks={_default:{get:function(a){var b;return null==a.elem[a.prop]||a.elem.style&&null!=a.elem.style[a.prop]?(b=n.css(a.elem,a.prop,""),b&&"auto"!==b?b:0):a.elem[a.prop]},set:function(a){n.fx.step[a.prop]?n.fx.step[a.prop](a):a.elem.style&&(null!=a.elem.style[n.cssProps[a.prop]]||n.cssHooks[a.prop])?n.style(a.elem,a.prop,a.now+a.unit):a.elem[a.prop]=a.now}}},Kb.propHooks.scrollTop=Kb.propHooks.scrollLeft={set:function(a){a.elem.nodeType&&a.elem.parentNode&&(a.elem[a.prop]=a.now)}},n.easing={linear:function(a){return a},swing:function(a){return.5-Math.cos(a*Math.PI)/2}},n.fx=Kb.prototype.init,n.fx.step={};var Lb,Mb,Nb=/^(?:toggle|show|hide)$/,Ob=new RegExp("^(?:([+-])=|)("+Q+")([a-z%]*)$","i"),Pb=/queueHooks$/,Qb=[Vb],Rb={"*":[function(a,b){var c=this.createTween(a,b),d=c.cur(),e=Ob.exec(b),f=e&&e[3]||(n.cssNumber[a]?"":"px"),g=(n.cssNumber[a]||"px"!==f&&+d)&&Ob.exec(n.css(c.elem,a)),h=1,i=20;if(g&&g[3]!==f){f=f||g[3],e=e||[],g=+d||1;do h=h||".5",g/=h,n.style(c.elem,a,g+f);while(h!==(h=c.cur()/d)&&1!==h&&--i)}return e&&(g=c.start=+g||+d||0,c.unit=f,c.end=e[1]?g+(e[1]+1)*e[2]:+e[2]),c}]};function Sb(){return setTimeout(function(){Lb=void 0}),Lb=n.now()}function Tb(a,b){var c,d=0,e={height:a};for(b=b?1:0;4>d;d+=2-b)c=R[d],e["margin"+c]=e["padding"+c]=a;return b&&(e.opacity=e.width=a),e}function Ub(a,b,c){for(var d,e=(Rb[b]||[]).concat(Rb["*"]),f=0,g=e.length;g>f;f++)if(d=e[f].call(c,b,a))return d}function Vb(a,b,c){var d,e,f,g,h,i,j,k,l=this,m={},o=a.style,p=a.nodeType&&S(a),q=L.get(a,"fxshow");c.queue||(h=n._queueHooks(a,"fx"),null==h.unqueued&&(h.unqueued=0,i=h.empty.fire,h.empty.fire=function(){h.unqueued||i()}),h.unqueued++,l.always(function(){l.always(function(){h.unqueued--,n.queue(a,"fx").length||h.empty.fire()})})),1===a.nodeType&&("height"in b||"width"in b)&&(c.overflow=[o.overflow,o.overflowX,o.overflowY],j=n.css(a,"display"),k="none"===j?L.get(a,"olddisplay")||tb(a.nodeName):j,"inline"===k&&"none"===n.css(a,"float")&&(o.display="inline-block")),c.overflow&&(o.overflow="hidden",l.always(function(){o.overflow=c.overflow[0],o.overflowX=c.overflow[1],o.overflowY=c.overflow[2]}));for(d in b)if(e=b[d],Nb.exec(e)){if(delete b[d],f=f||"toggle"===e,e===(p?"hide":"show")){if("show"!==e||!q||void 0===q[d])continue;p=!0}m[d]=q&&q[d]||n.style(a,d)}else j=void 0;if(n.isEmptyObject(m))"inline"===("none"===j?tb(a.nodeName):j)&&(o.display=j);else{q?"hidden"in q&&(p=q.hidden):q=L.access(a,"fxshow",{}),f&&(q.hidden=!p),p?n(a).show():l.done(function(){n(a).hide()}),l.done(function(){var b;L.remove(a,"fxshow");for(b in m)n.style(a,b,m[b])});for(d in m)g=Ub(p?q[d]:0,d,l),d in q||(q[d]=g.start,p&&(g.end=g.start,g.start="width"===d||"height"===d?1:0))}}function Wb(a,b){var c,d,e,f,g;for(c in a)if(d=n.camelCase(c),e=b[d],f=a[c],n.isArray(f)&&(e=f[1],f=a[c]=f[0]),c!==d&&(a[d]=f,delete a[c]),g=n.cssHooks[d],g&&"expand"in g){f=g.expand(f),delete a[d];for(c in f)c in a||(a[c]=f[c],b[c]=e)}else b[d]=e}function Xb(a,b,c){var d,e,f=0,g=Qb.length,h=n.Deferred().always(function(){delete i.elem}),i=function(){if(e)return!1;for(var b=Lb||Sb(),c=Math.max(0,j.startTime+j.duration-b),d=c/j.duration||0,f=1-d,g=0,i=j.tweens.length;i>g;g++)j.tweens[g].run(f);return h.notifyWith(a,[j,f,c]),1>f&&i?c:(h.resolveWith(a,[j]),!1)},j=h.promise({elem:a,props:n.extend({},b),opts:n.extend(!0,{specialEasing:{}},c),originalProperties:b,originalOptions:c,startTime:Lb||Sb(),duration:c.duration,tweens:[],createTween:function(b,c){var d=n.Tween(a,j.opts,b,c,j.opts.specialEasing[b]||j.opts.easing);return j.tweens.push(d),d},stop:function(b){var c=0,d=b?j.tweens.length:0;if(e)return this;for(e=!0;d>c;c++)j.tweens[c].run(1);return b?h.resolveWith(a,[j,b]):h.rejectWith(a,[j,b]),this}}),k=j.props;for(Wb(k,j.opts.specialEasing);g>f;f++)if(d=Qb[f].call(j,a,k,j.opts))return d;return n.map(k,Ub,j),n.isFunction(j.opts.start)&&j.opts.start.call(a,j),n.fx.timer(n.extend(i,{elem:a,anim:j,queue:j.opts.queue})),j.progress(j.opts.progress).done(j.opts.done,j.opts.complete).fail(j.opts.fail).always(j.opts.always)}n.Animation=n.extend(Xb,{tweener:function(a,b){n.isFunction(a)?(b=a,a=["*"]):a=a.split(" ");for(var c,d=0,e=a.length;e>d;d++)c=a[d],Rb[c]=Rb[c]||[],Rb[c].unshift(b)},prefilter:function(a,b){b?Qb.unshift(a):Qb.push(a)}}),n.speed=function(a,b,c){var d=a&&"object"==typeof a?n.extend({},a):{complete:c||!c&&b||n.isFunction(a)&&a,duration:a,easing:c&&b||b&&!n.isFunction(b)&&b};return d.duration=n.fx.off?0:"number"==typeof d.duration?d.duration:d.duration in n.fx.speeds?n.fx.speeds[d.duration]:n.fx.speeds._default,(null==d.queue||d.queue===!0)&&(d.queue="fx"),d.old=d.complete,d.complete=function(){n.isFunction(d.old)&&d.old.call(this),d.queue&&n.dequeue(this,d.queue)},d},n.fn.extend({fadeTo:function(a,b,c,d){return this.filter(S).css("opacity",0).show().end().animate({opacity:b},a,c,d)},animate:function(a,b,c,d){var e=n.isEmptyObject(a),f=n.speed(b,c,d),g=function(){var b=Xb(this,n.extend({},a),f);(e||L.get(this,"finish"))&&b.stop(!0)};return g.finish=g,e||f.queue===!1?this.each(g):this.queue(f.queue,g)},stop:function(a,b,c){var d=function(a){var b=a.stop;delete a.stop,b(c)};return"string"!=typeof a&&(c=b,b=a,a=void 0),b&&a!==!1&&this.queue(a||"fx",[]),this.each(function(){var b=!0,e=null!=a&&a+"queueHooks",f=n.timers,g=L.get(this);if(e)g[e]&&g[e].stop&&d(g[e]);else for(e in g)g[e]&&g[e].stop&&Pb.test(e)&&d(g[e]);for(e=f.length;e--;)f[e].elem!==this||null!=a&&f[e].queue!==a||(f[e].anim.stop(c),b=!1,f.splice(e,1));(b||!c)&&n.dequeue(this,a)})},finish:function(a){return a!==!1&&(a=a||"fx"),this.each(function(){var b,c=L.get(this),d=c[a+"queue"],e=c[a+"queueHooks"],f=n.timers,g=d?d.length:0;for(c.finish=!0,n.queue(this,a,[]),e&&e.stop&&e.stop.call(this,!0),b=f.length;b--;)f[b].elem===this&&f[b].queue===a&&(f[b].anim.stop(!0),f.splice(b,1));for(b=0;g>b;b++)d[b]&&d[b].finish&&d[b].finish.call(this);delete c.finish})}}),n.each(["toggle","show","hide"],function(a,b){var c=n.fn[b];n.fn[b]=function(a,d,e){return null==a||"boolean"==typeof a?c.apply(this,arguments):this.animate(Tb(b,!0),a,d,e)}}),n.each({slideDown:Tb("show"),slideUp:Tb("hide"),slideToggle:Tb("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(a,b){n.fn[a]=function(a,c,d){return this.animate(b,a,c,d)}}),n.timers=[],n.fx.tick=function(){var a,b=0,c=n.timers;for(Lb=n.now();b<c.length;b++)a=c[b],a()||c[b]!==a||c.splice(b--,1);c.length||n.fx.stop(),Lb=void 0},n.fx.timer=function(a){n.timers.push(a),a()?n.fx.start():n.timers.pop()},n.fx.interval=13,n.fx.start=function(){Mb||(Mb=setInterval(n.fx.tick,n.fx.interval))},n.fx.stop=function(){clearInterval(Mb),Mb=null},n.fx.speeds={slow:600,fast:200,_default:400},n.fn.delay=function(a,b){return a=n.fx?n.fx.speeds[a]||a:a,b=b||"fx",this.queue(b,function(b,c){var d=setTimeout(b,a);c.stop=function(){clearTimeout(d)}})},function(){var a=l.createElement("input"),b=l.createElement("select"),c=b.appendChild(l.createElement("option"));a.type="checkbox",k.checkOn=""!==a.value,k.optSelected=c.selected,b.disabled=!0,k.optDisabled=!c.disabled,a=l.createElement("input"),a.value="t",a.type="radio",k.radioValue="t"===a.value}();var Yb,Zb,$b=n.expr.attrHandle;n.fn.extend({attr:function(a,b){return J(this,n.attr,a,b,arguments.length>1)},removeAttr:function(a){return this.each(function(){n.removeAttr(this,a)})}}),n.extend({attr:function(a,b,c){var d,e,f=a.nodeType;if(a&&3!==f&&8!==f&&2!==f)return typeof a.getAttribute===U?n.prop(a,b,c):(1===f&&n.isXMLDoc(a)||(b=b.toLowerCase(),d=n.attrHooks[b]||(n.expr.match.bool.test(b)?Zb:Yb)),void 0===c?d&&"get"in d&&null!==(e=d.get(a,b))?e:(e=n.find.attr(a,b),null==e?void 0:e):null!==c?d&&"set"in d&&void 0!==(e=d.set(a,c,b))?e:(a.setAttribute(b,c+""),c):void n.removeAttr(a,b))
  4. },removeAttr:function(a,b){var c,d,e=0,f=b&&b.match(E);if(f&&1===a.nodeType)while(c=f[e++])d=n.propFix[c]||c,n.expr.match.bool.test(c)&&(a[d]=!1),a.removeAttribute(c)},attrHooks:{type:{set:function(a,b){if(!k.radioValue&&"radio"===b&&n.nodeName(a,"input")){var c=a.value;return a.setAttribute("type",b),c&&(a.value=c),b}}}}}),Zb={set:function(a,b,c){return b===!1?n.removeAttr(a,c):a.setAttribute(c,c),c}},n.each(n.expr.match.bool.source.match(/\w+/g),function(a,b){var c=$b[b]||n.find.attr;$b[b]=function(a,b,d){var e,f;return d||(f=$b[b],$b[b]=e,e=null!=c(a,b,d)?b.toLowerCase():null,$b[b]=f),e}});var _b=/^(?:input|select|textarea|button)$/i;n.fn.extend({prop:function(a,b){return J(this,n.prop,a,b,arguments.length>1)},removeProp:function(a){return this.each(function(){delete this[n.propFix[a]||a]})}}),n.extend({propFix:{"for":"htmlFor","class":"className"},prop:function(a,b,c){var d,e,f,g=a.nodeType;if(a&&3!==g&&8!==g&&2!==g)return f=1!==g||!n.isXMLDoc(a),f&&(b=n.propFix[b]||b,e=n.propHooks[b]),void 0!==c?e&&"set"in e&&void 0!==(d=e.set(a,c,b))?d:a[b]=c:e&&"get"in e&&null!==(d=e.get(a,b))?d:a[b]},propHooks:{tabIndex:{get:function(a){return a.hasAttribute("tabindex")||_b.test(a.nodeName)||a.href?a.tabIndex:-1}}}}),k.optSelected||(n.propHooks.selected={get:function(a){var b=a.parentNode;return b&&b.parentNode&&b.parentNode.selectedIndex,null}}),n.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){n.propFix[this.toLowerCase()]=this});var ac=/[\t\r\n\f]/g;n.fn.extend({addClass:function(a){var b,c,d,e,f,g,h="string"==typeof a&&a,i=0,j=this.length;if(n.isFunction(a))return this.each(function(b){n(this).addClass(a.call(this,b,this.className))});if(h)for(b=(a||"").match(E)||[];j>i;i++)if(c=this[i],d=1===c.nodeType&&(c.className?(" "+c.className+" ").replace(ac," "):" ")){f=0;while(e=b[f++])d.indexOf(" "+e+" ")<0&&(d+=e+" ");g=n.trim(d),c.className!==g&&(c.className=g)}return this},removeClass:function(a){var b,c,d,e,f,g,h=0===arguments.length||"string"==typeof a&&a,i=0,j=this.length;if(n.isFunction(a))return this.each(function(b){n(this).removeClass(a.call(this,b,this.className))});if(h)for(b=(a||"").match(E)||[];j>i;i++)if(c=this[i],d=1===c.nodeType&&(c.className?(" "+c.className+" ").replace(ac," "):"")){f=0;while(e=b[f++])while(d.indexOf(" "+e+" ")>=0)d=d.replace(" "+e+" "," ");g=a?n.trim(d):"",c.className!==g&&(c.className=g)}return this},toggleClass:function(a,b){var c=typeof a;return"boolean"==typeof b&&"string"===c?b?this.addClass(a):this.removeClass(a):this.each(n.isFunction(a)?function(c){n(this).toggleClass(a.call(this,c,this.className,b),b)}:function(){if("string"===c){var b,d=0,e=n(this),f=a.match(E)||[];while(b=f[d++])e.hasClass(b)?e.removeClass(b):e.addClass(b)}else(c===U||"boolean"===c)&&(this.className&&L.set(this,"__className__",this.className),this.className=this.className||a===!1?"":L.get(this,"__className__")||"")})},hasClass:function(a){for(var b=" "+a+" ",c=0,d=this.length;d>c;c++)if(1===this[c].nodeType&&(" "+this[c].className+" ").replace(ac," ").indexOf(b)>=0)return!0;return!1}});var bc=/\r/g;n.fn.extend({val:function(a){var b,c,d,e=this[0];{if(arguments.length)return d=n.isFunction(a),this.each(function(c){var e;1===this.nodeType&&(e=d?a.call(this,c,n(this).val()):a,null==e?e="":"number"==typeof e?e+="":n.isArray(e)&&(e=n.map(e,function(a){return null==a?"":a+""})),b=n.valHooks[this.type]||n.valHooks[this.nodeName.toLowerCase()],b&&"set"in b&&void 0!==b.set(this,e,"value")||(this.value=e))});if(e)return b=n.valHooks[e.type]||n.valHooks[e.nodeName.toLowerCase()],b&&"get"in b&&void 0!==(c=b.get(e,"value"))?c:(c=e.value,"string"==typeof c?c.replace(bc,""):null==c?"":c)}}}),n.extend({valHooks:{option:{get:function(a){var b=n.find.attr(a,"value");return null!=b?b:n.trim(n.text(a))}},select:{get:function(a){for(var b,c,d=a.options,e=a.selectedIndex,f="select-one"===a.type||0>e,g=f?null:[],h=f?e+1:d.length,i=0>e?h:f?e:0;h>i;i++)if(c=d[i],!(!c.selected&&i!==e||(k.optDisabled?c.disabled:null!==c.getAttribute("disabled"))||c.parentNode.disabled&&n.nodeName(c.parentNode,"optgroup"))){if(b=n(c).val(),f)return b;g.push(b)}return g},set:function(a,b){var c,d,e=a.options,f=n.makeArray(b),g=e.length;while(g--)d=e[g],(d.selected=n.inArray(d.value,f)>=0)&&(c=!0);return c||(a.selectedIndex=-1),f}}}}),n.each(["radio","checkbox"],function(){n.valHooks[this]={set:function(a,b){return n.isArray(b)?a.checked=n.inArray(n(a).val(),b)>=0:void 0}},k.checkOn||(n.valHooks[this].get=function(a){return null===a.getAttribute("value")?"on":a.value})}),n.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu".split(" "),function(a,b){n.fn[b]=function(a,c){return arguments.length>0?this.on(b,null,a,c):this.trigger(b)}}),n.fn.extend({hover:function(a,b){return this.mouseenter(a).mouseleave(b||a)},bind:function(a,b,c){return this.on(a,null,b,c)},unbind:function(a,b){return this.off(a,null,b)},delegate:function(a,b,c,d){return this.on(b,a,c,d)},undelegate:function(a,b,c){return 1===arguments.length?this.off(a,"**"):this.off(b,a||"**",c)}});var cc=n.now(),dc=/\?/;n.parseJSON=function(a){return JSON.parse(a+"")},n.parseXML=function(a){var b,c;if(!a||"string"!=typeof a)return null;try{c=new DOMParser,b=c.parseFromString(a,"text/xml")}catch(d){b=void 0}return(!b||b.getElementsByTagName("parsererror").length)&&n.error("Invalid XML: "+a),b};var ec,fc,gc=/#.*$/,hc=/([?&])_=[^&]*/,ic=/^(.*?):[ \t]*([^\r\n]*)$/gm,jc=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,kc=/^(?:GET|HEAD)$/,lc=/^\/\//,mc=/^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,nc={},oc={},pc="*/".concat("*");try{fc=location.href}catch(qc){fc=l.createElement("a"),fc.href="",fc=fc.href}ec=mc.exec(fc.toLowerCase())||[];function rc(a){return function(b,c){"string"!=typeof b&&(c=b,b="*");var d,e=0,f=b.toLowerCase().match(E)||[];if(n.isFunction(c))while(d=f[e++])"+"===d[0]?(d=d.slice(1)||"*",(a[d]=a[d]||[]).unshift(c)):(a[d]=a[d]||[]).push(c)}}function sc(a,b,c,d){var e={},f=a===oc;function g(h){var i;return e[h]=!0,n.each(a[h]||[],function(a,h){var j=h(b,c,d);return"string"!=typeof j||f||e[j]?f?!(i=j):void 0:(b.dataTypes.unshift(j),g(j),!1)}),i}return g(b.dataTypes[0])||!e["*"]&&g("*")}function tc(a,b){var c,d,e=n.ajaxSettings.flatOptions||{};for(c in b)void 0!==b[c]&&((e[c]?a:d||(d={}))[c]=b[c]);return d&&n.extend(!0,a,d),a}function uc(a,b,c){var d,e,f,g,h=a.contents,i=a.dataTypes;while("*"===i[0])i.shift(),void 0===d&&(d=a.mimeType||b.getResponseHeader("Content-Type"));if(d)for(e in h)if(h[e]&&h[e].test(d)){i.unshift(e);break}if(i[0]in c)f=i[0];else{for(e in c){if(!i[0]||a.converters[e+" "+i[0]]){f=e;break}g||(g=e)}f=f||g}return f?(f!==i[0]&&i.unshift(f),c[f]):void 0}function vc(a,b,c,d){var e,f,g,h,i,j={},k=a.dataTypes.slice();if(k[1])for(g in a.converters)j[g.toLowerCase()]=a.converters[g];f=k.shift();while(f)if(a.responseFields[f]&&(c[a.responseFields[f]]=b),!i&&d&&a.dataFilter&&(b=a.dataFilter(b,a.dataType)),i=f,f=k.shift())if("*"===f)f=i;else if("*"!==i&&i!==f){if(g=j[i+" "+f]||j["* "+f],!g)for(e in j)if(h=e.split(" "),h[1]===f&&(g=j[i+" "+h[0]]||j["* "+h[0]])){g===!0?g=j[e]:j[e]!==!0&&(f=h[0],k.unshift(h[1]));break}if(g!==!0)if(g&&a["throws"])b=g(b);else try{b=g(b)}catch(l){return{state:"parsererror",error:g?l:"No conversion from "+i+" to "+f}}}return{state:"success",data:b}}n.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:fc,type:"GET",isLocal:jc.test(ec[1]),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":pc,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":n.parseJSON,"text xml":n.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(a,b){return b?tc(tc(a,n.ajaxSettings),b):tc(n.ajaxSettings,a)},ajaxPrefilter:rc(nc),ajaxTransport:rc(oc),ajax:function(a,b){"object"==typeof a&&(b=a,a=void 0),b=b||{};var c,d,e,f,g,h,i,j,k=n.ajaxSetup({},b),l=k.context||k,m=k.context&&(l.nodeType||l.jquery)?n(l):n.event,o=n.Deferred(),p=n.Callbacks("once memory"),q=k.statusCode||{},r={},s={},t=0,u="canceled",v={readyState:0,getResponseHeader:function(a){var b;if(2===t){if(!f){f={};while(b=ic.exec(e))f[b[1].toLowerCase()]=b[2]}b=f[a.toLowerCase()]}return null==b?null:b},getAllResponseHeaders:function(){return 2===t?e:null},setRequestHeader:function(a,b){var c=a.toLowerCase();return t||(a=s[c]=s[c]||a,r[a]=b),this},overrideMimeType:function(a){return t||(k.mimeType=a),this},statusCode:function(a){var b;if(a)if(2>t)for(b in a)q[b]=[q[b],a[b]];else v.always(a[v.status]);return this},abort:function(a){var b=a||u;return c&&c.abort(b),x(0,b),this}};if(o.promise(v).complete=p.add,v.success=v.done,v.error=v.fail,k.url=((a||k.url||fc)+"").replace(gc,"").replace(lc,ec[1]+"//"),k.type=b.method||b.type||k.method||k.type,k.dataTypes=n.trim(k.dataType||"*").toLowerCase().match(E)||[""],null==k.crossDomain&&(h=mc.exec(k.url.toLowerCase()),k.crossDomain=!(!h||h[1]===ec[1]&&h[2]===ec[2]&&(h[3]||("http:"===h[1]?"80":"443"))===(ec[3]||("http:"===ec[1]?"80":"443")))),k.data&&k.processData&&"string"!=typeof k.data&&(k.data=n.param(k.data,k.traditional)),sc(nc,k,b,v),2===t)return v;i=k.global,i&&0===n.active++&&n.event.trigger("ajaxStart"),k.type=k.type.toUpperCase(),k.hasContent=!kc.test(k.type),d=k.url,k.hasContent||(k.data&&(d=k.url+=(dc.test(d)?"&":"?")+k.data,delete k.data),k.cache===!1&&(k.url=hc.test(d)?d.replace(hc,"$1_="+cc++):d+(dc.test(d)?"&":"?")+"_="+cc++)),k.ifModified&&(n.lastModified[d]&&v.setRequestHeader("If-Modified-Since",n.lastModified[d]),n.etag[d]&&v.setRequestHeader("If-None-Match",n.etag[d])),(k.data&&k.hasContent&&k.contentType!==!1||b.contentType)&&v.setRequestHeader("Content-Type",k.contentType),v.setRequestHeader("Accept",k.dataTypes[0]&&k.accepts[k.dataTypes[0]]?k.accepts[k.dataTypes[0]]+("*"!==k.dataTypes[0]?", "+pc+"; q=0.01":""):k.accepts["*"]);for(j in k.headers)v.setRequestHeader(j,k.headers[j]);if(k.beforeSend&&(k.beforeSend.call(l,v,k)===!1||2===t))return v.abort();u="abort";for(j in{success:1,error:1,complete:1})v[j](k[j]);if(c=sc(oc,k,b,v)){v.readyState=1,i&&m.trigger("ajaxSend",[v,k]),k.async&&k.timeout>0&&(g=setTimeout(function(){v.abort("timeout")},k.timeout));try{t=1,c.send(r,x)}catch(w){if(!(2>t))throw w;x(-1,w)}}else x(-1,"No Transport");function x(a,b,f,h){var j,r,s,u,w,x=b;2!==t&&(t=2,g&&clearTimeout(g),c=void 0,e=h||"",v.readyState=a>0?4:0,j=a>=200&&300>a||304===a,f&&(u=uc(k,v,f)),u=vc(k,u,v,j),j?(k.ifModified&&(w=v.getResponseHeader("Last-Modified"),w&&(n.lastModified[d]=w),w=v.getResponseHeader("etag"),w&&(n.etag[d]=w)),204===a||"HEAD"===k.type?x="nocontent":304===a?x="notmodified":(x=u.state,r=u.data,s=u.error,j=!s)):(s=x,(a||!x)&&(x="error",0>a&&(a=0))),v.status=a,v.statusText=(b||x)+"",j?o.resolveWith(l,[r,x,v]):o.rejectWith(l,[v,x,s]),v.statusCode(q),q=void 0,i&&m.trigger(j?"ajaxSuccess":"ajaxError",[v,k,j?r:s]),p.fireWith(l,[v,x]),i&&(m.trigger("ajaxComplete",[v,k]),--n.active||n.event.trigger("ajaxStop")))}return v},getJSON:function(a,b,c){return n.get(a,b,c,"json")},getScript:function(a,b){return n.get(a,void 0,b,"script")}}),n.each(["get","post"],function(a,b){n[b]=function(a,c,d,e){return n.isFunction(c)&&(e=e||d,d=c,c=void 0),n.ajax({url:a,type:b,dataType:e,data:c,success:d})}}),n.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(a,b){n.fn[b]=function(a){return this.on(b,a)}}),n._evalUrl=function(a){return n.ajax({url:a,type:"GET",dataType:"script",async:!1,global:!1,"throws":!0})},n.fn.extend({wrapAll:function(a){var b;return n.isFunction(a)?this.each(function(b){n(this).wrapAll(a.call(this,b))}):(this[0]&&(b=n(a,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstElementChild)a=a.firstElementChild;return a}).append(this)),this)},wrapInner:function(a){return this.each(n.isFunction(a)?function(b){n(this).wrapInner(a.call(this,b))}:function(){var b=n(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=n.isFunction(a);return this.each(function(c){n(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(){return this.parent().each(function(){n.nodeName(this,"body")||n(this).replaceWith(this.childNodes)}).end()}}),n.expr.filters.hidden=function(a){return a.offsetWidth<=0&&a.offsetHeight<=0},n.expr.filters.visible=function(a){return!n.expr.filters.hidden(a)};var wc=/%20/g,xc=/\[\]$/,yc=/\r?\n/g,zc=/^(?:submit|button|image|reset|file)$/i,Ac=/^(?:input|select|textarea|keygen)/i;function Bc(a,b,c,d){var e;if(n.isArray(b))n.each(b,function(b,e){c||xc.test(a)?d(a,e):Bc(a+"["+("object"==typeof e?b:"")+"]",e,c,d)});else if(c||"object"!==n.type(b))d(a,b);else for(e in b)Bc(a+"["+e+"]",b[e],c,d)}n.param=function(a,b){var c,d=[],e=function(a,b){b=n.isFunction(b)?b():null==b?"":b,d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};if(void 0===b&&(b=n.ajaxSettings&&n.ajaxSettings.traditional),n.isArray(a)||a.jquery&&!n.isPlainObject(a))n.each(a,function(){e(this.name,this.value)});else for(c in a)Bc(c,a[c],b,e);return d.join("&").replace(wc,"+")},n.fn.extend({serialize:function(){return n.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var a=n.prop(this,"elements");return a?n.makeArray(a):this}).filter(function(){var a=this.type;return this.name&&!n(this).is(":disabled")&&Ac.test(this.nodeName)&&!zc.test(a)&&(this.checked||!T.test(a))}).map(function(a,b){var c=n(this).val();return null==c?null:n.isArray(c)?n.map(c,function(a){return{name:b.name,value:a.replace(yc,"\r\n")}}):{name:b.name,value:c.replace(yc,"\r\n")}}).get()}}),n.ajaxSettings.xhr=function(){try{return new XMLHttpRequest}catch(a){}};var Cc=0,Dc={},Ec={0:200,1223:204},Fc=n.ajaxSettings.xhr();a.ActiveXObject&&n(a).on("unload",function(){for(var a in Dc)Dc[a]()}),k.cors=!!Fc&&"withCredentials"in Fc,k.ajax=Fc=!!Fc,n.ajaxTransport(function(a){var b;return k.cors||Fc&&!a.crossDomain?{send:function(c,d){var e,f=a.xhr(),g=++Cc;if(f.open(a.type,a.url,a.async,a.username,a.password),a.xhrFields)for(e in a.xhrFields)f[e]=a.xhrFields[e];a.mimeType&&f.overrideMimeType&&f.overrideMimeType(a.mimeType),a.crossDomain||c["X-Requested-With"]||(c["X-Requested-With"]="XMLHttpRequest");for(e in c)f.setRequestHeader(e,c[e]);b=function(a){return function(){b&&(delete Dc[g],b=f.onload=f.onerror=null,"abort"===a?f.abort():"error"===a?d(f.status,f.statusText):d(Ec[f.status]||f.status,f.statusText,"string"==typeof f.responseText?{text:f.responseText}:void 0,f.getAllResponseHeaders()))}},f.onload=b(),f.onerror=b("error"),b=Dc[g]=b("abort");try{f.send(a.hasContent&&a.data||null)}catch(h){if(b)throw h}},abort:function(){b&&b()}}:void 0}),n.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/(?:java|ecma)script/},converters:{"text script":function(a){return n.globalEval(a),a}}}),n.ajaxPrefilter("script",function(a){void 0===a.cache&&(a.cache=!1),a.crossDomain&&(a.type="GET")}),n.ajaxTransport("script",function(a){if(a.crossDomain){var b,c;return{send:function(d,e){b=n("<script>").prop({async:!0,charset:a.scriptCharset,src:a.url}).on("load error",c=function(a){b.remove(),c=null,a&&e("error"===a.type?404:200,a.type)}),l.head.appendChild(b[0])},abort:function(){c&&c()}}}});var Gc=[],Hc=/(=)\?(?=&|$)|\?\?/;n.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var a=Gc.pop()||n.expando+"_"+cc++;return this[a]=!0,a}}),n.ajaxPrefilter("json jsonp",function(b,c,d){var e,f,g,h=b.jsonp!==!1&&(Hc.test(b.url)?"url":"string"==typeof b.data&&!(b.contentType||"").indexOf("application/x-www-form-urlencoded")&&Hc.test(b.data)&&"data");return h||"jsonp"===b.dataTypes[0]?(e=b.jsonpCallback=n.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,h?b[h]=b[h].replace(Hc,"$1"+e):b.jsonp!==!1&&(b.url+=(dc.test(b.url)?"&":"?")+b.jsonp+"="+e),b.converters["script json"]=function(){return g||n.error(e+" was not called"),g[0]},b.dataTypes[0]="json",f=a[e],a[e]=function(){g=arguments},d.always(function(){a[e]=f,b[e]&&(b.jsonpCallback=c.jsonpCallback,Gc.push(e)),g&&n.isFunction(f)&&f(g[0]),g=f=void 0}),"script"):void 0}),n.parseHTML=function(a,b,c){if(!a||"string"!=typeof a)return null;"boolean"==typeof b&&(c=b,b=!1),b=b||l;var d=v.exec(a),e=!c&&[];return d?[b.createElement(d[1])]:(d=n.buildFragment([a],b,e),e&&e.length&&n(e).remove(),n.merge([],d.childNodes))};var Ic=n.fn.load;n.fn.load=function(a,b,c){if("string"!=typeof a&&Ic)return Ic.apply(this,arguments);var d,e,f,g=this,h=a.indexOf(" ");return h>=0&&(d=n.trim(a.slice(h)),a=a.slice(0,h)),n.isFunction(b)?(c=b,b=void 0):b&&"object"==typeof b&&(e="POST"),g.length>0&&n.ajax({url:a,type:e,dataType:"html",data:b}).done(function(a){f=arguments,g.html(d?n("<div>").append(n.parseHTML(a)).find(d):a)}).complete(c&&function(a,b){g.each(c,f||[a.responseText,b,a])}),this},n.expr.filters.animated=function(a){return n.grep(n.timers,function(b){return a===b.elem}).length};var Jc=a.document.documentElement;function Kc(a){return n.isWindow(a)?a:9===a.nodeType&&a.defaultView}n.offset={setOffset:function(a,b,c){var d,e,f,g,h,i,j,k=n.css(a,"position"),l=n(a),m={};"static"===k&&(a.style.position="relative"),h=l.offset(),f=n.css(a,"top"),i=n.css(a,"left"),j=("absolute"===k||"fixed"===k)&&(f+i).indexOf("auto")>-1,j?(d=l.position(),g=d.top,e=d.left):(g=parseFloat(f)||0,e=parseFloat(i)||0),n.isFunction(b)&&(b=b.call(a,c,h)),null!=b.top&&(m.top=b.top-h.top+g),null!=b.left&&(m.left=b.left-h.left+e),"using"in b?b.using.call(a,m):l.css(m)}},n.fn.extend({offset:function(a){if(arguments.length)return void 0===a?this:this.each(function(b){n.offset.setOffset(this,a,b)});var b,c,d=this[0],e={top:0,left:0},f=d&&d.ownerDocument;if(f)return b=f.documentElement,n.contains(b,d)?(typeof d.getBoundingClientRect!==U&&(e=d.getBoundingClientRect()),c=Kc(f),{top:e.top+c.pageYOffset-b.clientTop,left:e.left+c.pageXOffset-b.clientLeft}):e},position:function(){if(this[0]){var a,b,c=this[0],d={top:0,left:0};return"fixed"===n.css(c,"position")?b=c.getBoundingClientRect():(a=this.offsetParent(),b=this.offset(),n.nodeName(a[0],"html")||(d=a.offset()),d.top+=n.css(a[0],"borderTopWidth",!0),d.left+=n.css(a[0],"borderLeftWidth",!0)),{top:b.top-d.top-n.css(c,"marginTop",!0),left:b.left-d.left-n.css(c,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||Jc;while(a&&!n.nodeName(a,"html")&&"static"===n.css(a,"position"))a=a.offsetParent;return a||Jc})}}),n.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(b,c){var d="pageYOffset"===c;n.fn[b]=function(e){return J(this,function(b,e,f){var g=Kc(b);return void 0===f?g?g[c]:b[e]:void(g?g.scrollTo(d?a.pageXOffset:f,d?f:a.pageYOffset):b[e]=f)},b,e,arguments.length,null)}}),n.each(["top","left"],function(a,b){n.cssHooks[b]=yb(k.pixelPosition,function(a,c){return c?(c=xb(a,b),vb.test(c)?n(a).position()[b]+"px":c):void 0})}),n.each({Height:"height",Width:"width"},function(a,b){n.each({padding:"inner"+a,content:b,"":"outer"+a},function(c,d){n.fn[d]=function(d,e){var f=arguments.length&&(c||"boolean"!=typeof d),g=c||(d===!0||e===!0?"margin":"border");return J(this,function(b,c,d){var e;return n.isWindow(b)?b.document.documentElement["client"+a]:9===b.nodeType?(e=b.documentElement,Math.max(b.body["scroll"+a],e["scroll"+a],b.body["offset"+a],e["offset"+a],e["client"+a])):void 0===d?n.css(b,c,g):n.style(b,c,d,g)},b,f?d:void 0,f,null)}})}),n.fn.size=function(){return this.length},n.fn.andSelf=n.fn.addBack,"function"==typeof define&&define.amd&&define("jquery",[],function(){return n});var Lc=a.jQuery,Mc=a.$;return n.noConflict=function(b){return a.$===n&&(a.$=Mc),b&&a.jQuery===n&&(a.jQuery=Lc),n},typeof b===U&&(a.jQuery=a.$=n),n});
  5. //# sourceMappingURL=jquery.min.map
  6. !function(a){"use strict";function b(a,b){var c=(65535&a)+(65535&b),d=(a>>16)+(b>>16)+(c>>16);return d<<16|65535&c}function c(a,b){return a<<b|a>>>32-b}function d(a,d,e,f,g,h){return b(c(b(b(d,a),b(f,h)),g),e)}function e(a,b,c,e,f,g,h){return d(b&c|~b&e,a,b,f,g,h)}function f(a,b,c,e,f,g,h){return d(b&e|c&~e,a,b,f,g,h)}function g(a,b,c,e,f,g,h){return d(b^c^e,a,b,f,g,h)}function h(a,b,c,e,f,g,h){return d(c^(b|~e),a,b,f,g,h)}function i(a,c){a[c>>5]|=128<<c%32,a[(c+64>>>9<<4)+14]=c;var d,i,j,k,l,m=1732584193,n=-271733879,o=-1732584194,p=271733878;for(d=0;d<a.length;d+=16)i=m,j=n,k=o,l=p,m=e(m,n,o,p,a[d],7,-680876936),p=e(p,m,n,o,a[d+1],12,-389564586),o=e(o,p,m,n,a[d+2],17,606105819),n=e(n,o,p,m,a[d+3],22,-1044525330),m=e(m,n,o,p,a[d+4],7,-176418897),p=e(p,m,n,o,a[d+5],12,1200080426),o=e(o,p,m,n,a[d+6],17,-1473231341),n=e(n,o,p,m,a[d+7],22,-45705983),m=e(m,n,o,p,a[d+8],7,1770035416),p=e(p,m,n,o,a[d+9],12,-1958414417),o=e(o,p,m,n,a[d+10],17,-42063),n=e(n,o,p,m,a[d+11],22,-1990404162),m=e(m,n,o,p,a[d+12],7,1804603682),p=e(p,m,n,o,a[d+13],12,-40341101),o=e(o,p,m,n,a[d+14],17,-1502002290),n=e(n,o,p,m,a[d+15],22,1236535329),m=f(m,n,o,p,a[d+1],5,-165796510),p=f(p,m,n,o,a[d+6],9,-1069501632),o=f(o,p,m,n,a[d+11],14,643717713),n=f(n,o,p,m,a[d],20,-373897302),m=f(m,n,o,p,a[d+5],5,-701558691),p=f(p,m,n,o,a[d+10],9,38016083),o=f(o,p,m,n,a[d+15],14,-660478335),n=f(n,o,p,m,a[d+4],20,-405537848),m=f(m,n,o,p,a[d+9],5,568446438),p=f(p,m,n,o,a[d+14],9,-1019803690),o=f(o,p,m,n,a[d+3],14,-187363961),n=f(n,o,p,m,a[d+8],20,1163531501),m=f(m,n,o,p,a[d+13],5,-1444681467),p=f(p,m,n,o,a[d+2],9,-51403784),o=f(o,p,m,n,a[d+7],14,1735328473),n=f(n,o,p,m,a[d+12],20,-1926607734),m=g(m,n,o,p,a[d+5],4,-378558),p=g(p,m,n,o,a[d+8],11,-2022574463),o=g(o,p,m,n,a[d+11],16,1839030562),n=g(n,o,p,m,a[d+14],23,-35309556),m=g(m,n,o,p,a[d+1],4,-1530992060),p=g(p,m,n,o,a[d+4],11,1272893353),o=g(o,p,m,n,a[d+7],16,-155497632),n=g(n,o,p,m,a[d+10],23,-1094730640),m=g(m,n,o,p,a[d+13],4,681279174),p=g(p,m,n,o,a[d],11,-358537222),o=g(o,p,m,n,a[d+3],16,-722521979),n=g(n,o,p,m,a[d+6],23,76029189),m=g(m,n,o,p,a[d+9],4,-640364487),p=g(p,m,n,o,a[d+12],11,-421815835),o=g(o,p,m,n,a[d+15],16,530742520),n=g(n,o,p,m,a[d+2],23,-995338651),m=h(m,n,o,p,a[d],6,-198630844),p=h(p,m,n,o,a[d+7],10,1126891415),o=h(o,p,m,n,a[d+14],15,-1416354905),n=h(n,o,p,m,a[d+5],21,-57434055),m=h(m,n,o,p,a[d+12],6,1700485571),p=h(p,m,n,o,a[d+3],10,-1894986606),o=h(o,p,m,n,a[d+10],15,-1051523),n=h(n,o,p,m,a[d+1],21,-2054922799),m=h(m,n,o,p,a[d+8],6,1873313359),p=h(p,m,n,o,a[d+15],10,-30611744),o=h(o,p,m,n,a[d+6],15,-1560198380),n=h(n,o,p,m,a[d+13],21,1309151649),m=h(m,n,o,p,a[d+4],6,-145523070),p=h(p,m,n,o,a[d+11],10,-1120210379),o=h(o,p,m,n,a[d+2],15,718787259),n=h(n,o,p,m,a[d+9],21,-343485551),m=b(m,i),n=b(n,j),o=b(o,k),p=b(p,l);return[m,n,o,p]}function j(a){var b,c="";for(b=0;b<32*a.length;b+=8)c+=String.fromCharCode(a[b>>5]>>>b%32&255);return c}function k(a){var b,c=[];for(c[(a.length>>2)-1]=void 0,b=0;b<c.length;b+=1)c[b]=0;for(b=0;b<8*a.length;b+=8)c[b>>5]|=(255&a.charCodeAt(b/8))<<b%32;return c}function l(a){return j(i(k(a),8*a.length))}function m(a,b){var c,d,e=k(a),f=[],g=[];for(f[15]=g[15]=void 0,e.length>16&&(e=i(e,8*a.length)),c=0;16>c;c+=1)f[c]=909522486^e[c],g[c]=1549556828^e[c];return d=i(f.concat(k(b)),512+8*b.length),j(i(g.concat(d),640))}function n(a){var b,c,d="0123456789abcdef",e="";for(c=0;c<a.length;c+=1)b=a.charCodeAt(c),e+=d.charAt(b>>>4&15)+d.charAt(15&b);return e}function o(a){return unescape(encodeURIComponent(a))}function p(a){return l(o(a))}function q(a){return n(p(a))}function r(a,b){return m(o(a),o(b))}function s(a,b){return n(r(a,b))}function t(a,b,c){return b?c?r(b,a):s(b,a):c?p(a):q(a)}"function"==typeof define&&define.amd?define(function(){return t}):a.md5=t}(this);
  7. /* mousetrap v1.4.6 craig.is/killing/mice */
  8. (function(J,r,f){function s(a,b,d){a.addEventListener?a.addEventListener(b,d,!1):a.attachEvent("on"+b,d)}function A(a){if("keypress"==a.type){var b=String.fromCharCode(a.which);a.shiftKey||(b=b.toLowerCase());return b}return h[a.which]?h[a.which]:B[a.which]?B[a.which]:String.fromCharCode(a.which).toLowerCase()}function t(a){a=a||{};var b=!1,d;for(d in n)a[d]?b=!0:n[d]=0;b||(u=!1)}function C(a,b,d,c,e,v){var g,k,f=[],h=d.type;if(!l[a])return[];"keyup"==h&&w(a)&&(b=[a]);for(g=0;g<l[a].length;++g)if(k=
  9. l[a][g],!(!c&&k.seq&&n[k.seq]!=k.level||h!=k.action||("keypress"!=h||d.metaKey||d.ctrlKey)&&b.sort().join(",")!==k.modifiers.sort().join(","))){var m=c&&k.seq==c&&k.level==v;(!c&&k.combo==e||m)&&l[a].splice(g,1);f.push(k)}return f}function K(a){var b=[];a.shiftKey&&b.push("shift");a.altKey&&b.push("alt");a.ctrlKey&&b.push("ctrl");a.metaKey&&b.push("meta");return b}function x(a,b,d,c){m.stopCallback(b,b.target||b.srcElement,d,c)||!1!==a(b,d)||(b.preventDefault?b.preventDefault():b.returnValue=!1,b.stopPropagation?
  10. b.stopPropagation():b.cancelBubble=!0)}function y(a){"number"!==typeof a.which&&(a.which=a.keyCode);var b=A(a);b&&("keyup"==a.type&&z===b?z=!1:m.handleKey(b,K(a),a))}function w(a){return"shift"==a||"ctrl"==a||"alt"==a||"meta"==a}function L(a,b,d,c){function e(b){return function(){u=b;++n[a];clearTimeout(D);D=setTimeout(t,1E3)}}function v(b){x(d,b,a);"keyup"!==c&&(z=A(b));setTimeout(t,10)}for(var g=n[a]=0;g<b.length;++g){var f=g+1===b.length?v:e(c||E(b[g+1]).action);F(b[g],f,c,a,g)}}function E(a,b){var d,
  11. c,e,f=[];d="+"===a?["+"]:a.split("+");for(e=0;e<d.length;++e)c=d[e],G[c]&&(c=G[c]),b&&"keypress"!=b&&H[c]&&(c=H[c],f.push("shift")),w(c)&&f.push(c);d=c;e=b;if(!e){if(!p){p={};for(var g in h)95<g&&112>g||h.hasOwnProperty(g)&&(p[h[g]]=g)}e=p[d]?"keydown":"keypress"}"keypress"==e&&f.length&&(e="keydown");return{key:c,modifiers:f,action:e}}function F(a,b,d,c,e){q[a+":"+d]=b;a=a.replace(/\s+/g," ");var f=a.split(" ");1<f.length?L(a,f,b,d):(d=E(a,d),l[d.key]=l[d.key]||[],C(d.key,d.modifiers,{type:d.action},
  12. c,a,e),l[d.key][c?"unshift":"push"]({callback:b,modifiers:d.modifiers,action:d.action,seq:c,level:e,combo:a}))}var h={8:"backspace",9:"tab",13:"enter",16:"shift",17:"ctrl",18:"alt",20:"capslock",27:"esc",32:"space",33:"pageup",34:"pagedown",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",45:"ins",46:"del",91:"meta",93:"meta",224:"meta"},B={106:"*",107:"+",109:"-",110:".",111:"/",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},H={"~":"`","!":"1",
  13. "@":"2","#":"3",$:"4","%":"5","^":"6","&":"7","*":"8","(":"9",")":"0",_:"-","+":"=",":":";",'"':"'","<":",",">":".","?":"/","|":"\\"},G={option:"alt",command:"meta","return":"enter",escape:"esc",mod:/Mac|iPod|iPhone|iPad/.test(navigator.platform)?"meta":"ctrl"},p,l={},q={},n={},D,z=!1,I=!1,u=!1;for(f=1;20>f;++f)h[111+f]="f"+f;for(f=0;9>=f;++f)h[f+96]=f;s(r,"keypress",y);s(r,"keydown",y);s(r,"keyup",y);var m={bind:function(a,b,d){a=a instanceof Array?a:[a];for(var c=0;c<a.length;++c)F(a[c],b,d);return this},
  14. unbind:function(a,b){return m.bind(a,function(){},b)},trigger:function(a,b){if(q[a+":"+b])q[a+":"+b]({},a);return this},reset:function(){l={};q={};return this},stopCallback:function(a,b){return-1<(" "+b.className+" ").indexOf(" mousetrap ")?!1:"INPUT"==b.tagName||"SELECT"==b.tagName||"TEXTAREA"==b.tagName||b.isContentEditable},handleKey:function(a,b,d){var c=C(a,b,d),e;b={};var f=0,g=!1;for(e=0;e<c.length;++e)c[e].seq&&(f=Math.max(f,c[e].level));for(e=0;e<c.length;++e)c[e].seq?c[e].level==f&&(g=!0,
  15. b[c[e].seq]=1,x(c[e].callback,d,c[e].combo,c[e].seq)):g||x(c[e].callback,d,c[e].combo);c="keypress"==d.type&&I;d.type!=u||w(a)||c||t(b);I=g&&"keydown"==d.type}};J.Mousetrap=m;"function"===typeof define&&define.amd&&define(m)})(window,document);
  16. Mousetrap=function(a){var d={},e=a.stopCallback;a.stopCallback=function(b,c,a){return d[a]?!1:e(b,c,a)};a.bindGlobal=function(b,c,e){a.bind(b,c,e);if(b instanceof Array)for(c=0;c<b.length;c++)d[b[c]]=!0;else d[b]=!0};return a}(Mousetrap);
  17. /* ToolTips */
  18. (function(c){function b(e,d){return(typeof e=="function")?(e.call(d)):e}function a(e,d){this.$element=c(e);this.options=d;this.enabled=true;this.fixTitle()}a.prototype={show:function(){var g=this.getTitle();if(g&&this.enabled){var f=this.tip();f.find(".tipsy-inner")[this.options.html?"html":"text"](g);f[0].className="tipsy";f.remove().css({top:0,left:0,visibility:"hidden",display:"block"}).prependTo(document.body);var j=c.extend({},this.$element.offset(),{width:this.$element[0].offsetWidth,height:this.$element[0].offsetHeight});
  19. var d=f[0].offsetWidth,i=f[0].offsetHeight,h=b(this.options.gravity,this.$element[0]);var e;switch(h.charAt(0)){case"n":e={top:j.top+j.height+this.options.offset,left:j.left+j.width/2-d/2};break;case"s":e={top:j.top-i-this.options.offset,left:j.left+j.width/2-d/2};break;case"e":e={top:j.top+j.height/2-i/2,left:j.left-d-this.options.offset};break;case"w":e={top:j.top+j.height/2-i/2,left:j.left+j.width+this.options.offset};break}if(h.length==2){if(h.charAt(1)=="w"){e.left=j.left+j.width/2-15}else{e.left=j.left+j.width/2-d+15
  20. }}f.css(e).addClass("tipsy-"+h);f.find(".tipsy-arrow")[0].className="tipsy-arrow tipsy-arrow-"+h.charAt(0);if(this.options.className){f.addClass(b(this.options.className,this.$element[0]))}if(this.options.fade){f.stop().css({opacity:0,display:"block",visibility:"visible"}).animate({opacity:this.options.opacity})}else{f.css({visibility:"visible",opacity:this.options.opacity})}}},hide:function(){if(this.options.fade){this.tip().stop().fadeOut(function(){c(this).remove()})}else{this.tip().remove()}},fixTitle:function(){var d=this.$element;
  21. if(d.attr("title")||typeof(d.attr("original-title"))!="string"){d.attr("original-title",d.attr("title")||"").removeAttr("title")}},getTitle:function(){var f,d=this.$element,e=this.options;this.fixTitle();var f,e=this.options;if(typeof e.title=="string"){f=d.attr(e.title=="title"?"original-title":e.title)}else{if(typeof e.title=="function"){f=e.title.call(d[0])}}f=(""+f).replace(/(^\s*|\s*$)/,"");return f||e.fallback},tip:function(){if(!this.$tip){this.$tip=c('<div class="tipsy"></div>').html('<div class="tipsy-arrow"></div><div class="tipsy-inner"></div>')
  22. }return this.$tip},validate:function(){if(!this.$element[0].parentNode){this.hide();this.$element=null;this.options=null}},enable:function(){this.enabled=true},disable:function(){this.enabled=false},toggleEnabled:function(){this.enabled=!this.enabled}};c.fn.tipsy=function(h){if(h===true){return this.data("tipsy")}else{if(typeof h=="string"){var j=this.data("tipsy");if(j){j[h]()}return this}}h=c.extend({},c.fn.tipsy.defaults,h);function g(l){var m=c.data(l,"tipsy");if(!m){m=new a(l,c.fn.tipsy.elementOptions(l,h));
  23. c.data(l,"tipsy",m)}return m}function k(){var l=g(this);l.hoverState="in";if(h.delayIn==0){l.show()}else{l.fixTitle();setTimeout(function(){if(l.hoverState=="in"){l.show()}},h.delayIn)}}function f(){var l=g(this);l.hoverState="out";if(h.delayOut==0){l.hide()}else{setTimeout(function(){if(l.hoverState=="out"){l.hide()}},h.delayOut)}}if(!h.live){this.each(function(){g(this)})}if(h.trigger!="manual"){var d=h.live?"live":"bind",i=h.trigger=="hover"?"mouseenter":"focus",e=h.trigger=="hover"?"mouseleave":"blur";
  24. this[d](i,k)[d](e,f)}return this};c.fn.tipsy.defaults={className:null,delayIn:0,delayOut:0,fade:false,fallback:"",gravity:"n",html:false,live:false,offset:0,opacity:0.8,title:"title",trigger:"hover"};c.fn.tipsy.elementOptions=function(e,d){return c.metadata?c.extend({},d,c(e).metadata()):d};c.fn.tipsy.autoNS=function(){return c(this).offset().top>(c(document).scrollTop()+c(window).height()/2)?"s":"n"};c.fn.tipsy.autoWE=function(){return c(this).offset().left>(c(document).scrollLeft()+c(window).width()/2)?"e":"w"
  25. };c.fn.tipsy.autoBounds=function(e,d){return function(){var f={ns:d[0],ew:(d.length>1?d[1]:false)},i=c(document).scrollTop()+e,g=c(document).scrollLeft()+e,h=c(this);if(h.offset().top<i){f.ns="n"}if(h.offset().left<g){f.ew="w"}if(c(window).width()+c(document).scrollLeft()-h.offset().left<e){f.ew="e"}if(c(window).height()+c(document).scrollTop()-h.offset().top<e){f.ns="s"}return f.ns+(f.ew?f.ew:"")}}})(jQuery);
  26. /* Browser Detection */
  27. var BrowserDetect={init:function(){this.browser=this.searchString(this.dataBrowser)||"An unknown browser";this.version=this.searchVersion(navigator.userAgent)||this.searchVersion(navigator.appVersion)||"an unknown version";this.OS=this.searchString(this.dataOS)||"an unknown OS"},searchString:function(d){for(var a=0;a<d.length;a++){var b=d[a].string;var c=d[a].prop;this.versionSearchString=d[a].versionSearch||d[a].identity;if(b){if(b.indexOf(d[a].subString)!=-1){return d[a].identity}}else{if(c){return d[a].identity}}}},searchVersion:function(b){var a=b.indexOf(this.versionSearchString);if(a==-1){return}return parseFloat(b.substring(a+this.versionSearchString.length+1))},dataBrowser:[{string:navigator.userAgent,subString:"Chrome",identity:"Chrome"},{string:navigator.userAgent,subString:"OmniWeb",versionSearch:"OmniWeb/",identity:"OmniWeb"},{string:navigator.vendor,subString:"Apple",identity:"Safari",versionSearch:"Version"},{prop:window.opera,identity:"Opera"},{string:navigator.vendor,subString:"iCab",identity:"iCab"},{string:navigator.vendor,subString:"KDE",identity:"Konqueror"},{string:navigator.userAgent,subString:"Firefox",identity:"Firefox"},{string:navigator.vendor,subString:"Camino",identity:"Camino"},{string:navigator.userAgent,subString:"Netscape",identity:"Netscape"},{string:navigator.userAgent,subString:"MSIE",identity:"Explorer",versionSearch:"MSIE"},{string:navigator.userAgent,subString:"Gecko",identity:"Mozilla",versionSearch:"rv"},{string:navigator.userAgent,subString:"Mozilla",identity:"Netscape",versionSearch:"Mozilla"}],dataOS:[{string:navigator.platform,subString:"Win",identity:"Windows"},{string:navigator.platform,subString:"Mac",identity:"Mac"},{string:navigator.userAgent,subString:"iPhone",identity:"iPhone/iPod"},{string:navigator.platform,subString:"Linux",identity:"Linux"}]};BrowserDetect.init();
  28. function mobileBrowser() { if (/Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent)) return true; else return false; }
  29. /* GET */
  30. function gup(b){b=b.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var a="[\\?&]"+b+"=([^&#]*)",d=new RegExp(a),c=d.exec(window.location.href);if(c===null){return""}else{return c[1]}};
  31. /*! jQuery Retina Plugin */
  32. (function(a){a.fn.retina=function(c){var d={"retina-background":false,"retina-suffix":"@2x"};if(c){a.extend(d,c)}var b=function(f,g){var e=new Image();e.onload=function(){g(e)};e.src=f};if(window.devicePixelRatio>1){this.each(function(){var e=a(this);if(this.tagName.toLowerCase()=="img"&&e.attr("src")){var g=e.attr("src").replace(/\.(?!.*\.)/,d["retina-suffix"]+".");b(g,function(h){e.attr("src",h.src);var i=a("<div>").append(e.clone()).remove().html();if(!(/(width|height)=["']\d+["']/.test(i))){e.attr("width",h.width/2)
  33. }})}if(d["retina-background"]){var f=e.css("background-image");if(/^url\(.*\)$/.test(f)){var g=f.substring(4,f.length-1).replace(/\.(?!.*\.)/,d["retina-suffix"]+".");b(g,function(h){e.css("background-image","url("+h.src+")");if(e.css("background-size")=="auto auto"){e.css("background-size",(h.width/2)+"px auto")}})}}})}}})(jQuery);
  34. (function($) {
  35. var Swipe = function(el) {
  36. var self = this;
  37. this.el = $(el);
  38. this.pos = { start: { x: 0, y: 0 }, end: { x: 0, y: 0 } };
  39. this.startTime;
  40. el.on('touchstart', function(e) { self.touchStart(e); });
  41. el.on('touchmove', function(e) { self.touchMove(e); });
  42. el.on('touchend', function(e) { self.swipeEnd(); });
  43. el.on('mousedown', function(e) { self.mouseDown(e); });
  44. };
  45. Swipe.prototype = {
  46. touchStart: function(e) {
  47. var touch = e.originalEvent.touches[0];
  48. this.swipeStart(e, touch.pageX, touch.pageY);
  49. },
  50. touchMove: function(e) {
  51. var touch = e.originalEvent.touches[0];
  52. this.swipeMove(e, touch.pageX, touch.pageY);
  53. },
  54. mouseDown: function(e) {
  55. var self = this;
  56. this.swipeStart(e, e.pageX, e.pageY);
  57. this.el.on('mousemove', function(e) { self.mouseMove(e); });
  58. this.el.on('mouseup', function() { self.mouseUp(); });
  59. },
  60. mouseMove: function(e) {
  61. this.swipeMove(e, e.pageX, e.pageY);
  62. },
  63. mouseUp: function(e) {
  64. this.swipeEnd(e);
  65. this.el.off('mousemove');
  66. this.el.off('mouseup');
  67. },
  68. swipeStart: function(e, x, y) {
  69. this.pos.start.x = x;
  70. this.pos.start.y = y;
  71. this.pos.end.x = x;
  72. this.pos.end.y = y;
  73. this.startTime = new Date().getTime();
  74. this.trigger('swipeStart', e);
  75. },
  76. swipeMove: function(e, x, y) {
  77. this.pos.end.x = x;
  78. this.pos.end.y = y;
  79. this.trigger('swipeMove', e);
  80. },
  81. swipeEnd: function(e) {
  82. this.trigger('swipeEnd', e);
  83. },
  84. trigger: function(e, originalEvent) {
  85. var self = this;
  86. var
  87. event = $.Event(e),
  88. x = self.pos.start.x - self.pos.end.x,
  89. y = self.pos.end.y - self.pos.start.y,
  90. radians = Math.atan2(y, x),
  91. direction = 'up',
  92. distance = Math.round(Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2))),
  93. angle = Math.round(radians * 180 / Math.PI),
  94. speed = Math.round(distance / ( new Date().getTime() - self.startTime ) * 1000);
  95. if ( angle < 0 ) {
  96. angle = 360 - Math.abs(angle);
  97. }
  98. if ( ( angle <= 45 && angle >= 0 ) || ( angle <= 360 && angle >= 315 ) ) {
  99. direction = 'left';
  100. } else if ( angle >= 135 && angle <= 225 ) {
  101. direction = 'right';
  102. } else if ( angle > 45 && angle < 135 ) {
  103. direction = 'down';
  104. }
  105. event.originalEvent = originalEvent;
  106. event.swipe = { x: x, y: y, direction: direction, distance: distance, angle: angle, speed: speed };
  107. $(self.el).trigger(event);
  108. }
  109. };
  110. $.fn.swipe = function() {
  111. var swipe = new Swipe(this);
  112. return this;
  113. };
  114. })(jQuery);
  115. /**
  116. * @name Album Module
  117. * @description Takes care of every action an album can handle and execute.
  118. * @author Tobias Reich
  119. * @copyright 2014 by Tobias Reich
  120. */
  121. album = {
  122. json: null,
  123. getID: function() {
  124. var id;
  125. if (photo.json) id = photo.json.album;
  126. else if (album.json) id = album.json.id;
  127. else id = $(".album:hover, .album.active").attr("data-id");
  128. // Search
  129. if (!id) id = $(".album:hover, .album.active").attr("data-id");
  130. if (!id) id = $(".photo:hover, .photo.active").attr("data-album-id");
  131. if (id) return id;
  132. else return false;
  133. },
  134. load: function(albumID, refresh) {
  135. var startTime,
  136. params,
  137. durationTime,
  138. waitTime;
  139. password.get(albumID, function() {
  140. if (!refresh) {
  141. loadingBar.show();
  142. lychee.animate(".album:nth-child(-n+50), .photo:nth-child(-n+50)", "contentZoomOut");
  143. lychee.animate(".divider", "fadeOut");
  144. }
  145. startTime = new Date().getTime();
  146. params = "getAlbum&albumID=" + albumID + "&password=" + password.value;
  147. lychee.api(params, function(data) {
  148. if (data==="Warning: Album private!") {
  149. if (document.location.hash.replace("#", "").split("/")[1]!=undefined) {
  150. // Display photo only
  151. lychee.setMode("view");
  152. } else {
  153. // Album not public
  154. lychee.content.show();
  155. lychee.goto("");
  156. }
  157. return false;
  158. }
  159. if (data==="Warning: Wrong password!") {
  160. album.load(albumID, refresh);
  161. return false;
  162. }
  163. album.json = data;
  164. durationTime = (new Date().getTime() - startTime);
  165. if (durationTime>300) waitTime = 0; else if (refresh) waitTime = 0; else waitTime = 300 - durationTime;
  166. if (!visible.albums()&&!visible.photo()&&!visible.album()) waitTime = 0;
  167. setTimeout(function() {
  168. view.album.init();
  169. if (!refresh) {
  170. lychee.animate(".album:nth-child(-n+50), .photo:nth-child(-n+50)", "contentZoomIn");
  171. view.header.mode("album");
  172. }
  173. }, waitTime);
  174. });
  175. });
  176. },
  177. parse: function(photo) {
  178. if (!album.json.title) album.json.title = "Untitled";
  179. },
  180. add: function() {
  181. var title,
  182. params,
  183. buttons,
  184. isNumber = function(n) { return !isNaN(parseFloat(n)) && isFinite(n) };
  185. buttons = [
  186. ["Create Album", function() {
  187. title = $(".message input.text").val();
  188. if (title.length===0) title = "Untitled";
  189. modal.close();
  190. params = "addAlbum&title=" + escape(encodeURI(title));
  191. lychee.api(params, function(data) {
  192. if (data===true) data = 1; // Avoid first album to be true
  193. if (data!==false&&isNumber(data)) lychee.goto(data);
  194. else lychee.error(null, params, data);
  195. });
  196. }],
  197. ["Cancel", function() {}]
  198. ];
  199. modal.show("New Album", "Enter a title for this album: <input class='text' type='text' maxlength='30' placeholder='Title' value='Untitled'>", buttons);
  200. },
  201. delete: function(albumIDs) {
  202. var params,
  203. buttons,
  204. albumTitle;
  205. if (!albumIDs) return false;
  206. if (albumIDs instanceof Array===false) albumIDs = [albumIDs];
  207. buttons = [
  208. ["", function() {
  209. params = "deleteAlbum&albumIDs=" + albumIDs;
  210. lychee.api(params, function(data) {
  211. if (visible.albums()) {
  212. albumIDs.forEach(function(id, index, array) {
  213. albums.json.num--;
  214. view.albums.content.delete(id);
  215. });
  216. } else lychee.goto("");
  217. if (data!==true) lychee.error(null, params, data);
  218. });
  219. }],
  220. ["", function() {}]
  221. ];
  222. if (albumIDs.toString()==="0") {
  223. buttons[0][0] = "Clear Unsorted";
  224. buttons[1][0] = "Keep Unsorted";
  225. modal.show("Clear Unsorted", "Are you sure you want to delete all photos from 'Unsorted'?<br>This action can't be undone!", buttons);
  226. } else if (albumIDs.length===1) {
  227. buttons[0][0] = "Delete Album and Photos";
  228. buttons[1][0] = "Keep Album";
  229. // Get title
  230. if (album.json) albumTitle = album.json.title;
  231. else if (albums.json) albumTitle = albums.json.content[albumIDs].title;
  232. modal.show("Delete Album", "Are you sure you want to delete the album '" + albumTitle + "' and all of the photos it contains? This action can't be undone!", buttons);
  233. } else {
  234. buttons[0][0] = "Delete Albums and Photos";
  235. buttons[1][0] = "Keep Albums";
  236. modal.show("Delete Albums", "Are you sure you want to delete all " + albumIDs.length + " selected albums and all of the photos they contain? This action can't be undone!", buttons);
  237. }
  238. },
  239. setTitle: function(albumIDs) {
  240. var oldTitle = "",
  241. newTitle,
  242. params,
  243. buttons;
  244. if (!albumIDs) return false;
  245. if (albumIDs instanceof Array===false) albumIDs = [albumIDs];
  246. if (albumIDs.length===1) {
  247. // Get old title if only one album is selected
  248. if (album.json) oldTitle = album.json.title;
  249. else if (albums.json) oldTitle = albums.json.content[albumIDs].title;
  250. if (!oldTitle) oldTitle = "";
  251. oldTitle = oldTitle.replace("'", "&apos;");
  252. }
  253. buttons = [
  254. ["Set Title", function() {
  255. // Get input
  256. newTitle = $(".message input.text").val();
  257. // Remove html from input
  258. newTitle = lychee.removeHTML(newTitle);
  259. // Set to Untitled when empty
  260. newTitle = (newTitle==="") ? "Untitled" : newTitle;
  261. if (visible.album()) {
  262. album.json.title = newTitle;
  263. view.album.title();
  264. } else if (visible.albums()) {
  265. albumIDs.forEach(function(id, index, array) {
  266. albums.json.content[id].title = newTitle;
  267. view.albums.content.title(id);
  268. });
  269. }
  270. params = "setAlbumTitle&albumIDs=" + albumIDs + "&title=" + escape(encodeURI(newTitle));
  271. lychee.api(params, function(data) {
  272. if (data!==true) lychee.error(null, params, data);
  273. });
  274. }],
  275. ["Cancel", function() {}]
  276. ];
  277. if (albumIDs.length===1) modal.show("Set Title", "Enter a new title for this album: <input class='text' type='text' maxlength='30' placeholder='Title' value='" + oldTitle + "'>", buttons);
  278. else modal.show("Set Titles", "Enter a title for all " + albumIDs.length + " selected album: <input class='text' type='text' maxlength='30' placeholder='Title' value='" + oldTitle + "'>", buttons);
  279. },
  280. setDescription: function(photoID) {
  281. var oldDescription = album.json.description.replace("'", "&apos;"),
  282. description,
  283. params,
  284. buttons;
  285. buttons = [
  286. ["Set Description", function() {
  287. // Get input
  288. description = $(".message input.text").val();
  289. // Remove html from input
  290. description = lychee.removeHTML(description);
  291. if (visible.album()) {
  292. album.json.description = description;
  293. view.album.description();
  294. }
  295. params = "setAlbumDescription&albumID=" + photoID + "&description=" + escape(encodeURI(description));
  296. lychee.api(params, function(data) {
  297. if (data!==true) lychee.error(null, params, data);
  298. });
  299. }],
  300. ["Cancel", function() {}]
  301. ];
  302. modal.show("Set Description", "Please enter a description for this album: <input class='text' type='text' maxlength='800' placeholder='Description' value='" + oldDescription + "'>", buttons);
  303. },
  304. setPublic: function(albumID, e) {
  305. var params,
  306. password = "",
  307. listed = false,
  308. downloadable = false;
  309. if (!visible.message()&&album.json.public==0) {
  310. modal.show("Share Album", "This album will be shared with the following properties:</p><form><div class='choice'><input type='checkbox' name='listed' value='listed' checked><h2>Visible</h2><p>Listed to visitors of your Lychee.</p></div><div class='choice'><input type='checkbox' name='downloadable' value='downloadable'><h2>Downloadable</h2><p>Visitors of your Lychee can download this album.</p></div><div class='choice'><input type='checkbox' name='password' value='password'><h2>Password protected</h2><p>Only accessible with a valid password.<input class='text' type='password' placeholder='password' value='' style='display: none;'></p></div></form><p style='display: none;'>", [["Share Album", function() { album.setPublic(album.getID(), e) }], ["Cancel", function() {}]], -170);
  311. $(".message .choice input[name='password']").on("change", function() {
  312. if ($(this).prop('checked')===true) $(".message .choice input.text").show();
  313. else $(".message .choice input.text").hide();
  314. });
  315. return true;
  316. }
  317. if (visible.message()) {
  318. if ($(".message .choice input[name='password']:checked").val()==="password") {
  319. password = md5($(".message input.text").val());
  320. album.json.password = 1;
  321. } else {
  322. password = "";
  323. album.json.password = 0;
  324. }
  325. if ($(".message .choice input[name='listed']:checked").val()==="listed") listed = true;
  326. if ($(".message .choice input[name='downloadable']:checked").val()==="downloadable") downloadable = true;
  327. }
  328. params = "setAlbumPublic&albumID=" + albumID + "&password=" + password + "&visible=" + listed + "&downloadable=" + downloadable;
  329. if (visible.album()) {
  330. album.json.public = (album.json.public==0) ? 1 : 0;
  331. album.json.password = (album.json.public==0) ? 0 : album.json.password;
  332. view.album.public();
  333. view.album.password();
  334. if (album.json.public==1) contextMenu.shareAlbum(albumID, e);
  335. }
  336. lychee.api(params, function(data) {
  337. if (data!==true) lychee.error(null, params, data);
  338. });
  339. },
  340. share: function(service) {
  341. var link = "",
  342. url = location.href;
  343. switch (service) {
  344. case 0:
  345. link = "https://twitter.com/share?url=" + encodeURI(url);
  346. break;
  347. case 1:
  348. link = "http://www.facebook.com/sharer.php?u=" + encodeURI(url) + "&t=" + encodeURI(album.json.title);
  349. break;
  350. case 2:
  351. link = "mailto:?subject=" + encodeURI(album.json.title) + "&body=" + encodeURI(url);
  352. break;
  353. default:
  354. link = "";
  355. break;
  356. }
  357. if (link.length>5) location.href = link;
  358. },
  359. getArchive: function(albumID) {
  360. var link;
  361. if (location.href.indexOf("index.html")>0) link = location.href.replace(location.hash, "").replace("index.html", "php/api.php?function=getAlbumArchive&albumID=" + albumID);
  362. else link = location.href.replace(location.hash, "") + "php/api.php?function=getAlbumArchive&albumID=" + albumID;
  363. if (lychee.publicMode) link += "&password=" + password.value;
  364. location.href = link;
  365. }
  366. };
  367. /**
  368. * @name Albums Module
  369. * @description Takes care of every action albums can handle and execute.
  370. * @author Tobias Reich
  371. * @copyright 2014 by Tobias Reich
  372. */
  373. albums = {
  374. json: null,
  375. load: function() {
  376. var startTime,
  377. durationTime,
  378. waitTime;
  379. lychee.animate(".album:nth-child(-n+50), .photo:nth-child(-n+50)", "contentZoomOut");
  380. lychee.animate(".divider", "fadeOut");
  381. startTime = new Date().getTime();
  382. lychee.api("getAlbums", function(data) {
  383. /* Smart Albums */
  384. data.unsortedAlbum = {
  385. id: 0,
  386. title: "Unsorted",
  387. sysdate: data.unsortedNum + " photos",
  388. unsorted: 1,
  389. thumb0: data.unsortedThumb0,
  390. thumb1: data.unsortedThumb1,
  391. thumb2: data.unsortedThumb2
  392. };
  393. data.starredAlbum = {
  394. id: "f",
  395. title: "Starred",
  396. sysdate: data.starredNum + " photos",
  397. star: 1,
  398. thumb0: data.starredThumb0,
  399. thumb1: data.starredThumb1,
  400. thumb2: data.starredThumb2
  401. };
  402. data.publicAlbum = {
  403. id: "s",
  404. title: "Public",
  405. sysdate: data.publicNum + " photos",
  406. public: 1,
  407. thumb0: data.publicThumb0,
  408. thumb1: data.publicThumb1,
  409. thumb2: data.publicThumb2
  410. };
  411. data.recentAlbum = {
  412. id: "r",
  413. title: "Recent",
  414. sysdate: data.recentNum + " photos",
  415. recent: 1,
  416. thumb0: data.recentThumb0,
  417. thumb1: data.recentThumb1,
  418. thumb2: data.recentThumb2
  419. };
  420. albums.json = data;
  421. durationTime = (new Date().getTime() - startTime);
  422. if (durationTime>300) waitTime = 0; else waitTime = 300 - durationTime;
  423. if (!visible.albums()&&!visible.photo()&&!visible.album()) waitTime = 0;
  424. if (visible.album()&&lychee.content.html()==="") waitTime = 0;
  425. setTimeout(function() {
  426. view.header.mode("albums");
  427. view.albums.init();
  428. lychee.animate(".album:nth-child(-n+50), .photo:nth-child(-n+50)", "contentZoomIn");
  429. }, waitTime);
  430. });
  431. },
  432. parse: function(album) {
  433. if (album.password&&lychee.publicMode) {
  434. album.thumb0 = "assets/img/password.svg";
  435. album.thumb1 = "assets/img/password.svg";
  436. album.thumb2 = "assets/img/password.svg";
  437. } else {
  438. if (!album.thumb0) album.thumb0 = "assets/img/no_images.svg";
  439. if (!album.thumb1) album.thumb1 = "assets/img/no_images.svg";
  440. if (!album.thumb2) album.thumb2 = "assets/img/no_images.svg";
  441. }
  442. }
  443. };
  444. /**
  445. * @name Build Module
  446. * @description This module is used to generate HTML-Code.
  447. * @author Tobias Reich
  448. * @copyright 2014 by Tobias Reich
  449. */
  450. build = {
  451. divider: function(title) {
  452. return "<div class='divider fadeIn'><h1>" + title + "</h1></div>";
  453. },
  454. editIcon: function(id) {
  455. return "<div id='" + id + "' class='edit'><a class='icon-pencil'></a></div>";
  456. },
  457. multiselect: function(top, left) {
  458. return "<div id='multiselect' style='top: " + top + "px; left: " + left + "px;'></div>";
  459. },
  460. album: function(albumJSON) {
  461. if (!albumJSON) return "";
  462. var album = "",
  463. longTitle = "",
  464. title = albumJSON.title,
  465. typeThumb = "";
  466. if (title.length>18) {
  467. title = albumJSON.title.substr(0, 18) + "...";
  468. longTitle = albumJSON.title;
  469. }
  470. if (albumJSON.thumb0.split('.').pop()==="svg") typeThumb = "nonretina";
  471. album += "<div class='album' data-id='" + albumJSON.id + "' data-password='" + albumJSON.password + "'>";
  472. album += "<img src='" + albumJSON.thumb2 + "' width='200' height='200' alt='thumb' data-type='nonretina'>";
  473. album += "<img src='" + albumJSON.thumb1 + "' width='200' height='200' alt='thumb' data-type='nonretina'>";
  474. album += "<img src='" + albumJSON.thumb0 + "' width='200' height='200' alt='thumb' data-type='" + typeThumb + "'>";
  475. album += "<div class='overlay'>";
  476. if (albumJSON.password&&!lychee.publicMode) album += "<h1><span class='icon-lock'></span> " + title + "</h1>";
  477. else album += "<h1 title='" + longTitle + "'>" + title + "</h1>";
  478. album += "<a>" + albumJSON.sysdate + "</a>";
  479. album += "</div>";
  480. if (!lychee.publicMode) {
  481. if(albumJSON.star==1) album += "<a class='badge red icon-star'></a>";
  482. if(albumJSON.public==1) album += "<a class='badge red icon-share'></a>";
  483. if(albumJSON.unsorted==1) album += "<a class='badge red icon-reorder'></a>";
  484. if(albumJSON.recent==1) album += "<a class='badge red icon-time'></a>";
  485. }
  486. album += "</div>";
  487. return album;
  488. },
  489. photo: function(photoJSON) {
  490. if (!photoJSON) return "";
  491. var photo = "",
  492. longTitle = "",
  493. title = photoJSON.title;
  494. if (title.length>18) {
  495. title = photoJSON.title.substr(0, 18) + "...";
  496. longTitle = photoJSON.title;
  497. }
  498. photo += "<div class='photo' data-album-id='" + photoJSON.album + "' data-id='" + photoJSON.id + "'>";
  499. photo += "<img src='" + photoJSON.thumbUrl + "' width='200' height='200' alt='thumb'>";
  500. photo += "<div class='overlay'>";
  501. photo += "<h1 title='" + longTitle + "'>" + title + "</h1>";
  502. if (photoJSON.cameraDate==1) {
  503. photo += "<a><span class='icon-camera' title='Photo Date'></span>" + photoJSON.sysdate + "</a>";
  504. } else {
  505. photo += "<a>" + photoJSON.sysdate + "</a>";
  506. }
  507. photo += "</div>";
  508. if (photoJSON.star==1) photo += "<a class='badge red icon-star'></a>";
  509. if (!lychee.publicMode&&photoJSON.public==1&&album.json.public!=1) photo += "<a class='badge red icon-share'></a>";
  510. photo += "</div>";
  511. return photo;
  512. },
  513. imageview: function(photoJSON, isSmall, visibleControls) {
  514. if (!photoJSON) return "";
  515. var view = "";
  516. view += "<div class='arrow_wrapper previous'><a id='previous' class='icon-caret-left'></a></div>";
  517. view += "<div class='arrow_wrapper next'><a id='next' class='icon-caret-right'></a></div>";
  518. if (isSmall) {
  519. if (visibleControls)
  520. view += "<div id='image' class='small' style='background-image: url(" + photoJSON.url + "); width: " + photoJSON.width + "px; height: " + photoJSON.height + "px; margin-top: -" + parseInt(photoJSON.height/2-20) + "px; margin-left: -" + photoJSON.width/2 + "px;'></div>";
  521. else
  522. view += "<div id='image' class='small' style='background-image: url(" + photoJSON.url + "); width: " + photoJSON.width + "px; height: " + photoJSON.height + "px; margin-top: -" + parseInt(photoJSON.height/2) + "px; margin-left: -" + photoJSON.width/2 + "px;'></div>";
  523. } else {
  524. if (visibleControls)
  525. view += "<div id='image' style='background-image: url(" + photoJSON.url + ")'></div>";
  526. else
  527. view += "<div id='image' style='background-image: url(" + photoJSON.url + ");' class='full'></div>";
  528. }
  529. return view;
  530. },
  531. no_content: function(typ) {
  532. var no_content = "";
  533. no_content += "<div class='no_content fadeIn'>";
  534. no_content += "<a class='icon icon-" + typ + "'></a>";
  535. if (typ==="search") no_content += "<p>No results</p>";
  536. else if (typ==="share") no_content += "<p>No public albums</p>";
  537. else if (typ==="cog") no_content += "<p>No configuration</p>";
  538. no_content += "</div>";
  539. return no_content;
  540. },
  541. modal: function(title, text, button, marginTop, closeButton) {
  542. var modal = "",
  543. custom_style = "";
  544. if (marginTop) custom_style = "style='margin-top: " + marginTop + "px;'";
  545. modal += "<div class='message_overlay fadeIn'>";
  546. modal += "<div class='message center'" + custom_style + ">";
  547. modal += "<h1>" + title + "</h1>";
  548. if (closeButton!==false) {
  549. modal += "<a class='close icon-remove-sign'></a>";
  550. }
  551. modal += "<p>" + text + "</p>";
  552. $.each(button, function(index) {
  553. if (this[0]!=="") {
  554. if (index===0) modal += "<a class='button active'>" + this[0] + "</a>";
  555. else modal += "<a class='button'>" + this[0] + "</a>";
  556. }
  557. });
  558. modal += "</div>";
  559. modal += "</div>";
  560. return modal;
  561. },
  562. signInModal: function() {
  563. var modal = "";
  564. modal += "<div class='message_overlay'>";
  565. modal += "<div class='message center'>";
  566. modal += "<h1><a class='icon-lock'></a> Sign In</h1>";
  567. modal += "<a class='close icon-remove-sign'></a>";
  568. modal += "<div class='sign_in'>";
  569. modal += "<input id='username' type='text' name='' value='' placeholder='username'>";
  570. modal += "<input id='password' type='password' name='' value='' placeholder='password'>";
  571. modal += "</div>";
  572. modal += "<div id='version'>Version " + lychee.version + "<span> &#8211; <a target='_blank' href='" + lychee.updateURL + "'>Update available!</a><span></div>";
  573. modal += "<a onclick='lychee.login()' class='button active'>Sign in</a>";
  574. modal += "</div>";
  575. modal += "</div>";
  576. return modal;
  577. },
  578. uploadModal: function(title, files) {
  579. var modal = "";
  580. modal += "<div class='upload_overlay fadeIn'>";
  581. modal += "<div class='upload_message center'>";
  582. modal += "<h1>" + title + "</h1>";
  583. modal += "<a class='close icon-remove-sign'></a>";
  584. modal += "<div class='rows'>";
  585. for (var i = 0; i < files.length; i++) {
  586. if (files[i].name.length>40) files[i].name = files[i].name.substr(0, 17) + "..." + files[i].name.substr(files[i].name.length-20, 20);
  587. modal += "<div class='row'>";
  588. modal += "<a class='name'>" + lychee.escapeHTML(files[i].name) + "</a>";
  589. if (files[i].supported===true) modal += "<a class='status'></a>";
  590. else modal += "<a class='status error'>Not supported</a>";
  591. modal += "<p class='notice'></p>";
  592. modal += "</div>";
  593. }
  594. modal += "</div>";
  595. modal += "</div>";
  596. modal += "</div>";
  597. return modal;
  598. },
  599. contextMenu: function(items) {
  600. var menu = "";
  601. menu += "<div class='contextmenu_bg'></div>";
  602. menu += "<div class='contextmenu'>";
  603. menu += "<table>";
  604. menu += "<tbody>";
  605. $.each(items, function(index) {
  606. if (items[index][0]==="separator"&&items[index][1]===-1) menu += "<tr class='separator'></tr>";
  607. else if (items[index][1]===-1) menu += "<tr class='no_hover'><td>" + items[index][0] + "</td></tr>";
  608. else if (items[index][2]!=undefined) menu += "<tr><td onclick='" + items[index][2] + "; window.contextMenu.close();'>" + items[index][0] + "</td></tr>";
  609. else menu += "<tr><td onclick='window.contextMenu.fns[" + items[index][1] + "](); window.contextMenu.close();'>" + items[index][0] + "</td></tr>";
  610. });
  611. menu += "</tbody>";
  612. menu += "</table>";
  613. menu += "</div>";
  614. return menu;
  615. },
  616. tags: function(tags, forView) {
  617. var html = "",
  618. editTagsHTML = (forView===true||lychee.publicMode) ? "" : " " + build.editIcon("edit_tags");
  619. if (tags!=="") {
  620. tags = tags.split(",");
  621. tags.forEach(function(tag, index, array) {
  622. html += "<a class='tag'>" + tag + "<span class='icon-remove' data-index='" + index + "'></span></a>";
  623. });
  624. html += editTagsHTML;
  625. } else {
  626. html = "<div class='empty'>No Tags" + editTagsHTML + "</div>";
  627. }
  628. return html;
  629. },
  630. infoboxPhoto: function(photoJSON, forView) {
  631. if (!photoJSON) return "";
  632. var infobox = "",
  633. public,
  634. editTitleHTML,
  635. editDescriptionHTML,
  636. infos;
  637. infobox += "<div class='header'><h1>About</h1><a class='icon-remove-sign'></a></div>";
  638. infobox += "<div class='wrapper'>";
  639. switch (photoJSON.public) {
  640. case "0":
  641. public = "No";
  642. break;
  643. case "1":
  644. public = "Yes";
  645. break;
  646. case "2":
  647. public = "Yes (Album)";
  648. break;
  649. default:
  650. public = "-";
  651. break;
  652. }
  653. editTitleHTML = (forView===true||lychee.publicMode) ? "" : " " + build.editIcon("edit_title");
  654. editDescriptionHTML = (forView===true||lychee.publicMode) ? "" : " " + build.editIcon("edit_description");
  655. infos = [
  656. ["", "Basics"],
  657. ["Title", photoJSON.title + editTitleHTML],
  658. ["Uploaded", photoJSON.sysdate],
  659. ["Description", photoJSON.description + editDescriptionHTML],
  660. ["", "Image"],
  661. ["Size", photoJSON.size],
  662. ["Format", photoJSON.type],
  663. ["Resolution", photoJSON.width + " x " + photoJSON.height],
  664. ["Tags", build.tags(photoJSON.tags, forView)]
  665. ];
  666. if ((photoJSON.takestamp+photoJSON.make+photoJSON.model+photoJSON.shutter+photoJSON.aperture+photoJSON.focal+photoJSON.iso)!="0") {
  667. infos = infos.concat([
  668. ["", "Camera"],
  669. ["Captured", photoJSON.takedate],
  670. ["Make", photoJSON.make],
  671. ["Type/Model", photoJSON.model],
  672. ["Shutter Speed", photoJSON.shutter],
  673. ["Aperture", photoJSON.aperture],
  674. ["Focal Length", photoJSON.focal],
  675. ["ISO", photoJSON.iso]
  676. ]);
  677. }
  678. infos = infos.concat([
  679. ["", "Share"],
  680. ["Public", public]
  681. ]);
  682. $.each(infos, function(index) {
  683. if (infos[index][1]===""||infos[index][1]===undefined||infos[index][1]===null) infos[index][1] = "-";
  684. switch (infos[index][0]) {
  685. case "": // Separator
  686. infobox += "</table>";
  687. infobox += "<div class='separator'><h1>" + infos[index][1] + "</h1></div>";
  688. infobox += "<table>";
  689. break;
  690. case "Tags": // Tags
  691. if (forView!==true&&!lychee.publicMode) {
  692. infobox += "</table>";
  693. infobox += "<div class='separator'><h1>" + infos[index][0] + "</h1></div>";
  694. infobox += "<div id='tags'>" + infos[index][1] + "</div>";
  695. }
  696. break;
  697. default: // Item
  698. infobox += "<tr>";
  699. infobox += "<td>" + infos[index][0] + "</td>";
  700. infobox += "<td class='attr_" + infos[index][0].toLowerCase() + "'>" + infos[index][1] + "</td>";
  701. infobox += "</tr>";
  702. break;
  703. }
  704. });
  705. infobox += "</table>";
  706. infobox += "<div class='bumper'></div>";
  707. infobox += "</div>";
  708. return infobox;
  709. },
  710. infoboxAlbum: function(albumJSON, forView) {
  711. if (!albumJSON) return "";
  712. var infobox = "",
  713. public = "-",
  714. password = "-",
  715. downloadable = "-",
  716. editTitleHTML,
  717. editDescriptionHTML,
  718. infos;
  719. infobox += "<div class='header'><h1>About</h1><a class='icon-remove-sign'></a></div>";
  720. infobox += "<div class='wrapper'>";
  721. switch (albumJSON.public) {
  722. case "0":
  723. public = "No";
  724. break;
  725. case "1":
  726. public = "Yes";
  727. break;
  728. }
  729. switch (albumJSON.password) {
  730. case false:
  731. password = "No";
  732. break;
  733. case true:
  734. password = "Yes";
  735. break;
  736. }
  737. switch (albumJSON.downloadable) {
  738. case "0":
  739. downloadable = "No";
  740. break;
  741. case "1":
  742. downloadable = "Yes";
  743. break;
  744. }
  745. editTitleHTML = (forView===true||lychee.publicMode) ? "" : " " + build.editIcon("edit_title_album");
  746. editDescriptionHTML = (forView===true||lychee.publicMode) ? "" : " " + build.editIcon("edit_description_album");
  747. infos = [
  748. ["", "Basics"],
  749. ["Title", albumJSON.title + editTitleHTML],
  750. ["Description", albumJSON.description + editDescriptionHTML],
  751. ["", "Album"],
  752. ["Created", albumJSON.sysdate],
  753. ["Images", albumJSON.num],
  754. ["", "Share"],
  755. ["Public", public],
  756. ["Downloadable", downloadable],
  757. ["Password", password]
  758. ];
  759. $.each(infos, function(index) {
  760. if (infos[index][1]===""||infos[index][1]===undefined||infos[index][1]===null) infos[index][1] = "-";
  761. if (infos[index][0]==="") {
  762. infobox += "</table>";
  763. infobox += "<div class='separator'><h1>" + infos[index][1] + "</h1></div>";
  764. infobox += "<table id='infos'>";
  765. } else {
  766. infobox += "<tr>";
  767. infobox += "<td>" + infos[index][0] + "</td>";
  768. infobox += "<td class='attr_" + infos[index][0].toLowerCase() + "'>" + infos[index][1] + "</td>";
  769. infobox += "</tr>";
  770. }
  771. });
  772. infobox += "</table>";
  773. infobox += "<div class='bumper'></div>";
  774. infobox += "</div>";
  775. return infobox;
  776. }
  777. };
  778. /**
  779. * @name ContextMenu Module
  780. * @description This module is used for the context menu.
  781. * @author Tobias Reich
  782. * @copyright 2014 by Tobias Reich
  783. */
  784. contextMenu = {
  785. fns: null,
  786. show: function(items, mouse_x, mouse_y, orientation) {
  787. contextMenu.close();
  788. $("body")
  789. .css("overflow", "hidden")
  790. .append(build.contextMenu(items));
  791. // Do not leave the screen
  792. if ((mouse_x+$(".contextmenu").outerWidth(true))>$("html").width()) orientation = "left";
  793. if ((mouse_y+$(".contextmenu").outerHeight(true))>$("html").height()) mouse_y -= (mouse_y+$(".contextmenu").outerHeight(true)-$("html").height());
  794. if (mouse_x>$(document).width()) mouse_x = $(document).width();
  795. if (mouse_x<0) mouse_x = 0;
  796. if (mouse_y>$(document).height()) mouse_y = $(document).height();
  797. if (mouse_y<0) mouse_y = 0;
  798. if (orientation==="left") mouse_x -= $(".contextmenu").outerWidth(true);
  799. if (mouse_x===null||
  800. mouse_x===undefined||
  801. isNaN(mouse_x)||
  802. mouse_y===null||
  803. mouse_y===undefined||
  804. isNaN(mouse_y)) {
  805. mouse_x = "10px";
  806. mouse_y = "10px";
  807. }
  808. $(".contextmenu").css({
  809. "top": mouse_y,
  810. "left": mouse_x,
  811. "opacity": 0.98
  812. });
  813. },
  814. add: function(e) {
  815. var mouse_x = e.pageX,
  816. mouse_y = e.pageY - $(document).scrollTop(),
  817. items;
  818. upload.notify();
  819. contextMenu.fns = [
  820. function() { $("#upload_files").click() },
  821. function() { upload.start.url() },
  822. function() { upload.start.dropbox() },
  823. function() { upload.start.server() },
  824. function() { album.add() }
  825. ];
  826. items = [
  827. ["<a class='icon-picture'></a> Upload Photo", 0],
  828. ["separator", -1],
  829. ["<a class='icon-link'></a> Import from Link", 1],
  830. ["<a class='icon-folder-open'></a> Import from Dropbox", 2],
  831. ["<a class='icon-hdd'></a> Import from Server", 3],
  832. ["separator", -1],
  833. ["<a class='icon-folder-close'></a> New Album", 4]
  834. ];
  835. contextMenu.show(items, mouse_x, mouse_y, "left");
  836. },
  837. settings: function(e) {
  838. var mouse_x = e.pageX,
  839. mouse_y = e.pageY - $(document).scrollTop(),
  840. items;
  841. contextMenu.fns = [
  842. function() { settings.setLogin() },
  843. function() { settings.setSorting() },
  844. function() { settings.setDropboxKey() },
  845. function() { window.open(lychee.website); },
  846. function() { window.open("plugins/check/"); },
  847. function() { window.open("plugins/displaylog/"); },
  848. function() { lychee.logout() }
  849. ];
  850. items = [
  851. ["<a class='icon-user'></a> Change Login", 0],
  852. ["<a class='icon-sort'></a> Change Sorting", 1],
  853. ["<a class='icon-folder-open'></a> Set Dropbox", 2],
  854. ["separator", -1],
  855. ["<a class='icon-info-sign'></a> About Lychee", 3],
  856. ["<a class='icon-dashboard'></a> Diagnostics", 4],
  857. ["<a class='icon-list'></a> Show Log", 5],
  858. ["separator", -1],
  859. ["<a class='icon-signout'></a> Sign Out", 6]
  860. ];
  861. contextMenu.show(items, mouse_x, mouse_y, "right");
  862. },
  863. album: function(albumID, e) {
  864. var mouse_x = e.pageX,
  865. mouse_y = e.pageY - $(document).scrollTop(),
  866. items;
  867. if (albumID==="0"||albumID==="f"||albumID==="s"||albumID==="r") return false;
  868. contextMenu.fns = [
  869. function() { album.setTitle([albumID]) },
  870. function() { album.delete([albumID]) }
  871. ];
  872. items = [
  873. ["<a class='icon-edit'></a> Rename", 0],
  874. ["<a class='icon-trash'></a> Delete", 1]
  875. ];
  876. contextMenu.show(items, mouse_x, mouse_y, "right");
  877. $(".album[data-id='" + albumID + "']").addClass("active");
  878. },
  879. albumMulti: function(albumIDs, e) {
  880. var mouse_x = e.pageX,
  881. mouse_y = e.pageY - $(document).scrollTop(),
  882. items;
  883. multiselect.stopResize();
  884. contextMenu.fns = [
  885. function() { album.setTitle(albumIDs) },
  886. function() { album.delete(albumIDs) },
  887. ];
  888. items = [
  889. ["<a class='icon-edit'></a> Rename All", 0],
  890. ["<a class='icon-trash'></a> Delete All", 1]
  891. ];
  892. contextMenu.show(items, mouse_x, mouse_y, "right");
  893. },
  894. photo: function(photoID, e) {
  895. var mouse_x = e.pageX,
  896. mouse_y = e.pageY - $(document).scrollTop(),
  897. items;
  898. contextMenu.fns = [
  899. function() { photo.setStar([photoID]) },
  900. function() { photo.editTags([photoID]) },
  901. function() { photo.setTitle([photoID]) },
  902. function() { contextMenu.move([photoID], e, "right") },
  903. function() { photo.delete([photoID]) }
  904. ];
  905. items = [
  906. ["<a class='icon-star'></a> Star", 0],
  907. ["<a class='icon-tags'></a> Tags", 1],
  908. ["separator", -1],
  909. ["<a class='icon-edit'></a> Rename", 2],
  910. ["<a class='icon-folder-open'></a> Move", 3],
  911. ["<a class='icon-trash'></a> Delete", 4]
  912. ];
  913. contextMenu.show(items, mouse_x, mouse_y, "right");
  914. $(".photo[data-id='" + photoID + "']").addClass("active");
  915. },
  916. photoMulti: function(photoIDs, e) {
  917. var mouse_x = e.pageX,
  918. mouse_y = e.pageY - $(document).scrollTop(),
  919. items;
  920. multiselect.stopResize();
  921. contextMenu.fns = [
  922. function() { photo.setStar(photoIDs) },
  923. function() { photo.editTags(photoIDs) },
  924. function() { photo.setTitle(photoIDs) },
  925. function() { contextMenu.move(photoIDs, e, "right") },
  926. function() { photo.delete(photoIDs) }
  927. ];
  928. items = [
  929. ["<a class='icon-star'></a> Star All", 0],
  930. ["<a class='icon-tags'></a> Tag All", 1],
  931. ["separator", -1],
  932. ["<a class='icon-edit'></a> Rename All", 2],
  933. ["<a class='icon-folder-open'></a> Move All", 3],
  934. ["<a class='icon-trash'></a> Delete All", 4]
  935. ];
  936. contextMenu.show(items, mouse_x, mouse_y, "right");
  937. },
  938. photoMore: function(photoID, e) {
  939. var mouse_x = e.pageX,
  940. mouse_y = e.pageY - $(document).scrollTop(),
  941. items;
  942. contextMenu.fns = [
  943. function() { window.open(photo.getDirectLink()) },
  944. function() { photo.getArchive(photoID) }
  945. ];
  946. items = [["<a class='icon-resize-full'></a> Full Photo", 0]];
  947. if ((album.json&&album.json.downloadable&&album.json.downloadable==="1"&&lychee.publicMode)||!lychee.publicMode) items.push(["<a class='icon-circle-arrow-down'></a> Download", 1]);
  948. contextMenu.show(items, mouse_x, mouse_y, "right");
  949. },
  950. move: function(photoIDs, e, orientation) {
  951. var mouse_x = e.pageX,
  952. mouse_y = e.pageY - $(document).scrollTop(),
  953. items = [];
  954. contextMenu.close(true);
  955. if (album.getID()!=="0") {
  956. items = [
  957. ["Unsorted", 0, "photo.setAlbum([" + photoIDs + "], 0)"],
  958. ["separator", -1]
  959. ];
  960. }
  961. lychee.api("getAlbums", function(data) {
  962. if (data.num===0) {
  963. items = [["New Album", 0, "album.add()"]];
  964. } else {
  965. $.each(data.content, function(index) {
  966. if (this.id!=album.getID()) items.push([this.title, 0, "photo.setAlbum([" + photoIDs + "], " + this.id + ")"]);
  967. });
  968. }
  969. if (!visible.photo()) contextMenu.show(items, mouse_x, mouse_y, "right");
  970. else contextMenu.show(items, mouse_x, mouse_y, "left");
  971. });
  972. },
  973. sharePhoto: function(photoID, e) {
  974. var mouse_x = e.pageX,
  975. mouse_y = e.pageY,
  976. items;
  977. mouse_y -= $(document).scrollTop();
  978. contextMenu.fns = [
  979. function() { photo.setPublic(photoID) },
  980. function() { photo.share(photoID, 0) },
  981. function() { photo.share(photoID, 1) },
  982. function() { photo.share(photoID, 2) },
  983. function() { photo.share(photoID, 3) },
  984. function() { window.open(photo.getDirectLink()) }
  985. ];
  986. link = photo.getViewLink(photoID);
  987. if (photo.json.public==="2") link = location.href;
  988. items = [
  989. ["<input readonly id='link' value='" + link + "'>", -1],
  990. ["separator", -1],
  991. ["<a class='icon-eye-close'></a> Make Private", 0],
  992. ["separator", -1],
  993. ["<a class='icon-twitter'></a> Twitter", 1],
  994. ["<a class='icon-facebook'></a> Facebook", 2],
  995. ["<a class='icon-envelope'></a> Mail", 3],
  996. ["<a class='icon-hdd'></a> Dropbox", 4],
  997. ["<a class='icon-link'></a> Direct Link", 5]
  998. ];
  999. contextMenu.show(items, mouse_x, mouse_y, "left");
  1000. $(".contextmenu input").focus().select();
  1001. },
  1002. shareAlbum: function(albumID, e) {
  1003. var mouse_x = e.pageX,
  1004. mouse_y = e.pageY,
  1005. items;
  1006. mouse_y -= $(document).scrollTop();
  1007. contextMenu.fns = [
  1008. function() { album.setPublic(albumID) },
  1009. function() { album.share(0) },
  1010. function() { album.share(1) },
  1011. function() { album.share(2) },
  1012. function() { password.remove(albumID) }
  1013. ];
  1014. items = [
  1015. ["<input readonly id='link' value='" + location.href + "'>", -1],
  1016. ["separator", -1],
  1017. ["<a class='icon-eye-close'></a> Make Private", 0],
  1018. ["separator", -1],
  1019. ["<a class='icon-twitter'></a> Twitter", 1],
  1020. ["<a class='icon-facebook'></a> Facebook", 2],
  1021. ["<a class='icon-envelope'></a> Mail", 3],
  1022. ];
  1023. contextMenu.show(items, mouse_x, mouse_y, "left");
  1024. $(".contextmenu input").focus().select();
  1025. },
  1026. close: function(leaveSelection) {
  1027. if (!visible.contextMenu()) return false;
  1028. contextMenu.fns = [];
  1029. $(".contextmenu_bg, .contextmenu").remove();
  1030. $("body").css("overflow", "auto");
  1031. if (leaveSelection!==true) {
  1032. $(".photo.active, .album.active").removeClass("active");
  1033. if (visible.multiselect()) multiselect.close();
  1034. }
  1035. }
  1036. };
  1037. /**
  1038. * @name Init Module
  1039. * @author Tobias Reich
  1040. * @copyright 2014 by Tobias Reich
  1041. */
  1042. $(document).ready(function(){
  1043. /* Event Name */
  1044. var event_name = (mobileBrowser()) ? "touchend" : "click";
  1045. /* Disable ContextMenu */
  1046. $(document).bind("contextmenu", function(e) { e.preventDefault() });
  1047. /* Tooltips */
  1048. if (!mobileBrowser()) $(".tools").tipsy({gravity: 'n', fade: false, delayIn: 0, opacity: 1});
  1049. /* Multiselect */
  1050. $("#content").on("mousedown", multiselect.show);
  1051. $(document).on("mouseup", multiselect.getSelection);
  1052. /* Header */
  1053. $("#hostedwith").on(event_name, function() { window.open(lychee.website) });
  1054. $("#button_signin").on(event_name, lychee.loginDialog);
  1055. $("#button_settings").on("click", contextMenu.settings);
  1056. $("#button_share").on(event_name, function(e) {
  1057. if (photo.json.public==1||photo.json.public==2) contextMenu.sharePhoto(photo.getID(), e);
  1058. else photo.setPublic(photo.getID(), e);
  1059. });
  1060. $("#button_share_album").on(event_name, function(e) {
  1061. if (album.json.public==1) contextMenu.shareAlbum(album.getID(), e);
  1062. else album.setPublic(album.getID(), e);
  1063. });
  1064. $("#button_more").on(event_name, function(e) { contextMenu.photoMore(photo.getID(), e) });
  1065. $("#button_trash_album").on(event_name, function() { album.delete([album.getID()]) });
  1066. $("#button_move").on(event_name, function(e) { contextMenu.move([photo.getID()], e) });
  1067. $("#button_trash").on(event_name, function() { photo.delete([photo.getID()]) });
  1068. $("#button_info_album").on(event_name, function() { view.infobox.show() });
  1069. $("#button_info").on(event_name, function() { view.infobox.show() });
  1070. $("#button_archive").on(event_name, function() { album.getArchive(album.getID()) });
  1071. $("#button_star").on(event_name, function() { photo.setStar([photo.getID()]) });
  1072. /* Search */
  1073. $("#search").on("keyup click", function() { search.find($(this).val()) });
  1074. /* Clear Search */
  1075. $("#clearSearch").on(event_name, function () {
  1076. $("#search").focus();
  1077. search.reset();
  1078. });
  1079. /* Back Buttons */
  1080. $("#button_back_home").on(event_name, function() { lychee.goto("") });
  1081. $("#button_back").on(event_name, function() { lychee.goto(album.getID()) });
  1082. /* Image View */
  1083. lychee.imageview
  1084. .on(event_name, ".arrow_wrapper.previous", photo.previous)
  1085. .on(event_name, ".arrow_wrapper.next", photo.next);
  1086. /* Infobox */
  1087. $("#infobox")
  1088. .on(event_name, ".header a", function() { view.infobox.hide() })
  1089. .on(event_name, "#edit_title_album", function() { album.setTitle([album.getID()]) })
  1090. .on(event_name, "#edit_description_album", function() { album.setDescription(album.getID()) })
  1091. .on(event_name, "#edit_title", function() { photo.setTitle([photo.getID()]) })
  1092. .on(event_name, "#edit_description", function() { photo.setDescription(photo.getID()) })
  1093. .on(event_name, "#edit_tags", function() { photo.editTags([photo.getID()]) })
  1094. .on(event_name, "#tags .tag span", function() { photo.deleteTag(photo.getID(), $(this).data('index')) });
  1095. /* Keyboard */
  1096. Mousetrap
  1097. .bind('left', function() { if (visible.photo()) $("#imageview a#previous").click() })
  1098. .bind('right', function() { if (visible.photo()) $("#imageview a#next").click() })
  1099. .bind(['u', 'ctrl+u'], function() { $("#upload_files").click() })
  1100. .bind(['s', 'ctrl+s', 'f', 'ctrl+f'], function(e) {
  1101. if (visible.photo()) {
  1102. $("#button_star").click();
  1103. } else if (visible.albums()) {
  1104. e.preventDefault();
  1105. $("#search").focus();
  1106. }
  1107. })
  1108. .bind(['r', 'ctrl+r'], function(e) {
  1109. e.preventDefault();
  1110. if (visible.album()) album.setTitle(album.getID());
  1111. else if (visible.photo()) photo.setTitle([photo.getID()]);
  1112. })
  1113. .bind(['d', 'ctrl+d'], function(e) {
  1114. e.preventDefault();
  1115. if (visible.photo()) photo.setDescription(photo.getID());
  1116. else if (visible.album()) album.setDescription(album.getID());
  1117. })
  1118. .bind(['t', 'ctrl+t'], function(e) {
  1119. if (visible.photo()) {
  1120. e.preventDefault();
  1121. photo.editTags([photo.getID()]);
  1122. }
  1123. })
  1124. .bind(['i', 'ctrl+i'], function() {
  1125. if (visible.infobox()) view.infobox.hide();
  1126. else if (visible.infoboxbutton()) view.infobox.show();
  1127. })
  1128. .bind(['command+backspace', 'ctrl+backspace'], function() {
  1129. if (visible.photo()&&!visible.message()) photo.delete([photo.getID()]);
  1130. else if (visible.album()&&!visible.message()) album.delete([album.getID()]);
  1131. });
  1132. Mousetrap.bindGlobal('enter', function() {
  1133. if ($(".message .button.active").length) $(".message .button.active").addClass("pressed").click()
  1134. });
  1135. Mousetrap.bindGlobal(['esc', 'command+up'], function(e) {
  1136. e.preventDefault();
  1137. if (visible.message()&&$(".message .close").length>0) modal.close();
  1138. else if (visible.contextMenu()) contextMenu.close();
  1139. else if (visible.infobox()) view.infobox.hide();
  1140. else if (visible.photo()) lychee.goto(album.getID());
  1141. else if (visible.album()) lychee.goto("");
  1142. else if (visible.albums()&&$("#search").val().length!==0) search.reset();
  1143. });
  1144. if (mobileBrowser()) {
  1145. $(document)
  1146. /* Fullscreen on mobile */
  1147. .on('touchend', '#image', function(e) {
  1148. if (swipe.obj===null||(swipe.offset>=-5&&swipe.offset<=5)) {
  1149. if (visible.controls()) view.header.hide(e, 0);
  1150. else view.header.show();
  1151. }
  1152. })
  1153. /* Swipe on mobile */
  1154. .swipe().on('swipeStart', function() { if (visible.photo()) swipe.start($("#image")) })
  1155. .swipe().on('swipeMove', function(e) { if (visible.photo()) swipe.move(e.swipe) })
  1156. .swipe().on('swipeEnd', function(e) { if (visible.photo()) swipe.stop(e.swipe, photo.previous, photo.next) });
  1157. }
  1158. /* Document */
  1159. $(document)
  1160. /* Login */
  1161. .on("keyup", "#password", function() { if ($(this).val().length>0) $(this).removeClass("error") })
  1162. /* Header */
  1163. .on(event_name, "#title.editable", function() {
  1164. if (visible.photo()) photo.setTitle([photo.getID()]);
  1165. else album.setTitle([album.getID()]);
  1166. })
  1167. /* Navigation */
  1168. .on("click", ".album", function() { lychee.goto($(this).attr("data-id")) })
  1169. .on("click", ".photo", function() { lychee.goto(album.getID() + "/" + $(this).attr("data-id")) })
  1170. /* Modal */
  1171. .on(event_name, ".message .close", modal.close)
  1172. .on(event_name, ".message .button:first", function() { if (modal.fns!==null) modal.fns[0](); if (!visible.signin()) modal.close() })
  1173. .on(event_name, ".message .button:last", function() { if (modal.fns!==null) modal.fns[1](); if (!visible.signin()) modal.close() })
  1174. /* Add Dialog */
  1175. .on(event_name, ".button_add", function(e) { contextMenu.add(e) })
  1176. /* Context Menu */
  1177. .on("contextmenu", ".photo", function(e) { contextMenu.photo(photo.getID(), e) })
  1178. .on("contextmenu", ".album", function(e) { contextMenu.album(album.getID(), e) })
  1179. .on(event_name, ".contextmenu_bg", contextMenu.close)
  1180. .on("contextmenu", ".contextmenu_bg", contextMenu.close)
  1181. /* Infobox */
  1182. .on(event_name, "#infobox_overlay", view.infobox.hide)
  1183. /* Upload */
  1184. .on("change", "#upload_files", function() { modal.close(); upload.start.local(this.files) })
  1185. .on(event_name, ".upload_message a.close", upload.close)
  1186. .on("dragover", function(e) { e.preventDefault(); }, false)
  1187. .on("drop", function(e) {
  1188. e.stopPropagation();
  1189. e.preventDefault();
  1190. if (e.originalEvent.dataTransfer.files.length>0) upload.start.local(e.originalEvent.dataTransfer.files);
  1191. else if (e.originalEvent.dataTransfer.getData('Text').length>3) upload.start.url(e.originalEvent.dataTransfer.getData('Text'));
  1192. return true;
  1193. });
  1194. /* Init */
  1195. lychee.init();
  1196. });
  1197. /**
  1198. * @name LoadingBar Module
  1199. * @description This module is used to show and hide the loading bar.
  1200. * @author Tobias Reich
  1201. * @copyright 2014 by Tobias Reich
  1202. */
  1203. loadingBar = {
  1204. status: null,
  1205. show: function(status, errorText) {
  1206. if (status==='error') {
  1207. // Set status
  1208. loadingBar.status = 'error';
  1209. // Parse text
  1210. if (errorText) errorText = errorText.replace('<br>', '');
  1211. if (!errorText) errorText = 'Whoops, it looks like something went wrong. Please reload the site and try again!';
  1212. // Move header down
  1213. if (visible.controls()) lychee.header.addClass('error');
  1214. // Modify loading
  1215. lychee.loadingBar
  1216. .removeClass('loading uploading error')
  1217. .addClass(status)
  1218. .html('<h1>Error: <span>' + errorText + '</span></h1>')
  1219. .show()
  1220. .css('height', '40px');
  1221. // Set timeout
  1222. clearTimeout(lychee.loadingBar.data('timeout'));
  1223. lychee.loadingBar.data('timeout', setTimeout(function() { loadingBar.hide(true) }, 3000));
  1224. return true;
  1225. }
  1226. if (loadingBar.status===null) {
  1227. // Set status
  1228. loadingBar.status = 'loading';
  1229. // Set timeout
  1230. clearTimeout(lychee.loadingBar.data('timeout'));
  1231. lychee.loadingBar.data('timeout', setTimeout(function() {
  1232. // Move header down
  1233. if (visible.controls()) lychee.header.addClass('loading');
  1234. // Modify loading
  1235. lychee.loadingBar
  1236. .removeClass('loading uploading error')
  1237. .addClass('loading')
  1238. .show();
  1239. }, 1000));
  1240. return true;
  1241. }
  1242. },
  1243. hide: function(force) {
  1244. if ((loadingBar.status!=='error'&&loadingBar.status!==null)||force) {
  1245. // Remove status
  1246. loadingBar.status = null;
  1247. // Move header up
  1248. if (visible.controls()) lychee.header.removeClass('error loading');
  1249. // Modify loading
  1250. lychee.loadingBar
  1251. .html('')
  1252. .css('height', '3px');
  1253. // Set timeout
  1254. clearTimeout(lychee.loadingBar.data('timeout'));
  1255. setTimeout(function() { lychee.loadingBar.hide() }, 300);
  1256. }
  1257. }
  1258. };
  1259. /**
  1260. * @name Lychee Module
  1261. * @description This module provides the basic functions of Lychee.
  1262. * @author Tobias Reich
  1263. * @copyright 2014 by Tobias Reich
  1264. */
  1265. var lychee = {
  1266. title: "",
  1267. version: "2.6.1",
  1268. version_code: "020601",
  1269. api_path: "php/api.php",
  1270. update_path: "http://lychee.electerious.com/version/index.php",
  1271. updateURL: "https://github.com/electerious/Lychee",
  1272. website: "http://lychee.electerious.com",
  1273. publicMode: false,
  1274. viewMode: false,
  1275. debugMode: false,
  1276. username: "",
  1277. checkForUpdates: false,
  1278. sorting: "",
  1279. location: "",
  1280. dropbox: false,
  1281. dropboxKey: '',
  1282. loadingBar: $("#loading"),
  1283. header: $("header"),
  1284. content: $("#content"),
  1285. imageview: $("#imageview"),
  1286. infobox: $("#infobox"),
  1287. init: function() {
  1288. var params;
  1289. params = "init&version=" + lychee.version_code;
  1290. lychee.api(params, function(data) {
  1291. if (data.loggedIn!==true) {
  1292. lychee.setMode("public");
  1293. } else {
  1294. lychee.username = data.config.username || '';
  1295. lychee.sorting = data.config.sorting || '';
  1296. lychee.dropboxKey = data.config.dropboxKey || '';
  1297. lychee.location = data.config.location || '';
  1298. }
  1299. // No configuration
  1300. if (data==="Warning: No configuration!") {
  1301. lychee.header.hide();
  1302. lychee.content.hide();
  1303. $("body").append(build.no_content("cog"));
  1304. settings.createConfig();
  1305. return true;
  1306. }
  1307. // No login
  1308. if (data.config.login===false) {
  1309. settings.createLogin();
  1310. }
  1311. lychee.checkForUpdates = data.config.checkForUpdates;
  1312. $(window).bind("popstate", lychee.load);
  1313. lychee.load();
  1314. });
  1315. },
  1316. api: function(params, callback, loading) {
  1317. if (loading===undefined) loadingBar.show();
  1318. $.ajax({
  1319. type: "POST",
  1320. url: lychee.api_path,
  1321. data: "function=" + params,
  1322. dataType: "text",
  1323. success: function(data) {
  1324. setTimeout(function() { loadingBar.hide() }, 100);
  1325. if (typeof data==="string"&&data.substring(0, 7)==="Error: ") {
  1326. lychee.error(data.substring(7, data.length), params, data);
  1327. upload.close(true);
  1328. return false;
  1329. }
  1330. if (data==="1") data = true;
  1331. else if (data==="") data = false;
  1332. if (typeof data==="string"&&data.substring(0, 1)==="{"&&data.substring(data.length-1, data.length)==="}") data = $.parseJSON(data);
  1333. if (lychee.debugMode) console.log(data);
  1334. callback(data);
  1335. },
  1336. error: function(jqXHR, textStatus, errorThrown) {
  1337. lychee.error("Server error or API not found.", params, errorThrown);
  1338. upload.close(true);
  1339. }
  1340. });
  1341. },
  1342. login: function() {
  1343. var user = $("input#username").val(),
  1344. password = md5($("input#password").val()),
  1345. params;
  1346. params = "login&user=" + user + "&password=" + password;
  1347. lychee.api(params, function(data) {
  1348. if (data===true) {
  1349. localStorage.setItem("lychee_username", user);
  1350. window.location.reload();
  1351. } else {
  1352. $("#password").val("").addClass("error").focus();
  1353. $(".message .button.active").removeClass("pressed");
  1354. }
  1355. });
  1356. },
  1357. loginDialog: function() {
  1358. var local_username;
  1359. $("body").append(build.signInModal());
  1360. $("#username").focus();
  1361. if (localStorage) {
  1362. local_username = localStorage.getItem("lychee_username");
  1363. if (local_username!==null) {
  1364. if (local_username.length>0) $("#username").val(local_username);
  1365. $("#password").focus();
  1366. }
  1367. }
  1368. if (lychee.checkForUpdates==="1") lychee.getUpdate();
  1369. },
  1370. logout: function() {
  1371. lychee.api("logout", function(data) {
  1372. window.location.reload();
  1373. });
  1374. },
  1375. goto: function(url) {
  1376. if (url===undefined) url = "#";
  1377. else url = "#" + url;
  1378. history.pushState(null, null, url);
  1379. lychee.load();
  1380. },
  1381. load: function() {
  1382. var albumID = "",
  1383. photoID = "",
  1384. hash = document.location.hash.replace("#", "").split("/");
  1385. $(".no_content").remove();
  1386. contextMenu.close();
  1387. multiselect.close();
  1388. if (hash[0]!==undefined) albumID = hash[0];
  1389. if (hash[1]!==undefined) photoID = hash[1];
  1390. if (albumID&&photoID) {
  1391. // Trash data
  1392. albums.json = null;
  1393. photo.json = null;
  1394. // Show Photo
  1395. if (lychee.content.html()===""||($("#search").length&&$("#search").val().length!==0)) {
  1396. lychee.content.hide();
  1397. album.load(albumID, true);
  1398. }
  1399. photo.load(photoID, albumID);
  1400. } else if (albumID) {
  1401. // Trash data
  1402. albums.json = null;
  1403. photo.json = null;
  1404. // Show Album
  1405. if (visible.photo()) view.photo.hide();
  1406. if (album.json&&albumID==album.json.id) view.album.title();
  1407. else album.load(albumID);
  1408. } else {
  1409. // Trash data
  1410. albums.json = null;
  1411. album.json = null;
  1412. photo.json = null;
  1413. search.code = "";
  1414. // Show Albums
  1415. if (visible.album()) view.album.hide();
  1416. if (visible.photo()) view.photo.hide();
  1417. albums.load();
  1418. }
  1419. },
  1420. getUpdate: function() {
  1421. $.ajax({
  1422. url: lychee.update_path,
  1423. success: function(data) { if (parseInt(data)>parseInt(lychee.version_code)) $("#version span").show(); }
  1424. });
  1425. },
  1426. setTitle: function(title, editable) {
  1427. if (lychee.title==="") lychee.title = document.title;
  1428. if (title==="Albums") document.title = lychee.title;
  1429. else document.title = lychee.title + " - " + title;
  1430. if (editable) $("#title").addClass("editable");
  1431. else $("#title").removeClass("editable");
  1432. $("#title").html(title);
  1433. },
  1434. setMode: function(mode) {
  1435. $("#button_settings, #button_settings, #button_search, #search, #button_trash_album, #button_share_album, .button_add, .button_divider").remove();
  1436. $("#button_trash, #button_move, #button_share, #button_star").remove();
  1437. $(document)
  1438. .on("mouseenter", "#title.editable", function() { $(this).removeClass("editable") })
  1439. .off("click", "#title.editable")
  1440. .off("touchend", "#title.editable")
  1441. .off("contextmenu", ".photo")
  1442. .off("contextmenu", ".album")
  1443. .off("drop");
  1444. Mousetrap
  1445. .unbind(['u', 'ctrl+u'])
  1446. .unbind(['s', 'ctrl+s'])
  1447. .unbind(['r', 'ctrl+r'])
  1448. .unbind(['d', 'ctrl+d'])
  1449. .unbind(['t', 'ctrl+t'])
  1450. .unbind(['command+backspace', 'ctrl+backspace']);
  1451. if (mode==="public") {
  1452. $("header #button_signin, header #hostedwith").show();
  1453. lychee.publicMode = true;
  1454. } else if (mode==="view") {
  1455. Mousetrap.unbind('esc');
  1456. $("#button_back, a#next, a#previous").remove();
  1457. $(".no_content").remove();
  1458. lychee.publicMode = true;
  1459. lychee.viewMode = true;
  1460. }
  1461. },
  1462. animate: function(obj, animation) {
  1463. var animations = [
  1464. ["fadeIn", "fadeOut"],
  1465. ["contentZoomIn", "contentZoomOut"]
  1466. ];
  1467. if (!obj.jQuery) obj = $(obj);
  1468. for (var i = 0; i < animations.length; i++) {
  1469. for (var x = 0; x < animations[i].length; x++) {
  1470. if (animations[i][x]==animation) {
  1471. obj.removeClass(animations[i][0] + " " + animations[i][1]).addClass(animation);
  1472. return true;
  1473. }
  1474. }
  1475. }
  1476. return false;
  1477. },
  1478. escapeHTML: function(s) {
  1479. return s.replace(/&/g, '&amp;')
  1480. .replace(/"/g, '&quot;')
  1481. .replace(/</g, '&lt;')
  1482. .replace(/>/g, '&gt;');
  1483. },
  1484. loadDropbox: function(callback) {
  1485. if (!lychee.dropbox&&lychee.dropboxKey) {
  1486. loadingBar.show();
  1487. var g = document.createElement("script"),
  1488. s = document.getElementsByTagName("script")[0];
  1489. g.src = "https://www.dropbox.com/static/api/1/dropins.js";
  1490. g.id = "dropboxjs";
  1491. g.type = "text/javascript";
  1492. g.async = "true";
  1493. g.setAttribute("data-app-key", lychee.dropboxKey);
  1494. g.onload = g.onreadystatechange = function() {
  1495. var rs = this.readyState;
  1496. if (rs&&rs!=="complete"&&rs!=="loaded") return;
  1497. lychee.dropbox = true;
  1498. loadingBar.hide();
  1499. callback();
  1500. };
  1501. s.parentNode.insertBefore(g, s);
  1502. } else if (lychee.dropbox&&lychee.dropboxKey) {
  1503. callback();
  1504. } else {
  1505. settings.setDropboxKey(callback);
  1506. }
  1507. },
  1508. removeHTML: function(html) {
  1509. var tmp = document.createElement("DIV");
  1510. tmp.innerHTML = html;
  1511. return tmp.textContent || tmp.innerText;
  1512. },
  1513. error: function(errorThrown, params, data) {
  1514. console.error({
  1515. description: errorThrown,
  1516. params: params,
  1517. response: data
  1518. });
  1519. loadingBar.show("error", errorThrown);
  1520. }
  1521. };
  1522. /**
  1523. * @name Modal Module
  1524. * @description Build, show and hide a modal.
  1525. * @author Tobias Reich
  1526. * @copyright 2014 by Tobias Reich
  1527. */
  1528. modal = {
  1529. fns: null,
  1530. show: function(title, text, buttons, marginTop, closeButton) {
  1531. if (!buttons) {
  1532. buttons = [
  1533. ["", function() {}],
  1534. ["", function() {}]
  1535. ];
  1536. }
  1537. modal.fns = [buttons[0][1], buttons[1][1]];
  1538. $("body").append(build.modal(title, text, buttons, marginTop, closeButton));
  1539. $(".message input:first-child").focus().select();
  1540. },
  1541. close: function() {
  1542. modal.fns = null;
  1543. $(".message_overlay").removeClass("fadeIn").css("opacity", 0);
  1544. setTimeout(function() { $(".message_overlay").remove() }, 300);
  1545. }
  1546. };
  1547. /**
  1548. * @name Multiselect Module
  1549. * @description Select multiple albums or photos.
  1550. * @author Tobias Reich
  1551. * @copyright 2014 by Tobias Reich
  1552. */
  1553. multiselect = {
  1554. position: {
  1555. top: null,
  1556. right: null,
  1557. bottom: null,
  1558. left: null
  1559. },
  1560. show: function(e) {
  1561. if (mobileBrowser()) return false;
  1562. if (lychee.publicMode) return false;
  1563. if (visible.search()) return false;
  1564. if ($('.album:hover, .photo:hover').length!==0) return false;
  1565. if (visible.multiselect()) $('#multiselect').remove();
  1566. multiselect.position.top = e.pageY;
  1567. multiselect.position.right = -1 * (e.pageX - $(document).width());
  1568. multiselect.position.bottom = -1 * (multiselect.position.top - $(window).height());
  1569. multiselect.position.left = e.pageX;
  1570. $('body').append(build.multiselect(multiselect.position.top, multiselect.position.left));
  1571. $(document).on('mousemove', multiselect.resize);
  1572. },
  1573. resize: function(e) {
  1574. var mouse_x = e.pageX,
  1575. mouse_y = e.pageY,
  1576. newHeight,
  1577. newWidth;
  1578. if (multiselect.position.top===null||
  1579. multiselect.position.right===null||
  1580. multiselect.position.bottom===null||
  1581. multiselect.position.left===null) return false;
  1582. if (mouse_y>=multiselect.position.top) {
  1583. // Do not leave the screen
  1584. newHeight = e.pageY - multiselect.position.top;
  1585. if ((multiselect.position.top+newHeight)>=$(document).height())
  1586. newHeight -= (multiselect.position.top + newHeight) - $(document).height() + 2;
  1587. $('#multiselect').css({
  1588. top: multiselect.position.top,
  1589. bottom: 'inherit',
  1590. height: newHeight
  1591. });
  1592. } else {
  1593. $('#multiselect').css({
  1594. top: 'inherit',
  1595. bottom: multiselect.position.bottom,
  1596. height: multiselect.position.top - e.pageY
  1597. });
  1598. }
  1599. if (mouse_x>=multiselect.position.left) {
  1600. // Do not leave the screen
  1601. newWidth = e.pageX - multiselect.position.left;
  1602. if ((multiselect.position.left+newWidth)>=$(document).width())
  1603. newWidth -= (multiselect.position.left + newWidth) - $(document).width() + 2;
  1604. $('#multiselect').css({
  1605. right: 'inherit',
  1606. left: multiselect.position.left,
  1607. width: newWidth
  1608. });
  1609. } else {
  1610. $('#multiselect').css({
  1611. right: multiselect.position.right,
  1612. left: 'inherit',
  1613. width: multiselect.position.left - e.pageX
  1614. });
  1615. }
  1616. },
  1617. stopResize: function() {
  1618. $(document).off('mousemove');
  1619. },
  1620. getSize: function() {
  1621. if (!visible.multiselect()) return false;
  1622. return {
  1623. top: $('#multiselect').offset().top,
  1624. left: $('#multiselect').offset().left,
  1625. width: parseInt($('#multiselect').css('width').replace('px', '')),
  1626. height: parseInt($('#multiselect').css('height').replace('px', ''))
  1627. };
  1628. },
  1629. getSelection: function(e) {
  1630. var tolerance = 150,
  1631. id,
  1632. ids = [],
  1633. offset,
  1634. size = multiselect.getSize();
  1635. if (visible.contextMenu()) return false;
  1636. if (!visible.multiselect()) return false;
  1637. $('.photo, .album').each(function() {
  1638. offset = $(this).offset();
  1639. if (offset.top>=(size.top-tolerance)&&
  1640. offset.left>=(size.left-tolerance)&&
  1641. (offset.top+206)<=(size.top+size.height+tolerance)&&
  1642. (offset.left+206)<=(size.left+size.width+tolerance)) {
  1643. id = $(this).data('id');
  1644. if (id!=='0'&&id!==0&&id!=='f'&&id!=='s'&&id!=='r'&&id!==null&id!==undefined) {
  1645. ids.push(id);
  1646. $(this).addClass('active');
  1647. }
  1648. }
  1649. });
  1650. if (ids.length!==0&&visible.album()) contextMenu.photoMulti(ids, e);
  1651. else if (ids.length!==0&&visible.albums()) contextMenu.albumMulti(ids, e);
  1652. else multiselect.close();
  1653. },
  1654. close: function() {
  1655. multiselect.stopResize();
  1656. multiselect.position.top = null;
  1657. multiselect.position.right = null;
  1658. multiselect.position.bottom = null;
  1659. multiselect.position.left = null;
  1660. lychee.animate('#multiselect', 'fadeOut');
  1661. setTimeout(function() {
  1662. $('#multiselect').remove();
  1663. }, 300);
  1664. }
  1665. };
  1666. /**
  1667. * @name Password Module
  1668. * @description Controls the access to password-protected albums and photos.
  1669. * @author Tobias Reich
  1670. * @copyright 2014 by Tobias Reich
  1671. */
  1672. password = {
  1673. value: "",
  1674. get: function(albumID, callback) {
  1675. var passwd = $(".message input.text").val(),
  1676. params;
  1677. if (!lychee.publicMode) callback();
  1678. else if (album.json&&album.json.password==false) callback();
  1679. else if (albums.json&&albums.json.content[albumID].password==false) callback();
  1680. else if (!albums.json&&!album.json) {
  1681. // Continue without password
  1682. album.json = {password: true};
  1683. callback("");
  1684. } else if (passwd==undefined) {
  1685. // Request password
  1686. password.getDialog(albumID, callback);
  1687. } else {
  1688. // Check password
  1689. params = "checkAlbumAccess&albumID=" + albumID + "&password=" + md5(passwd);
  1690. lychee.api(params, function(data) {
  1691. if (data===true) {
  1692. password.value = md5(passwd);
  1693. callback();
  1694. } else {
  1695. lychee.goto("");
  1696. loadingBar.show("error", "Access denied. Wrong password!");
  1697. }
  1698. });
  1699. }
  1700. },
  1701. getDialog: function(albumID, callback) {
  1702. var buttons;
  1703. buttons = [
  1704. ["Enter", function() { password.get(albumID, callback) }],
  1705. ["Cancel", lychee.goto]
  1706. ];
  1707. modal.show("<a class='icon-lock'></a> Enter Password", "This album is protected by a password. Enter the password below to view the photos of this album: <input class='text' type='password' placeholder='password' value=''>", buttons, -110, false);
  1708. }
  1709. };
  1710. /**
  1711. * @name Photo Module
  1712. * @description Takes care of every action a photo can handle and execute.
  1713. * @author Tobias Reich
  1714. * @copyright 2014 by Tobias Reich
  1715. */
  1716. photo = {
  1717. json: null,
  1718. getID: function() {
  1719. var id;
  1720. if (photo.json) id = photo.json.id;
  1721. else id = $(".photo:hover, .photo.active").attr("data-id");
  1722. if (id) return id;
  1723. else return false;
  1724. },
  1725. load: function(photoID, albumID) {
  1726. var params,
  1727. checkPasswd;
  1728. params = "getPhoto&photoID=" + photoID + "&albumID=" + albumID + "&password=" + password.value;
  1729. lychee.api(params, function(data) {
  1730. if (data==="Warning: Wrong password!") {
  1731. checkPasswd = function() {
  1732. if (password.value!=="") photo.load(photoID, albumID);
  1733. else setTimeout(checkPasswd, 250);
  1734. };
  1735. checkPasswd();
  1736. return false;
  1737. }
  1738. photo.json = data;
  1739. if (!visible.photo()) view.photo.show();
  1740. view.photo.init();
  1741. lychee.imageview.show();
  1742. setTimeout(function() { lychee.content.show() }, 300);
  1743. });
  1744. },
  1745. parse: function() {
  1746. if (!photo.json.title) photo.json.title = "Untitled";
  1747. },
  1748. previous: function(animate) {
  1749. var delay = 0;
  1750. if (photo.getID()!==false&&
  1751. album.json&&
  1752. album.json.content[photo.getID()]&&
  1753. album.json.content[photo.getID()].previousPhoto!=="") {
  1754. if (animate===true) {
  1755. delay = 200;
  1756. $("#image").css({
  1757. WebkitTransform: 'translateX(100%)',
  1758. MozTransform: 'translateX(100%)',
  1759. transform: 'translateX(100%)',
  1760. opacity: 0
  1761. });
  1762. }
  1763. setTimeout(function() {
  1764. if (photo.getID()===false) return false;
  1765. lychee.goto(album.getID() + "/" + album.json.content[photo.getID()].previousPhoto)
  1766. }, delay);
  1767. }
  1768. },
  1769. next: function(animate) {
  1770. var delay = 0;
  1771. if (photo.getID()!==false&&
  1772. album.json&&
  1773. album.json.content[photo.getID()]&&
  1774. album.json.content[photo.getID()].nextPhoto!=="") {
  1775. if (animate===true) {
  1776. delay = 200;
  1777. $("#image").css({
  1778. WebkitTransform: 'translateX(-100%)',
  1779. MozTransform: 'translateX(-100%)',
  1780. transform: 'translateX(-100%)',
  1781. opacity: 0
  1782. });
  1783. }
  1784. setTimeout(function() {
  1785. if (photo.getID()===false) return false;
  1786. lychee.goto(album.getID() + "/" + album.json.content[photo.getID()].nextPhoto);
  1787. }, delay);
  1788. }
  1789. },
  1790. delete: function(photoIDs) {
  1791. var params,
  1792. buttons,
  1793. photoTitle;
  1794. if (!photoIDs) return false;
  1795. if (photoIDs instanceof Array===false) photoIDs = [photoIDs];
  1796. if (photoIDs.length===1) {
  1797. // Get title if only one photo is selected
  1798. if (visible.photo()) photoTitle = photo.json.title;
  1799. else photoTitle = album.json.content[photoIDs].title;
  1800. if (photoTitle==="") photoTitle = "Untitled";
  1801. }
  1802. buttons = [
  1803. ["", function() {
  1804. photoIDs.forEach(function(id, index, array) {
  1805. // Change reference for the next and previous photo
  1806. if (album.json.content[id].nextPhoto!==""||album.json.content[id].previousPhoto!=="") {
  1807. nextPhoto = album.json.content[id].nextPhoto;
  1808. previousPhoto = album.json.content[id].previousPhoto;
  1809. album.json.content[previousPhoto].nextPhoto = nextPhoto;
  1810. album.json.content[nextPhoto].previousPhoto = previousPhoto;
  1811. }
  1812. album.json.content[id] = null;
  1813. view.album.content.delete(id);
  1814. });
  1815. // Only when search is not active
  1816. if (!visible.albums()) lychee.goto(album.getID());
  1817. params = "deletePhoto&photoIDs=" + photoIDs;
  1818. lychee.api(params, function(data) {
  1819. if (data!==true) lychee.error(null, params, data);
  1820. });
  1821. }],
  1822. ["", function() {}]
  1823. ];
  1824. if (photoIDs.length===1) {
  1825. buttons[0][0] = "Delete Photo";
  1826. buttons[1][0] = "Keep Photo";
  1827. modal.show("Delete Photo", "Are you sure you want to delete the photo '" + photoTitle + "'?<br>This action can't be undone!", buttons);
  1828. } else {
  1829. buttons[0][0] = "Delete Photos";
  1830. buttons[1][0] = "Keep Photos";
  1831. modal.show("Delete Photos", "Are you sure you want to delete all " + photoIDs.length + " selected photo?<br>This action can't be undone!", buttons);
  1832. }
  1833. },
  1834. setTitle: function(photoIDs) {
  1835. var oldTitle = "",
  1836. newTitle,
  1837. params,
  1838. buttons;
  1839. if (!photoIDs) return false;
  1840. if (photoIDs instanceof Array===false) photoIDs = [photoIDs];
  1841. if (photoIDs.length===1) {
  1842. // Get old title if only one photo is selected
  1843. if (photo.json) oldTitle = photo.json.title;
  1844. else if (album.json) oldTitle = album.json.content[photoIDs].title;
  1845. oldTitle = oldTitle.replace("'", "&apos;");
  1846. }
  1847. buttons = [
  1848. ["Set Title", function() {
  1849. // Get input
  1850. newTitle = $(".message input.text").val();
  1851. // Remove html from input
  1852. newTitle = lychee.removeHTML(newTitle);
  1853. if (visible.photo()) {
  1854. photo.json.title = (newTitle==="") ? "Untitled" : newTitle;
  1855. view.photo.title();
  1856. }
  1857. photoIDs.forEach(function(id, index, array) {
  1858. album.json.content[id].title = newTitle;
  1859. view.album.content.title(id);
  1860. });
  1861. params = "setPhotoTitle&photoIDs=" + photoIDs + "&title=" + escape(encodeURI(newTitle));
  1862. lychee.api(params, function(data) {
  1863. if (data!==true) lychee.error(null, params, data);
  1864. });
  1865. }],
  1866. ["Cancel", function() {}]
  1867. ];
  1868. if (photoIDs.length===1) modal.show("Set Title", "Enter a new title for this photo: <input class='text' type='text' maxlength='30' placeholder='Title' value='" + oldTitle + "'>", buttons);
  1869. else modal.show("Set Titles", "Enter a title for all " + photoIDs.length + " selected photos: <input class='text' type='text' maxlength='30' placeholder='Title' value=''>", buttons);
  1870. },
  1871. setAlbum: function(photoIDs, albumID) {
  1872. var params,
  1873. nextPhoto,
  1874. previousPhoto;
  1875. if (!photoIDs) return false;
  1876. if (visible.photo) lychee.goto(album.getID());
  1877. if (photoIDs instanceof Array===false) photoIDs = [photoIDs];
  1878. photoIDs.forEach(function(id, index, array) {
  1879. // Change reference for the next and previous photo
  1880. if (album.json.content[id].nextPhoto!==""||album.json.content[id].previousPhoto!=="") {
  1881. nextPhoto = album.json.content[id].nextPhoto;
  1882. previousPhoto = album.json.content[id].previousPhoto;
  1883. album.json.content[previousPhoto].nextPhoto = nextPhoto;
  1884. album.json.content[nextPhoto].previousPhoto = previousPhoto;
  1885. }
  1886. album.json.content[id] = null;
  1887. view.album.content.delete(id);
  1888. });
  1889. params = "setPhotoAlbum&photoIDs=" + photoIDs + "&albumID=" + albumID;
  1890. lychee.api(params, function(data) {
  1891. if (data!==true) lychee.error(null, params, data);
  1892. });
  1893. },
  1894. setStar: function(photoIDs) {
  1895. var params;
  1896. if (!photoIDs) return false;
  1897. if (visible.photo()) {
  1898. photo.json.star = (photo.json.star==0) ? 1 : 0;
  1899. view.photo.star();
  1900. }
  1901. photoIDs.forEach(function(id, index, array) {
  1902. album.json.content[id].star = (album.json.content[id].star==0) ? 1 : 0;
  1903. view.album.content.star(id);
  1904. });
  1905. params = "setPhotoStar&photoIDs=" + photoIDs;
  1906. lychee.api(params, function(data) {
  1907. if (data!==true) lychee.error(null, params, data);
  1908. });
  1909. },
  1910. setPublic: function(photoID, e) {
  1911. var params;
  1912. if (photo.json.public==2) {
  1913. modal.show("Public Album", "This photo is located in a public album. To make this photo private or public, edit the visibility of the associated album.", [["Show Album", function() { lychee.goto(photo.json.original_album) }], ["Close", function() {}]]);
  1914. return false;
  1915. }
  1916. if (visible.photo()) {
  1917. photo.json.public = (photo.json.public==0) ? 1 : 0;
  1918. view.photo.public();
  1919. if (photo.json.public==1) contextMenu.sharePhoto(photoID, e);
  1920. }
  1921. album.json.content[photoID].public = (album.json.content[photoID].public==0) ? 1 : 0;
  1922. view.album.content.public(photoID);
  1923. params = "setPhotoPublic&photoID=" + photoID;
  1924. lychee.api(params, function(data) {
  1925. if (data!==true) lychee.error(null, params, data);
  1926. });
  1927. },
  1928. setDescription: function(photoID) {
  1929. var oldDescription = photo.json.description.replace("'", "&apos;"),
  1930. description,
  1931. params,
  1932. buttons;
  1933. buttons = [
  1934. ["Set Description", function() {
  1935. // Get input
  1936. description = $(".message input.text").val();
  1937. // Remove html from input
  1938. description = lychee.removeHTML(description);
  1939. if (visible.photo()) {
  1940. photo.json.description = description;
  1941. view.photo.description();
  1942. }
  1943. params = "setPhotoDescription&photoID=" + photoID + "&description=" + escape(encodeURI(description));
  1944. lychee.api(params, function(data) {
  1945. if (data!==true) lychee.error(null, params, data);
  1946. });
  1947. }],
  1948. ["Cancel", function() {}]
  1949. ];
  1950. modal.show("Set Description", "Enter a description for this photo: <input class='text' type='text' maxlength='800' placeholder='Description' value='" + oldDescription + "'>", buttons);
  1951. },
  1952. editTags: function(photoIDs) {
  1953. var oldTags = "",
  1954. tags = "",
  1955. buttons;
  1956. if (!photoIDs) return false;
  1957. if (photoIDs instanceof Array===false) photoIDs = [photoIDs];
  1958. // Get tags
  1959. if (visible.photo()) oldTags = photo.json.tags;
  1960. if (visible.album()&&photoIDs.length===1) oldTags = album.json.content[photoIDs].tags;
  1961. if (visible.album()&&photoIDs.length>1) {
  1962. var same = true;
  1963. photoIDs.forEach(function(id, index, array) {
  1964. if(album.json.content[id].tags===album.json.content[photoIDs[0]].tags&&same===true) same = true;
  1965. else same = false;
  1966. });
  1967. if (same) oldTags = album.json.content[photoIDs[0]].tags;
  1968. }
  1969. // Improve tags
  1970. oldTags = oldTags.replace(/,/g, ', ');
  1971. buttons = [
  1972. ["Set Tags", function() {
  1973. tags = $(".message input.text").val();
  1974. photo.setTags(photoIDs, tags);
  1975. }],
  1976. ["Cancel", function() {}]
  1977. ];
  1978. if (photoIDs.length===1) modal.show("Set Tags", "Enter your tags for this photo. You can add multiple tags by separating them with a comma: <input class='text' type='text' maxlength='800' placeholder='Tags' value='" + oldTags + "'>", buttons);
  1979. else modal.show("Set Tags", "Enter your tags for all " + photoIDs.length + " selected photos. Existing tags will be overwritten. You can add multiple tags by separating them with a comma: <input class='text' type='text' maxlength='800' placeholder='Tags' value='" + oldTags + "'>", buttons);
  1980. },
  1981. setTags: function(photoIDs, tags) {
  1982. var params;
  1983. if (!photoIDs) return false;
  1984. if (photoIDs instanceof Array===false) photoIDs = [photoIDs];
  1985. // Parse tags
  1986. tags = tags.replace(/(\ ,\ )|(\ ,)|(,\ )|(,{1,}\ {0,})|(,$|^,)/g, ',');
  1987. tags = tags.replace(/,$|^,|(\ ){0,}$/g, '');
  1988. // Remove html from input
  1989. tags = lychee.removeHTML(tags);
  1990. if (visible.photo()) {
  1991. photo.json.tags = tags;
  1992. view.photo.tags();
  1993. }
  1994. photoIDs.forEach(function(id, index, array) {
  1995. album.json.content[id].tags = tags;
  1996. });
  1997. params = "setPhotoTags&photoIDs=" + photoIDs + "&tags=" + tags;
  1998. lychee.api(params, function(data) {
  1999. if (data!==true) lychee.error(null, params, data);
  2000. });
  2001. },
  2002. deleteTag: function(photoID, index) {
  2003. var tags;
  2004. // Remove
  2005. tags = photo.json.tags.split(',');
  2006. tags.splice(index, 1);
  2007. // Save
  2008. photo.json.tags = tags.toString();
  2009. photo.setTags([photoID], photo.json.tags);
  2010. },
  2011. share: function(photoID, service) {
  2012. var link = "",
  2013. url = photo.getViewLink(photoID),
  2014. filename = "unknown";
  2015. switch (service) {
  2016. case 0:
  2017. link = "https://twitter.com/share?url=" + encodeURI(url);
  2018. break;
  2019. case 1:
  2020. link = "http://www.facebook.com/sharer.php?u=" + encodeURI(url) + "&t=" + encodeURI(photo.json.title);
  2021. break;
  2022. case 2:
  2023. link = "mailto:?subject=" + encodeURI(photo.json.title) + "&body=" + encodeURI(url);
  2024. break;
  2025. case 3:
  2026. lychee.loadDropbox(function() {
  2027. filename = photo.json.title + "." + photo.getDirectLink().split('.').pop();
  2028. Dropbox.save(photo.getDirectLink(), filename);
  2029. });
  2030. break;
  2031. default:
  2032. link = "";
  2033. break;
  2034. }
  2035. if (link.length>5) location.href = link;
  2036. },
  2037. isSmall: function() {
  2038. var size = {
  2039. width: false,
  2040. height: false
  2041. };
  2042. if (photo.json.width<$(window).width()-60) size.width = true;
  2043. if (photo.json.height<$(window).height()-100) size.height = true;
  2044. if (size.width&&size.height) return true;
  2045. else return false;
  2046. },
  2047. getArchive: function(photoID) {
  2048. var link;
  2049. if (location.href.indexOf("index.html")>0) link = location.href.replace(location.hash, "").replace("index.html", "php/api.php?function=getPhotoArchive&photoID=" + photoID);
  2050. else link = location.href.replace(location.hash, "") + "php/api.php?function=getPhotoArchive&photoID=" + photoID;
  2051. if (lychee.publicMode) link += "&password=" + password.value;
  2052. location.href = link;
  2053. },
  2054. getDirectLink: function() {
  2055. return $("#imageview #image").css("background-image").replace(/"/g,"").replace(/url\(|\)$/ig, "");
  2056. },
  2057. getViewLink: function(photoID) {
  2058. if (location.href.indexOf("index.html")>0) return location.href.replace("index.html" + location.hash, "view.php?p=" + photoID);
  2059. else return location.href.replace(location.hash, "view.php?p=" + photoID);
  2060. }
  2061. };
  2062. /**
  2063. * @name Search Module
  2064. * @description Searches through your photos and albums.
  2065. * @author Tobias Reich
  2066. * @copyright 2014 by Tobias Reich
  2067. */
  2068. search = {
  2069. code: null,
  2070. find: function(term) {
  2071. var params,
  2072. albumsData = "",
  2073. photosData = "",
  2074. code;
  2075. clearTimeout($(window).data("timeout"));
  2076. $(window).data("timeout", setTimeout(function() {
  2077. if ($("#search").val().length!==0) {
  2078. params = "search&term=" + term;
  2079. lychee.api(params, function(data) {
  2080. if (data&&data.albums) {
  2081. albums.json = { content: data.albums };
  2082. $.each(albums.json.content, function() {
  2083. albums.parse(this);
  2084. albumsData += build.album(this);
  2085. });
  2086. }
  2087. if (data&&data.photos) {
  2088. album.json = { content: data.photos };
  2089. $.each(album.json.content, function() {
  2090. photosData += build.photo(this);
  2091. });
  2092. }
  2093. if (albumsData===""&&photosData==="") code = "error";
  2094. else if (albumsData==="") code = build.divider("Photos")+photosData;
  2095. else if (photosData==="") code = build.divider("Albums")+albumsData;
  2096. else code = build.divider("Photos")+photosData+build.divider("Albums")+albumsData;
  2097. if (search.code!==md5(code)) {
  2098. $(".no_content").remove();
  2099. lychee.animate(".album:nth-child(-n+50), .photo:nth-child(-n+50)", "contentZoomOut");
  2100. lychee.animate(".divider", "fadeOut");
  2101. search.code = md5(code);
  2102. setTimeout(function() {
  2103. if (code==="error") $("body").append(build.no_content("search"));
  2104. else {
  2105. lychee.content.html(code);
  2106. lychee.animate(".album:nth-child(-n+50), .photo:nth-child(-n+50)", "contentZoomIn");
  2107. $("img[data-type!='svg']").retina();
  2108. }
  2109. }, 300);
  2110. }
  2111. });
  2112. } else search.reset();
  2113. }, 250));
  2114. },
  2115. reset: function() {
  2116. $("#search").val("");
  2117. $(".no_content").remove();
  2118. if (search.code!=="") {
  2119. // Trash data
  2120. albums.json = null;
  2121. album.json = null;
  2122. photo.json = null;
  2123. search.code = "";
  2124. lychee.animate(".divider", "fadeOut");
  2125. albums.load();
  2126. }
  2127. }
  2128. };
  2129. /**
  2130. * @name Settings Module
  2131. * @description Lets you change settings.
  2132. * @author Tobias Reich
  2133. * @copyright 2014 by Tobias Reich
  2134. */
  2135. var settings = {
  2136. createConfig: function() {
  2137. var dbName,
  2138. dbUser,
  2139. dbPassword,
  2140. dbHost,
  2141. buttons,
  2142. params;
  2143. buttons = [
  2144. ["Connect", function() {
  2145. dbHost = $(".message input.text#dbHost").val();
  2146. dbUser = $(".message input.text#dbUser").val();
  2147. dbPassword = $(".message input.text#dbPassword").val();
  2148. dbName = $(".message input.text#dbName").val();
  2149. if (dbHost.length<1) dbHost = "localhost";
  2150. if (dbName.length<1) dbName = "lychee";
  2151. params = "dbCreateConfig&dbName=" + escape(dbName) + "&dbUser=" + escape(dbUser) + "&dbPassword=" + escape(dbPassword) + "&dbHost=" + escape(dbHost);
  2152. lychee.api(params, function(data) {
  2153. if (data!==true) {
  2154. // Configuration failed
  2155. setTimeout(function() {
  2156. // Connection failed
  2157. if (data.indexOf("Warning: Connection failed!")!==-1) {
  2158. buttons = [
  2159. ["Retry", function() { setTimeout(settings.createConfig, 400) }],
  2160. ["", function() {}]
  2161. ];
  2162. modal.show("Connection Failed", "Unable to connect to host database because access was denied. Double-check your host, username and password and ensure that access from your current location is permitted.", buttons, null, false);
  2163. return false;
  2164. }
  2165. // Creation failed
  2166. if (data.indexOf("Warning: Creation failed!")!==-1) {
  2167. buttons = [
  2168. ["Retry", function() { setTimeout(settings.createConfig, 400) }],
  2169. ["", function() {}]
  2170. ];
  2171. modal.show("Creation Failed", "Unable to create the database. Double-check your host, username and password and ensure that the specified user has the rights to modify and add content to the database.", buttons, null, false);
  2172. return false;
  2173. }
  2174. // Could not create file
  2175. if (data.indexOf("Warning: Could not create file!")!==-1) {
  2176. buttons = [
  2177. ["Retry", function() { setTimeout(settings.createConfig, 400) }],
  2178. ["", function() {}]
  2179. ];
  2180. modal.show("Saving Failed", "Unable to save this configuration. Permission denied in <b>'data/'</b>. Please set the read, write and execute rights for others in <b>'data/'</b> and <b>'uploads/'</b>. Take a look the readme for more information.", buttons, null, false);
  2181. return false;
  2182. }
  2183. // Something went wrong
  2184. buttons = [
  2185. ["Retry", function() { setTimeout(settings.createConfig, 400) }],
  2186. ["", function() {}]
  2187. ];
  2188. modal.show("Configuration Failed", "Something unexpected happened. Please try again and check your installation and server. Take a look the readme for more information.", buttons, null, false);
  2189. return false;
  2190. }, 400);
  2191. } else {
  2192. // Configuration successful
  2193. window.location.reload();
  2194. }
  2195. });
  2196. }],
  2197. ["", function() {}]
  2198. ];
  2199. modal.show("Configuration", "Enter your database connection details below: <input id='dbHost' class='text less' type='text' placeholder='Host (optional)' value=''><input id='dbUser' class='text less' type='text' placeholder='Username' value=''><input id='dbPassword' class='text more' type='password' placeholder='Password' value=''><br>Lychee will create its own database. If required, you can enter the name of an existing database instead:<input id='dbName' class='text more' type='text' placeholder='Database (optional)' value=''>", buttons, -215, false);
  2200. },
  2201. createLogin: function() {
  2202. var username,
  2203. password,
  2204. params,
  2205. buttons;
  2206. buttons = [
  2207. ["Create Login", function() {
  2208. username = $(".message input.text#username").val();
  2209. password = $(".message input.text#password").val();
  2210. if (username.length<1||password.length<1) {
  2211. setTimeout(function() {
  2212. buttons = [
  2213. ["Retry", function() { setTimeout(settings.createLogin, 400) }],
  2214. ["", function() {}]
  2215. ];
  2216. modal.show("Wrong Input", "The username or password you entered is not long enough. Please try again with another username and password!", buttons, null, false);
  2217. return false;
  2218. }, 400);
  2219. } else {
  2220. params = "setLogin&username=" + escape(username) + "&password=" + md5(password);
  2221. lychee.api(params, function(data) {
  2222. if (data!==true) {
  2223. setTimeout(function() {
  2224. buttons = [
  2225. ["Retry", function() { setTimeout(settings.createLogin, 400) }],
  2226. ["", function() {}]
  2227. ];
  2228. modal.show("Creation Failed", "Unable to save login. Please try again with another username and password!", buttons, null, false);
  2229. return false;
  2230. }, 400);
  2231. }
  2232. });
  2233. }
  2234. }],
  2235. ["", function() {}]
  2236. ];
  2237. modal.show("Create Login", "Enter a username and password for your installation: <input id='username' class='text less' type='text' placeholder='New Username' value=''><input id='password' class='text' type='password' placeholder='New Password' value=''>", buttons, -122, false);
  2238. },
  2239. setLogin: function() {
  2240. var old_password,
  2241. username,
  2242. password,
  2243. params,
  2244. buttons;
  2245. buttons = [
  2246. ["Change Login", function() {
  2247. old_password = $(".message input.text#old_password").val();
  2248. username = $(".message input.text#username").val();
  2249. password = $(".message input.text#password").val();
  2250. if (old_password.length<1) {
  2251. loadingBar.show("error", "Your old password was entered incorrectly. Please try again!");
  2252. return false;
  2253. }
  2254. if (username.length<1) {
  2255. loadingBar.show("error", "Your new username was entered incorrectly. Please try again!");
  2256. return false;
  2257. }
  2258. if (password.length<1) {
  2259. loadingBar.show("error", "Your new password was entered incorrectly. Please try again!");
  2260. return false;
  2261. }
  2262. params = "setLogin&oldPassword=" + md5(old_password) + "&username=" + escape(username) + "&password=" + md5(password);
  2263. lychee.api(params, function(data) {
  2264. if (data!==true) lychee.error(null, params, data);
  2265. });
  2266. }],
  2267. ["Cancel", function() {}]
  2268. ];
  2269. modal.show("Change Login", "Enter your current password: <input id='old_password' class='text more' type='password' placeholder='Current Password' value=''><br>Your username and password will be changed to the following: <input id='username' class='text less' type='text' placeholder='New Username' value=''><input id='password' class='text' type='password' placeholder='New Password' value=''>", buttons, -171);
  2270. },
  2271. setSorting: function() {
  2272. var buttons,
  2273. sorting,
  2274. params;
  2275. buttons = [
  2276. ["Change Sorting", function() {
  2277. sorting[0] = $("select#settings_type").val();
  2278. sorting[1] = $("select#settings_order").val();
  2279. params = "setSorting&type=" + sorting[0] + "&order=" + sorting[1];
  2280. lychee.api(params, function(data) {
  2281. if (data===true) {
  2282. lychee.sorting = "ORDER BY " + sorting[0] + " " + sorting[1];
  2283. lychee.load();
  2284. } else lychee.error(null, params, data);
  2285. });
  2286. }],
  2287. ["Cancel", function() {}]
  2288. ];
  2289. modal.show("Change Sorting",
  2290. "Sort photos by \
  2291. <select id='settings_type'> \
  2292. <option value='id'>Upload Time</option> \
  2293. <option value='takestamp'>Take Date</option> \
  2294. <option value='title'>Title</option> \
  2295. <option value='description'>Description</option> \
  2296. <option value='public'>Public</option> \
  2297. <option value='star'>Star</option> \
  2298. <option value='type'>Photo Format</option> \
  2299. </select> \
  2300. in an \
  2301. <select id='settings_order'> \
  2302. <option value='ASC'>Ascending</option> \
  2303. <option value='DESC'>Descending</option> \
  2304. </select> \
  2305. order.\
  2306. ", buttons);
  2307. if (lychee.sorting!=="") {
  2308. sorting = lychee.sorting.replace("ORDER BY ", "").split(" ");
  2309. $("select#settings_type").val(sorting[0]);
  2310. $("select#settings_order").val(sorting[1]);
  2311. }
  2312. },
  2313. setDropboxKey: function(callback) {
  2314. var buttons,
  2315. params,
  2316. key;
  2317. buttons = [
  2318. ["Set Key", function() {
  2319. key = $(".message input.text#key").val();
  2320. params = "setDropboxKey&key=" + key;
  2321. lychee.api(params, function(data) {
  2322. if (data===true) {
  2323. lychee.dropboxKey = key;
  2324. if (callback) lychee.loadDropbox(callback);
  2325. } else lychee.error(null, params, data);
  2326. });
  2327. }],
  2328. ["Cancel", function() {}]
  2329. ];
  2330. modal.show("Set Dropbox Key", "In order to import photos from your Dropbox, you need a valid drop-ins app key from <a href='https://www.dropbox.com/developers/apps/create'>their website</a>. Generate yourself a personal key and enter it below: <input id='key' class='text' type='text' placeholder='Dropbox API Key' value='" + lychee.dropboxKey + "'>", buttons);
  2331. }
  2332. };
  2333. /**
  2334. * @name Swipe Module
  2335. * @description Swipes and moves an object.
  2336. * @author Tobias Reich
  2337. * @copyright 2014 by Tobias Reich
  2338. */
  2339. swipe = {
  2340. obj: null,
  2341. tolerance: 150,
  2342. offset: 0,
  2343. start: function(obj, tolerance) {
  2344. if (obj) swipe.obj = obj;
  2345. if (tolerance) swipe.tolerance = tolerance;
  2346. return true;
  2347. },
  2348. move: function(e) {
  2349. if (swipe.obj===null) return false;
  2350. swipe.offset = -1 * e.x;
  2351. swipe.obj.css({
  2352. WebkitTransform: 'translateX(' + swipe.offset + 'px)',
  2353. MozTransform: 'translateX(' + swipe.offset + 'px)',
  2354. transform: 'translateX(' + swipe.offset + 'px)'
  2355. });
  2356. },
  2357. stop: function(e, left, right) {
  2358. if (e.x<=-swipe.tolerance) left(true);
  2359. else if (e.x>=swipe.tolerance) right(true);
  2360. else if (swipe.obj!==null) {
  2361. swipe.obj.css({
  2362. WebkitTransform: 'translateX(0px)',
  2363. MozTransform: 'translateX(0px)',
  2364. transform: 'translateX(0px)'
  2365. });
  2366. }
  2367. swipe.obj = null;
  2368. swipe.offset = 0;
  2369. }
  2370. };
  2371. /**
  2372. * @name Album Module
  2373. * @description Takes care of every action an album can handle and execute.
  2374. * @author Tobias Reich
  2375. * @copyright 2014 by Tobias Reich
  2376. */
  2377. upload = {
  2378. show: function(title, files, callback) {
  2379. upload.close(true);
  2380. $("body").append(build.uploadModal(title, files));
  2381. if (callback!=null&&callback!=undefined) callback();
  2382. },
  2383. notify: function(title, text) {
  2384. var popup;
  2385. if (!text||text==="") text = "You can now manage your new photo(s).";
  2386. if (!window.webkitNotifications) return false;
  2387. if (window.webkitNotifications.checkPermission()!==0) window.webkitNotifications.requestPermission();
  2388. if (window.webkitNotifications.checkPermission()===0&&title) {
  2389. popup = window.webkitNotifications.createNotification("", title, text);
  2390. popup.show();
  2391. }
  2392. },
  2393. start: {
  2394. local: function(files) {
  2395. var albumID = album.getID(),
  2396. error = false,
  2397. process = function(files, file) {
  2398. var formData = new FormData(),
  2399. xhr = new XMLHttpRequest(),
  2400. pre_progress = 0,
  2401. progress,
  2402. finish = function() {
  2403. window.onbeforeunload = null;
  2404. $("#upload_files").val("");
  2405. if (error===false) {
  2406. // Success
  2407. upload.close();
  2408. upload.notify("Upload complete");
  2409. } else {
  2410. // Error
  2411. $(".upload_message a.close").show();
  2412. upload.notify("Upload complete", "Failed to upload one or more photos.");
  2413. }
  2414. if (album.getID()===false) lychee.goto("0");
  2415. else album.load(albumID);
  2416. };
  2417. // Check if file is supported
  2418. if (file.supported===false) {
  2419. // Skip file
  2420. if (file.next!==null) process(files, file.next);
  2421. else {
  2422. // Look for supported files
  2423. // If zero files are supported, hide the upload after a delay
  2424. var hasSupportedFiles = false;
  2425. for (var i = 0; i < files.length; i++) {
  2426. if (files[i].supported===true) {
  2427. hasSupportedFiles = true;
  2428. break;
  2429. }
  2430. }
  2431. if (hasSupportedFiles===false) setTimeout(finish, 2000);
  2432. }
  2433. return false;
  2434. }
  2435. formData.append("function", "upload");
  2436. formData.append("albumID", albumID);
  2437. formData.append(0, file);
  2438. xhr.open("POST", lychee.api_path);
  2439. xhr.onload = function() {
  2440. var wait = false;
  2441. file.ready = true;
  2442. // Set status
  2443. if (xhr.status===200&&xhr.responseText==="1") {
  2444. // Success
  2445. $(".upload_message .rows .row:nth-child(" + (file.num+1) + ") .status")
  2446. .html("Finished")
  2447. .addClass("success");
  2448. } else {
  2449. // Error
  2450. $(".upload_message .rows .row:nth-child(" + (file.num+1) + ") .status")
  2451. .html("Error")
  2452. .addClass("error");
  2453. $(".upload_message .rows .row:nth-child(" + (file.num+1) + ") p.notice")
  2454. .html("Server returned an unknown response. Please take a look at the console of your browser for further details.")
  2455. .show();
  2456. // Set global error
  2457. error = true;
  2458. // Throw error
  2459. lychee.error("Upload failed. Server returned the status code " + xhr.status + "!", xhr, xhr.responseText);
  2460. }
  2461. // Check if there are file which are not finished
  2462. for (var i = 0; i < files.length; i++) {
  2463. if (files[i].ready===false) {
  2464. wait = true;
  2465. break;
  2466. }
  2467. }
  2468. // Finish upload when all files are finished
  2469. if (wait===false) finish();
  2470. };
  2471. xhr.upload.onprogress = function(e) {
  2472. if (e.lengthComputable) {
  2473. // Calculate progress
  2474. progress = (e.loaded / e.total * 100 | 0);
  2475. // Set progress when progress has changed
  2476. if (progress>pre_progress) {
  2477. $(".upload_message .rows .row:nth-child(" + (file.num+1) + ") .status").html(progress + "%");
  2478. pre_progress = progress;
  2479. }
  2480. if (progress>=100) {
  2481. // Scroll to the uploading file
  2482. var scrollPos = 0;
  2483. if ((file.num+1)>4) scrollPos = (file.num + 1 - 4) * 40
  2484. $(".upload_message .rows").scrollTop(scrollPos);
  2485. // Set status to processing
  2486. $(".upload_message .rows .row:nth-child(" + (file.num+1) + ") .status").html("Processing");
  2487. // Upload next file
  2488. if (file.next!==null) process(files, file.next);
  2489. }
  2490. }
  2491. };
  2492. xhr.send(formData);
  2493. };
  2494. if (files.length<=0) return false;
  2495. if (albumID===false||visible.albums()===true) albumID = 0;
  2496. for (var i = 0; i < files.length; i++) {
  2497. files[i].num = i;
  2498. files[i].ready = false;
  2499. files[i].supported = true;
  2500. if (i < files.length-1) files[i].next = files[i+1];
  2501. else files[i].next = null;
  2502. // Check if file is supported
  2503. if (files[i].type!=="image/jpeg"&&files[i].type!=="image/jpg"&&files[i].type!=="image/png"&&files[i].type!=="image/gif") {
  2504. files[i].ready = true;
  2505. files[i].supported = false;
  2506. }
  2507. }
  2508. window.onbeforeunload = function() { return "Lychee is currently uploading!"; };
  2509. upload.show("Uploading", files);
  2510. // Upload first file
  2511. process(files, files[0]);
  2512. },
  2513. url: function() {
  2514. var albumID = album.getID(),
  2515. params,
  2516. extension,
  2517. buttons,
  2518. link,
  2519. files = [];
  2520. if (albumID===false) albumID = 0;
  2521. buttons = [
  2522. ["Import", function() {
  2523. link = $(".message input.text").val();
  2524. if (link&&link.length>3) {
  2525. extension = link.split('.').pop();
  2526. if (extension!=="jpeg"&&extension!=="jpg"&&extension!=="png"&&extension!=="gif"&&extension!=="webp") {
  2527. loadingBar.show("error", "The file format of this link is not supported.");
  2528. return false;
  2529. }
  2530. files[0] = {
  2531. name: link,
  2532. supported: true
  2533. }
  2534. upload.show("Importing URL", files, function() {
  2535. $(".upload_message .rows .row .status").html("Importing");
  2536. });
  2537. params = "importUrl&url=" + escape(encodeURI(link)) + "&albumID=" + albumID;
  2538. lychee.api(params, function(data) {
  2539. upload.close();
  2540. upload.notify("Import complete");
  2541. if (album.getID()===false) lychee.goto("0");
  2542. else album.load(albumID);
  2543. if (data!==true) lychee.error(null, params, data);
  2544. });
  2545. } else loadingBar.show("error", "Link to short or too long. Please try another one!");
  2546. }],
  2547. ["Cancel", function() {}]
  2548. ];
  2549. modal.show("Import from Link", "Please enter the direct link to a photo to import it: <input class='text' type='text' placeholder='http://' value='http://'>", buttons);
  2550. },
  2551. server: function() {
  2552. var albumID = album.getID(),
  2553. params,
  2554. buttons,
  2555. files = [],
  2556. path;
  2557. if (albumID===false) albumID = 0;
  2558. buttons = [
  2559. ["Import", function() {
  2560. path = $(".message input.text").val();
  2561. files[0] = {
  2562. name: path,
  2563. supported: true
  2564. };
  2565. upload.show("Importing from server", files, function() {
  2566. $(".upload_message .rows .row .status").html("Importing");
  2567. });
  2568. params = "importServer&albumID=" + albumID + "&path=" + escape(encodeURI(path));
  2569. lychee.api(params, function(data) {
  2570. upload.close();
  2571. upload.notify("Import complete");
  2572. if (data==="Notice: Import only contains albums!") {
  2573. if (visible.albums()) lychee.load();
  2574. else lychee.goto("");
  2575. }
  2576. else if (album.getID()===false) lychee.goto("0");
  2577. else album.load(albumID);
  2578. if (data==="Notice: Import only contains albums!") return true;
  2579. else if (data==="Warning: Folder empty!") lychee.error("Folder empty. No photos imported!", params, data);
  2580. else if (data!==true) lychee.error(null, params, data);
  2581. });
  2582. }],
  2583. ["Cancel", function() {}]
  2584. ];
  2585. modal.show("Import from Server", "This action will import all photos, folders and sub-folders which are located in the following directory. The <b>original files will be deleted</b> after the import when possible. <input class='text' type='text' maxlength='100' placeholder='Absolute path to directory' value='" + lychee.location + "uploads/import/'>", buttons);
  2586. },
  2587. dropbox: function() {
  2588. var albumID = album.getID(),
  2589. params,
  2590. links = "";
  2591. if (albumID===false) albumID = 0;
  2592. lychee.loadDropbox(function() {
  2593. Dropbox.choose({
  2594. linkType: "direct",
  2595. multiselect: true,
  2596. success: function(files) {
  2597. for (var i = 0; i < files.length; i++) {
  2598. links += files[i].link + ",";
  2599. files[i] = {
  2600. name: files[i].link,
  2601. supported: true
  2602. };
  2603. }
  2604. // Remove last comma
  2605. links = links.substr(0, links.length-1);
  2606. upload.show("Importing from Dropbox", files, function() {
  2607. $(".upload_message .rows .row .status").html("Importing");
  2608. });
  2609. params = "importUrl&url=" + escape(links) + "&albumID=" + albumID;
  2610. lychee.api(params, function(data) {
  2611. upload.close();
  2612. upload.notify("Import complete");
  2613. if (album.getID()===false) lychee.goto("0");
  2614. else album.load(albumID);
  2615. if (data!==true) lychee.error(null, params, data);
  2616. });
  2617. }
  2618. });
  2619. });
  2620. }
  2621. },
  2622. close: function(force) {
  2623. if (force===true) {
  2624. $(".upload_overlay").remove();
  2625. } else {
  2626. $(".upload_overlay").removeClass("fadeIn").css("opacity", 0);
  2627. setTimeout(function() { $(".upload_overlay").remove() }, 300);
  2628. }
  2629. }
  2630. };
  2631. /**
  2632. * @name UI View
  2633. * @description Responsible to reflect data changes to the UI.
  2634. * @author Tobias Reich
  2635. * @copyright 2014 by Tobias Reich
  2636. */
  2637. view = {
  2638. header: {
  2639. show: function() {
  2640. var newMargin = -1*($("#imageview #image").height()/2)+20;
  2641. clearTimeout($(window).data("timeout"));
  2642. lychee.imageview.removeClass("full");
  2643. lychee.header.removeClass("hidden");
  2644. lychee.loadingBar.css("opacity", 1);
  2645. if ($("#imageview #image.small").length>0) $("#imageview #image").css('margin-top', newMargin);
  2646. else $("#imageview #image").removeClass('full');
  2647. },
  2648. hide: function(e, delay) {
  2649. var newMargin = -1*($("#imageview #image").height()/2);
  2650. if (delay===undefined) delay = 500;
  2651. if (visible.photo()&&!visible.infobox()&&!visible.contextMenu()&&!visible.message()) {
  2652. clearTimeout($(window).data("timeout"));
  2653. $(window).data("timeout", setTimeout(function() {
  2654. lychee.imageview.addClass("full");
  2655. lychee.header.addClass("hidden");
  2656. lychee.loadingBar.css("opacity", 0);
  2657. if ($("#imageview #image.small").length>0) $("#imageview #image").css('margin-top', newMargin);
  2658. else $("#imageview #image").addClass('full');
  2659. }, delay));
  2660. }
  2661. },
  2662. mode: function(mode) {
  2663. var albumID = album.getID();
  2664. switch (mode) {
  2665. case "albums":
  2666. lychee.header.removeClass("view");
  2667. $("#tools_album, #tools_photo").hide();
  2668. $("#tools_albums").show();
  2669. break;
  2670. case "album":
  2671. lychee.header.removeClass("view");
  2672. $("#tools_albums, #tools_photo").hide();
  2673. $("#tools_album").show();
  2674. album.json.content === false ? $("#button_archive").hide() : $("#button_archive").show();
  2675. if (lychee.publicMode&&album.json.downloadable==="0") $("#button_archive").hide();
  2676. if (albumID==="s"||albumID==="f"||albumID==="r") {
  2677. $("#button_info_album, #button_trash_album, #button_share_album").hide();
  2678. } else if (albumID==="0") {
  2679. $("#button_info_album, #button_share_album").hide();
  2680. $("#button_trash_album").show();
  2681. } else {
  2682. $("#button_info_album, #button_trash_album, #button_share_album").show();
  2683. }
  2684. break;
  2685. case "photo":
  2686. lychee.header.addClass("view");
  2687. $("#tools_albums, #tools_album").hide();
  2688. $("#tools_photo").show();
  2689. break;
  2690. }
  2691. }
  2692. },
  2693. infobox: {
  2694. show: function() {
  2695. if (!visible.infobox()) $("body").append("<div id='infobox_overlay' class='fadeIn'></div>");
  2696. lychee.infobox.addClass("active");
  2697. },
  2698. hide: function() {
  2699. lychee.animate("#infobox_overlay", "fadeOut");
  2700. setTimeout(function() { $("#infobox_overlay").remove() }, 300);
  2701. lychee.infobox.removeClass("active");
  2702. }
  2703. },
  2704. albums: {
  2705. init: function() {
  2706. view.albums.title();
  2707. view.albums.content.init();
  2708. },
  2709. title: function() {
  2710. lychee.setTitle("Albums", false);
  2711. },
  2712. content: {
  2713. init: function() {
  2714. var smartData = "",
  2715. albumsData = "";
  2716. /* Smart Albums */
  2717. albums.parse(albums.json.unsortedAlbum);
  2718. albums.parse(albums.json.publicAlbum);
  2719. albums.parse(albums.json.starredAlbum);
  2720. albums.parse(albums.json.recentAlbum);
  2721. if (!lychee.publicMode) smartData = build.divider("Smart Albums") + build.album(albums.json.unsortedAlbum) + build.album(albums.json.starredAlbum) + build.album(albums.json.publicAlbum) + build.album(albums.json.recentAlbum);
  2722. /* Albums */
  2723. if (albums.json.content) {
  2724. if (!lychee.publicMode) albumsData = build.divider("Albums");
  2725. $.each(albums.json.content, function() {
  2726. albums.parse(this);
  2727. albumsData += build.album(this);
  2728. });
  2729. }
  2730. if (smartData===""&&albumsData==="") {
  2731. lychee.content.html('');
  2732. $("body").append(build.no_content("share"));
  2733. } else {
  2734. lychee.content.html(smartData + albumsData);
  2735. }
  2736. $("img[data-type!='nonretina']").retina();
  2737. },
  2738. title: function(albumID) {
  2739. var prefix = "",
  2740. longTitle = "",
  2741. title = albums.json.content[albumID].title;
  2742. if (albums.json.content[albumID].password) prefix = "<span class='icon-lock'></span> ";
  2743. if (title.length>18) {
  2744. longTitle = title;
  2745. title = title.substr(0, 18) + "...";
  2746. }
  2747. $(".album[data-id='" + albumID + "'] .overlay h1")
  2748. .html(prefix + title)
  2749. .attr("title", longTitle);
  2750. },
  2751. delete: function(albumID) {
  2752. $(".album[data-id='" + albumID + "']").css("opacity", 0).animate({
  2753. width: 0,
  2754. marginLeft: 0
  2755. }, 300, function() {
  2756. $(this).remove();
  2757. if (albums.json.num<=0) lychee.animate(".divider:last-of-type", "fadeOut");
  2758. });
  2759. }
  2760. }
  2761. },
  2762. album: {
  2763. init: function() {
  2764. album.parse();
  2765. view.album.infobox();
  2766. view.album.title();
  2767. view.album.public();
  2768. view.album.content.init();
  2769. album.json.init = 1;
  2770. },
  2771. hide: function() {
  2772. view.infobox.hide();
  2773. },
  2774. title: function() {
  2775. if ((visible.album()||!album.json.init)&&!visible.photo()) {
  2776. switch (album.getID()) {
  2777. case "f":
  2778. lychee.setTitle("Starred", false);
  2779. break;
  2780. case "s":
  2781. lychee.setTitle("Public", false);
  2782. break;
  2783. case "r":
  2784. lychee.setTitle("Recent", false);
  2785. break;
  2786. case "0":
  2787. lychee.setTitle("Unsorted", false);
  2788. break;
  2789. default:
  2790. if (album.json.init) $("#infobox .attr_title").html(album.json.title + " " + build.editIcon("edit_title_album"));
  2791. lychee.setTitle(album.json.title, true);
  2792. break;
  2793. }
  2794. }
  2795. },
  2796. content: {
  2797. init: function() {
  2798. var photosData = "";
  2799. $.each(album.json.content, function() {
  2800. photosData += build.photo(this);
  2801. });
  2802. lychee.content.html(photosData);
  2803. $("img[data-type!='svg']").retina();
  2804. },
  2805. title: function(photoID) {
  2806. var longTitle = "",
  2807. title = album.json.content[photoID].title;
  2808. if (title.length>18) {
  2809. longTitle = title;
  2810. title = title.substr(0, 18) + "...";
  2811. }
  2812. $(".photo[data-id='" + photoID + "'] .overlay h1")
  2813. .html(title)
  2814. .attr("title", longTitle);
  2815. },
  2816. star: function(photoID) {
  2817. $(".photo[data-id='" + photoID + "'] .icon-star").remove();
  2818. if (album.json.content[photoID].star==1) $(".photo[data-id='" + photoID + "']").append("<a class='badge red icon-star'></a>");
  2819. },
  2820. public: function(photoID) {
  2821. $(".photo[data-id='" + photoID + "'] .icon-share").remove();
  2822. if (album.json.content[photoID].public==1) $(".photo[data-id='" + photoID + "']").append("<a class='badge red icon-share'></a>");
  2823. },
  2824. delete: function(photoID) {
  2825. $(".photo[data-id='" + photoID + "']").css("opacity", 0).animate({
  2826. width: 0,
  2827. marginLeft: 0
  2828. }, 300, function() {
  2829. $(this).remove();
  2830. // Only when search is not active
  2831. if (!visible.albums()) {
  2832. album.json.num--;
  2833. view.album.num();
  2834. view.album.title();
  2835. }
  2836. });
  2837. }
  2838. },
  2839. description: function() {
  2840. $("#infobox .attr_description").html(album.json.description + " " + build.editIcon("edit_description_album"));
  2841. },
  2842. num: function() {
  2843. $("#infobox .attr_images").html(album.json.num);
  2844. },
  2845. public: function() {
  2846. if (album.json.public==1) {
  2847. $("#button_share_album a").addClass("active");
  2848. $("#button_share_album").attr("title", "Share Album");
  2849. $(".photo .icon-share").remove();
  2850. if (album.json.init) $("#infobox .attr_visibility").html("Public");
  2851. } else {
  2852. $("#button_share_album a").removeClass("active");
  2853. $("#button_share_album").attr("title", "Make Public");
  2854. if (album.json.init) $("#infobox .attr_visibility").html("Private");
  2855. }
  2856. },
  2857. password: function() {
  2858. if (album.json.password==1) $("#infobox .attr_password").html("Yes");
  2859. else $("#infobox .attr_password").html("No");
  2860. },
  2861. infobox: function() {
  2862. if ((visible.album()||!album.json.init)&&!visible.photo()) lychee.infobox.html(build.infoboxAlbum(album.json)).show();
  2863. }
  2864. },
  2865. photo: {
  2866. init: function() {
  2867. photo.parse();
  2868. view.photo.infobox();
  2869. view.photo.title();
  2870. view.photo.star();
  2871. view.photo.public();
  2872. view.photo.photo();
  2873. photo.json.init = 1;
  2874. },
  2875. show: function() {
  2876. // Change header
  2877. lychee.content.addClass("view");
  2878. view.header.mode("photo");
  2879. // Make body not scrollable
  2880. $("body").css("overflow", "hidden");
  2881. // Fullscreen
  2882. $(document)
  2883. .bind("mouseenter", view.header.show)
  2884. .bind("mouseleave", view.header.hide);
  2885. lychee.animate(lychee.imageview, "fadeIn");
  2886. },
  2887. hide: function() {
  2888. view.header.show();
  2889. if (visible.infobox) view.infobox.hide();
  2890. lychee.content.removeClass("view");
  2891. view.header.mode("album");
  2892. // Make body scrollable
  2893. $("body").css("overflow", "auto");
  2894. // Disable Fullscreen
  2895. $(document)
  2896. .unbind("mouseenter")
  2897. .unbind("mouseleave");
  2898. // Hide Photo
  2899. lychee.animate(lychee.imageview, "fadeOut");
  2900. setTimeout(function() {
  2901. lychee.imageview.hide();
  2902. view.album.infobox();
  2903. }, 300);
  2904. },
  2905. title: function() {
  2906. if (photo.json.init) $("#infobox .attr_title").html(photo.json.title + " " + build.editIcon("edit_title"));
  2907. lychee.setTitle(photo.json.title, true);
  2908. },
  2909. description: function() {
  2910. if (photo.json.init) $("#infobox .attr_description").html(photo.json.description + " " + build.editIcon("edit_description"));
  2911. },
  2912. star: function() {
  2913. $("#button_star a").removeClass("icon-star-empty icon-star");
  2914. if (photo.json.star==1) {
  2915. // Starred
  2916. $("#button_star a").addClass("icon-star");
  2917. $("#button_star").attr("title", "Unstar Photo");
  2918. } else {
  2919. // Unstarred
  2920. $("#button_star a").addClass("icon-star-empty");
  2921. $("#button_star").attr("title", "Star Photo");
  2922. }
  2923. },
  2924. public: function() {
  2925. if (photo.json.public==1||photo.json.public==2) {
  2926. // Photo public
  2927. $("#button_share a").addClass("active");
  2928. $("#button_share").attr("title", "Share Photo");
  2929. if (photo.json.init) $("#infobox .attr_visibility").html("Public");
  2930. } else {
  2931. // Photo private
  2932. $("#button_share a").removeClass("active");
  2933. $("#button_share").attr("title", "Make Public");
  2934. if (photo.json.init) $("#infobox .attr_visibility").html("Private");
  2935. }
  2936. },
  2937. tags: function() {
  2938. $("#infobox #tags").html(build.tags(photo.json.tags));
  2939. },
  2940. photo: function() {
  2941. lychee.imageview.html(build.imageview(photo.json, photo.isSmall(), visible.controls()));
  2942. if ((album.json&&album.json.content&&album.json.content[photo.getID()]&&album.json.content[photo.getID()].nextPhoto==="")||lychee.viewMode) $("a#next").hide();
  2943. if ((album.json&&album.json.content&&album.json.content[photo.getID()]&&album.json.content[photo.getID()].previousPhoto==="")||lychee.viewMode) $("a#previous").hide();
  2944. },
  2945. infobox: function() {
  2946. lychee.infobox.html(build.infoboxPhoto(photo.json)).show();
  2947. }
  2948. }
  2949. };
  2950. /**
  2951. * @name Visible Module
  2952. * @description This module is used to check if elements are visible or not.
  2953. * @author Tobias Reich
  2954. * @copyright 2014 by Tobias Reich
  2955. */
  2956. visible = {
  2957. albums: function() {
  2958. if ($('#tools_albums').css('display')==='block') return true;
  2959. else return false;
  2960. },
  2961. album: function() {
  2962. if ($('#tools_album').css('display')==='block') return true;
  2963. else return false;
  2964. },
  2965. photo: function() {
  2966. if ($('#imageview.fadeIn').length>0) return true;
  2967. else return false;
  2968. },
  2969. search: function() {
  2970. if (search.code!==null&&search.code!=='') return true;
  2971. else return false;
  2972. },
  2973. infobox: function() {
  2974. if ($('#infobox.active').length>0) return true;
  2975. else return false;
  2976. },
  2977. infoboxbutton: function() {
  2978. if (visible.albums()) return false;
  2979. if (visible.photo()) return true;
  2980. if (visible.album()&&$('#button_info_album:visible').length>0) return true;
  2981. else return false;
  2982. },
  2983. controls: function() {
  2984. if (lychee.loadingBar.css('opacity')<1) return false;
  2985. else return true;
  2986. },
  2987. message: function() {
  2988. if ($('.message').length>0) return true;
  2989. else return false;
  2990. },
  2991. signin: function() {
  2992. if ($('.message .sign_in').length>0) return true;
  2993. else return false;
  2994. },
  2995. contextMenu: function() {
  2996. if ($('.contextmenu').length>0) return true;
  2997. else return false;
  2998. },
  2999. multiselect: function() {
  3000. if ($('#multiselect').length>0) return true;
  3001. else return false;
  3002. }
  3003. };