sui.js 213 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015
  1. (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
  2. /**
  3. * Ajax Autocomplete for jQuery, version 1.2.9
  4. * (c) 2013 Tomas Kirda
  5. *
  6. * Ajax Autocomplete for jQuery is freely distributable under the terms of an MIT-style license.
  7. * For details, see the web site: https://github.com/devbridge/jQuery-Autocomplete
  8. *
  9. */
  10. /*jslint browser: true, white: true, plusplus: true */
  11. /*global define, window, document, jQuery */
  12. // Expose plugin as an AMD module if AMD loader is present:
  13. !function ($) {
  14. 'use strict';
  15. var
  16. utils = (function () {
  17. return {
  18. escapeRegExChars: function (value) {
  19. return value.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
  20. },
  21. createNode: function (containerClass) {
  22. var ul = document.createElement('ul');
  23. ul.className = containerClass;
  24. ul.style.position = 'absolute';
  25. ul.style.display = 'none';
  26. return ul;
  27. }
  28. };
  29. }()),
  30. keys = {
  31. ESC: 27,
  32. TAB: 9,
  33. RETURN: 13,
  34. LEFT: 37,
  35. UP: 38,
  36. RIGHT: 39,
  37. DOWN: 40
  38. };
  39. function Autocomplete(el, options) {
  40. var that = this;
  41. // Shared variables:
  42. that.element = el;
  43. that.el = $(el);
  44. that.suggestions = [];
  45. that.badQueries = [];
  46. that.selectedIndex = -1;
  47. that.currentValue = that.element.value;
  48. that.intervalId = 0;
  49. that.cachedResponse = {};
  50. that.onChangeInterval = null;
  51. that.onChange = null;
  52. that.isLocal = false;
  53. that.suggestionsContainer = null;
  54. that.options = that.getOptions(options);
  55. that.classes = {
  56. selected: 'active',
  57. suggestion: 'autocomplete-suggestion'
  58. };
  59. that.hint = null;
  60. that.hintValue = '';
  61. that.selection = null;
  62. // Initialize and set options:
  63. that.initialize();
  64. that.setOptions(options);
  65. }
  66. Autocomplete.utils = utils;
  67. $.Autocomplete = Autocomplete;
  68. Autocomplete.formatResult = function (suggestion, currentValue) {
  69. var pattern = '(' + utils.escapeRegExChars(currentValue) + ')';
  70. return suggestion.value.replace(new RegExp(pattern, 'gi'), '<strong>$1<\/strong>');
  71. };
  72. Autocomplete.prototype = {
  73. killerFn: null,
  74. initialize: function () {
  75. var that = this,
  76. suggestionSelector = '.' + that.classes.suggestion,
  77. selected = that.classes.selected,
  78. options = that.options,
  79. container;
  80. // Remove autocomplete attribute to prevent native suggestions:
  81. that.element.setAttribute('autocomplete', 'off');
  82. that.killerFn = function (e) {
  83. if ($(e.target).closest('.' + that.options.containerClass).length === 0) {
  84. that.killSuggestions();
  85. that.disableKillerFn();
  86. }
  87. };
  88. that.suggestionsContainer = Autocomplete.utils.createNode(options.containerClass);
  89. container = $(that.suggestionsContainer);
  90. container.appendTo(options.appendTo);
  91. // Only set width if it was provided:
  92. if (options.width !== 'auto') {
  93. container.width(options.width);
  94. }
  95. // Listen for mouse over event on suggestions list:
  96. container.on('mouseover.autocomplete', suggestionSelector, function () {
  97. that.activate($(this).data('index'));
  98. });
  99. // Deselect active element when mouse leaves suggestions container:
  100. container.on('mouseout.autocomplete', function () {
  101. that.selectedIndex = -1;
  102. container.children('.' + selected).removeClass(selected);
  103. });
  104. // Listen for click event on suggestions list:
  105. container.on('click.autocomplete', suggestionSelector, function () {
  106. that.select($(this).data('index'));
  107. });
  108. that.fixPosition();
  109. that.fixPositionCapture = function () {
  110. if (that.visible) {
  111. that.fixPosition();
  112. }
  113. };
  114. $(window).on('resize.autocomplete', that.fixPositionCapture);
  115. that.el.on('keydown.autocomplete', function (e) { that.onKeyPress(e); });
  116. that.el.on('keyup.autocomplete', function (e) { that.onKeyUp(e); });
  117. that.el.on('blur.autocomplete', function () { that.onBlur(); });
  118. that.el.on('focus.autocomplete', function () { that.onFocus(); });
  119. that.el.on('change.autocomplete', function (e) { that.onKeyUp(e); });
  120. },
  121. onFocus: function () {
  122. var that = this;
  123. that.fixPosition();
  124. if (that.options.minChars <= that.el.val().length) {
  125. that.onValueChange();
  126. }
  127. },
  128. onBlur: function () {
  129. this.enableKillerFn();
  130. },
  131. setOptions: function (suppliedOptions) {
  132. var that = this,
  133. options = that.options;
  134. $.extend(options, suppliedOptions);
  135. that.isLocal = $.isArray(options.lookup);
  136. if (that.isLocal) {
  137. options.lookup = that.verifySuggestionsFormat(options.lookup);
  138. }
  139. // Adjust height, width and z-index:
  140. $(that.suggestionsContainer).css({
  141. 'max-height': options.maxHeight + 'px',
  142. 'width': options.width + 'px',
  143. 'z-index': options.zIndex
  144. });
  145. },
  146. clearCache: function () {
  147. this.cachedResponse = {};
  148. this.badQueries = [];
  149. },
  150. clear: function () {
  151. this.clearCache();
  152. this.currentValue = '';
  153. this.suggestions = [];
  154. },
  155. disable: function () {
  156. var that = this;
  157. that.disabled = true;
  158. if (that.currentRequest) {
  159. that.currentRequest.abort();
  160. }
  161. },
  162. enable: function () {
  163. this.disabled = false;
  164. },
  165. fixPosition: function () {
  166. var that = this,
  167. offset,
  168. styles;
  169. // Don't adjsut position if custom container has been specified:
  170. if (that.options.appendTo !== 'body') {
  171. return;
  172. }
  173. offset = that.el.offset();
  174. styles = {
  175. top: (offset.top + that.el.outerHeight()) + 'px',
  176. left: offset.left + 'px'
  177. };
  178. if (that.options.width === 'auto') {
  179. styles.width = (that.el.outerWidth() - 2) + 'px';
  180. }
  181. $(that.suggestionsContainer).css(styles);
  182. },
  183. enableKillerFn: function () {
  184. var that = this;
  185. $(document).on('click.autocomplete', that.killerFn);
  186. },
  187. disableKillerFn: function () {
  188. var that = this;
  189. $(document).off('click.autocomplete', that.killerFn);
  190. },
  191. killSuggestions: function () {
  192. var that = this;
  193. that.stopKillSuggestions();
  194. that.intervalId = window.setInterval(function () {
  195. that.hide();
  196. that.stopKillSuggestions();
  197. }, 50);
  198. },
  199. stopKillSuggestions: function () {
  200. window.clearInterval(this.intervalId);
  201. },
  202. isCursorAtEnd: function () {
  203. var that = this,
  204. valLength = that.el.val().length,
  205. selectionStart = that.element.selectionStart,
  206. range;
  207. if (typeof selectionStart === 'number') {
  208. return selectionStart === valLength;
  209. }
  210. if (document.selection) {
  211. range = document.selection.createRange();
  212. range.moveStart('character', -valLength);
  213. return valLength === range.text.length;
  214. }
  215. return true;
  216. },
  217. onKeyPress: function (e) {
  218. var that = this;
  219. // If suggestions are hidden and user presses arrow down, display suggestions:
  220. if (!that.disabled && !that.visible && e.which === keys.DOWN && that.currentValue) {
  221. that.suggest();
  222. return;
  223. }
  224. if (that.disabled || !that.visible) {
  225. return;
  226. }
  227. switch (e.which) {
  228. case keys.ESC:
  229. that.el.val(that.currentValue);
  230. that.hide();
  231. break;
  232. case keys.RIGHT:
  233. if (that.hint && that.options.onHint && that.isCursorAtEnd()) {
  234. that.selectHint();
  235. return;
  236. }
  237. break;
  238. case keys.TAB:
  239. if (that.hint && that.options.onHint) {
  240. that.selectHint();
  241. return;
  242. }
  243. // Fall through to RETURN
  244. break;
  245. case keys.RETURN:
  246. if (that.selectedIndex === -1) {
  247. that.hide();
  248. return;
  249. }
  250. that.select(that.selectedIndex);
  251. if (e.which === keys.TAB && that.options.tabDisabled === false) {
  252. return;
  253. }
  254. break;
  255. case keys.UP:
  256. that.moveUp();
  257. break;
  258. case keys.DOWN:
  259. that.moveDown();
  260. break;
  261. default:
  262. return;
  263. }
  264. // Cancel event if function did not return:
  265. e.stopImmediatePropagation();
  266. e.preventDefault();
  267. },
  268. onKeyUp: function (e) {
  269. var that = this;
  270. if (that.disabled) {
  271. return;
  272. }
  273. switch (e.which) {
  274. case keys.UP:
  275. case keys.DOWN:
  276. return;
  277. }
  278. clearInterval(that.onChangeInterval);
  279. if (that.currentValue !== that.el.val()) {
  280. that.findBestHint();
  281. if (that.options.deferRequestBy > 0) {
  282. // Defer lookup in case when value changes very quickly:
  283. that.onChangeInterval = setInterval(function () {
  284. that.onValueChange();
  285. }, that.options.deferRequestBy);
  286. } else {
  287. that.onValueChange();
  288. }
  289. }
  290. },
  291. onValueChange: function () {
  292. var that = this,
  293. options = that.options,
  294. value = that.el.val(),
  295. query = that.getQuery(value),
  296. index;
  297. if (that.selection) {
  298. that.selection = null;
  299. (options.onInvalidateSelection || $.noop).call(that.element);
  300. }
  301. clearInterval(that.onChangeInterval);
  302. that.currentValue = value;
  303. that.selectedIndex = -1;
  304. // Check existing suggestion for the match before proceeding:
  305. if (options.triggerSelectOnValidInput) {
  306. index = that.findSuggestionIndex(query);
  307. if (index !== -1) {
  308. that.select(index);
  309. return;
  310. }
  311. }
  312. if (query.length < options.minChars) {
  313. that.hide();
  314. } else {
  315. that.getSuggestions(query);
  316. }
  317. },
  318. findSuggestionIndex: function (query) {
  319. var that = this,
  320. index = -1,
  321. queryLowerCase = query.toLowerCase();
  322. $.each(that.suggestions, function (i, suggestion) {
  323. if (suggestion.value.toLowerCase() === queryLowerCase) {
  324. index = i;
  325. return false;
  326. }
  327. });
  328. return index;
  329. },
  330. getQuery: function (value) {
  331. var delimiter = this.options.delimiter,
  332. parts;
  333. if (!delimiter) {
  334. return value;
  335. }
  336. parts = value.split(delimiter);
  337. return $.trim(parts[parts.length - 1]);
  338. },
  339. getSuggestionsLocal: function (query) {
  340. var that = this,
  341. options = that.options,
  342. queryLowerCase = query.toLowerCase(),
  343. filter = options.lookupFilter,
  344. limit = parseInt(options.lookupLimit, 10),
  345. data;
  346. data = {
  347. suggestions: $.grep(options.lookup, function (suggestion) {
  348. return filter(suggestion, query, queryLowerCase);
  349. })
  350. };
  351. if (limit && data.suggestions.length > limit) {
  352. data.suggestions = data.suggestions.slice(0, limit);
  353. }
  354. return data;
  355. },
  356. getSuggestions: function (q) {
  357. var response,
  358. that = this,
  359. options = that.options,
  360. serviceUrl = options.serviceUrl,
  361. params,
  362. cacheKey;
  363. options.params[options.paramName] = q;
  364. params = options.ignoreParams ? null : options.params;
  365. if (that.isLocal) {
  366. response = that.getSuggestionsLocal(q);
  367. } else {
  368. if ($.isFunction(serviceUrl)) {
  369. serviceUrl = serviceUrl.call(that.element, q);
  370. }
  371. cacheKey = serviceUrl + '?' + $.param(params || {});
  372. response = that.cachedResponse[cacheKey];
  373. }
  374. if (response && $.isArray(response.suggestions)) {
  375. that.suggestions = response.suggestions;
  376. that.suggest();
  377. } else if (!that.isBadQuery(q)) {
  378. if (options.onSearchStart.call(that.element, options.params) === false) {
  379. return;
  380. }
  381. if (that.currentRequest) {
  382. that.currentRequest.abort();
  383. }
  384. that.currentRequest = $.ajax({
  385. url: serviceUrl,
  386. data: params,
  387. type: options.type,
  388. dataType: options.dataType
  389. }).done(function (data) {
  390. var result;
  391. that.currentRequest = null;
  392. result = options.transformResult(data);
  393. that.processResponse(result, q, cacheKey);
  394. options.onSearchComplete.call(that.element, q, result.suggestions);
  395. }).fail(function (jqXHR, textStatus, errorThrown) {
  396. options.onSearchError.call(that.element, q, jqXHR, textStatus, errorThrown);
  397. });
  398. }
  399. },
  400. isBadQuery: function (q) {
  401. if (!this.options.preventBadQueries){
  402. return false;
  403. }
  404. var badQueries = this.badQueries,
  405. i = badQueries.length;
  406. while (i--) {
  407. if (q.indexOf(badQueries[i]) === 0) {
  408. return true;
  409. }
  410. }
  411. return false;
  412. },
  413. hide: function () {
  414. var that = this;
  415. that.visible = false;
  416. that.selectedIndex = -1;
  417. $(that.suggestionsContainer).hide();
  418. that.signalHint(null);
  419. },
  420. suggest: function () {
  421. if (this.suggestions.length === 0) {
  422. this.hide();
  423. return;
  424. }
  425. var that = this,
  426. options = that.options,
  427. formatResult = options.formatResult,
  428. value = that.getQuery(that.currentValue),
  429. className = that.classes.suggestion,
  430. classSelected = that.classes.selected,
  431. container = $(that.suggestionsContainer),
  432. beforeRender = options.beforeRender,
  433. html = '',
  434. index,
  435. width;
  436. if (options.triggerSelectOnValidInput) {
  437. index = that.findSuggestionIndex(value);
  438. if (index !== -1) {
  439. that.select(index);
  440. return;
  441. }
  442. }
  443. // Build suggestions inner HTML:
  444. $.each(that.suggestions, function (i, suggestion) {
  445. html += '<li class="' + className + '" data-index="' + i + '"><a>' + formatResult(suggestion, value) + '</a></li>';
  446. });
  447. // If width is auto, adjust width before displaying suggestions,
  448. // because if instance was created before input had width, it will be zero.
  449. // Also it adjusts if input width has changed.
  450. // -2px to account for suggestions border.
  451. if (options.width === 'auto') {
  452. width = that.el.outerWidth() - 2;
  453. container.width(width > 0 ? width : 300);
  454. }
  455. container.html(html);
  456. // Select first value by default:
  457. if (options.autoSelectFirst) {
  458. that.selectedIndex = 0;
  459. container.children().first().addClass(classSelected);
  460. }
  461. if ($.isFunction(beforeRender)) {
  462. beforeRender.call(that.element, container);
  463. }
  464. container.show();
  465. that.visible = true;
  466. that.findBestHint();
  467. },
  468. findBestHint: function () {
  469. var that = this,
  470. value = that.el.val().toLowerCase(),
  471. bestMatch = null;
  472. if (!value) {
  473. return;
  474. }
  475. $.each(that.suggestions, function (i, suggestion) {
  476. var foundMatch = suggestion.value.toLowerCase().indexOf(value) === 0;
  477. if (foundMatch) {
  478. bestMatch = suggestion;
  479. }
  480. return !foundMatch;
  481. });
  482. that.signalHint(bestMatch);
  483. },
  484. signalHint: function (suggestion) {
  485. var hintValue = '',
  486. that = this;
  487. if (suggestion) {
  488. hintValue = that.currentValue + suggestion.value.substr(that.currentValue.length);
  489. }
  490. if (that.hintValue !== hintValue) {
  491. that.hintValue = hintValue;
  492. that.hint = suggestion;
  493. (this.options.onHint || $.noop)(hintValue);
  494. }
  495. },
  496. verifySuggestionsFormat: function (suggestions) {
  497. // If suggestions is string array, convert them to supported format:
  498. if (suggestions.length && typeof suggestions[0] === 'string') {
  499. return $.map(suggestions, function (value) {
  500. return { value: value, data: null };
  501. });
  502. }
  503. return suggestions;
  504. },
  505. processResponse: function (result, originalQuery, cacheKey) {
  506. var that = this,
  507. options = that.options;
  508. result.suggestions = that.verifySuggestionsFormat(result.suggestions);
  509. // Cache results if cache is not disabled:
  510. if (!options.noCache) {
  511. that.cachedResponse[cacheKey] = result;
  512. if (options.preventBadQueries && result.suggestions.length === 0) {
  513. that.badQueries.push(originalQuery);
  514. }
  515. }
  516. // Return if originalQuery is not matching current query:
  517. if (originalQuery !== that.getQuery(that.currentValue)) {
  518. return;
  519. }
  520. that.suggestions = result.suggestions;
  521. that.suggest();
  522. },
  523. activate: function (index) {
  524. var that = this,
  525. activeItem,
  526. selected = that.classes.selected,
  527. container = $(that.suggestionsContainer),
  528. children = container.children();
  529. container.children('.' + selected).removeClass(selected);
  530. that.selectedIndex = index;
  531. if (that.selectedIndex !== -1 && children.length > that.selectedIndex) {
  532. activeItem = children.get(that.selectedIndex);
  533. $(activeItem).addClass(selected);
  534. return activeItem;
  535. }
  536. return null;
  537. },
  538. selectHint: function () {
  539. var that = this,
  540. i = $.inArray(that.hint, that.suggestions);
  541. that.select(i);
  542. },
  543. select: function (i) {
  544. var that = this;
  545. that.hide();
  546. that.onSelect(i);
  547. },
  548. moveUp: function () {
  549. var that = this;
  550. if (that.selectedIndex === -1) {
  551. return;
  552. }
  553. if (that.selectedIndex === 0) {
  554. $(that.suggestionsContainer).children().first().removeClass(that.classes.selected);
  555. that.selectedIndex = -1;
  556. that.el.val(that.currentValue);
  557. that.findBestHint();
  558. return;
  559. }
  560. that.adjustScroll(that.selectedIndex - 1);
  561. },
  562. moveDown: function () {
  563. var that = this;
  564. if (that.selectedIndex === (that.suggestions.length - 1)) {
  565. return;
  566. }
  567. that.adjustScroll(that.selectedIndex + 1);
  568. },
  569. adjustScroll: function (index) {
  570. var that = this,
  571. activeItem = that.activate(index),
  572. offsetTop,
  573. upperBound,
  574. lowerBound,
  575. heightDelta = 25;
  576. if (!activeItem) {
  577. return;
  578. }
  579. offsetTop = activeItem.offsetTop;
  580. upperBound = $(that.suggestionsContainer).scrollTop();
  581. lowerBound = upperBound + that.options.maxHeight - heightDelta;
  582. if (offsetTop < upperBound) {
  583. $(that.suggestionsContainer).scrollTop(offsetTop);
  584. } else if (offsetTop > lowerBound) {
  585. $(that.suggestionsContainer).scrollTop(offsetTop - that.options.maxHeight + heightDelta);
  586. }
  587. that.el.val(that.getValue(that.suggestions[index].value));
  588. that.signalHint(null);
  589. },
  590. onSelect: function (index) {
  591. var that = this,
  592. onSelectCallback = that.options.onSelect,
  593. suggestion = that.suggestions[index];
  594. that.currentValue = that.getValue(suggestion.value);
  595. if (that.currentValue !== that.el.val()) {
  596. that.el.val(that.currentValue);
  597. }
  598. that.signalHint(null);
  599. that.suggestions = [];
  600. that.selection = suggestion;
  601. if ($.isFunction(onSelectCallback)) {
  602. onSelectCallback.call(that.element, suggestion);
  603. }
  604. },
  605. getValue: function (value) {
  606. var that = this,
  607. delimiter = that.options.delimiter,
  608. currentValue,
  609. parts;
  610. if (!delimiter) {
  611. return value;
  612. }
  613. currentValue = that.currentValue;
  614. parts = currentValue.split(delimiter);
  615. if (parts.length === 1) {
  616. return value;
  617. }
  618. return currentValue.substr(0, currentValue.length - parts[parts.length - 1].length) + value;
  619. },
  620. dispose: function () {
  621. var that = this;
  622. that.el.off('.autocomplete').removeData('autocomplete');
  623. that.disableKillerFn();
  624. $(window).off('resize.autocomplete', that.fixPositionCapture);
  625. $(that.suggestionsContainer).remove();
  626. },
  627. getOptions: function (options) {
  628. return options = $.extend({}, $.fn.autocomplete.defaults, this.el.data(), options);
  629. }
  630. };
  631. // Create chainable jQuery plugin:
  632. $.fn.autocomplete = function (option, args) {
  633. var dataKey = 'autocomplete';
  634. return this.each(function () {
  635. var $this = $(this)
  636. , data = $this.data(dataKey)
  637. , options = typeof option == 'object' && option
  638. if (!data) $this.data(dataKey, (data = new Autocomplete(this, options)))
  639. if (typeof option == 'string') data[option]()
  640. });
  641. };
  642. $.fn.autocomplete.defaults = {
  643. autoSelectFirst: false,
  644. appendTo: 'body',
  645. serviceUrl: null,
  646. lookup: null,
  647. onSelect: null,
  648. width: 'auto',
  649. minChars: 1,
  650. maxHeight: 300,
  651. deferRequestBy: 0,
  652. params: {},
  653. formatResult: Autocomplete.formatResult,
  654. delimiter: null,
  655. zIndex: 9999,
  656. type: 'GET',
  657. noCache: false,
  658. onSearchStart: $.noop,
  659. onSearchComplete: $.noop,
  660. onSearchError: $.noop,
  661. containerClass: 'sui-dropdown-menu sui-suggestion-container',
  662. tabDisabled: false,
  663. dataType: 'text',
  664. currentRequest: null,
  665. triggerSelectOnValidInput: true,
  666. preventBadQueries: true,
  667. lookupFilter: function (suggestion, originalQuery, queryLowerCase) {
  668. return suggestion.value.toLowerCase().indexOf(queryLowerCase) !== -1;
  669. },
  670. paramName: 'query',
  671. transformResult: function (response) {
  672. return typeof response === 'string' ? $.parseJSON(response) : response;
  673. }
  674. };
  675. $(function() {
  676. $("[data-toggle='autocomplete']").autocomplete();
  677. });
  678. }(window.jQuery);
  679. },{}],2:[function(require,module,exports){
  680. /* ============================================================
  681. * bootstrap-button.js v2.3.2
  682. * http://getbootstrap.com/2.3.2/javascript.html#buttons
  683. * ============================================================
  684. * Copyright 2013 Twitter, Inc.
  685. *
  686. * Licensed under the Apache License, Version 2.0 (the "License");
  687. * you may not use this file except in compliance with the License.
  688. * You may obtain a copy of the License at
  689. *
  690. * http://www.apache.org/licenses/LICENSE-2.0
  691. *
  692. * Unless required by applicable law or agreed to in writing, software
  693. * distributed under the License is distributed on an "AS IS" BASIS,
  694. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  695. * See the License for the specific language governing permissions and
  696. * limitations under the License.
  697. * ============================================================ */
  698. !function ($) {
  699. "use strict";
  700. /* BUTTON PUBLIC CLASS DEFINITION
  701. * ============================== */
  702. var Button = function (element, options) {
  703. this.$element = $(element)
  704. this.options = $.extend({}, $.fn.button.defaults, options)
  705. }
  706. Button.prototype.setState = function (state) {
  707. var d = 'disabled'
  708. , $el = this.$element
  709. , data = $el.data()
  710. , val = $el.is('input') ? 'val' : 'html'
  711. state = state + 'Text'
  712. data.resetText || $el.data('resetText', $el[val]())
  713. $el[val](data[state] || this.options[state])
  714. // push to event loop to allow forms to submit
  715. setTimeout(function () {
  716. state == 'loadingText' ?
  717. $el.addClass(d).attr(d, d) :
  718. $el.removeClass(d).removeAttr(d)
  719. }, 0)
  720. }
  721. Button.prototype.toggle = function () {
  722. var $parent = this.$element.closest('[data-toggle="buttons-radio"]')
  723. $parent && $parent
  724. .find('.active')
  725. .removeClass('active')
  726. this.$element.toggleClass('active')
  727. }
  728. /* BUTTON PLUGIN DEFINITION
  729. * ======================== */
  730. var old = $.fn.button
  731. $.fn.button = function (option) {
  732. return this.each(function () {
  733. var $this = $(this)
  734. , data = $this.data('button')
  735. , options = typeof option == 'object' && option
  736. if (!data) $this.data('button', (data = new Button(this, options)))
  737. if (option == 'toggle') data.toggle()
  738. else if (option) data.setState(option)
  739. })
  740. }
  741. $.fn.button.defaults = {
  742. loadingText: 'loading...'
  743. }
  744. $.fn.button.Constructor = Button
  745. /* BUTTON NO CONFLICT
  746. * ================== */
  747. $.fn.button.noConflict = function () {
  748. $.fn.button = old
  749. return this
  750. }
  751. /* BUTTON DATA-API
  752. * =============== */
  753. $(document).on('click.button.data-api', '[data-toggle^=button]', function (e) {
  754. var $btn = $(e.target)
  755. if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn')
  756. $btn.button('toggle')
  757. })
  758. }(window.jQuery);
  759. },{}],3:[function(require,module,exports){
  760. /* ==========================================================
  761. * bootstrap-carousel.js v2.3.2
  762. * http://getbootstrap.com/2.3.2/javascript.html#carousel
  763. * ==========================================================
  764. * Copyright 2013 Twitter, Inc.
  765. *
  766. * Licensed under the Apache License, Version 2.0 (the "License");
  767. * you may not use this file except in compliance with the License.
  768. * You may obtain a copy of the License at
  769. *
  770. * http://www.apache.org/licenses/LICENSE-2.0
  771. *
  772. * Unless required by applicable law or agreed to in writing, software
  773. * distributed under the License is distributed on an "AS IS" BASIS,
  774. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  775. * See the License for the specific language governing permissions and
  776. * limitations under the License.
  777. * ========================================================== */
  778. !function ($) {
  779. "use strict";
  780. /* CAROUSEL CLASS DEFINITION
  781. * ========================= */
  782. var Carousel = function (element, options) {
  783. this.$element = $(element)
  784. this.$indicators = this.$element.find('.carousel-indicators')
  785. this.options = options
  786. this.options.pause == 'hover' && this.$element
  787. .on('mouseenter', $.proxy(this.pause, this))
  788. .on('mouseleave', $.proxy(this.cycle, this))
  789. }
  790. Carousel.prototype = {
  791. cycle: function (e) {
  792. if (!e) this.paused = false
  793. if (this.interval) clearInterval(this.interval);
  794. this.options.interval
  795. && !this.paused
  796. && (this.interval = setInterval($.proxy(this.next, this), this.options.interval))
  797. return this
  798. }
  799. , getActiveIndex: function () {
  800. this.$active = this.$element.find('.item.active')
  801. this.$items = this.$active.parent().children()
  802. return this.$items.index(this.$active)
  803. }
  804. , to: function (pos) {
  805. var activeIndex = this.getActiveIndex()
  806. , that = this
  807. if (pos > (this.$items.length - 1) || pos < 0) return
  808. if (this.sliding) {
  809. return this.$element.one('slid', function () {
  810. that.to(pos)
  811. })
  812. }
  813. if (activeIndex == pos) {
  814. return this.pause().cycle()
  815. }
  816. return this.slide(pos > activeIndex ? 'next' : 'prev', $(this.$items[pos]))
  817. }
  818. , pause: function (e) {
  819. if (!e) this.paused = true
  820. if (this.$element.find('.next, .prev').length && $.support.transition.end) {
  821. this.$element.trigger($.support.transition.end)
  822. this.cycle(true)
  823. }
  824. clearInterval(this.interval)
  825. this.interval = null
  826. return this
  827. }
  828. , next: function () {
  829. if (this.sliding) return
  830. return this.slide('next')
  831. }
  832. , prev: function () {
  833. if (this.sliding) return
  834. return this.slide('prev')
  835. }
  836. , slide: function (type, next) {
  837. var $active = this.$element.find('.item.active')
  838. , $next = next || $active[type]()
  839. , isCycling = this.interval
  840. , direction = type == 'next' ? 'left' : 'right'
  841. , fallback = type == 'next' ? 'first' : 'last'
  842. , that = this
  843. , e
  844. this.sliding = true
  845. isCycling && this.pause()
  846. $next = $next.length ? $next : this.$element.find('.item')[fallback]()
  847. e = $.Event('slide', {
  848. relatedTarget: $next[0]
  849. , direction: direction
  850. })
  851. if ($next.hasClass('active')) return
  852. if (this.$indicators.length) {
  853. this.$indicators.find('.active').removeClass('active')
  854. this.$element.one('slid', function () {
  855. var $nextIndicator = $(that.$indicators.children()[that.getActiveIndex()])
  856. $nextIndicator && $nextIndicator.addClass('active')
  857. })
  858. }
  859. if ($.support.transition && this.$element.hasClass('slide')) {
  860. this.$element.trigger(e)
  861. if (e.isDefaultPrevented()) return
  862. $next.addClass(type)
  863. $next[0].offsetWidth // force reflow
  864. $active.addClass(direction)
  865. $next.addClass(direction)
  866. this.$element.one($.support.transition.end, function () {
  867. $next.removeClass([type, direction].join(' ')).addClass('active')
  868. $active.removeClass(['active', direction].join(' '))
  869. that.sliding = false
  870. setTimeout(function () { that.$element.trigger('slid') }, 0)
  871. })
  872. } else {
  873. this.$element.trigger(e)
  874. if (e.isDefaultPrevented()) return
  875. $active.removeClass('active')
  876. $next.addClass('active')
  877. this.sliding = false
  878. this.$element.trigger('slid')
  879. }
  880. isCycling && this.cycle()
  881. return this
  882. }
  883. }
  884. /* CAROUSEL PLUGIN DEFINITION
  885. * ========================== */
  886. var old = $.fn.carousel
  887. $.fn.carousel = function (option) {
  888. return this.each(function () {
  889. var $this = $(this)
  890. , data = $this.data('carousel')
  891. , options = $.extend({}, $.fn.carousel.defaults, $this.data(), typeof option == 'object' && option)
  892. , action = typeof option == 'string' ? option : options.slide
  893. if (!data) $this.data('carousel', (data = new Carousel(this, options)))
  894. if (typeof option == 'number') data.to(option)
  895. else if (action) data[action]()
  896. else if (options.autoStart) data.pause().cycle()
  897. })
  898. }
  899. $.fn.carousel.defaults = {
  900. interval: 5000
  901. , pause: 'hover'
  902. , autoStart: true
  903. }
  904. $.fn.carousel.Constructor = Carousel
  905. /* CAROUSEL NO CONFLICT
  906. * ==================== */
  907. $.fn.carousel.noConflict = function () {
  908. $.fn.carousel = old
  909. return this
  910. }
  911. /* CAROUSEL DATA-API
  912. * ================= */
  913. $(document).on('click.sui-carousel.data-api', '[data-slide], [data-slide-to]', function (e) {
  914. var $this = $(this), href
  915. , $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
  916. , options = $.extend({}, $target.data(), $this.data())
  917. , slideIndex
  918. $target.carousel(options)
  919. if (slideIndex = $this.attr('data-slide-to')) {
  920. $target.data('carousel').pause().to(slideIndex).cycle()
  921. }
  922. e.preventDefault()
  923. })
  924. $(function() {
  925. $("[data-ride='carousel']").carousel();
  926. });
  927. }(window.jQuery);
  928. },{}],4:[function(require,module,exports){
  929. !function ($) {
  930. "use strict";
  931. var CHECKED_CLASS = 'checked';
  932. var HALF_CHECKED_CLASS = 'halfchecked';
  933. var DISABLED_CLASS= 'disabled';
  934. var Checkbox = function (element, options) {
  935. this.$element = $(element)
  936. //this.options = $.extend({}, $.fn.checkbox.defaults, options)
  937. this.$checkbox = this.$element.find("input")
  938. }
  939. var old = $.fn.checkbox
  940. $.fn.checkbox = function (option) {
  941. return this.each(function () {
  942. var $this = $(this)
  943. , data = $this.data('checkbox')
  944. , options = typeof option == 'object' && option
  945. if (!data) $this.data('checkbox', (data = new Checkbox(this, options)))
  946. else if (option) data[option]()
  947. })
  948. }
  949. Checkbox.prototype.toggle = function () {
  950. if(this.$checkbox.prop("checked")) this.uncheck()
  951. else this.check()
  952. this.$checkbox.trigger("change")
  953. }
  954. Checkbox.prototype.check = function () {
  955. if(this.$checkbox.prop("disabled")) return
  956. this.$checkbox.prop('checked', true)
  957. this.$checkbox.trigger("change")
  958. }
  959. Checkbox.prototype.uncheck = function () {
  960. if(this.$checkbox.prop("disabled")) return
  961. this.$checkbox.prop('checked', false)
  962. this.$checkbox.trigger("change")
  963. }
  964. Checkbox.prototype.halfcheck = function () {
  965. if(this.$checkbox.prop("disabled")) return
  966. this.$checkbox.prop('checked', false)
  967. this.$element.removeClass(CHECKED_CLASS).addClass("halfchecked")
  968. }
  969. Checkbox.prototype.disable = function () {
  970. this.$checkbox.prop('disabled', true)
  971. this.$checkbox.trigger("change")
  972. }
  973. Checkbox.prototype.enable = function () {
  974. this.$checkbox.prop('disabled', false)
  975. this.$checkbox.trigger("change")
  976. }
  977. $.fn.checkbox.defaults = {
  978. loadingText: 'loading...'
  979. }
  980. $.fn.checkbox.Constructor = Checkbox
  981. /* NO CONFLICT
  982. * ================== */
  983. $.fn.checkbox.noConflict = function () {
  984. $.fn.checkbox = old
  985. return this
  986. }
  987. $.fn.radio = $.fn.checkbox;
  988. // update status on document;
  989. $(document).on("change", "input[type='checkbox'], input[type='radio']", function(e) {
  990. var $checkbox= $(e.currentTarget);
  991. var $container = $checkbox.parent();
  992. var update = function($checkbox) {
  993. var $container = $checkbox.parent();
  994. if($checkbox.prop("checked")) $container.removeClass(HALF_CHECKED_CLASS).addClass(CHECKED_CLASS)
  995. else $container.removeClass(CHECKED_CLASS).removeClass(HALF_CHECKED_CLASS)
  996. if($checkbox.prop('disabled')) $container.addClass(DISABLED_CLASS)
  997. else $container.removeClass(DISABLED_CLASS)
  998. }
  999. if($container.hasClass("checkbox-pretty") || $container.hasClass("radio-pretty")) {
  1000. update($checkbox);
  1001. }
  1002. if($checkbox.attr('type').toLowerCase() === 'radio') {
  1003. var name = $checkbox.attr("name");
  1004. $("input[name='"+name+"']").each(function() {
  1005. update($(this));
  1006. });
  1007. }
  1008. });
  1009. }(window.jQuery);
  1010. },{}],5:[function(require,module,exports){
  1011. /*jshint sub:true*/
  1012. /*
  1013. * js come from :bootstrap-datepicker.js
  1014. * Started by Stefan Petre; improvements by Andrew Rowls + contributors
  1015. * you con get the source from github: https://github.com/eternicode/bootstrap-datepicker
  1016. */
  1017. ! function($, undefined) {
  1018. var $window = $(window);
  1019. function UTCDate() {
  1020. return new Date(Date.UTC.apply(Date, arguments));
  1021. }
  1022. function UTCToday() {
  1023. var today = new Date();
  1024. return UTCDate(today.getFullYear(), today.getMonth(), today.getDate());
  1025. }
  1026. function alias(method) {
  1027. return function() {
  1028. return this[method].apply(this, arguments);
  1029. };
  1030. }
  1031. var DateArray = (function() {
  1032. var extras = {
  1033. get: function(i) {
  1034. return this.slice(i)[0];
  1035. },
  1036. contains: function(d) {
  1037. // Array.indexOf is not cross-browser;
  1038. // $.inArray doesn't work with Dates
  1039. var val = d && d.valueOf();
  1040. for (var i = 0, l = this.length; i < l; i++)
  1041. if (this[i].valueOf() === val)
  1042. return i;
  1043. return -1;
  1044. },
  1045. remove: function(i) {
  1046. this.splice(i, 1);
  1047. },
  1048. replace: function(new_array) {
  1049. if (!new_array)
  1050. return;
  1051. if (!$.isArray(new_array))
  1052. new_array = [new_array];
  1053. this.clear();
  1054. this.push.apply(this, new_array);
  1055. },
  1056. clear: function() {
  1057. this.length = 0;
  1058. },
  1059. copy: function() {
  1060. var a = new DateArray();
  1061. a.replace(this);
  1062. return a;
  1063. }
  1064. };
  1065. return function() {
  1066. var a = [];
  1067. a.push.apply(a, arguments);
  1068. $.extend(a, extras);
  1069. return a;
  1070. };
  1071. })();
  1072. // Picker object
  1073. var Datepicker = function(element, options) {
  1074. this.dates = new DateArray();
  1075. this.viewDate = UTCToday();
  1076. this.focusDate = null;
  1077. this._process_options(options);
  1078. this.element = $(element);
  1079. this.isInline = false;
  1080. this.isInput = this.element.is('input');
  1081. this.component = this.element.is('.date') ? this.element.find('.add-on, .input-group-addon, .sui-btn') : false;
  1082. this.hasInput = this.component && this.element.find('input').length;
  1083. if (this.component && this.component.length === 0)
  1084. this.component = false;
  1085. this.picker = $(DPGlobal.template);
  1086. if (this.o.timepicker) {
  1087. this.timepickerContainer = this.picker.find('.timepicker-container');
  1088. this.timepickerContainer.timepicker();
  1089. this.timepicker = this.timepickerContainer.data('timepicker');
  1090. this.timepicker._render();
  1091. //this.setTimeValue();
  1092. }
  1093. this._buildEvents();
  1094. this._attachEvents();
  1095. if (this.isInline) {
  1096. this.picker.addClass('datepicker-inline').appendTo(this.element);
  1097. } else {
  1098. this.picker.addClass('datepicker-dropdown dropdown-menu');
  1099. }
  1100. if (this.o.rtl) {
  1101. this.picker.addClass('datepicker-rtl');
  1102. }
  1103. if (this.o.size === 'small') {
  1104. this.picker.addClass('datepicker-small');
  1105. }
  1106. this.viewMode = this.o.startView;
  1107. if (this.o.calendarWeeks)
  1108. this.picker.find('tfoot th.today')
  1109. .attr('colspan', function(i, val) {
  1110. return parseInt(val) + 1;
  1111. });
  1112. this._allow_update = false;
  1113. this.setStartDate(this._o.startDate);
  1114. this.setEndDate(this._o.endDate);
  1115. this.setDaysOfWeekDisabled(this.o.daysOfWeekDisabled);
  1116. this.fillDow();
  1117. this.fillMonths();
  1118. this._allow_update = true;
  1119. this.update();
  1120. this.showMode();
  1121. if (this.isInline) {
  1122. this.show();
  1123. }
  1124. };
  1125. Datepicker.prototype = {
  1126. constructor: Datepicker,
  1127. _process_options: function(opts) {
  1128. // Store raw options for reference
  1129. this._o = $.extend({}, this._o, opts);
  1130. // Processed options
  1131. var o = this.o = $.extend({}, this._o);
  1132. // Check if "de-DE" style date is available, if not language should
  1133. // fallback to 2 letter code eg "de"
  1134. var lang = o.language;
  1135. if (!dates[lang]) {
  1136. lang = lang.split('-')[0];
  1137. if (!dates[lang])
  1138. lang = defaults.language;
  1139. }
  1140. o.language = lang;
  1141. switch (o.startView) {
  1142. case 2:
  1143. case 'decade':
  1144. o.startView = 2;
  1145. break;
  1146. case 1:
  1147. case 'year':
  1148. o.startView = 1;
  1149. break;
  1150. default:
  1151. o.startView = 0;
  1152. }
  1153. switch (o.minViewMode) {
  1154. case 1:
  1155. case 'months':
  1156. o.minViewMode = 1;
  1157. break;
  1158. case 2:
  1159. case 'years':
  1160. o.minViewMode = 2;
  1161. break;
  1162. default:
  1163. o.minViewMode = 0;
  1164. }
  1165. o.startView = Math.max(o.startView, o.minViewMode);
  1166. // true, false, or Number > 0
  1167. if (o.multidate !== true) {
  1168. o.multidate = Number(o.multidate) || false;
  1169. if (o.multidate !== false)
  1170. o.multidate = Math.max(0, o.multidate);
  1171. else
  1172. o.multidate = 1;
  1173. }
  1174. o.multidateSeparator = String(o.multidateSeparator);
  1175. o.weekStart %= 7;
  1176. o.weekEnd = ((o.weekStart + 6) % 7);
  1177. var format = DPGlobal.parseFormat(o.format);
  1178. if (o.startDate !== -Infinity) {
  1179. if (!!o.startDate) {
  1180. if (o.startDate instanceof Date)
  1181. o.startDate = this._local_to_utc(this._zero_time(o.startDate));
  1182. else
  1183. o.startDate = DPGlobal.parseDate(o.startDate, format, o.language);
  1184. } else {
  1185. o.startDate = -Infinity;
  1186. }
  1187. }
  1188. if (o.endDate !== Infinity) {
  1189. if (!!o.endDate) {
  1190. if (o.endDate instanceof Date)
  1191. o.endDate = this._local_to_utc(this._zero_time(o.endDate));
  1192. else
  1193. o.endDate = DPGlobal.parseDate(o.endDate, format, o.language);
  1194. } else {
  1195. o.endDate = Infinity;
  1196. }
  1197. }
  1198. o.daysOfWeekDisabled = o.daysOfWeekDisabled || [];
  1199. if (!$.isArray(o.daysOfWeekDisabled))
  1200. o.daysOfWeekDisabled = o.daysOfWeekDisabled.split(/[,\s]*/);
  1201. o.daysOfWeekDisabled = $.map(o.daysOfWeekDisabled, function(d) {
  1202. return parseInt(d, 10);
  1203. });
  1204. var plc = String(o.orientation).toLowerCase().split(/\s+/g),
  1205. _plc = o.orientation.toLowerCase();
  1206. plc = $.grep(plc, function(word) {
  1207. return (/^auto|left|right|top|bottom$/).test(word);
  1208. });
  1209. o.orientation = {
  1210. x: 'auto',
  1211. y: 'auto'
  1212. };
  1213. if (!_plc || _plc === 'auto')
  1214. ; // no action
  1215. else if (plc.length === 1) {
  1216. switch (plc[0]) {
  1217. case 'top':
  1218. case 'bottom':
  1219. o.orientation.y = plc[0];
  1220. break;
  1221. case 'left':
  1222. case 'right':
  1223. o.orientation.x = plc[0];
  1224. break;
  1225. }
  1226. } else {
  1227. _plc = $.grep(plc, function(word) {
  1228. return (/^left|right$/).test(word);
  1229. });
  1230. o.orientation.x = _plc[0] || 'auto';
  1231. _plc = $.grep(plc, function(word) {
  1232. return (/^top|bottom$/).test(word);
  1233. });
  1234. o.orientation.y = _plc[0] || 'auto';
  1235. }
  1236. },
  1237. _events: [],
  1238. _secondaryEvents: [],
  1239. _applyEvents: function(evs) {
  1240. for (var i = 0, el, ch, ev; i < evs.length; i++) {
  1241. el = evs[i][0];
  1242. if (evs[i].length === 2) {
  1243. ch = undefined;
  1244. ev = evs[i][1];
  1245. } else if (evs[i].length === 3) {
  1246. ch = evs[i][1];
  1247. ev = evs[i][2];
  1248. }
  1249. el.on(ev, ch);
  1250. }
  1251. },
  1252. _unapplyEvents: function(evs) {
  1253. for (var i = 0, el, ev, ch; i < evs.length; i++) {
  1254. el = evs[i][0];
  1255. if (evs[i].length === 2) {
  1256. ch = undefined;
  1257. ev = evs[i][1];
  1258. } else if (evs[i].length === 3) {
  1259. ch = evs[i][1];
  1260. ev = evs[i][2];
  1261. }
  1262. el.off(ev, ch);
  1263. }
  1264. },
  1265. _buildEvents: function() {
  1266. if (this.isInput) { // single input
  1267. this._events = [
  1268. [this.element, {
  1269. focus: $.proxy(this.show, this),
  1270. keyup: $.proxy(function(e) {
  1271. if ($.inArray(e.keyCode, [27, 37, 39, 38, 40, 32, 13, 9]) === -1)
  1272. this.update();
  1273. }, this),
  1274. keydown: $.proxy(this.keydown, this)
  1275. }]
  1276. ];
  1277. } else if (this.component && this.hasInput) { // component: input + button
  1278. this._events = [
  1279. // For components that are not readonly, allow keyboard nav
  1280. [this.element.find('input'), {
  1281. focus: $.proxy(this.show, this),
  1282. keyup: $.proxy(function(e) {
  1283. if ($.inArray(e.keyCode, [27, 37, 39, 38, 40, 32, 13, 9]) === -1)
  1284. this.update();
  1285. }, this),
  1286. keydown: $.proxy(this.keydown, this)
  1287. }],
  1288. [this.component, {
  1289. click: $.proxy(this.show, this)
  1290. }]
  1291. ];
  1292. } else if (this.element.is('div')) { // inline datepicker
  1293. this.isInline = true;
  1294. } else {
  1295. this._events = [
  1296. [this.element, {
  1297. click: $.proxy(this.show, this)
  1298. }]
  1299. ];
  1300. }
  1301. //timepicker change
  1302. if (this.o.timepicker) {
  1303. this._events.push(
  1304. [this.timepickerContainer, {
  1305. 'time:change': $.proxy(this.timeChange, this)
  1306. }]
  1307. )
  1308. }
  1309. this._events.push(
  1310. // Component: listen for blur on element descendants
  1311. [this.element, '*', {
  1312. blur: $.proxy(function(e) {
  1313. this._focused_from = e.target;
  1314. }, this)
  1315. }],
  1316. // Input: listen for blur on element
  1317. [this.element, {
  1318. blur: $.proxy(function(e) {
  1319. this._focused_from = e.target;
  1320. }, this)
  1321. }]
  1322. );
  1323. this._secondaryEvents = [
  1324. [this.picker, {
  1325. click: $.proxy(this.click, this)
  1326. }],
  1327. [$(window), {
  1328. resize: $.proxy(this.place, this)
  1329. }],
  1330. [$(document), {
  1331. 'mousedown touchstart': $.proxy(function(e) {
  1332. // Clicked outside the datepicker, hide it
  1333. if (!(
  1334. this.element.is(e.target) ||
  1335. this.element.find(e.target).length ||
  1336. this.picker.is(e.target) ||
  1337. this.picker.find(e.target).length
  1338. )) {
  1339. this.hide();
  1340. }
  1341. }, this)
  1342. }]
  1343. ];
  1344. },
  1345. _attachEvents: function() {
  1346. this._detachEvents();
  1347. this._applyEvents(this._events);
  1348. },
  1349. _detachEvents: function() {
  1350. this._unapplyEvents(this._events);
  1351. },
  1352. _attachSecondaryEvents: function() {
  1353. this._detachSecondaryEvents();
  1354. this._applyEvents(this._secondaryEvents);
  1355. if (this.o.timepicker) {
  1356. this.timepicker._attachSecondaryEvents();
  1357. }
  1358. },
  1359. _detachSecondaryEvents: function() {
  1360. this._unapplyEvents(this._secondaryEvents);
  1361. if (this.o.timepicker) {
  1362. this.timepicker._detachSecondaryEvents();
  1363. }
  1364. },
  1365. _trigger: function(event, altdate) {
  1366. var date = altdate || this.dates.get(-1),
  1367. local_date = this._utc_to_local(date);
  1368. this.element.trigger({
  1369. type: event,
  1370. date: local_date,
  1371. dates: $.map(this.dates, this._utc_to_local),
  1372. format: $.proxy(function(ix, format) {
  1373. if (arguments.length === 0) {
  1374. ix = this.dates.length - 1;
  1375. format = this.o.format;
  1376. } else if (typeof ix === 'string') {
  1377. format = ix;
  1378. ix = this.dates.length - 1;
  1379. }
  1380. format = format || this.o.format;
  1381. var date = this.dates.get(ix);
  1382. return DPGlobal.formatDate(date, format, this.o.language);
  1383. }, this)
  1384. });
  1385. },
  1386. timeChange: function(e) {
  1387. this.setValue();
  1388. },
  1389. show: function(e) {
  1390. if (e && e.type === "focus" && this.picker.is(":visible")) return;
  1391. if (!this.isInline)
  1392. this.picker.appendTo('body');
  1393. this.picker.show();
  1394. this.place();
  1395. this._attachSecondaryEvents();
  1396. if (this.o.timepicker) {
  1397. this.timepicker._show();
  1398. }
  1399. this._trigger('show');
  1400. },
  1401. hide: function() {
  1402. if (this.isInline)
  1403. return;
  1404. if (!this.picker.is(':visible'))
  1405. return;
  1406. this.focusDate = null;
  1407. this.picker.hide().detach();
  1408. this._detachSecondaryEvents();
  1409. this.viewMode = this.o.startView;
  1410. this.showMode();
  1411. if (
  1412. this.o.forceParse &&
  1413. (
  1414. this.isInput && this.element.val() ||
  1415. this.hasInput && this.element.find('input').val()
  1416. )
  1417. )
  1418. this.setValue();
  1419. if (this.o.timepicker) {
  1420. this.timepicker._hide();
  1421. }
  1422. this._trigger('hide');
  1423. },
  1424. remove: function() {
  1425. this.hide();
  1426. this._detachEvents();
  1427. this._detachSecondaryEvents();
  1428. this.picker.remove();
  1429. delete this.element.data().datepicker;
  1430. if (!this.isInput) {
  1431. delete this.element.data().date;
  1432. }
  1433. },
  1434. _utc_to_local: function(utc) {
  1435. return utc && new Date(utc.getTime() + (utc.getTimezoneOffset() * 60000));
  1436. },
  1437. _local_to_utc: function(local) {
  1438. return local && new Date(local.getTime() - (local.getTimezoneOffset() * 60000));
  1439. },
  1440. _zero_time: function(local) {
  1441. return local && new Date(local.getFullYear(), local.getMonth(), local.getDate());
  1442. },
  1443. _zero_utc_time: function(utc) {
  1444. return utc && new Date(Date.UTC(utc.getUTCFullYear(), utc.getUTCMonth(), utc.getUTCDate()));
  1445. },
  1446. getDates: function() {
  1447. return $.map(this.dates, this._utc_to_local);
  1448. },
  1449. getUTCDates: function() {
  1450. return $.map(this.dates, function(d) {
  1451. return new Date(d);
  1452. });
  1453. },
  1454. getDate: function() {
  1455. return this._utc_to_local(this.getUTCDate());
  1456. },
  1457. getUTCDate: function() {
  1458. return new Date(this.dates.get(-1));
  1459. },
  1460. setDates: function() {
  1461. var args = $.isArray(arguments[0]) ? arguments[0] : arguments;
  1462. this.update.apply(this, args);
  1463. this._trigger('changeDate');
  1464. this.setValue();
  1465. },
  1466. setUTCDates: function() {
  1467. var args = $.isArray(arguments[0]) ? arguments[0] : arguments;
  1468. this.update.apply(this, $.map(args, this._utc_to_local));
  1469. this._trigger('changeDate');
  1470. this.setValue();
  1471. },
  1472. setDate: alias('setDates'),
  1473. setUTCDate: alias('setUTCDates'),
  1474. setValue: function() {
  1475. var formatted = this.getFormattedDate();
  1476. if (!this.isInput) {
  1477. if (this.component) {
  1478. this.element.find('input').val(formatted).change();
  1479. }
  1480. } else {
  1481. this.element.val(formatted).change();
  1482. }
  1483. },
  1484. setTimeValue: function() {
  1485. var val, minute, hour, time;
  1486. time = {
  1487. hour: (new Date()).getHours(),
  1488. minute: (new Date()).getMinutes()
  1489. };
  1490. if (this.isInput) {
  1491. element = this.element;
  1492. } else if (this.component) {
  1493. element = this.element.find('input');
  1494. }
  1495. if (element) {
  1496. val = $.trim(element.val());
  1497. if (val) {
  1498. var tokens = val.split(" "); //datetime
  1499. if (tokens.length === 2) {
  1500. val = tokens[1];
  1501. }
  1502. }
  1503. val = val.split(':');
  1504. for (var i = val.length - 1; i >= 0; i--) {
  1505. val[i] = $.trim(val[i]);
  1506. }
  1507. if (val.length === 2) {
  1508. minute = parseInt(val[1], 10);
  1509. if (minute >= 0 && minute < 60) {
  1510. time.minute = minute;
  1511. }
  1512. hour = parseInt(val[0].slice(-2), 10);
  1513. if (hour >= 0 && hour < 24) {
  1514. time.hour = hour;
  1515. }
  1516. }
  1517. }
  1518. this.timepickerContainer.data("time", time.hour + ":" + time.minute);
  1519. },
  1520. getFormattedDate: function(format) {
  1521. if (format === undefined)
  1522. format = this.o.format;
  1523. var lang = this.o.language;
  1524. var text = $.map(this.dates, function(d) {
  1525. return DPGlobal.formatDate(d, format, lang);
  1526. }).join(this.o.multidateSeparator);
  1527. if (this.o.timepicker) {
  1528. if (!text) {
  1529. text = DPGlobal.formatDate(new Date(), format, lang);
  1530. }
  1531. text = text + " " + this.timepickerContainer.data('time');
  1532. }
  1533. return text;
  1534. },
  1535. setStartDate: function(startDate) {
  1536. this._process_options({
  1537. startDate: startDate
  1538. });
  1539. this.update();
  1540. this.updateNavArrows();
  1541. },
  1542. setEndDate: function(endDate) {
  1543. this._process_options({
  1544. endDate: endDate
  1545. });
  1546. this.update();
  1547. this.updateNavArrows();
  1548. },
  1549. setDaysOfWeekDisabled: function(daysOfWeekDisabled) {
  1550. this._process_options({
  1551. daysOfWeekDisabled: daysOfWeekDisabled
  1552. });
  1553. this.update();
  1554. this.updateNavArrows();
  1555. },
  1556. place: function() {
  1557. if (this.isInline)
  1558. return;
  1559. var calendarWidth = this.picker.outerWidth(),
  1560. calendarHeight = this.picker.outerHeight(),
  1561. visualPadding = 10,
  1562. windowWidth = $window.width(),
  1563. windowHeight = $window.height(),
  1564. scrollTop = $window.scrollTop();
  1565. var zIndex = parseInt(this.element.parents().filter(function() {
  1566. return $(this).css('z-index') !== 'auto';
  1567. }).first().css('z-index')) + 10;
  1568. var offset = this.component ? this.component.parent().offset() : this.element.offset();
  1569. var height = this.component ? this.component.outerHeight(true) : this.element.outerHeight(false);
  1570. var width = this.component ? this.component.outerWidth(true) : this.element.outerWidth(false);
  1571. var left = offset.left,
  1572. top = offset.top;
  1573. this.picker.removeClass(
  1574. 'datepicker-orient-top datepicker-orient-bottom ' +
  1575. 'datepicker-orient-right datepicker-orient-left'
  1576. );
  1577. if (this.o.orientation.x !== 'auto') {
  1578. this.picker.addClass('datepicker-orient-' + this.o.orientation.x);
  1579. if (this.o.orientation.x === 'right')
  1580. left -= calendarWidth - width;
  1581. }
  1582. // auto x orientation is best-placement: if it crosses a window
  1583. // edge, fudge it sideways
  1584. else {
  1585. // Default to left
  1586. this.picker.addClass('datepicker-orient-left');
  1587. if (offset.left < 0)
  1588. left -= offset.left - visualPadding;
  1589. else if (offset.left + calendarWidth > windowWidth)
  1590. left = windowWidth - calendarWidth - visualPadding;
  1591. }
  1592. // auto y orientation is best-situation: top or bottom, no fudging,
  1593. // decision based on which shows more of the calendar
  1594. var yorient = this.o.orientation.y,
  1595. top_overflow, bottom_overflow;
  1596. if (yorient === 'auto') {
  1597. top_overflow = -scrollTop + offset.top - calendarHeight;
  1598. bottom_overflow = scrollTop + windowHeight - (offset.top + height + calendarHeight);
  1599. if (Math.max(top_overflow, bottom_overflow) === bottom_overflow)
  1600. yorient = 'top';
  1601. else
  1602. yorient = 'bottom';
  1603. }
  1604. this.picker.addClass('datepicker-orient-' + yorient);
  1605. if (yorient === 'top')
  1606. top += height + 6;
  1607. else
  1608. top -= calendarHeight + parseInt(this.picker.css('padding-top')) + 6;
  1609. this.picker.css({
  1610. top: top,
  1611. left: left,
  1612. zIndex: zIndex
  1613. });
  1614. },
  1615. _getTime:function(date){
  1616. var h,m;
  1617. date = new Date(date);
  1618. h = date.getHours();
  1619. if (h<10) {
  1620. h = "0" + h;
  1621. }
  1622. m = date.getMinutes();
  1623. if (m<10) {
  1624. m = "0" + m;
  1625. }
  1626. return h + ":" + m;
  1627. },
  1628. _allow_update: true,
  1629. update: function() {
  1630. if (!this._allow_update)
  1631. return;
  1632. var oldDates = this.dates.copy(),
  1633. dates = [],
  1634. fromArgs = false;
  1635. if (arguments.length) {
  1636. $.each(arguments, $.proxy(function(i, date) {
  1637. //获取第一个的时间,用来update 时间
  1638. if (this.o.timepicker&&i === 0) {
  1639. this.timepicker.update(this._getTime(date)); //不要更新input
  1640. }
  1641. if (date instanceof Date)
  1642. date = this._local_to_utc(date);
  1643. else if(typeof date == "string" && this.o.timepicker){
  1644. date = date.split(" ")[0];
  1645. }
  1646. dates.push(date);
  1647. }, this));
  1648. fromArgs = true;
  1649. } else {
  1650. dates = this.isInput ? this.element.val() : this.element.data('date') || this.element.find('input').val();
  1651. if (dates&&this.o.timepicker) {//合体模式
  1652. var tokens = dates.split(" ");
  1653. if (tokens.length === 2) { //有时间
  1654. dates = tokens[0];
  1655. //调用timepicker 的_updateUI
  1656. this.timepicker.update(tokens[1],true); //不要更新input
  1657. }
  1658. }
  1659. if (dates && this.o.multidate)
  1660. dates = dates.split(this.o.multidateSeparator);
  1661. else
  1662. dates = [dates];
  1663. delete this.element.data().date;
  1664. }
  1665. dates = $.map(dates, $.proxy(function(date) {
  1666. return DPGlobal.parseDate(date, this.o.format, this.o.language);
  1667. }, this));
  1668. dates = $.grep(dates, $.proxy(function(date) {
  1669. return (
  1670. date < this.o.startDate ||
  1671. date > this.o.endDate ||
  1672. !date
  1673. );
  1674. }, this), true);
  1675. this.dates.replace(dates);
  1676. if (this.dates.length)
  1677. this.viewDate = new Date(this.dates.get(-1));
  1678. else if (this.viewDate < this.o.startDate)
  1679. this.viewDate = new Date(this.o.startDate);
  1680. else if (this.viewDate > this.o.endDate)
  1681. this.viewDate = new Date(this.o.endDate);
  1682. if (fromArgs) {
  1683. // setting date by clicking
  1684. this.setValue();
  1685. } else if (dates.length) {
  1686. // setting date by typing
  1687. if (String(oldDates) !== String(this.dates))
  1688. this._trigger('changeDate');
  1689. }
  1690. if (!this.dates.length && oldDates.length)
  1691. this._trigger('clearDate');
  1692. this.fill();
  1693. },
  1694. fillDow: function() {
  1695. var dowCnt = this.o.weekStart,
  1696. html = '<tr class="week-content">';
  1697. if (this.o.calendarWeeks) {
  1698. var cell = '<th class="cw">&nbsp;</th>';
  1699. html += cell;
  1700. this.picker.find('.datepicker-days thead tr:first-child').prepend(cell);
  1701. }
  1702. while (dowCnt < this.o.weekStart + 7) {
  1703. html += '<th class="dow">' + dates[this.o.language].daysMin[(dowCnt++) % 7] + '</th>';
  1704. }
  1705. html += '</tr>';
  1706. this.picker.find('.datepicker-days thead').append(html);
  1707. },
  1708. fillMonths: function() {
  1709. var html = '',
  1710. i = 0;
  1711. while (i < 12) {
  1712. html += '<span class="month">' + dates[this.o.language].monthsShort[i++] + '</span>';
  1713. }
  1714. this.picker.find('.datepicker-months td').html(html);
  1715. },
  1716. setRange: function(range) {
  1717. if (!range || !range.length)
  1718. delete this.range;
  1719. else
  1720. this.range = $.map(range, function(d) {
  1721. return d.valueOf();
  1722. });
  1723. this.fill();
  1724. },
  1725. getClassNames: function(date) {
  1726. var cls = [],
  1727. year = this.viewDate.getUTCFullYear(),
  1728. month = this.viewDate.getUTCMonth(),
  1729. today = new Date();
  1730. if (date.getUTCFullYear() < year || (date.getUTCFullYear() === year && date.getUTCMonth() < month)) {
  1731. cls.push('old');
  1732. } else if (date.getUTCFullYear() > year || (date.getUTCFullYear() === year && date.getUTCMonth() > month)) {
  1733. cls.push('new');
  1734. }
  1735. if (this.focusDate && date.valueOf() === this.focusDate.valueOf())
  1736. cls.push('focused');
  1737. // Compare internal UTC date with local today, not UTC today
  1738. if (this.o.todayHighlight &&
  1739. date.getUTCFullYear() === today.getFullYear() &&
  1740. date.getUTCMonth() === today.getMonth() &&
  1741. date.getUTCDate() === today.getDate()) {
  1742. cls.push('today');
  1743. }
  1744. if (this.dates.contains(date) !== -1)
  1745. cls.push('active');
  1746. if (date.valueOf() < this.o.startDate || date.valueOf() > this.o.endDate ||
  1747. $.inArray(date.getUTCDay(), this.o.daysOfWeekDisabled) !== -1) {
  1748. cls.push('disabled');
  1749. }
  1750. if (this.range) {
  1751. if (date > this.range[0] && date < this.range[this.range.length - 1]) {
  1752. cls.push('range');
  1753. }
  1754. if ($.inArray(date.valueOf(), this.range) !== -1) {
  1755. cls.push('selected');
  1756. }
  1757. }
  1758. return cls;
  1759. },
  1760. fill: function() {
  1761. var d = new Date(this.viewDate),
  1762. year = d.getUTCFullYear(),
  1763. month = d.getUTCMonth(),
  1764. startYear = this.o.startDate !== -Infinity ? this.o.startDate.getUTCFullYear() : -Infinity,
  1765. startMonth = this.o.startDate !== -Infinity ? this.o.startDate.getUTCMonth() : -Infinity,
  1766. endYear = this.o.endDate !== Infinity ? this.o.endDate.getUTCFullYear() : Infinity,
  1767. endMonth = this.o.endDate !== Infinity ? this.o.endDate.getUTCMonth() : Infinity,
  1768. todaytxt = dates[this.o.language].today || dates['en'].today || '',
  1769. cleartxt = dates[this.o.language].clear || dates['en'].clear || '',
  1770. tooltip;
  1771. this.picker.find('.datepicker-days thead th.datepicker-switch')
  1772. .text(year + '年 ' + dates[this.o.language].months[month]);
  1773. this.picker.find('tfoot th.today')
  1774. .text(todaytxt)
  1775. .toggle(this.o.todayBtn !== false);
  1776. this.picker.find('tfoot th.clear')
  1777. .text(cleartxt)
  1778. .toggle(this.o.clearBtn !== false);
  1779. this.updateNavArrows();
  1780. this.fillMonths();
  1781. var prevMonth = UTCDate(year, month - 1, 28),
  1782. day = DPGlobal.getDaysInMonth(prevMonth.getUTCFullYear(), prevMonth.getUTCMonth());
  1783. prevMonth.setUTCDate(day);
  1784. prevMonth.setUTCDate(day - (prevMonth.getUTCDay() - this.o.weekStart + 7) % 7);
  1785. var nextMonth = new Date(prevMonth);
  1786. nextMonth.setUTCDate(nextMonth.getUTCDate() + 42);
  1787. nextMonth = nextMonth.valueOf();
  1788. var html = [];
  1789. var clsName;
  1790. while (prevMonth.valueOf() < nextMonth) {
  1791. if (prevMonth.getUTCDay() === this.o.weekStart) {
  1792. html.push('<tr>');
  1793. if (this.o.calendarWeeks) {
  1794. // ISO 8601: First week contains first thursday.
  1795. // ISO also states week starts on Monday, but we can be more abstract here.
  1796. var
  1797. // Start of current week: based on weekstart/current date
  1798. ws = new Date(+prevMonth + (this.o.weekStart - prevMonth.getUTCDay() - 7) % 7 * 864e5),
  1799. // Thursday of this week
  1800. th = new Date(Number(ws) + (7 + 4 - ws.getUTCDay()) % 7 * 864e5),
  1801. // First Thursday of year, year from thursday
  1802. yth = new Date(Number(yth = UTCDate(th.getUTCFullYear(), 0, 1)) + (7 + 4 - yth.getUTCDay()) % 7 * 864e5),
  1803. // Calendar week: ms between thursdays, div ms per day, div 7 days
  1804. calWeek = (th - yth) / 864e5 / 7 + 1;
  1805. html.push('<td class="cw">' + calWeek + '</td>');
  1806. }
  1807. }
  1808. clsName = this.getClassNames(prevMonth);
  1809. clsName.push('day');
  1810. if (this.o.beforeShowDay !== $.noop) {
  1811. var before = this.o.beforeShowDay(this._utc_to_local(prevMonth));
  1812. if (before === undefined)
  1813. before = {};
  1814. else if (typeof(before) === 'boolean')
  1815. before = {
  1816. enabled: before
  1817. };
  1818. else if (typeof(before) === 'string')
  1819. before = {
  1820. classes: before
  1821. };
  1822. if (before.enabled === false)
  1823. clsName.push('disabled');
  1824. if (before.classes)
  1825. clsName = clsName.concat(before.classes.split(/\s+/));
  1826. if (before.tooltip)
  1827. tooltip = before.tooltip;
  1828. }
  1829. clsName = $.unique(clsName);
  1830. var currentDate;
  1831. var today = new Date();
  1832. if (this.o.todayHighlight &&
  1833. prevMonth.getUTCFullYear() === today.getFullYear() &&
  1834. prevMonth.getUTCMonth() === today.getMonth() &&
  1835. prevMonth.getUTCDate() === today.getDate()) {
  1836. currentDate = '今日';
  1837. } else {
  1838. currentDate = prevMonth.getUTCDate();
  1839. }
  1840. html.push('<td class="' + clsName.join(' ') + '"' + (tooltip ? ' title="' + tooltip + '"' : '') + 'data-day="' + prevMonth.getUTCDate() + '"' + '>' + currentDate + '</td>');
  1841. if (prevMonth.getUTCDay() === this.o.weekEnd) {
  1842. html.push('</tr>');
  1843. }
  1844. prevMonth.setUTCDate(prevMonth.getUTCDate() + 1);
  1845. }
  1846. this.picker.find('.datepicker-days tbody').empty().append(html.join(''));
  1847. var months = this.picker.find('.datepicker-months')
  1848. .find('th:eq(1)')
  1849. .text(year)
  1850. .end()
  1851. .find('span').removeClass('active');
  1852. $.each(this.dates, function(i, d) {
  1853. if (d.getUTCFullYear() === year)
  1854. months.eq(d.getUTCMonth()).addClass('active');
  1855. });
  1856. if (year < startYear || year > endYear) {
  1857. months.addClass('disabled');
  1858. }
  1859. if (year === startYear) {
  1860. months.slice(0, startMonth).addClass('disabled');
  1861. }
  1862. if (year === endYear) {
  1863. months.slice(endMonth + 1).addClass('disabled');
  1864. }
  1865. html = '';
  1866. year = parseInt(year / 10, 10) * 10;
  1867. var yearCont = this.picker.find('.datepicker-years')
  1868. .find('th:eq(1)')
  1869. .text(year + '-' + (year + 9))
  1870. .end()
  1871. .find('td');
  1872. year -= 1;
  1873. var years = $.map(this.dates, function(d) {
  1874. return d.getUTCFullYear();
  1875. }),
  1876. classes;
  1877. for (var i = -1; i < 11; i++) {
  1878. classes = ['year'];
  1879. if (i === -1)
  1880. classes.push('old');
  1881. else if (i === 10)
  1882. classes.push('new');
  1883. if ($.inArray(year, years) !== -1)
  1884. classes.push('active');
  1885. if (year < startYear || year > endYear)
  1886. classes.push('disabled');
  1887. html += '<span class="' + classes.join(' ') + '">' + year + '</span>';
  1888. year += 1;
  1889. }
  1890. yearCont.html(html);
  1891. },
  1892. updateNavArrows: function() {
  1893. if (!this._allow_update)
  1894. return;
  1895. var d = new Date(this.viewDate),
  1896. year = d.getUTCFullYear(),
  1897. month = d.getUTCMonth();
  1898. switch (this.viewMode) {
  1899. case 0:
  1900. if (this.o.startDate !== -Infinity && year <= this.o.startDate.getUTCFullYear() && month <= this.o.startDate.getUTCMonth()) {
  1901. this.picker.find('.prev').css({
  1902. visibility: 'hidden'
  1903. });
  1904. } else {
  1905. this.picker.find('.prev').css({
  1906. visibility: 'visible'
  1907. });
  1908. }
  1909. if (this.o.endDate !== Infinity && year >= this.o.endDate.getUTCFullYear() && month >= this.o.endDate.getUTCMonth()) {
  1910. this.picker.find('.next').css({
  1911. visibility: 'hidden'
  1912. });
  1913. } else {
  1914. this.picker.find('.next').css({
  1915. visibility: 'visible'
  1916. });
  1917. }
  1918. break;
  1919. case 1:
  1920. case 2:
  1921. if (this.o.startDate !== -Infinity && year <= this.o.startDate.getUTCFullYear()) {
  1922. this.picker.find('.prev').css({
  1923. visibility: 'hidden'
  1924. });
  1925. } else {
  1926. this.picker.find('.prev').css({
  1927. visibility: 'visible'
  1928. });
  1929. }
  1930. if (this.o.endDate !== Infinity && year >= this.o.endDate.getUTCFullYear()) {
  1931. this.picker.find('.next').css({
  1932. visibility: 'hidden'
  1933. });
  1934. } else {
  1935. this.picker.find('.next').css({
  1936. visibility: 'visible'
  1937. });
  1938. }
  1939. break;
  1940. }
  1941. },
  1942. click: function(e) {
  1943. e.preventDefault();
  1944. if ($(e.target).parents(".timepicker-container")[0]) {
  1945. return;
  1946. }
  1947. var target = $(e.target).closest('span, td, th'),
  1948. year, month, day;
  1949. if (target.length === 1) {
  1950. switch (target[0].nodeName.toLowerCase()) {
  1951. case 'th':
  1952. switch (target[0].className) {
  1953. case 'datepicker-switch':
  1954. this.showMode(1);
  1955. break;
  1956. case 'prev':
  1957. case 'next':
  1958. var dir = DPGlobal.modes[this.viewMode].navStep * (target[0].className === 'prev' ? -1 : 1);
  1959. switch (this.viewMode) {
  1960. case 0:
  1961. this.viewDate = this.moveMonth(this.viewDate, dir);
  1962. this._trigger('changeMonth', this.viewDate);
  1963. break;
  1964. case 1:
  1965. case 2:
  1966. this.viewDate = this.moveYear(this.viewDate, dir);
  1967. if (this.viewMode === 1)
  1968. this._trigger('changeYear', this.viewDate);
  1969. break;
  1970. }
  1971. this.fill();
  1972. break;
  1973. case 'today':
  1974. var date = new Date();
  1975. date = UTCDate(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);
  1976. this.showMode(-2);
  1977. var which = this.o.todayBtn === 'linked' ? null : 'view';
  1978. this._setDate(date, which);
  1979. break;
  1980. case 'clear':
  1981. var element;
  1982. if (this.isInput)
  1983. element = this.element;
  1984. else if (this.component)
  1985. element = this.element.find('input');
  1986. if (element)
  1987. element.val("").change();
  1988. this.update();
  1989. this._trigger('changeDate');
  1990. if (this.o.autoclose)
  1991. this.hide();
  1992. break;
  1993. }
  1994. break;
  1995. case 'span':
  1996. if (!target.is('.disabled') && !target.is('[data-num]')) {
  1997. this.viewDate.setUTCDate(1);
  1998. if (target.is('.month')) {
  1999. day = 1;
  2000. month = target.parent().find('span').index(target);
  2001. year = this.viewDate.getUTCFullYear();
  2002. this.viewDate.setUTCMonth(month);
  2003. this._trigger('changeMonth', this.viewDate);
  2004. if (this.o.minViewMode === 1) {
  2005. this._setDate(UTCDate(year, month, day));
  2006. }
  2007. } else {
  2008. day = 1;
  2009. month = 0;
  2010. year = parseInt(target.text(), 10) || 0;
  2011. this.viewDate.setUTCFullYear(year);
  2012. this._trigger('changeYear', this.viewDate);
  2013. if (this.o.minViewMode === 2) {
  2014. this._setDate(UTCDate(year, month, day));
  2015. }
  2016. }
  2017. this.showMode(-1);
  2018. this.fill();
  2019. }
  2020. break;
  2021. case 'td':
  2022. if (target.is('.day') && !target.is('.disabled')) {
  2023. day = target.data('day');
  2024. day = parseInt(day, 10) || 1;
  2025. year = this.viewDate.getUTCFullYear();
  2026. month = this.viewDate.getUTCMonth();
  2027. if (target.is('.old')) {
  2028. if (month === 0) {
  2029. month = 11;
  2030. year -= 1;
  2031. } else {
  2032. month -= 1;
  2033. }
  2034. } else if (target.is('.new')) {
  2035. if (month === 11) {
  2036. month = 0;
  2037. year += 1;
  2038. } else {
  2039. month += 1;
  2040. }
  2041. }
  2042. this._setDate(UTCDate(year, month, day));
  2043. }
  2044. break;
  2045. }
  2046. }
  2047. if (this.picker.is(':visible') && this._focused_from) {
  2048. $(this._focused_from).focus();
  2049. }
  2050. delete this._focused_from;
  2051. },
  2052. _toggle_multidate: function(date) {
  2053. var ix = this.dates.contains(date);
  2054. if (!date) {
  2055. this.dates.clear();
  2056. } else if (ix !== -1) {
  2057. this.dates.remove(ix);
  2058. } else {
  2059. this.dates.push(date);
  2060. }
  2061. if (typeof this.o.multidate === 'number')
  2062. while (this.dates.length > this.o.multidate)
  2063. this.dates.remove(0);
  2064. },
  2065. _setDate: function(date, which) {
  2066. if (!which || which === 'date')
  2067. this._toggle_multidate(date && new Date(date));
  2068. if (!which || which === 'view')
  2069. this.viewDate = date && new Date(date);
  2070. this.fill();
  2071. this.setValue();
  2072. this._trigger('changeDate');
  2073. var element;
  2074. if (this.isInput) {
  2075. element = this.element;
  2076. } else if (this.component) {
  2077. element = this.element.find('input');
  2078. }
  2079. if (element) {
  2080. element.change();
  2081. }
  2082. if (this.o.autoclose && (!which || which === 'date')) {
  2083. this.hide();
  2084. }
  2085. },
  2086. moveMonth: function(date, dir) {
  2087. if (!date)
  2088. return undefined;
  2089. if (!dir)
  2090. return date;
  2091. var new_date = new Date(date.valueOf()),
  2092. day = new_date.getUTCDate(),
  2093. month = new_date.getUTCMonth(),
  2094. mag = Math.abs(dir),
  2095. new_month, test;
  2096. dir = dir > 0 ? 1 : -1;
  2097. if (mag === 1) {
  2098. test = dir === -1
  2099. // If going back one month, make sure month is not current month
  2100. // (eg, Mar 31 -> Feb 31 == Feb 28, not Mar 02)
  2101. ? function() {
  2102. return new_date.getUTCMonth() === month;
  2103. }
  2104. // If going forward one month, make sure month is as expected
  2105. // (eg, Jan 31 -> Feb 31 == Feb 28, not Mar 02)
  2106. : function() {
  2107. return new_date.getUTCMonth() !== new_month;
  2108. };
  2109. new_month = month + dir;
  2110. new_date.setUTCMonth(new_month);
  2111. // Dec -> Jan (12) or Jan -> Dec (-1) -- limit expected date to 0-11
  2112. if (new_month < 0 || new_month > 11)
  2113. new_month = (new_month + 12) % 12;
  2114. } else {
  2115. // For magnitudes >1, move one month at a time...
  2116. for (var i = 0; i < mag; i++)
  2117. // ...which might decrease the day (eg, Jan 31 to Feb 28, etc)...
  2118. new_date = this.moveMonth(new_date, dir);
  2119. // ...then reset the day, keeping it in the new month
  2120. new_month = new_date.getUTCMonth();
  2121. new_date.setUTCDate(day);
  2122. test = function() {
  2123. return new_month !== new_date.getUTCMonth();
  2124. };
  2125. }
  2126. // Common date-resetting loop -- if date is beyond end of month, make it
  2127. // end of month
  2128. while (test()) {
  2129. new_date.setUTCDate(--day);
  2130. new_date.setUTCMonth(new_month);
  2131. }
  2132. return new_date;
  2133. },
  2134. moveYear: function(date, dir) {
  2135. return this.moveMonth(date, dir * 12);
  2136. },
  2137. dateWithinRange: function(date) {
  2138. return date >= this.o.startDate && date <= this.o.endDate;
  2139. },
  2140. keydown: function(e) {
  2141. if (this.picker.is(':not(:visible)')) {
  2142. if (e.keyCode === 27) // allow escape to hide and re-show picker
  2143. this.show();
  2144. return;
  2145. }
  2146. var dateChanged = false,
  2147. dir, newDate, newViewDate,
  2148. focusDate = this.focusDate || this.viewDate;
  2149. switch (e.keyCode) {
  2150. case 27: // escape
  2151. if (this.focusDate) {
  2152. this.focusDate = null;
  2153. this.viewDate = this.dates.get(-1) || this.viewDate;
  2154. this.fill();
  2155. } else
  2156. this.hide();
  2157. e.preventDefault();
  2158. break;
  2159. case 37: // left
  2160. case 39: // right
  2161. if (!this.o.keyboardNavigation)
  2162. break;
  2163. dir = e.keyCode === 37 ? -1 : 1;
  2164. if (e.ctrlKey) {
  2165. newDate = this.moveYear(this.dates.get(-1) || UTCToday(), dir);
  2166. newViewDate = this.moveYear(focusDate, dir);
  2167. this._trigger('changeYear', this.viewDate);
  2168. } else if (e.shiftKey) {
  2169. newDate = this.moveMonth(this.dates.get(-1) || UTCToday(), dir);
  2170. newViewDate = this.moveMonth(focusDate, dir);
  2171. this._trigger('changeMonth', this.viewDate);
  2172. } else {
  2173. newDate = new Date(this.dates.get(-1) || UTCToday());
  2174. newDate.setUTCDate(newDate.getUTCDate() + dir);
  2175. newViewDate = new Date(focusDate);
  2176. newViewDate.setUTCDate(focusDate.getUTCDate() + dir);
  2177. }
  2178. if (this.dateWithinRange(newDate)) {
  2179. this.focusDate = this.viewDate = newViewDate;
  2180. this.setValue();
  2181. this.fill();
  2182. e.preventDefault();
  2183. }
  2184. break;
  2185. case 38: // up
  2186. case 40: // down
  2187. if (!this.o.keyboardNavigation)
  2188. break;
  2189. dir = e.keyCode === 38 ? -1 : 1;
  2190. if (e.ctrlKey) {
  2191. newDate = this.moveYear(this.dates.get(-1) || UTCToday(), dir);
  2192. newViewDate = this.moveYear(focusDate, dir);
  2193. this._trigger('changeYear', this.viewDate);
  2194. } else if (e.shiftKey) {
  2195. newDate = this.moveMonth(this.dates.get(-1) || UTCToday(), dir);
  2196. newViewDate = this.moveMonth(focusDate, dir);
  2197. this._trigger('changeMonth', this.viewDate);
  2198. } else {
  2199. newDate = new Date(this.dates.get(-1) || UTCToday());
  2200. newDate.setUTCDate(newDate.getUTCDate() + dir * 7);
  2201. newViewDate = new Date(focusDate);
  2202. newViewDate.setUTCDate(focusDate.getUTCDate() + dir * 7);
  2203. }
  2204. if (this.dateWithinRange(newDate)) {
  2205. this.focusDate = this.viewDate = newViewDate;
  2206. this.setValue();
  2207. this.fill();
  2208. e.preventDefault();
  2209. }
  2210. break;
  2211. case 32: // spacebar
  2212. // Spacebar is used in manually typing dates in some formats.
  2213. // As such, its behavior should not be hijacked.
  2214. break;
  2215. case 13: // enter
  2216. focusDate = this.focusDate || this.dates.get(-1) || this.viewDate;
  2217. this._toggle_multidate(focusDate);
  2218. dateChanged = true;
  2219. this.focusDate = null;
  2220. this.viewDate = this.dates.get(-1) || this.viewDate;
  2221. this.setValue();
  2222. this.fill();
  2223. if (this.picker.is(':visible')) {
  2224. e.preventDefault();
  2225. if (this.o.autoclose)
  2226. this.hide();
  2227. }
  2228. break;
  2229. case 9: // tab
  2230. this.focusDate = null;
  2231. this.viewDate = this.dates.get(-1) || this.viewDate;
  2232. this.fill();
  2233. this.hide();
  2234. break;
  2235. }
  2236. if (dateChanged) {
  2237. if (this.dates.length)
  2238. this._trigger('changeDate');
  2239. else
  2240. this._trigger('clearDate');
  2241. var element;
  2242. if (this.isInput) {
  2243. element = this.element;
  2244. } else if (this.component) {
  2245. element = this.element.find('input');
  2246. }
  2247. if (element) {
  2248. element.change();
  2249. }
  2250. }
  2251. },
  2252. showMode: function(dir) {
  2253. if (dir) {
  2254. this.viewMode = Math.max(this.o.minViewMode, Math.min(2, this.viewMode + dir));
  2255. }
  2256. this.picker
  2257. .find('>div')
  2258. .hide()
  2259. .filter('.datepicker-' + DPGlobal.modes[this.viewMode].clsName)
  2260. .css('display', 'block');
  2261. this.updateNavArrows();
  2262. }
  2263. };
  2264. var DateRangePicker = function(element, options) {
  2265. this.element = $(element);
  2266. this.inputs = $.map(options.inputs, function(i) {
  2267. return i.jquery ? i[0] : i;
  2268. });
  2269. delete options.inputs;
  2270. $(this.inputs)
  2271. .datepicker(options)
  2272. .bind('changeDate', $.proxy(this.dateUpdated, this));
  2273. this.pickers = $.map(this.inputs, function(i) {
  2274. return $(i).data('datepicker');
  2275. });
  2276. this.updateDates();
  2277. };
  2278. DateRangePicker.prototype = {
  2279. updateDates: function() {
  2280. this.dates = $.map(this.pickers, function(i) {
  2281. return i.getUTCDate();
  2282. });
  2283. this.updateRanges();
  2284. },
  2285. updateRanges: function() {
  2286. var range = $.map(this.dates, function(d) {
  2287. return d.valueOf();
  2288. });
  2289. $.each(this.pickers, function(i, p) {
  2290. p.setRange(range);
  2291. });
  2292. },
  2293. dateUpdated: function(e) {
  2294. // `this.updating` is a workaround for preventing infinite recursion
  2295. // between `changeDate` triggering and `setUTCDate` calling. Until
  2296. // there is a better mechanism.
  2297. if (this.updating)
  2298. return;
  2299. this.updating = true;
  2300. var dp = $(e.target).data('datepicker'),
  2301. new_date = dp.getUTCDate(),
  2302. i = $.inArray(e.target, this.inputs),
  2303. l = this.inputs.length;
  2304. if (i === -1)
  2305. return;
  2306. $.each(this.pickers, function(i, p) {
  2307. if (!p.getUTCDate())
  2308. p.setUTCDate(new_date);
  2309. });
  2310. //临时修复选择后面的日期不会自动修正前面日期的bug
  2311. var j = 0;
  2312. for (j = 0; j < this.pickers.length; j++) {
  2313. this.dates[j] = this.pickers[j].getDate();
  2314. }
  2315. j = i - 1;
  2316. while (j >= 0 && new_date < this.dates[j]) {
  2317. this.pickers[j--].setUTCDate(new_date);
  2318. }
  2319. if (new_date < this.dates[i]) {
  2320. // Date being moved earlier/left
  2321. while (i >= 0 && new_date < this.dates[i]) {
  2322. this.pickers[i--].setUTCDate(new_date);
  2323. }
  2324. } else if (new_date > this.dates[i]) {
  2325. // Date being moved later/right
  2326. while (i < l && new_date > this.dates[i]) {
  2327. this.pickers[i++].setUTCDate(new_date);
  2328. }
  2329. }
  2330. this.updateDates();
  2331. delete this.updating;
  2332. },
  2333. remove: function() {
  2334. $.map(this.pickers, function(p) {
  2335. p.remove();
  2336. });
  2337. delete this.element.data().datepicker;
  2338. }
  2339. };
  2340. function opts_from_el(el, prefix) {
  2341. // Derive options from element data-attrs
  2342. var data = $(el).data(),
  2343. out = {},
  2344. inkey,
  2345. replace = new RegExp('^' + prefix.toLowerCase() + '([A-Z])');
  2346. prefix = new RegExp('^' + prefix.toLowerCase());
  2347. function re_lower(_, a) {
  2348. return a.toLowerCase();
  2349. }
  2350. for (var key in data)
  2351. if (prefix.test(key)) {
  2352. inkey = key.replace(replace, re_lower);
  2353. out[inkey] = data[key];
  2354. }
  2355. return out;
  2356. }
  2357. function opts_from_locale(lang) {
  2358. // Derive options from locale plugins
  2359. var out = {};
  2360. // Check if "de-DE" style date is available, if not language should
  2361. // fallback to 2 letter code eg "de"
  2362. if (!dates[lang]) {
  2363. lang = lang.split('-')[0];
  2364. if (!dates[lang])
  2365. return;
  2366. }
  2367. var d = dates[lang];
  2368. $.each(locale_opts, function(i, k) {
  2369. if (k in d)
  2370. out[k] = d[k];
  2371. });
  2372. return out;
  2373. }
  2374. var old = $.fn.datepicker;
  2375. $.fn.datepicker = function(option) {
  2376. var args = Array.apply(null, arguments);
  2377. args.shift();
  2378. var internal_return;
  2379. this.each(function() {
  2380. var $this = $(this),
  2381. data = $this.data('datepicker'),
  2382. options = typeof option === 'object' && option;
  2383. if (!data) {
  2384. var elopts = opts_from_el(this, 'date'),
  2385. // Preliminary otions
  2386. xopts = $.extend({}, defaults, elopts, options),
  2387. locopts = opts_from_locale(xopts.language),
  2388. // Options priority: js args, data-attrs, locales, defaults
  2389. opts = $.extend({}, defaults, locopts, elopts, options);
  2390. if ($this.is('.input-daterange') || opts.inputs) {
  2391. var ropts = {
  2392. inputs: opts.inputs || $this.find('input').toArray()
  2393. };
  2394. $this.data('datepicker', (data = new DateRangePicker(this, $.extend(opts, ropts))));
  2395. } else {
  2396. $this.data('datepicker', (data = new Datepicker(this, opts)));
  2397. }
  2398. }
  2399. if (typeof option === 'string' && typeof data[option] === 'function') {
  2400. internal_return = data[option].apply(data, args);
  2401. if (internal_return !== undefined)
  2402. return false;
  2403. }
  2404. });
  2405. if (internal_return !== undefined)
  2406. return internal_return;
  2407. else
  2408. return this;
  2409. };
  2410. var defaults = $.fn.datepicker.defaults = {
  2411. autoclose: true,
  2412. beforeShowDay: $.noop,
  2413. calendarWeeks: false,
  2414. clearBtn: false,
  2415. daysOfWeekDisabled: [],
  2416. endDate: Infinity,
  2417. forceParse: true,
  2418. format: 'yyyy-mm-dd',
  2419. keyboardNavigation: true,
  2420. language: 'zh-CN',
  2421. minViewMode: 0,
  2422. multidate: false,
  2423. multidateSeparator: ',',
  2424. orientation: "auto",
  2425. rtl: false,
  2426. size: '',
  2427. startDate: -Infinity,
  2428. startView: 0,
  2429. todayBtn: false,
  2430. todayHighlight: true,
  2431. weekStart: 0,
  2432. timepicker: false,
  2433. };
  2434. var locale_opts = $.fn.datepicker.locale_opts = [
  2435. 'format',
  2436. 'rtl',
  2437. 'weekStart'
  2438. ];
  2439. $.fn.datepicker.Constructor = Datepicker;
  2440. var dates = $.fn.datepicker.dates = {
  2441. "en": {
  2442. days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
  2443. daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
  2444. daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],
  2445. months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
  2446. monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
  2447. today: "Today",
  2448. clear: "Clear"
  2449. },
  2450. "zh-CN": {
  2451. days: ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日"],
  2452. daysShort: ["周日", "周一", "周二", "周三", "周四", "周五", "周六", "周日"],
  2453. daysMin: ["日", "一", "二", "三", "四", "五", "六", "日"],
  2454. months: ["1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"],
  2455. monthsShort: ["1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"],
  2456. today: "今日",
  2457. weekStart: 0
  2458. }
  2459. };
  2460. var DPGlobal = {
  2461. modes: [{
  2462. clsName: 'days',
  2463. navFnc: 'Month',
  2464. navStep: 1
  2465. }, {
  2466. clsName: 'months',
  2467. navFnc: 'FullYear',
  2468. navStep: 1
  2469. }, {
  2470. clsName: 'years',
  2471. navFnc: 'FullYear',
  2472. navStep: 10
  2473. }],
  2474. isLeapYear: function(year) {
  2475. return (((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0));
  2476. },
  2477. getDaysInMonth: function(year, month) {
  2478. return [31, (DPGlobal.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month];
  2479. },
  2480. validParts: /dd?|DD?|mm?|MM?|yy(?:yy)?/g,
  2481. nonpunctuation: /[^ -\/:-@\[\u3400-\u9fff-`{-~\t\n\r]+/g,
  2482. parseFormat: function(format) {
  2483. // IE treats \0 as a string end in inputs (truncating the value),
  2484. // so it's a bad format delimiter, anyway
  2485. var separators = format.replace(this.validParts, '\0').split('\0'),
  2486. parts = format.match(this.validParts);
  2487. if (!separators || !separators.length || !parts || parts.length === 0) {
  2488. throw new Error("Invalid date format.");
  2489. }
  2490. return {
  2491. separators: separators,
  2492. parts: parts
  2493. };
  2494. },
  2495. parseDate: function(date, format, language) {
  2496. if (!date)
  2497. return undefined;
  2498. if (date instanceof Date)
  2499. return date;
  2500. if (typeof format === 'string')
  2501. format = DPGlobal.parseFormat(format);
  2502. var part_re = /([\-+]\d+)([dmwy])/,
  2503. parts = date.match(/([\-+]\d+)([dmwy])/g),
  2504. part, dir, i;
  2505. if (/^[\-+]\d+[dmwy]([\s,]+[\-+]\d+[dmwy])*$/.test(date)) {
  2506. date = new Date();
  2507. for (i = 0; i < parts.length; i++) {
  2508. part = part_re.exec(parts[i]);
  2509. dir = parseInt(part[1]);
  2510. switch (part[2]) {
  2511. case 'd':
  2512. date.setUTCDate(date.getUTCDate() + dir);
  2513. break;
  2514. case 'm':
  2515. date = Datepicker.prototype.moveMonth.call(Datepicker.prototype, date, dir);
  2516. break;
  2517. case 'w':
  2518. date.setUTCDate(date.getUTCDate() + dir * 7);
  2519. break;
  2520. case 'y':
  2521. date = Datepicker.prototype.moveYear.call(Datepicker.prototype, date, dir);
  2522. break;
  2523. }
  2524. }
  2525. return UTCDate(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate(), 0, 0, 0);
  2526. }
  2527. parts = date && date.match(this.nonpunctuation) || [];
  2528. date = new Date();
  2529. var parsed = {},
  2530. setters_order = ['yyyy', 'yy', 'M', 'MM', 'm', 'mm', 'd', 'dd'],
  2531. setters_map = {
  2532. yyyy: function(d, v) {
  2533. return d.setUTCFullYear(v);
  2534. },
  2535. yy: function(d, v) {
  2536. return d.setUTCFullYear(2000 + v);
  2537. },
  2538. m: function(d, v) {
  2539. if (isNaN(d))
  2540. return d;
  2541. v -= 1;
  2542. while (v < 0) v += 12;
  2543. v %= 12;
  2544. d.setUTCMonth(v);
  2545. while (d.getUTCMonth() !== v)
  2546. d.setUTCDate(d.getUTCDate() - 1);
  2547. return d;
  2548. },
  2549. d: function(d, v) {
  2550. return d.setUTCDate(v);
  2551. }
  2552. },
  2553. val, filtered;
  2554. setters_map['M'] = setters_map['MM'] = setters_map['mm'] = setters_map['m'];
  2555. setters_map['dd'] = setters_map['d'];
  2556. date = UTCDate(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);
  2557. var fparts = format.parts.slice();
  2558. // Remove noop parts
  2559. if (parts.length !== fparts.length) {
  2560. fparts = $(fparts).filter(function(i, p) {
  2561. return $.inArray(p, setters_order) !== -1;
  2562. }).toArray();
  2563. }
  2564. // Process remainder
  2565. function match_part() {
  2566. var m = this.slice(0, parts[i].length),
  2567. p = parts[i].slice(0, m.length);
  2568. return m === p;
  2569. }
  2570. if (parts.length === fparts.length) {
  2571. var cnt;
  2572. for (i = 0, cnt = fparts.length; i < cnt; i++) {
  2573. val = parseInt(parts[i], 10);
  2574. part = fparts[i];
  2575. if (isNaN(val)) {
  2576. switch (part) {
  2577. case 'MM':
  2578. filtered = $(dates[language].months).filter(match_part);
  2579. val = $.inArray(filtered[0], dates[language].months) + 1;
  2580. break;
  2581. case 'M':
  2582. filtered = $(dates[language].monthsShort).filter(match_part);
  2583. val = $.inArray(filtered[0], dates[language].monthsShort) + 1;
  2584. break;
  2585. }
  2586. }
  2587. parsed[part] = val;
  2588. }
  2589. var _date, s;
  2590. for (i = 0; i < setters_order.length; i++) {
  2591. s = setters_order[i];
  2592. if (s in parsed && !isNaN(parsed[s])) {
  2593. _date = new Date(date);
  2594. setters_map[s](_date, parsed[s]);
  2595. if (!isNaN(_date))
  2596. date = _date;
  2597. }
  2598. }
  2599. }
  2600. return date;
  2601. },
  2602. formatDate: function(date, format, language) {
  2603. if (!date)
  2604. return '';
  2605. if (typeof format === 'string')
  2606. format = DPGlobal.parseFormat(format);
  2607. var val = {
  2608. d: date.getUTCDate(),
  2609. D: dates[language].daysShort[date.getUTCDay()],
  2610. DD: dates[language].days[date.getUTCDay()],
  2611. m: date.getUTCMonth() + 1,
  2612. M: dates[language].monthsShort[date.getUTCMonth()],
  2613. MM: dates[language].months[date.getUTCMonth()],
  2614. yy: date.getUTCFullYear().toString().substring(2),
  2615. yyyy: date.getUTCFullYear()
  2616. };
  2617. val.dd = (val.d < 10 ? '0' : '') + val.d;
  2618. val.mm = (val.m < 10 ? '0' : '') + val.m;
  2619. date = [];
  2620. var seps = $.extend([], format.separators);
  2621. for (var i = 0, cnt = format.parts.length; i <= cnt; i++) {
  2622. if (seps.length)
  2623. date.push(seps.shift());
  2624. date.push(val[format.parts[i]]);
  2625. }
  2626. return date.join('');
  2627. },
  2628. headTemplate: '<thead>' +
  2629. '<tr class="date-header">' +
  2630. '<th class="prev"><b></b></th>' +
  2631. '<th colspan="5" class="datepicker-switch"></th>' +
  2632. '<th class="next"><b></b></th>' +
  2633. '</tr>' +
  2634. '</thead>',
  2635. contTemplate: '<tbody><tr><td colspan="7"></td></tr></tbody>',
  2636. footTemplate: '<tfoot>' +
  2637. '<tr>' +
  2638. '<th colspan="7" class="today"></th>' +
  2639. '</tr>' +
  2640. '<tr>' +
  2641. '<th colspan="7" class="clear"></th>' +
  2642. '</tr>' +
  2643. '</tfoot>',
  2644. timepicerTemplate: '<div class="timepicker-container"></div>'
  2645. };
  2646. DPGlobal.template = '<div class="datepicker">' +
  2647. '<div class="datepicker-days clearfix">' +
  2648. '<table class=" table-condensed">' +
  2649. DPGlobal.headTemplate +
  2650. '<tbody></tbody>' +
  2651. DPGlobal.footTemplate +
  2652. '</table>' +
  2653. DPGlobal.timepicerTemplate +
  2654. '</div>' +
  2655. '<div class="datepicker-months">' +
  2656. '<table class="table-condensed">' +
  2657. DPGlobal.headTemplate +
  2658. DPGlobal.contTemplate +
  2659. DPGlobal.footTemplate +
  2660. '</table>' +
  2661. '</div>' +
  2662. '<div class="datepicker-years">' +
  2663. '<table class="table-condensed">' +
  2664. DPGlobal.headTemplate +
  2665. DPGlobal.contTemplate +
  2666. DPGlobal.footTemplate +
  2667. '</table>' +
  2668. '</div>' +
  2669. '</div>';
  2670. $.fn.datepicker.DPGlobal = DPGlobal;
  2671. /* DATEPICKER NO CONFLICT
  2672. * =================== */
  2673. $.fn.datepicker.noConflict = function() {
  2674. $.fn.datepicker = old;
  2675. return this;
  2676. };
  2677. /* DATEPICKER DATA-API
  2678. * ================== */
  2679. $(document).on(
  2680. 'focus.datepicker.data-api click.datepicker.data-api',
  2681. '[data-toggle="datepicker"]',
  2682. function(e) {
  2683. var $this = $(this);
  2684. if ($this.data('datepicker'))
  2685. return;
  2686. e.preventDefault();
  2687. // component click requires us to explicitly show it
  2688. $this.datepicker('show');
  2689. }
  2690. );
  2691. $(function() {
  2692. $('[data-toggle="datepicker-inline"]').datepicker();
  2693. });
  2694. }(window.jQuery, undefined);
  2695. },{}],6:[function(require,module,exports){
  2696. //proxy dropdown to document, so there is no need to init
  2697. !function ($) {
  2698. "use strict";
  2699. var toggleSelector = '[data-toggle=dropdown]',
  2700. containerClass = ".sui-dropdown, .sui-dropup";
  2701. var clearMenus = function () {
  2702. $('.sui-dropdown.open, .sui-dropup.open, .sui-btn-group.open').each(function () {
  2703. $(this).removeClass('open')
  2704. })
  2705. }
  2706. var getContainer = function($el) {
  2707. var $parent = $el.parent()
  2708. if ($parent.hasClass("dropdown-inner")) return $parent.parent()
  2709. return $parent;
  2710. }
  2711. var show = function() {
  2712. clearMenus()
  2713. var $el = $(this),
  2714. $container = getContainer($el);
  2715. if ($container.is('.disabled, :disabled')) return
  2716. $container.addClass("open")
  2717. $el.focus()
  2718. return false;
  2719. }
  2720. var hide = function() {
  2721. var $el = $(this),
  2722. $container = getContainer($el);
  2723. if ($container.is('.disabled, :disabled')) return
  2724. $container.removeClass("open")
  2725. $el.focus()
  2726. return false;
  2727. }
  2728. var toggle = function() {
  2729. var $el = $(this),
  2730. $container = getContainer($el),
  2731. active = $container.hasClass("open");
  2732. clearMenus()
  2733. if ($container.is('.disabled, :disabled')) return
  2734. if(active) $container.removeClass("open")
  2735. else $container.addClass("open")
  2736. $el.focus()
  2737. return false;
  2738. }
  2739. var setValue = function() {
  2740. var $target = $(this),
  2741. $li = $target.parent(),
  2742. $container = $target.parents(".sui-dropdown, .sui-dropup"),
  2743. $menu = $container.find("[role='menu']");
  2744. if($li.is(".disabled, :disabled")) return;
  2745. if ($container.is('.disabled, :disabled')) return;
  2746. $container.find("input").val($target.attr("value") || "").trigger("change")
  2747. $container.find(toggleSelector+ ' span').html($target.html())
  2748. $menu.find(".active").removeClass("active")
  2749. $li.addClass("active")
  2750. }
  2751. $(document).on("mouseover", containerClass, function() {
  2752. var $container = $(this), el;
  2753. if(el = $container.find('[data-trigger="hover"]')[0]) show.call(el);
  2754. })
  2755. $(document).on("mouseleave", containerClass, function() {
  2756. var $container = $(this), el;
  2757. if(el = $container.find('[data-trigger="hover"]')[0]) hide.call(el);
  2758. })
  2759. $(document).on("click", "[data-toggle='dropdown']", toggle)
  2760. $(document).on("click", function() {
  2761. var $this = $(this);
  2762. if(!($this.is(containerClass) || $this.parents(containerClass)[0])) clearMenus()
  2763. })
  2764. $(document).on("click", ".select .sui-dropdown-menu a", setValue)
  2765. // Dropdown api
  2766. $.fn.dropdown = function(option) {
  2767. return this.each(function() {
  2768. $(this).attr("data-toggle", "dropdown");
  2769. if(typeof option == 'string') {
  2770. switch(option) {
  2771. case "show":
  2772. show.call(this);
  2773. break;
  2774. case "hide":
  2775. hide.call(this);
  2776. break;
  2777. case "toggle":
  2778. toggle.call(this);
  2779. break;
  2780. }
  2781. }
  2782. });
  2783. }
  2784. }(window.jQuery);
  2785. },{}],7:[function(require,module,exports){
  2786. !function($) {
  2787. /**
  2788. * filesize 获得计算机文件体积大小(byte)对人更友好的格式
  2789. * @param {number | string} 可正确转为数字的数字(int、float)、字符串
  2790. * @param {Object} opt 可选的配置,目前只有保留的小数位数,默认为2
  2791. */
  2792. "use strict";
  2793. $.extend({
  2794. filesize: function(arg, options){
  2795. var result = ""
  2796. , opt = options || {}
  2797. , num = Number(arg)
  2798. , bytes = ["B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"]
  2799. , round = opt.round !== undefined ? opt.round : 2
  2800. , e;
  2801. if (isNaN(arg) || num < 0) {
  2802. throw new Error("无效的size参数");
  2803. }
  2804. if (num === 0) {
  2805. result = "0B";
  2806. }
  2807. else {
  2808. e = Math.floor(Math.log(num) / Math.log(1000));
  2809. if (e > 8) {
  2810. result = result * (1000 * (e - 8));
  2811. e = 8;
  2812. }
  2813. result = num / Math.pow(2, (e * 10));
  2814. result = result.toFixed(e > 0 ? round : 0) + bytes[e];
  2815. }
  2816. return result;
  2817. }
  2818. })
  2819. }(jQuery);
  2820. },{}],8:[function(require,module,exports){
  2821. /*jshint scripturl:true */
  2822. /*jshint funcscope:true */
  2823. /*jshint -W004 */
  2824. /**
  2825. * Intro.js v0.9.0
  2826. * https://github.com/usablica/intro.js
  2827. * MIT licensed
  2828. *
  2829. * Copyright (C) 2013 usabli.ca - A weekend project by Afshin Mehrabani (@afshinmeh)
  2830. */
  2831. !function ($) {
  2832. //Default config/variables
  2833. var VERSION = '0.9.0';
  2834. /**
  2835. * IntroJs main class
  2836. *
  2837. * @class IntroJs
  2838. */
  2839. function IntroJs(obj,options) {
  2840. this._targetElement = obj;
  2841. this._options = getOptions(options);
  2842. }
  2843. function getOptions(options) {
  2844. return options = $.extend({}, IntroJs.prototype.defaults, options);
  2845. }
  2846. /**
  2847. * Initiate a new introduction/guide from an element in the page
  2848. *
  2849. * @api private
  2850. * @method _introForElement
  2851. * @param {Object} targetElm
  2852. * @returns {Boolean} Success or not?
  2853. */
  2854. function _introForElement(targetElm) {
  2855. var introItems = [],
  2856. self = this;
  2857. var allIntroSteps=[];
  2858. if (this._options.steps) {
  2859. //use steps passed programmatically
  2860. for (var i = 0, stepsLength = this._options.steps.length; i < stepsLength; i++) {
  2861. var currentItem = _cloneObject(this._options.steps[i]);
  2862. //set the step
  2863. currentItem.step = introItems.length + 1;
  2864. //use querySelector function only when developer used CSS selector
  2865. if (typeof(currentItem.element) === 'string') {
  2866. //grab the element with given selector from the page
  2867. currentItem.element = document.querySelector(currentItem.element);
  2868. }
  2869. //intro without element
  2870. if (typeof(currentItem.element) === 'undefined' || currentItem.element === null) {
  2871. var floatingElementQuery = document.querySelector(".introjsFloatingElement");
  2872. if (floatingElementQuery === null) {
  2873. floatingElementQuery = document.createElement('div');
  2874. floatingElementQuery.className = 'introjsFloatingElement';
  2875. document.body.appendChild(floatingElementQuery);
  2876. }
  2877. currentItem.element = floatingElementQuery;
  2878. currentItem.position = 'floating';
  2879. }
  2880. if (currentItem.element !== null) {
  2881. introItems.push(currentItem);
  2882. }
  2883. }
  2884. } else {
  2885. //use steps from data-* annotations
  2886. allIntroSteps = targetElm.querySelectorAll('*[data-intro]');
  2887. //if there's no element to intro
  2888. if (allIntroSteps.length < 1) {
  2889. return false;
  2890. }
  2891. //first add intro items with data-step
  2892. for (var i = 0, elmsLength = allIntroSteps.length; i < elmsLength; i++) {
  2893. var currentElement = allIntroSteps[i];
  2894. var step = parseInt(currentElement.getAttribute('data-step'), 10);
  2895. if (step > 0) {
  2896. introItems[step - 1] = {
  2897. element: currentElement,
  2898. intro: currentElement.getAttribute('data-intro'),
  2899. step: parseInt(currentElement.getAttribute('data-step'), 10),
  2900. tooltipClass: currentElement.getAttribute('data-tooltipClass'),
  2901. position: currentElement.getAttribute('data-position') || this._options.tooltipPosition
  2902. };
  2903. }
  2904. }
  2905. //next add intro items without data-step
  2906. //todo: we need a cleanup here, two loops are redundant
  2907. var nextStep = 0;
  2908. for (var i = 0, elmsLength = allIntroSteps.length; i < elmsLength; i++) {
  2909. var currentElement = allIntroSteps[i];
  2910. if (currentElement.getAttribute('data-step') === null) {
  2911. while (true) {
  2912. if (typeof introItems[nextStep] === 'undefined') {
  2913. break;
  2914. } else {
  2915. nextStep++;
  2916. }
  2917. }
  2918. introItems[nextStep] = {
  2919. element: currentElement,
  2920. intro: currentElement.getAttribute('data-intro'),
  2921. step: nextStep + 1,
  2922. tooltipClass: currentElement.getAttribute('data-tooltipClass'),
  2923. position: currentElement.getAttribute('data-position') || this._options.tooltipPosition
  2924. };
  2925. }
  2926. }
  2927. }
  2928. //removing undefined/null elements
  2929. var tempIntroItems = [];
  2930. for (var z = 0; z < introItems.length; z++) {
  2931. introItems[z] && tempIntroItems.push(introItems[z]); // copy non-empty values to the end of the array
  2932. }
  2933. introItems = tempIntroItems;
  2934. //Ok, sort all items with given steps
  2935. introItems.sort(function (a, b) {
  2936. return a.step - b.step;
  2937. });
  2938. //set it to the introJs object
  2939. self._introItems = introItems;
  2940. //add overlay layer to the page
  2941. if(_addOverlayLayer.call(self, targetElm)) {
  2942. //then, start the show
  2943. _nextStep.call(self);
  2944. var skipButton = targetElm.querySelector('.introjs-skipbutton'),
  2945. nextStepButton = targetElm.querySelector('.introjs-nextbutton');
  2946. self._onKeyDown = function(e) {
  2947. if (e.keyCode === 27 && self._options.exitOnEsc === true) {
  2948. //escape key pressed, exit the intro
  2949. _exitIntro.call(self, targetElm);
  2950. //check if any callback is defined
  2951. if (self._introExitCallback !== undefined) {
  2952. self._introExitCallback.call(self);
  2953. }
  2954. } else if(e.keyCode === 37) {
  2955. //left arrow
  2956. _previousStep.call(self);
  2957. } else if (e.keyCode === 39 || e.keyCode === 13) {
  2958. //right arrow or enter
  2959. _nextStep.call(self);
  2960. //prevent default behaviour on hitting Enter, to prevent steps being skipped in some browsers
  2961. if(e.preventDefault) {
  2962. e.preventDefault();
  2963. } else {
  2964. e.returnValue = false;
  2965. }
  2966. }
  2967. };
  2968. self._onResize = function(e) {
  2969. _setHelperLayerPosition.call(self, document.querySelector('.sui-introjs-helperLayer'));
  2970. };
  2971. if (window.addEventListener) {
  2972. if (this._options.keyboardNavigation) {
  2973. window.addEventListener('keydown', self._onKeyDown, true);
  2974. }
  2975. //for window resize
  2976. window.addEventListener("resize", self._onResize, true);
  2977. } else if (document.attachEvent) { //IE
  2978. if (this._options.keyboardNavigation) {
  2979. document.attachEvent('onkeydown', self._onKeyDown);
  2980. }
  2981. //for window resize
  2982. document.attachEvent("onresize", self._onResize);
  2983. }
  2984. }
  2985. return false;
  2986. }
  2987. /*
  2988. * makes a copy of the object
  2989. * @api private
  2990. * @method _cloneObject
  2991. */
  2992. function _cloneObject(object) {
  2993. if (object === null || typeof (object) !== 'object' || typeof (object.nodeType) !== 'undefined') {
  2994. return object;
  2995. }
  2996. var temp = {};
  2997. for (var key in object) {
  2998. temp[key] = _cloneObject(object[key]);
  2999. }
  3000. return temp;
  3001. }
  3002. /**
  3003. * Go to specific step of introduction
  3004. *
  3005. * @api private
  3006. * @method _goToStep
  3007. */
  3008. function _goToStep(step) {
  3009. //because steps starts with zero
  3010. this._currentStep = step - 2;
  3011. if (typeof (this._introItems) !== 'undefined') {
  3012. _nextStep.call(this);
  3013. }
  3014. }
  3015. /**
  3016. * Go to next step on intro
  3017. *
  3018. * @api private
  3019. * @method _nextStep
  3020. */
  3021. function _nextStep() {
  3022. this._direction = 'forward';
  3023. if (typeof (this._currentStep) === 'undefined') {
  3024. this._currentStep = 0;
  3025. } else {
  3026. ++this._currentStep;
  3027. }
  3028. if ((this._introItems.length) <= this._currentStep) {
  3029. //end of the intro
  3030. //check if any callback is defined
  3031. if (typeof (this._introCompleteCallback) === 'function') {
  3032. this._introCompleteCallback.call(this);
  3033. }
  3034. _exitIntro.call(this, this._targetElement);
  3035. return;
  3036. }
  3037. var nextStep = this._introItems[this._currentStep];
  3038. if (typeof (this._introBeforeChangeCallback) !== 'undefined') {
  3039. this._introBeforeChangeCallback.call(this, nextStep.element);
  3040. }
  3041. _showElement.call(this, nextStep);
  3042. }
  3043. /**
  3044. * Go to previous step on intro
  3045. *
  3046. * @api private
  3047. * @method _nextStep
  3048. */
  3049. function _previousStep() {
  3050. this._direction = 'backward';
  3051. if (this._currentStep === 0) {
  3052. return false;
  3053. }
  3054. var nextStep = this._introItems[--this._currentStep];
  3055. if (typeof (this._introBeforeChangeCallback) !== 'undefined') {
  3056. this._introBeforeChangeCallback.call(this, nextStep.element);
  3057. }
  3058. _showElement.call(this, nextStep);
  3059. }
  3060. /**
  3061. * Exit from intro
  3062. *
  3063. * @api private
  3064. * @method _exitIntro
  3065. * @param {Object} targetElement
  3066. */
  3067. function _exitIntro(targetElement) {
  3068. //remove overlay layer from the page
  3069. var overlayLayer = targetElement.querySelector('.sui-introjs-overlay');
  3070. //return if intro already completed or skipped
  3071. if (overlayLayer === null) {
  3072. return;
  3073. }
  3074. //for fade-out animation
  3075. overlayLayer.style.opacity = 0;
  3076. setTimeout(function () {
  3077. if (overlayLayer.parentNode) {
  3078. overlayLayer.parentNode.removeChild(overlayLayer);
  3079. }
  3080. }, 500);
  3081. //remove all helper layers
  3082. var helperLayer = targetElement.querySelector('.sui-introjs-helperLayer');
  3083. if (helperLayer) {
  3084. helperLayer.parentNode.removeChild(helperLayer);
  3085. }
  3086. //remove intro floating element
  3087. var floatingElement = document.querySelector('.introjsFloatingElement');
  3088. if (floatingElement) {
  3089. floatingElement.parentNode.removeChild(floatingElement);
  3090. }
  3091. //remove `introjs-showElement` class from the element
  3092. var showElement = document.querySelector('.introjs-showElement');
  3093. if (showElement) {
  3094. showElement.className = showElement.className.replace(/introjs-[a-zA-Z]+/g, '').replace(/^\s+|\s+$/g, ''); // This is a manual trim.
  3095. }
  3096. //remove `introjs-fixParent` class from the elements
  3097. var fixParents = document.querySelectorAll('.introjs-fixParent');
  3098. if (fixParents && fixParents.length > 0) {
  3099. for (var i = fixParents.length - 1; i >= 0; i--) {
  3100. fixParents[i].className = fixParents[i].className.replace(/introjs-fixParent/g, '').replace(/^\s+|\s+$/g, '');
  3101. }
  3102. }
  3103. //clean listeners
  3104. if (window.removeEventListener) {
  3105. window.removeEventListener('keydown', this._onKeyDown, true);
  3106. } else if (document.detachEvent) { //IE
  3107. document.detachEvent('onkeydown', this._onKeyDown);
  3108. }
  3109. //set the step to zero
  3110. this._currentStep = undefined;
  3111. }
  3112. /**
  3113. * Render tooltip box in the page
  3114. *
  3115. * @api private
  3116. * @method _placeTooltip
  3117. * @param {Object} targetElement
  3118. * @param {Object} tooltipLayer
  3119. * @param {Object} arrowLayer
  3120. */
  3121. function _placeTooltip(targetElement, tooltipLayer, arrowLayer, helperNumberLayer) {
  3122. var tooltipCssClass = '',
  3123. currentStepObj,
  3124. tooltipOffset,
  3125. targetElementOffset;
  3126. //reset the old style
  3127. tooltipLayer.style.top = null;
  3128. tooltipLayer.style.right = null;
  3129. tooltipLayer.style.bottom = null;
  3130. tooltipLayer.style.left = null;
  3131. tooltipLayer.style.marginLeft = null;
  3132. tooltipLayer.style.marginTop = null;
  3133. arrowLayer.style.display = 'inherit';
  3134. if (typeof(helperNumberLayer) !== 'undefined' && helperNumberLayer !== null) {
  3135. helperNumberLayer.style.top = null;
  3136. helperNumberLayer.style.left = null;
  3137. }
  3138. //prevent error when `this._currentStep` is undefined
  3139. if (!this._introItems[this._currentStep]) return;
  3140. //if we have a custom css class for each step
  3141. currentStepObj = this._introItems[this._currentStep];
  3142. if (typeof (currentStepObj.tooltipClass) === 'string') {
  3143. tooltipCssClass = currentStepObj.tooltipClass;
  3144. } else {
  3145. tooltipCssClass = this._options.tooltipClass;
  3146. }
  3147. tooltipLayer.className = ('introjs-tooltip ' + tooltipCssClass).replace(/^\s+|\s+$/g, '');
  3148. //custom css class for tooltip boxes
  3149. var tooltipCssClass = this._options.tooltipClass;
  3150. currentTooltipPosition = this._introItems[this._currentStep].position;
  3151. switch (currentTooltipPosition) {
  3152. case 'top':
  3153. tooltipLayer.style.left = '15px';
  3154. tooltipLayer.style.top = '-' + (_getOffset(tooltipLayer).height + 10) + 'px';
  3155. arrowLayer.className = 'introjs-arrow bottom';
  3156. break;
  3157. case 'right':
  3158. tooltipLayer.style.left = (_getOffset(targetElement).width + 20) + 'px';
  3159. arrowLayer.className = 'introjs-arrow left';
  3160. break;
  3161. case 'left':
  3162. if (this._options.showStepNumbers === true) {
  3163. tooltipLayer.style.top = '15px';
  3164. }
  3165. tooltipLayer.style.right = (_getOffset(targetElement).width + 20) + 'px';
  3166. arrowLayer.className = 'introjs-arrow right';
  3167. break;
  3168. case 'floating':
  3169. arrowLayer.style.display = 'none';
  3170. //we have to adjust the top and left of layer manually for intro items without element
  3171. tooltipOffset = _getOffset(tooltipLayer);
  3172. tooltipLayer.style.left = '50%';
  3173. tooltipLayer.style.top = '50%';
  3174. tooltipLayer.style.marginLeft = '-' + (tooltipOffset.width / 2) + 'px';
  3175. tooltipLayer.style.marginTop = '-' + (tooltipOffset.height / 2) + 'px';
  3176. if (typeof(helperNumberLayer) !== 'undefined' && helperNumberLayer !== null) {
  3177. helperNumberLayer.style.left = '-' + ((tooltipOffset.width / 2) + 18) + 'px';
  3178. helperNumberLayer.style.top = '-' + ((tooltipOffset.height / 2) + 18) + 'px';
  3179. }
  3180. break;
  3181. case 'bottom-right-aligned':
  3182. arrowLayer.className = 'introjs-arrow top-right';
  3183. tooltipLayer.style.right = '0px';
  3184. tooltipLayer.style.bottom = '-' + (_getOffset(tooltipLayer).height + 10) + 'px';
  3185. break;
  3186. case 'bottom-middle-aligned':
  3187. targetElementOffset = _getOffset(targetElement);
  3188. tooltipOffset = _getOffset(tooltipLayer);
  3189. arrowLayer.className = 'introjs-arrow top-middle';
  3190. tooltipLayer.style.left = (targetElementOffset.width / 2 - tooltipOffset.width / 2) + 'px';
  3191. tooltipLayer.style.bottom = '-' + (tooltipOffset.height + 10) + 'px';
  3192. break;
  3193. default:
  3194. tooltipLayer.style.bottom = '-' + (_getOffset(tooltipLayer).height + 10) + 'px';
  3195. arrowLayer.className = 'introjs-arrow top';
  3196. break;
  3197. }
  3198. }
  3199. /**
  3200. * Update the position of the helper layer on the screen
  3201. *
  3202. * @api private
  3203. * @method _setHelperLayerPosition
  3204. * @param {Object} helperLayer
  3205. */
  3206. function _setHelperLayerPosition(helperLayer) {
  3207. if (helperLayer) {
  3208. //prevent error when `this._currentStep` in undefined
  3209. if (!this._introItems[this._currentStep]) return;
  3210. var currentElement = this._introItems[this._currentStep],
  3211. elementPosition = _getOffset(currentElement.element),
  3212. widthHeightPadding = 10;
  3213. if (currentElement.position === 'floating') {
  3214. widthHeightPadding = 0;
  3215. }
  3216. //set new position to helper layer
  3217. helperLayer.setAttribute('style', 'width: ' + (elementPosition.width + widthHeightPadding) + 'px; ' +
  3218. 'height:' + (elementPosition.height + widthHeightPadding) + 'px; ' +
  3219. 'top:' + (elementPosition.top - 5) + 'px;' +
  3220. 'left: ' + (elementPosition.left - 5) + 'px;');
  3221. }
  3222. }
  3223. /**
  3224. * Show an element on the page
  3225. *
  3226. * @api private
  3227. * @method _showElement
  3228. * @param {Object} targetElement
  3229. */
  3230. function _showElement(targetElement) {
  3231. if (typeof (this._introChangeCallback) !== 'undefined') {
  3232. this._introChangeCallback.call(this, targetElement.element);
  3233. }
  3234. var self = this,
  3235. oldHelperLayer = document.querySelector('.sui-introjs-helperLayer'),
  3236. elementPosition = _getOffset(targetElement.element);
  3237. if (oldHelperLayer !== null) {
  3238. var oldHelperNumberLayer = oldHelperLayer.querySelector('.introjs-helperNumberLayer'),
  3239. oldtooltipLayer = oldHelperLayer.querySelector('.introjs-tooltiptext'),
  3240. oldArrowLayer = oldHelperLayer.querySelector('.introjs-arrow'),
  3241. oldtooltipContainer = oldHelperLayer.querySelector('.introjs-tooltip'),
  3242. skipTooltipButton = oldHelperLayer.querySelector('.introjs-skipbutton'),
  3243. prevTooltipButton = oldHelperLayer.querySelector('.introjs-prevbutton'),
  3244. nextTooltipButton = oldHelperLayer.querySelector('.introjs-nextbutton');
  3245. //hide the tooltip
  3246. oldtooltipContainer.style.opacity = 0;
  3247. if (oldHelperNumberLayer !== null) {
  3248. var lastIntroItem = this._introItems[(targetElement.step - 2 >= 0 ? targetElement.step - 2 : 0)];
  3249. if (lastIntroItem !== null && (this._direction === 'forward' && lastIntroItem.position === 'floating') || (this._direction === 'backward' && targetElement.position === 'floating')) {
  3250. oldHelperNumberLayer.style.opacity = 0;
  3251. }
  3252. }
  3253. //set new position to helper layer
  3254. _setHelperLayerPosition.call(self, oldHelperLayer);
  3255. //remove `introjs-fixParent` class from the elements
  3256. var fixParents = document.querySelectorAll('.introjs-fixParent');
  3257. if (fixParents && fixParents.length > 0) {
  3258. for (var i = fixParents.length - 1; i >= 0; i--) {
  3259. fixParents[i].className = fixParents[i].className.replace(/introjs-fixParent/g, '').replace(/^\s+|\s+$/g, '');
  3260. }
  3261. }
  3262. //remove old classes
  3263. var oldShowElement = document.querySelector('.introjs-showElement');
  3264. oldShowElement.className = oldShowElement.className.replace(/introjs-[a-zA-Z]+/g, '').replace(/^\s+|\s+$/g, '');
  3265. //we should wait until the CSS3 transition is competed (it's 0.3 sec) to prevent incorrect `height` and `width` calculation
  3266. if (self._lastShowElementTimer) {
  3267. clearTimeout(self._lastShowElementTimer);
  3268. }
  3269. self._lastShowElementTimer = setTimeout(function() {
  3270. //set current step to the label
  3271. if (oldHelperNumberLayer !== null) {
  3272. oldHelperNumberLayer.innerHTML = targetElement.step;
  3273. }
  3274. //set current tooltip text
  3275. oldtooltipLayer.innerHTML = targetElement.intro;
  3276. //set the tooltip position
  3277. _placeTooltip.call(self, targetElement.element, oldtooltipContainer, oldArrowLayer, oldHelperNumberLayer);
  3278. //change active bullet
  3279. oldHelperLayer.querySelector('.introjs-bullets li > a.active').className = '';
  3280. oldHelperLayer.querySelector('.introjs-bullets li > a[data-stepnumber="' + targetElement.step + '"]').className = 'active';
  3281. //show the tooltip
  3282. oldtooltipContainer.style.opacity = 1;
  3283. if (oldHelperNumberLayer) oldHelperNumberLayer.style.opacity = 1;
  3284. }, 350);
  3285. } else {
  3286. var helperLayer = document.createElement('div'),
  3287. arrowLayer = document.createElement('div'),
  3288. tooltipLayer = document.createElement('div'),
  3289. tooltipTextLayer = document.createElement('div'),
  3290. bulletsLayer = document.createElement('div'),
  3291. buttonsLayer = document.createElement('div');
  3292. helperLayer.className = 'sui-introjs-helperLayer';
  3293. //set new position to helper layer
  3294. _setHelperLayerPosition.call(self, helperLayer);
  3295. //add helper layer to target element
  3296. this._targetElement.appendChild(helperLayer);
  3297. arrowLayer.className = 'introjs-arrow';
  3298. tooltipTextLayer.className = 'introjs-tooltiptext';
  3299. tooltipTextLayer.innerHTML = targetElement.intro;
  3300. bulletsLayer.className = 'introjs-bullets';
  3301. if (this._options.showBullets === false) {
  3302. bulletsLayer.style.display = 'none';
  3303. }
  3304. var ulContainer = document.createElement('ul');
  3305. var anchorclick = function() {
  3306. self.goToStep(this.getAttribute('data-stepnumber'));
  3307. };
  3308. for (var i = 0, stepsLength = this._introItems.length; i < stepsLength; i++) {
  3309. var innerLi = document.createElement('li');
  3310. var anchorLink = document.createElement('a');
  3311. anchorLink.onclick = anchorclick;
  3312. if (i === 0) anchorLink.className = "active";
  3313. anchorLink.href = 'javascript:void(0);';
  3314. anchorLink.innerHTML = "&nbsp;";
  3315. anchorLink.setAttribute('data-stepnumber', this._introItems[i].step);
  3316. innerLi.appendChild(anchorLink);
  3317. ulContainer.appendChild(innerLi);
  3318. }
  3319. bulletsLayer.appendChild(ulContainer);
  3320. buttonsLayer.className = 'introjs-tooltipbuttons';
  3321. if (this._options.showButtons === false) {
  3322. buttonsLayer.style.display = 'none';
  3323. }
  3324. tooltipLayer.className = 'introjs-tooltip';
  3325. tooltipLayer.appendChild(tooltipTextLayer);
  3326. tooltipLayer.appendChild(bulletsLayer);
  3327. //add helper layer number
  3328. if (this._options.showStepNumbers === true) {
  3329. var helperNumberLayer = document.createElement('span');
  3330. helperNumberLayer.className = 'introjs-helperNumberLayer';
  3331. helperNumberLayer.innerHTML = targetElement.step;
  3332. helperLayer.appendChild(helperNumberLayer);
  3333. }
  3334. tooltipLayer.appendChild(arrowLayer);
  3335. helperLayer.appendChild(tooltipLayer);
  3336. //next button
  3337. var nextTooltipButton = document.createElement('a');
  3338. nextTooltipButton.onclick = function() {
  3339. if (self._introItems.length - 1 !== self._currentStep) {
  3340. _nextStep.call(self);
  3341. }
  3342. };
  3343. nextTooltipButton.href = 'javascript:void(0);';
  3344. nextTooltipButton.innerHTML = this._options.nextLabel;
  3345. //previous button
  3346. var prevTooltipButton = document.createElement('a');
  3347. prevTooltipButton.onclick = function() {
  3348. if (self._currentStep !== 0) {
  3349. _previousStep.call(self);
  3350. }
  3351. };
  3352. prevTooltipButton.href = 'javascript:void(0);';
  3353. prevTooltipButton.innerHTML = this._options.prevLabel;
  3354. //skip button
  3355. var skipTooltipButton = document.createElement('a');
  3356. skipTooltipButton.className = 'sui-btn introjs-skipbutton';
  3357. skipTooltipButton.href = 'javascript:void(0);';
  3358. skipTooltipButton.innerHTML = this._options.skipLabel;
  3359. skipTooltipButton.onclick = function() {
  3360. if (self._introItems.length - 1 === self._currentStep && typeof (self._introCompleteCallback) === 'function') {
  3361. self._introCompleteCallback.call(self);
  3362. }
  3363. if (self._introItems.length - 1 !== self._currentStep && typeof (self._introExitCallback) === 'function') {
  3364. self._introExitCallback.call(self);
  3365. }
  3366. _exitIntro.call(self, self._targetElement);
  3367. };
  3368. buttonsLayer.appendChild(skipTooltipButton);
  3369. //in order to prevent displaying next/previous button always
  3370. if (this._introItems.length > 1) {
  3371. buttonsLayer.appendChild(prevTooltipButton);
  3372. buttonsLayer.appendChild(nextTooltipButton);
  3373. }
  3374. tooltipLayer.appendChild(buttonsLayer);
  3375. //set proper position
  3376. _placeTooltip.call(self, targetElement.element, tooltipLayer, arrowLayer, helperNumberLayer);
  3377. }
  3378. if (this._currentStep === 0 && this._introItems.length > 1) {
  3379. prevTooltipButton.className = 'sui-btn introjs-prevbutton disabled';
  3380. nextTooltipButton.className = 'sui-btn introjs-nextbutton';
  3381. skipTooltipButton.innerHTML = this._options.skipLabel;
  3382. } else if (this._introItems.length - 1 === this._currentStep || this._introItems.length === 1) {
  3383. skipTooltipButton.innerHTML = this._options.doneLabel;
  3384. prevTooltipButton.className = 'sui-btn introjs-prevbutton';
  3385. nextTooltipButton.className = 'sui-btn introjs-nextbutton disabled';
  3386. } else {
  3387. prevTooltipButton.className = 'sui-btn introjs-prevbutton';
  3388. nextTooltipButton.className = 'sui-btn introjs-nextbutton';
  3389. skipTooltipButton.innerHTML = this._options.skipLabel;
  3390. }
  3391. //Set focus on "next" button, so that hitting Enter always moves you onto the next step
  3392. nextTooltipButton.focus();
  3393. //add target element position style
  3394. targetElement.element.className += ' introjs-showElement';
  3395. var currentElementPosition = _getPropValue(targetElement.element, 'position');
  3396. if (currentElementPosition !== 'absolute' &&
  3397. currentElementPosition !== 'relative') {
  3398. //change to new intro item
  3399. targetElement.element.className += ' introjs-relativePosition';
  3400. }
  3401. var parentElm = targetElement.element.parentNode;
  3402. while (parentElm !== null) {
  3403. if (parentElm.tagName.toLowerCase() === 'body') break;
  3404. //fix The Stacking Contenxt problem.
  3405. //More detail: https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Understanding_z_index/The_stacking_context
  3406. var zIndex = _getPropValue(parentElm, 'z-index');
  3407. var opacity = parseFloat(_getPropValue(parentElm, 'opacity'));
  3408. if (/[0-9]+/.test(zIndex) || opacity < 1) {
  3409. parentElm.className += ' introjs-fixParent';
  3410. }
  3411. parentElm = parentElm.parentNode;
  3412. }
  3413. if (!_elementInViewport(targetElement.element) && this._options.scrollToElement === true) {
  3414. var rect = targetElement.element.getBoundingClientRect(),
  3415. winHeight=_getWinSize().height,
  3416. top = rect.bottom - (rect.bottom - rect.top),
  3417. bottom = rect.bottom - winHeight;
  3418. //Scroll up
  3419. if (top < 0 || targetElement.element.clientHeight > winHeight) {
  3420. window.scrollBy(0, top - 30); // 30px padding from edge to look nice
  3421. //Scroll down
  3422. } else {
  3423. window.scrollBy(0, bottom + 100); // 70px + 30px padding from edge to look nice
  3424. }
  3425. }
  3426. if (typeof (this._introAfterChangeCallback) !== 'undefined') {
  3427. this._introAfterChangeCallback.call(this, targetElement.element);
  3428. }
  3429. }
  3430. /**
  3431. * Get an element CSS property on the page
  3432. * Thanks to JavaScript Kit: http://www.javascriptkit.com/dhtmltutors/dhtmlcascade4.shtml
  3433. *
  3434. * @api private
  3435. * @method _getPropValue
  3436. * @param {Object} element
  3437. * @param {String} propName
  3438. * @returns Element's property value
  3439. */
  3440. function _getPropValue (element, propName) {
  3441. var propValue = '';
  3442. if (element.currentStyle) { //IE
  3443. propValue = element.currentStyle[propName];
  3444. } else if (document.defaultView && document.defaultView.getComputedStyle) { //Others
  3445. propValue = document.defaultView.getComputedStyle(element, null).getPropertyValue(propName);
  3446. }
  3447. //Prevent exception in IE
  3448. if (propValue && propValue.toLowerCase) {
  3449. return propValue.toLowerCase();
  3450. } else {
  3451. return propValue;
  3452. }
  3453. }
  3454. /**
  3455. * Provides a cross-browser way to get the screen dimensions
  3456. * via: http://stackoverflow.com/questions/5864467/internet-explorer-innerheight
  3457. *
  3458. * @api private
  3459. * @method _getWinSize
  3460. * @returns {Object} width and height attributes
  3461. */
  3462. function _getWinSize() {
  3463. if (window.innerWidth !== undefined) {
  3464. return { width: window.innerWidth, height: window.innerHeight };
  3465. } else {
  3466. var D = document.documentElement;
  3467. return { width: D.clientWidth, height: D.clientHeight };
  3468. }
  3469. }
  3470. /**
  3471. * Add overlay layer to the page
  3472. * http://stackoverflow.com/questions/123999/how-to-tell-if-a-dom-element-is-visible-in-the-current-viewport
  3473. *
  3474. * @api private
  3475. * @method _elementInViewport
  3476. * @param {Object} el
  3477. */
  3478. function _elementInViewport(el) {
  3479. var rect = el.getBoundingClientRect();
  3480. return (
  3481. rect.top >= 0 &&
  3482. rect.left >= 0 &&
  3483. (rect.bottom+80) <= window.innerHeight && // add 80 to get the text right
  3484. rect.right <= window.innerWidth
  3485. );
  3486. }
  3487. /**
  3488. * Add overlay layer to the page
  3489. *
  3490. * @api private
  3491. * @method _addOverlayLayer
  3492. * @param {Object} targetElm
  3493. */
  3494. function _addOverlayLayer(targetElm) {
  3495. var overlayLayer = document.createElement('div'),
  3496. styleText = '',
  3497. self = this;
  3498. //set css class name
  3499. overlayLayer.className = 'sui-introjs-overlay';
  3500. //check if the target element is body, we should calculate the size of overlay layer in a better way
  3501. if (targetElm.tagName.toLowerCase() === 'body') {
  3502. styleText += 'top: 0;bottom: 0; left: 0;right: 0;position: fixed;';
  3503. overlayLayer.setAttribute('style', styleText);
  3504. } else {
  3505. //set overlay layer position
  3506. var elementPosition = _getOffset(targetElm);
  3507. if (elementPosition) {
  3508. styleText += 'width: ' + elementPosition.width + 'px; height:' + elementPosition.height + 'px; top:' + elementPosition.top + 'px;left: ' + elementPosition.left + 'px;';
  3509. overlayLayer.setAttribute('style', styleText);
  3510. }
  3511. }
  3512. targetElm.appendChild(overlayLayer);
  3513. overlayLayer.onclick = function() {
  3514. if (self._options.exitOnOverlayClick === true) {
  3515. _exitIntro.call(self, targetElm);
  3516. //check if any callback is defined
  3517. if (self._introExitCallback !== undefined) {
  3518. self._introExitCallback.call(self);
  3519. }
  3520. }
  3521. };
  3522. setTimeout(function() {
  3523. styleText += 'opacity: ' + self._options.overlayOpacity.toString() + ';';
  3524. overlayLayer.setAttribute('style', styleText);
  3525. }, 10);
  3526. return true;
  3527. }
  3528. /**
  3529. * Get an element position on the page
  3530. * Thanks to `meouw`: http://stackoverflow.com/a/442474/375966
  3531. *
  3532. * @api private
  3533. * @method _getOffset
  3534. * @param {Object} element
  3535. * @returns Element's position info
  3536. */
  3537. function _getOffset(element) {
  3538. var elementPosition = {};
  3539. //set width
  3540. elementPosition.width = element.offsetWidth;
  3541. //set height
  3542. elementPosition.height = element.offsetHeight;
  3543. //calculate element top and left
  3544. var _x = 0;
  3545. var _y = 0;
  3546. while (element && !isNaN(element.offsetLeft) && !isNaN(element.offsetTop)) {
  3547. _x += element.offsetLeft;
  3548. _y += element.offsetTop;
  3549. element = element.offsetParent;
  3550. }
  3551. //set top
  3552. elementPosition.top = _y;
  3553. //set left
  3554. elementPosition.left = _x;
  3555. return elementPosition;
  3556. }
  3557. /**
  3558. * Overwrites obj1's values with obj2's and adds obj2's if non existent in obj1
  3559. * via: http://stackoverflow.com/questions/171251/how-can-i-merge-properties-of-two-javascript-objects-dynamically
  3560. *
  3561. * @param obj1
  3562. * @param obj2
  3563. * @returns obj3 a new object based on obj1 and obj2
  3564. */
  3565. function _mergeOptions(obj1,obj2) {
  3566. var obj3 = {};
  3567. for (var attrname in obj1) { obj3[attrname] = obj1[attrname]; }
  3568. for (var attrname in obj2) { obj3[attrname] = obj2[attrname]; }
  3569. return obj3;
  3570. }
  3571. var introJs = function (targetElm, options) {
  3572. if ($.isPlainObject(targetElm)||(!targetElm && !options)){
  3573. options = targetElm;
  3574. return new IntroJs(document.body, options);
  3575. } else if (targetElm.tagName) {
  3576. //Ok, create a new instance
  3577. return new IntroJs(targetElm, options);
  3578. } else if (typeof (targetElm) === 'string') {
  3579. //select the target element with query selector
  3580. var targetElement = document.querySelector(targetElm);
  3581. if (targetElement) {
  3582. return new IntroJs(targetElement, options);
  3583. } else {
  3584. throw new Error('There is no element with given selector.');
  3585. }
  3586. }
  3587. };
  3588. /**
  3589. * Current IntroJs version
  3590. *
  3591. * @property version
  3592. * @type String
  3593. */
  3594. introJs.version = VERSION;
  3595. //Prototype
  3596. IntroJs.prototype = {
  3597. defaults: {
  3598. /* Next button label in tooltip box */
  3599. nextLabel: '下一步 <i class="sui-icon icon-double-angle-right"></i> ',
  3600. /* Previous button label in tooltip box */
  3601. prevLabel: '<i class="sui-icon icon-double-angle-left"></i> 上一步',
  3602. /* Skip button label in tooltip box */
  3603. skipLabel: '知道了',
  3604. /* Done button label in tooltip box */
  3605. doneLabel: '知道了',
  3606. /* Default tooltip box position */
  3607. tooltipPosition: 'bottom',
  3608. /* Next CSS class for tooltip boxes */
  3609. tooltipClass: '',
  3610. /* Close introduction when pressing Escape button? */
  3611. exitOnEsc: true,
  3612. /* Close introduction when clicking on overlay layer? */
  3613. exitOnOverlayClick: true,
  3614. /* Show step numbers in introduction? */
  3615. showStepNumbers: true,
  3616. /* Let user use keyboard to navigate the tour? */
  3617. keyboardNavigation: true,
  3618. /* Show tour control buttons? */
  3619. showButtons: true,
  3620. /* Show tour bullets? */
  3621. showBullets: false,
  3622. /* Scroll to highlighted element? */
  3623. scrollToElement: true,
  3624. /* Set the overlay opacity */
  3625. overlayOpacity: 0.8
  3626. },
  3627. clone: function () {
  3628. return new IntroJs(this);
  3629. },
  3630. setOption: function(option, value) {
  3631. this._options[option] = value;
  3632. return this;
  3633. },
  3634. setOptions: function(options) {
  3635. this._options = _mergeOptions(this._options, options);
  3636. return this;
  3637. },
  3638. start: function () {
  3639. _introForElement.call(this, this._targetElement);
  3640. return this;
  3641. },
  3642. goToStep: function(step) {
  3643. _goToStep.call(this, step);
  3644. return this;
  3645. },
  3646. nextStep: function() {
  3647. _nextStep.call(this);
  3648. return this;
  3649. },
  3650. previousStep: function() {
  3651. _previousStep.call(this);
  3652. return this;
  3653. },
  3654. exit: function() {
  3655. _exitIntro.call(this, this._targetElement);
  3656. },
  3657. refresh: function() {
  3658. _setHelperLayerPosition.call(this, document.querySelector('.sui-introjs-helperLayer'));
  3659. return this;
  3660. },
  3661. onbeforechange: function(providedCallback) {
  3662. if (typeof (providedCallback) === 'function') {
  3663. this._introBeforeChangeCallback = providedCallback;
  3664. } else {
  3665. throw new Error('Provided callback for onbeforechange was not a function');
  3666. }
  3667. return this;
  3668. },
  3669. onchange: function(providedCallback) {
  3670. if (typeof (providedCallback) === 'function') {
  3671. this._introChangeCallback = providedCallback;
  3672. } else {
  3673. throw new Error('Provided callback for onchange was not a function.');
  3674. }
  3675. return this;
  3676. },
  3677. onafterchange: function(providedCallback) {
  3678. if (typeof (providedCallback) === 'function') {
  3679. this._introAfterChangeCallback = providedCallback;
  3680. } else {
  3681. throw new Error('Provided callback for onafterchange was not a function');
  3682. }
  3683. return this;
  3684. },
  3685. oncomplete: function(providedCallback) {
  3686. if (typeof (providedCallback) === 'function') {
  3687. this._introCompleteCallback = providedCallback;
  3688. } else {
  3689. throw new Error('Provided callback for oncomplete was not a function.');
  3690. }
  3691. return this;
  3692. },
  3693. onexit: function(providedCallback) {
  3694. if (typeof (providedCallback) === 'function') {
  3695. this._introExitCallback = providedCallback;
  3696. } else {
  3697. throw new Error('Provided callback for onexit was not a function.');
  3698. }
  3699. return this;
  3700. }
  3701. };
  3702. $.introJs = introJs;
  3703. }(jQuery);
  3704. },{}],9:[function(require,module,exports){
  3705. /* =========================================================
  3706. * bootstrap-modal.js v2.3.2
  3707. * http://getbootstrap.com/2.3.2/javascript.html#modals
  3708. * =========================================================
  3709. * @file bootstrap-modal.js
  3710. * @brief 弹层dpl,扩展自bootstrap2.3.2
  3711. * @author banbian, zangtao.zt@alibaba-inc.com
  3712. * @date 2014-01-14
  3713. */
  3714. !function ($) {
  3715. "use strict";
  3716. /* MODAL CLASS DEFINITION
  3717. * ====================== */
  3718. var Modal = function (element, options) {
  3719. this.options = options
  3720. //若element为null,则表示为js触发的alert、confirm弹层
  3721. if (element === null) {
  3722. var TPL = ''
  3723. //data-hidetype表明这类简单dialog调用hide方法时会从文档树里删除节点
  3724. + '<div class="sui-modal hide fade" tabindex="-1" role="dialog" id={%id%} data-hidetype="remove">'
  3725. + '<div class="modal-dialog">'
  3726. + '<div class="modal-content">'
  3727. + '<div class="modal-header">'
  3728. + (options.closeBtn ? '<button type="button" class="sui-close" data-dismiss="modal" aria-hidden="true">&times;</button>' : '')
  3729. + '<h4 class="modal-title">{%title%}</h4>'
  3730. + '</div>'
  3731. + '<div class="modal-body ' + (options.hasfoot ? '' : 'no-foot') + '">{%body%}</div>'
  3732. + (options.hasfoot ? '<div class="modal-footer">'
  3733. //增加data-ok="modal"参数
  3734. + '<button type="button" class="sui-btn btn-primary btn-large" data-ok="modal">{%ok_btn%}</button>'
  3735. + (options.cancelBtn ? '<button type="button" class="sui-btn btn-default btn-large" data-dismiss="modal">{%cancel_btn%}</button>' : '')
  3736. + '</div>' : '')
  3737. + '</div>'
  3738. + '</div>'
  3739. + '</div>';
  3740. element = $(TPL.replace('{%title%}', options.title)
  3741. .replace('{%body%}', options.body)
  3742. .replace('{%id%}', options.id)
  3743. .replace('{%ok_btn%}', options.okBtn)
  3744. .replace('{%cancel_btn%}', options.cancelBtn))
  3745. //如果不支持动画显示(默认支持)
  3746. $('body').append(element)
  3747. }
  3748. this.$element = $(element)
  3749. if (!options.transition) $(element).removeClass('fade')
  3750. this.init()
  3751. }
  3752. //对外接口只有toggle, show, hide
  3753. Modal.prototype = {
  3754. constructor: Modal
  3755. ,init: function () {
  3756. var ele = this.$element
  3757. , opt = this.options
  3758. , w = opt.width
  3759. , h = opt.height
  3760. , self = this
  3761. , standardW = {
  3762. small: 440 //默认宽度
  3763. ,normal: 590
  3764. ,large: 790
  3765. }
  3766. ele.delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this))
  3767. .delegate(':not(.disabled)[data-ok="modal"]', 'click.ok.modal', $.proxy(this.okHide, this))
  3768. if (w) {
  3769. standardW[w] && (w = standardW[w])
  3770. ele.width(w).css('margin-left', -parseInt(w) / 2)
  3771. }
  3772. h && ele.find('.modal-body').height(h);
  3773. if (typeof this.options.remote == 'string') {
  3774. this.$element.find('.modal-body').load(this.options.remote)
  3775. }
  3776. }
  3777. , toggle: function () {
  3778. return this[!this.isShown ? 'show' : 'hide']()
  3779. }
  3780. , show: function () {
  3781. var self = this
  3782. , e = $.Event('show')
  3783. , ele = this.$element
  3784. ele.trigger(e)
  3785. if (this.isShown || e.isDefaultPrevented()) return
  3786. this.isShown = true
  3787. this.escape()
  3788. this.backdrop(function () {
  3789. var transition = $.support.transition && ele.hasClass('fade')
  3790. if (!ele.parent().length) {
  3791. ele.appendTo(document.body) //don't move modals dom position
  3792. }
  3793. //处理dialog在页面中的定位
  3794. self.resize()
  3795. ele.show()
  3796. if (transition) {
  3797. ele[0].offsetWidth // force reflow
  3798. }
  3799. ele
  3800. .addClass('in')
  3801. .attr('aria-hidden', false)
  3802. self.enforceFocus()
  3803. transition ?
  3804. ele.one($.support.transition.end, function () {
  3805. callbackAfterTransition(self)
  3806. }) :
  3807. callbackAfterTransition(self)
  3808. function callbackAfterTransition(self) {
  3809. self.$element.focus().trigger('shown')
  3810. if (self.options.timeout > 0) {
  3811. self.timeid = setTimeout(function(){
  3812. self.hide();
  3813. }, self.options.timeout)
  3814. }
  3815. }
  3816. })
  3817. return ele
  3818. }
  3819. , hide: function (e) {
  3820. e && e.preventDefault()
  3821. var $ele = this.$element
  3822. e = $.Event('hide')
  3823. this.hideReason != 'ok' && $ele.trigger('cancelHide')
  3824. $ele.trigger(e)
  3825. if (!this.isShown || e.isDefaultPrevented()) return
  3826. this.isShown = false
  3827. this.escape()
  3828. $(document).off('focusin.modal')
  3829. this.timeid && clearTimeout(this.timeid)
  3830. $ele
  3831. .removeClass('in')
  3832. .attr('aria-hidden', true)
  3833. $.support.transition && $ele.hasClass('fade') ?
  3834. this.hideWithTransition() :
  3835. this.hideModal()
  3836. return $ele
  3837. }
  3838. , okHide: function(e){
  3839. var self = this
  3840. // 如果e为undefined而不是事件对象,则说明不是点击确定按钮触发的执行,而是手工调用,
  3841. // 那么直接执行hideWithOk
  3842. if (!e) {
  3843. hideWithOk()
  3844. return
  3845. }
  3846. var fn = this.options.okHide
  3847. , ifNeedHide = true
  3848. if (!fn) {
  3849. var eventArr = $._data(this.$element[0], 'events').okHide
  3850. if (eventArr && eventArr.length) {
  3851. fn = eventArr[eventArr.length - 1].handler;
  3852. }
  3853. }
  3854. typeof fn == 'function' && (ifNeedHide = fn.call(this))
  3855. //显式返回false,则不关闭对话框
  3856. if (ifNeedHide !== false){
  3857. hideWithOk()
  3858. }
  3859. function hideWithOk (){
  3860. self.hideReason = 'ok'
  3861. self.hide(e)
  3862. }
  3863. return self.$element
  3864. }
  3865. //对话框内部遮罩层
  3866. , shadeIn: function () {
  3867. var $ele = this.$element
  3868. if ($ele.find('.shade').length) return
  3869. var $shadeEle = $('<div class="shade in" style="background:' + this.options.bgcolor + '"></div>')
  3870. $shadeEle.appendTo($ele)
  3871. this.hasShaded = true
  3872. return this.$element
  3873. }
  3874. , shadeOut: function () {
  3875. this.$element.find('.shade').remove()
  3876. this.hasShaded = false
  3877. return this.$element
  3878. }
  3879. , shadeToggle: function () {
  3880. return this[!this.hasShaded ? 'shadeIn' : 'shadeOut']()
  3881. }
  3882. // dialog展示后,如果高度动态发生变化,比如塞入异步数据后撑高容器,则调用$dialog.modal('resize'),使dialog重新定位居中
  3883. , resize: function() {
  3884. var ele = this.$element
  3885. ,eleH = ele.height()
  3886. ,winH = $(window).height()
  3887. ,mt = 0
  3888. if (eleH >= winH)
  3889. mt = -winH/2
  3890. else
  3891. mt = (winH - eleH) / (1 + 1.618) - winH / 2
  3892. ele.css('margin-top', parseInt(mt))
  3893. return ele
  3894. }
  3895. , enforceFocus: function () {
  3896. var self = this
  3897. //防止多实例时循环触发
  3898. $(document).off('focusin.modal') .on('focusin.modal', function (e) {
  3899. if (self.$element[0] !== e.target && !self.$element.has(e.target).length) {
  3900. self.$element.focus()
  3901. }
  3902. })
  3903. }
  3904. , escape: function () {
  3905. var self = this
  3906. if (this.isShown && this.options.keyboard) {
  3907. this.$element.on('keyup.dismiss.modal', function ( e ) {
  3908. e.which == 27 && self.hide()
  3909. })
  3910. } else if (!this.isShown) {
  3911. this.$element.off('keyup.dismiss.modal')
  3912. }
  3913. }
  3914. , hideWithTransition: function () {
  3915. var self = this
  3916. , timeout = setTimeout(function () {
  3917. self.$element.off($.support.transition.end)
  3918. self.hideModal()
  3919. }, 300)
  3920. this.$element.one($.support.transition.end, function () {
  3921. clearTimeout(timeout)
  3922. self.hideModal()
  3923. })
  3924. }
  3925. , hideModal: function () {
  3926. var self = this
  3927. ,ele = this.$element
  3928. ele.hide()
  3929. this.backdrop(function () {
  3930. self.removeBackdrop()
  3931. ele.trigger(self.hideReason == 'ok' ? 'okHidden' : 'cancelHidden')
  3932. self.hideReason = null
  3933. ele.trigger('hidden')
  3934. //销毁静态方法生成的dialog元素 , 默认只有静态方法是remove类型
  3935. ele.data('hidetype') == 'remove' && ele.remove()
  3936. })
  3937. }
  3938. , removeBackdrop: function () {
  3939. this.$backdrop && this.$backdrop.remove()
  3940. this.$backdrop = null
  3941. }
  3942. , backdrop: function (callback) {
  3943. var self = this
  3944. , animate = this.$element.hasClass('fade') ? 'fade' : ''
  3945. , opt = this.options
  3946. if (this.isShown) {
  3947. var doAnimate = $.support.transition && animate
  3948. //如果显示背景遮罩层
  3949. if (opt.backdrop !== false) {
  3950. this.$backdrop = $('<div class="sui-modal-backdrop ' + animate + '" style="background:' + opt.bgcolor + '"/>')
  3951. .appendTo(document.body)
  3952. //遮罩层背景黑色半透明
  3953. this.$backdrop.click(
  3954. opt.backdrop == 'static' ?
  3955. $.proxy(this.$element[0].focus, this.$element[0])
  3956. : $.proxy(this.hide, this)
  3957. )
  3958. if (doAnimate) this.$backdrop[0].offsetWidth // force reflow
  3959. this.$backdrop.addClass('in ')
  3960. if (!callback) return
  3961. doAnimate ?
  3962. this.$backdrop.one($.support.transition.end, callback) :
  3963. callback()
  3964. } else {
  3965. callback && callback()
  3966. }
  3967. } else {
  3968. if (this.$backdrop) {
  3969. this.$backdrop.removeClass('in')
  3970. $.support.transition && this.$element.hasClass('fade')?
  3971. this.$backdrop.one($.support.transition.end, callback) :
  3972. callback()
  3973. } else {
  3974. callback && callback();
  3975. }
  3976. }
  3977. }
  3978. }
  3979. /* MODAL PLUGIN DEFINITION
  3980. * ======================= */
  3981. var old = $.fn.modal
  3982. $.fn.modal = function (option) {
  3983. //this指向dialog元素Dom,
  3984. //each让诸如 $('#qqq, #eee').modal(options) 的用法可行。
  3985. return this.each(function () {
  3986. var $this = $(this)
  3987. , data = $this.data('modal')
  3988. , options = $.extend({}, $.fn.modal.defaults, $this.data(), typeof option == 'object' && option)
  3989. //这里判断的目的是:第一次show时实例化dialog,之后的show则用缓存在data-modal里的对象。
  3990. if (!data) $this.data('modal', (data = new Modal(this, options)))
  3991. //如果是$('#xx').modal('toggle'),务必保证传入的字符串是Modal类原型链里已存在的方法。否则会报错has no method。
  3992. if (typeof option == 'string') data[option]()
  3993. else data.show()
  3994. })
  3995. }
  3996. $.fn.modal.defaults = {
  3997. backdrop: true
  3998. , bgcolor: '#000'
  3999. , keyboard: true
  4000. , hasfoot: true
  4001. , closeBtn: true
  4002. , transition: true
  4003. }
  4004. $.fn.modal.Constructor = Modal
  4005. /* MODAL NO CONFLICT
  4006. * ================= */
  4007. $.fn.modal.noConflict = function () {
  4008. $.fn.modal = old
  4009. return this
  4010. }
  4011. /* MODAL DATA-API
  4012. * ============== */
  4013. $(document).on('click.modal.data-api', '[data-toggle="modal"]', function (e) {
  4014. var $this = $(this)
  4015. , href = $this.attr('href')
  4016. //$target这里指dialog本体Dom(若存在)
  4017. //通过data-target="#foo"或href="#foo"指向
  4018. , $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) //strip for ie7
  4019. //remote,href属性如果以#开头,表示等同于data-target属性
  4020. , option = $target.data('modal') ? 'toggle' : $this.data()
  4021. e.preventDefault()
  4022. $target
  4023. .modal(option)
  4024. .one('hide', function () {
  4025. $this.focus()
  4026. })
  4027. })
  4028. /* jquery弹层静态方法,用于很少重复,不需记住状态的弹层,可方便的直接调用,最简单形式就是$.alert('我是alert')
  4029. * 若弹层内容是复杂的Dom结构, 建议将弹层html结构写到模版里,用$(xx).modal(options) 调用
  4030. *
  4031. * example
  4032. * $.alert({
  4033. * title: '自定义标题'
  4034. * body: 'html' //必填
  4035. * okBtn : '好的'
  4036. * cancelBtn : '雅达'
  4037. * closeBtn: true
  4038. * keyboard: true 是否可由esc按键关闭
  4039. * backdrop: true 决定是否为模态对话框添加一个背景遮罩层。另外,该属性指定'static'时,表示添加遮罩层,同时点击模态对话框的外部区域不会将其关闭。
  4040. * bgcolor : '#123456' 背景遮罩层颜色
  4041. * width: {number|string(px)|'small'|'normal'|'large'}推荐优先使用后三个描述性字符串,统一样式
  4042. * height: {number|string(px)} 高度
  4043. * timeout: {number} 1000 单位毫秒ms ,dialog打开后多久自动关闭
  4044. * transition: {Boolean} 是否以动画弹出对话框,默认为true。HTML使用方式只需把模板里的fade的class去掉即可
  4045. * hasfoot: {Boolean} 是否显示脚部 默认true
  4046. * remote: {string} 如果提供了远程url地址,就会加载远端内容
  4047. * show: fn --------------function(e){}
  4048. * shown: fn
  4049. * hide: fn
  4050. * hidden: fn
  4051. * okHide: function(e){alert('点击确认后、dialog消失前的逻辑,
  4052. * 函数返回true(默认)则dialog关闭,反之不关闭;若不传入则默认是直接返回true的函数
  4053. * 注意不要人肉返回undefined!!')}
  4054. * okHidden: function(e){alert('点击确认后、dialog消失后的逻辑')}
  4055. * cancelHide: fn
  4056. * cancelHidden: fn
  4057. * })
  4058. *
  4059. */
  4060. $.extend({
  4061. _modal: function(dialogCfg, customCfg){
  4062. var modalId = +new Date()
  4063. ,finalCfg = $.extend({}, $.fn.modal.defaults
  4064. , dialogCfg
  4065. , {id: modalId, okBtn: '确定'}
  4066. , (typeof customCfg == 'string' ? {body: customCfg} : customCfg))
  4067. var dialog = new Modal(null, finalCfg)
  4068. , $ele = dialog.$element
  4069. _bind(modalId, finalCfg)
  4070. $ele.data('modal', dialog).modal('show')
  4071. function _bind(id, eList){
  4072. var eType = ['show', 'shown', 'hide', 'hidden', 'okHidden', 'cancelHide', 'cancelHidden']
  4073. $.each(eType, function(k, v){
  4074. if (typeof eList[v] == 'function'){
  4075. $(document).on(v, '#'+id, $.proxy(eList[v], $('#' + id)[0]))
  4076. }
  4077. })
  4078. }
  4079. //静态方法对话框返回对话框元素的jQuery对象
  4080. return $ele
  4081. }
  4082. //为最常见的alert,confirm建立$.modal的快捷方式,
  4083. ,alert: function(customCfg){
  4084. var dialogCfg = {
  4085. type: 'alert'
  4086. ,title: '注意'
  4087. }
  4088. return $._modal(dialogCfg, customCfg)
  4089. }
  4090. ,confirm: function(customCfg){
  4091. var dialogCfg = {
  4092. type: 'confirm'
  4093. ,title: '提示'
  4094. ,cancelBtn: '取消'
  4095. }
  4096. return $._modal(dialogCfg, customCfg)
  4097. }
  4098. })
  4099. }(window.jQuery);
  4100. },{}],10:[function(require,module,exports){
  4101. //msgs组件添加叉叉关闭功能
  4102. !function ($) {
  4103. $(document).on('click.msgs', '[data-dismiss="msgs"]', function (e) {
  4104. e.preventDefault();
  4105. var $this = $(this),
  4106. $msg = $this.parents('.sui-msg').remove();
  4107. var id = $msg.attr("id");
  4108. if(id && $msg.hasClass("remember")) {
  4109. localStorage.setItem("sui-msg-" + id, 1);
  4110. }
  4111. })
  4112. $(function() {
  4113. $(".sui-msg.remember").each(function() {
  4114. var $this = $(this);
  4115. var id = $this.attr("id");
  4116. if(!id) return;
  4117. localStorage.getItem("sui-msg-" + id) || $this.show();
  4118. });
  4119. });
  4120. }(window.jQuery);
  4121. },{}],11:[function(require,module,exports){
  4122. !function ($) {
  4123. function Pagination(opts) {
  4124. this.itemsCount = opts.itemsCount;
  4125. this.pageSize = opts.pageSize;
  4126. this.displayPage = opts.displayPage < 5 ? 5 : opts.displayPage;
  4127. //itemsCount为0的时候应为1页
  4128. this.pages = Math.ceil(opts.itemsCount / opts.pageSize) || 1;
  4129. $.isNumeric(opts.pages) && (this.pages = opts.pages);
  4130. this.currentPage = opts.currentPage;
  4131. this.styleClass = opts.styleClass;
  4132. this.onSelect = opts.onSelect;
  4133. this.showCtrl = opts.showCtrl;
  4134. this.remote = opts.remote;
  4135. this.displayInfoType = ((opts.displayInfoType == 'itemsCount' && opts.itemsCount) ? 'itemsCount': 'pages');
  4136. }
  4137. /* jshint ignore:start */
  4138. Pagination.prototype = {
  4139. //generate the outer wrapper with the config of custom style
  4140. _draw: function () {
  4141. var tpl = '<div class="sui-pagination';
  4142. for (var i = 0; i < this.styleClass.length; i++) {
  4143. tpl += ' ' + this.styleClass[i];
  4144. }
  4145. tpl += '"></div>'
  4146. this.hookNode.html(tpl);
  4147. this._drawInner();
  4148. },
  4149. //generate the true pagination
  4150. _drawInner: function () {
  4151. var outer = this.hookNode.children('.sui-pagination');
  4152. var tpl = '<ul>' + '<li class="prev' + (this.currentPage - 1 <= 0 ? ' disabled' : ' ') + '"><a href="#" data="' + (this.currentPage - 1) + '">«上一页</a></li>';
  4153. if (this.pages <= this.displayPage || this.pages == this.displayPage + 1) {
  4154. for (var i = 1; i < this.pages + 1; i++) {
  4155. i == this.currentPage ? (tpl += '<li class="active"><a href="#" data="' + i + '">' + i + '</a></li>') : (tpl += '<li><a href="#" data="' + i + '">' + i + '</a></li>');
  4156. }
  4157. } else {
  4158. if (this.currentPage < this.displayPage - 1) {
  4159. for (var i = 1; i < this.displayPage; i++) {
  4160. i == this.currentPage ? (tpl += '<li class="active"><a href="#" data="' + i + '">' + i + '</a></li>') : (tpl += '<li><a href="#" data="' + i + '">' + i + '</a></li>');
  4161. }
  4162. tpl += '<li class="dotted"><span>...</span></li>';
  4163. tpl += '<li><a href="#" data="' + this.pages + '">' + this.pages + '</a></li>';
  4164. } else if (this.currentPage > this.pages - this.displayPage + 2 && this.currentPage <= this.pages) {
  4165. tpl += '<li><a href="#" data="1">1</a></li>';
  4166. tpl += '<li class="dotted"><span>...</span></li>';
  4167. for (var i = this.pages - this.displayPage + 2; i <= this.pages; i++) {
  4168. i == this.currentPage ? (tpl += '<li class="active"><a href="#" data="' + i + '">' + i + '</a></li>') : (tpl += '<li><a href="#" data="' + i + '">' + i + '</a></li>');
  4169. }
  4170. } else {
  4171. tpl += '<li><a href="#" data="1">1</a></li>';
  4172. tpl += '<li class="dotted"><span>...</span></li>';
  4173. var frontPage,
  4174. backPage,
  4175. middle = (this.displayPage - 3) / 2;
  4176. if ( (this.displayPage - 3) % 2 == 0 ) {
  4177. frontPage = backPage = middle;
  4178. } else {
  4179. frontPage = Math.floor(middle);
  4180. backPage = Math.ceil(middle);
  4181. }
  4182. for (var i = this.currentPage - frontPage; i <= this.currentPage + backPage; i++) {
  4183. i == this.currentPage ? (tpl += '<li class="active"><a href="#" data="' + i + '">' + i + '</a></li>') : (tpl += '<li><a href="#" data="' + i + '">' + i + '</a></li>');
  4184. }
  4185. tpl += '<li class="dotted"><span>...</span></li>';
  4186. tpl += '<li><a href="#" data="' + this.pages + '">' + this.pages + '</a></li>';
  4187. }
  4188. }
  4189. tpl += '<li class="next' + (this.currentPage + 1 > this.pages ? ' disabled' : ' ') + '"><a href="#" data="' + (this.currentPage + 1) + '">下一页»</a></li>' + '</ul>';
  4190. this.showCtrl && (tpl += this._drawCtrl());
  4191. outer.html(tpl);
  4192. },
  4193. //值传递
  4194. _drawCtrl: function () {
  4195. var tpl = '<div>&nbsp;' + (this.displayInfoType == 'itemsCount'? '<span>共' + this.itemsCount + '条</span>&nbsp;' :'<span>共' + this.pages + '页</span>&nbsp;') +
  4196. '<span>' + '&nbsp;到&nbsp;' + '<input type="text" class="page-num"/><button class="page-confirm">确定</button>' + '&nbsp;页' + '</span>' + '</div>';
  4197. return tpl;
  4198. },
  4199. _ctrl: function () {
  4200. var self = this,
  4201. pag = self.hookNode.children('.sui-pagination');
  4202. function doPagination() {
  4203. var tmpNum = parseInt(pag.find('.page-num').val());
  4204. if ($.isNumeric(tmpNum) && tmpNum <= self.pages && tmpNum > 0) {
  4205. if (!self.remote) {
  4206. self.currentPage = tmpNum;
  4207. self._drawInner();
  4208. }
  4209. if ($.isFunction(self.onSelect)) {
  4210. self.onSelect.call($(this), tmpNum);
  4211. }
  4212. }
  4213. }
  4214. pag.on('click', '.page-confirm', function (e) {
  4215. doPagination.call(this)
  4216. })
  4217. pag.on('keypress', '.page-num', function (e) {
  4218. e.which == 13 && doPagination.call(this)
  4219. })
  4220. },
  4221. _select: function () {
  4222. var self = this;
  4223. self.hookNode.children('.sui-pagination').on('click', 'a', function (e) {
  4224. e.preventDefault();
  4225. var tmpNum = parseInt($(this).attr('data'));
  4226. if (!$(this).parent().hasClass('disabled') && !$(this).parent().hasClass('active')) {
  4227. if (!self.remote) {
  4228. self.currentPage = tmpNum;
  4229. self._drawInner();
  4230. }
  4231. if ($.isFunction(self.onSelect)) {
  4232. self.onSelect.call($(this), tmpNum);
  4233. }
  4234. }
  4235. })
  4236. },
  4237. init: function (opts, hookNode) {
  4238. this.hookNode = hookNode;
  4239. this._draw();
  4240. this._select();
  4241. this.showCtrl && this._ctrl();
  4242. return this;
  4243. },
  4244. updateItemsCount: function (itemsCount, pageToGo) {
  4245. $.isNumeric(itemsCount) && (this.pages = Math.ceil(itemsCount / this.pageSize));
  4246. //如果最后一页没有数据了,返回到剩余最大页数
  4247. this.currentPage = this.currentPage > this.pages ? this.pages : this.currentPage;
  4248. $.isNumeric(pageToGo) && (this.currentPage = pageToGo);
  4249. this._drawInner();
  4250. },
  4251. updatePages: function (pages, pageToGo) {
  4252. $.isNumeric(pages) && (this.pages = pages);
  4253. this.currentPage = this.currentPage > this.pages ? this.pages : this.currentPage;
  4254. $.isNumeric(pageToGo) && (this.currentPage = pageToGo);
  4255. this._drawInner();
  4256. },
  4257. goToPage: function (page) {
  4258. if ($.isNumeric(page) && page <= this.pages && page > 0) {
  4259. this.currentPage = page;
  4260. this._drawInner()
  4261. }
  4262. }
  4263. }
  4264. /* jshint ignore:end */
  4265. var old = $.fn.pagination;
  4266. $.fn.pagination = function (options) {
  4267. var opts = $.extend({}, $.fn.pagination.defaults, typeof options == 'object' && options);
  4268. if (typeof options == 'string') {
  4269. args = $.makeArray(arguments);
  4270. args.shift();
  4271. }
  4272. var $this = $(this),
  4273. pag = $this.data('sui-pagination');
  4274. if (!pag) $this.data('sui-pagination', (pag = new Pagination(opts).init(opts, $(this))))
  4275. else if (typeof options == 'string') {
  4276. pag[options].apply(pag, args)
  4277. }
  4278. return pag;
  4279. };
  4280. $.fn.pagination.Constructor = Pagination;
  4281. $.fn.pagination.noConflict = function () {
  4282. $.fn.pagination = old;
  4283. return this
  4284. }
  4285. $.fn.pagination.defaults = {
  4286. pageSize: 10,
  4287. displayPage: 5,
  4288. currentPage: 1,
  4289. itemsCount: 0,
  4290. styleClass: [],
  4291. pages: null,
  4292. showCtrl: false,
  4293. onSelect: null,
  4294. remote: false
  4295. }
  4296. }(window.jQuery)
  4297. },{}],12:[function(require,module,exports){
  4298. //核心组件
  4299. require('./transition')
  4300. require('./msgs')
  4301. require('./filesize')
  4302. require('./button')
  4303. require('./dropdown')
  4304. require('./modal')
  4305. require('./tooltip')
  4306. require('./tab')
  4307. require('./pagination')
  4308. require('./validate')
  4309. require('./validate-rules')
  4310. require('./tree')
  4311. require('./datepicker')
  4312. require('./timepicker')
  4313. require('./checkbox')
  4314. require('./autocomplete')
  4315. require('./intro')
  4316. require('./carousel')
  4317. require('./template')
  4318. },{"./autocomplete":1,"./button":2,"./carousel":3,"./checkbox":4,"./datepicker":5,"./dropdown":6,"./filesize":7,"./intro":8,"./modal":9,"./msgs":10,"./pagination":11,"./tab":13,"./template":14,"./timepicker":15,"./tooltip":16,"./transition":17,"./tree":18,"./validate":20,"./validate-rules":19}],13:[function(require,module,exports){
  4319. /* ========================================================
  4320. * bootstrap-tab.js v2.3.2
  4321. * http://getbootstrap.com/2.3.2/javascript.html#tabs
  4322. * ========================================================
  4323. * Copyright 2013 Twitter, Inc.
  4324. *
  4325. * Licensed under the Apache License, Version 2.0 (the "License");
  4326. * you may not use this file except in compliance with the License.
  4327. * You may obtain a copy of the License at
  4328. *
  4329. * http://www.apache.org/licenses/LICENSE-2.0
  4330. *
  4331. * Unless required by applicable law or agreed to in writing, software
  4332. * distributed under the License is distributed on an "AS IS" BASIS,
  4333. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  4334. * See the License for the specific language governing permissions and
  4335. * limitations under the License.
  4336. * ======================================================== */
  4337. !function ($) {
  4338. "use strict";
  4339. /* TAB CLASS DEFINITION
  4340. * ==================== */
  4341. var Tab = function (element) {
  4342. this.element = $(element)
  4343. }
  4344. Tab.prototype = {
  4345. constructor: Tab
  4346. , show: function () {
  4347. var $this = this.element
  4348. , $ul = $this.closest('ul:not(.dropdown-menu)')
  4349. , selector = $this.attr('data-target')
  4350. , previous
  4351. , $target
  4352. , e
  4353. if (!selector) {
  4354. selector = $this.attr('href')
  4355. selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
  4356. }
  4357. if ( $this.parent('li').hasClass('active') ) return
  4358. previous = $ul.find('.active:last a')[0]
  4359. e = $.Event('show', {
  4360. relatedTarget: previous
  4361. })
  4362. $this.trigger(e)
  4363. if (e.isDefaultPrevented()) return
  4364. $target = $(selector)
  4365. this.activate($this.parent('li'), $ul)
  4366. this.activate($target, $target.parent(), function () {
  4367. $this.trigger({
  4368. type: 'shown'
  4369. , relatedTarget: previous
  4370. })
  4371. })
  4372. }
  4373. , activate: function ( element, container, callback) {
  4374. var $active = container.find('> .active')
  4375. , transition = callback
  4376. && $.support.transition
  4377. && $active.hasClass('fade')
  4378. function next() {
  4379. $active
  4380. .removeClass('active')
  4381. .find('> .dropdown-menu > .active')
  4382. .removeClass('active')
  4383. element.addClass('active')
  4384. if (transition) {
  4385. element[0].offsetWidth // reflow for transition
  4386. element.addClass('in')
  4387. } else {
  4388. element.removeClass('fade')
  4389. }
  4390. if ( element.parent('.dropdown-menu') ) {
  4391. element.closest('li.dropdown').addClass('active')
  4392. }
  4393. callback && callback()
  4394. }
  4395. transition ?
  4396. $active.one($.support.transition.end, next) :
  4397. next()
  4398. $active.removeClass('in')
  4399. }
  4400. }
  4401. /* TAB PLUGIN DEFINITION
  4402. * ===================== */
  4403. var old = $.fn.tab
  4404. $.fn.tab = function ( option ) {
  4405. return this.each(function () {
  4406. var $this = $(this)
  4407. , data = $this.data('tab')
  4408. if (!data) $this.data('tab', (data = new Tab(this)))
  4409. if (typeof option == 'string') data[option]()
  4410. })
  4411. }
  4412. $.fn.tab.Constructor = Tab
  4413. /* TAB NO CONFLICT
  4414. * =============== */
  4415. $.fn.tab.noConflict = function () {
  4416. $.fn.tab = old
  4417. return this
  4418. }
  4419. /* TAB DATA-API
  4420. * ============ */
  4421. $(document).on('click.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
  4422. e.preventDefault()
  4423. $(this).tab('show')
  4424. })
  4425. }(window.jQuery);
  4426. },{}],14:[function(require,module,exports){
  4427. /*jshint -W054 */
  4428. // use template in underscore: http://underscorejs.org/
  4429. // By default, Underscore uses ERB-style template delimiters, change the
  4430. // following template settings to use alternative delimiters.
  4431. !function ($) {
  4432. var escapeMap = {
  4433. '&': '&amp;',
  4434. '<': '&lt;',
  4435. '>': '&gt;',
  4436. '"': '&quot;',
  4437. "'": '&#x27;',
  4438. '`': '&#x60;'
  4439. };
  4440. // Functions for escaping and unescaping strings to/from HTML interpolation.
  4441. var createEscaper = function(map) {
  4442. var escaper = function(match) {
  4443. return map[match];
  4444. };
  4445. // Regexes for identifying a key that needs to be escaped
  4446. var keys = [];
  4447. for(var k in escapeMap) keys.push(k);
  4448. var source = '(?:' + keys.join('|') + ')';
  4449. var testRegexp = RegExp(source);
  4450. var replaceRegexp = RegExp(source, 'g');
  4451. return function(string) {
  4452. string = string == null ? '' : '' + string;
  4453. return testRegexp.test(string) ? string.replace(replaceRegexp, escaper) : string;
  4454. };
  4455. };
  4456. $.escape = createEscaper(escapeMap);
  4457. var templateSettings = {
  4458. evaluate : /<%([\s\S]+?)%>/g,
  4459. interpolate : /<%=([\s\S]+?)%>/g,
  4460. escape : /<%-([\s\S]+?)%>/g
  4461. };
  4462. // When customizing `templateSettings`, if you don't want to define an
  4463. // interpolation, evaluation or escaping regex, we need one that is
  4464. // guaranteed not to match.
  4465. var noMatch = /(.)^/;
  4466. // Certain characters need to be escaped so that they can be put into a
  4467. // string literal.
  4468. var escapes = {
  4469. "'": "'",
  4470. '\\': '\\',
  4471. '\r': 'r',
  4472. '\n': 'n',
  4473. '\u2028': 'u2028',
  4474. '\u2029': 'u2029'
  4475. };
  4476. var escaper = /\\|'|\r|\n|\u2028|\u2029/g;
  4477. var escapeChar = function(match) {
  4478. return '\\' + escapes[match];
  4479. };
  4480. // JavaScript micro-templating, similar to John Resig's implementation.
  4481. // Underscore templating handles arbitrary delimiters, preserves whitespace,
  4482. // and correctly escapes quotes within interpolated code.
  4483. // NB: `oldSettings` only exists for backwards compatibility.
  4484. $.template = function(text, settings, oldSettings) {
  4485. if (!settings && oldSettings) settings = oldSettings;
  4486. settings = $.extend({}, settings, templateSettings);
  4487. // Combine delimiters into one regular expression via alternation.
  4488. var matcher = RegExp([
  4489. (settings.escape || noMatch).source,
  4490. (settings.interpolate || noMatch).source,
  4491. (settings.evaluate || noMatch).source
  4492. ].join('|') + '|$', 'g');
  4493. // Compile the template source, escaping string literals appropriately.
  4494. var index = 0;
  4495. var source = "__p+='";
  4496. text.replace(matcher, function(match, escape, interpolate, evaluate, offset) {
  4497. source += text.slice(index, offset).replace(escaper, escapeChar);
  4498. index = offset + match.length;
  4499. if (escape) {
  4500. source += "'+\n((__t=(" + escape + "))==null?'':_.escape(__t))+\n'";
  4501. } else if (interpolate) {
  4502. source += "'+\n((__t=(" + interpolate + "))==null?'':__t)+\n'";
  4503. } else if (evaluate) {
  4504. source += "';\n" + evaluate + "\n__p+='";
  4505. }
  4506. // Adobe VMs need the match returned to produce the correct offest.
  4507. return match;
  4508. });
  4509. source += "';\n";
  4510. // If a variable is not specified, place data values in local scope.
  4511. if (!settings.variable) source = 'with(obj||{}){\n' + source + '}\n';
  4512. source = "var __t,__p='',__j=Array.prototype.join," +
  4513. "print=function(){__p+=__j.call(arguments,'');};\n" +
  4514. source + 'return __p;\n';
  4515. try {
  4516. var render = new Function(settings.variable || 'obj', '_', source);
  4517. } catch (e) {
  4518. e.source = source;
  4519. throw e;
  4520. }
  4521. var template = function(data) {
  4522. return render.call(this, data, $);
  4523. };
  4524. // Provide the compiled source as a convenience for precompilation.
  4525. var argument = settings.variable || 'obj';
  4526. template.source = 'function(' + argument + '){\n' + source + '}';
  4527. return template;
  4528. };
  4529. }(window.jQuery);
  4530. },{}],15:[function(require,module,exports){
  4531. /*jshint sub:true*/
  4532. !function ($) {
  4533. function TimePicker(element, cfg){
  4534. if(!(this instanceof TimePicker)){
  4535. return new TimePicker(element, cfg);
  4536. }
  4537. this.init(element, cfg);
  4538. }
  4539. TimePicker.prototype = {
  4540. _defaultCfg: {
  4541. hour: (new Date()).getHours(),
  4542. minute: (new Date()).getMinutes(),
  4543. orientation: {x: 'auto', y: 'auto'},
  4544. keyboardNavigation: true
  4545. },
  4546. init: function(element, cfg){
  4547. this.element = $(element)
  4548. this.isInline = false;
  4549. this.isInDatepicker = false;
  4550. this.isInput = this.element.is('input');
  4551. this.component = this.element.is('.date') ? this.element.find('.add-on, .input-group-addon, .sui-btn') : false;
  4552. this.hasInput = this.component && this.element.find('input').length;
  4553. if (this.component && this.component.length === 0)
  4554. this.component = false;
  4555. this.picker = $('<div class="timepicker"></div>');
  4556. this.o = this.config = $.extend(this._defaultCfg, cfg);
  4557. this._buildEvents();
  4558. this._attachEvents();
  4559. if(this.isInDatepicker){
  4560. this.picker.addClass('timepicker-in-datepicker').appendTo(this.element);
  4561. }else if (this.isInline){
  4562. this.picker.addClass('timepicker-inline').appendTo(this.element);
  4563. this._show();
  4564. }else{
  4565. this.picker.addClass('timepicker-dropdown dropdown-menu');
  4566. }
  4567. },
  4568. destory: function(){
  4569. this._detachSecondaryEvents();
  4570. this.picker.html('');
  4571. this.picker = null;
  4572. },
  4573. _show: function(){
  4574. if (!this.isInline&&!this.isInDatepicker)
  4575. this.picker.appendTo('body');
  4576. this.picker.show();
  4577. this._place();
  4578. this._render();
  4579. this._attachSecondaryEvents();
  4580. },
  4581. show: function () {
  4582. return this._show();
  4583. },
  4584. _hide: function(){
  4585. if (this.isInline || this.isInDatepicker)
  4586. return;
  4587. if (!this.picker.is(':visible'))
  4588. return;
  4589. this.focusDate = null;
  4590. this.picker.hide().detach();
  4591. this._detachSecondaryEvents();
  4592. this._setValue();
  4593. },
  4594. _keydown: function(e){
  4595. if (this.isInDatepicker) return;
  4596. if (this.picker.is(':not(:visible)')){
  4597. if (e.keyCode === 27) // allow escape to hide and re-show picker
  4598. this._show();
  4599. return;
  4600. }
  4601. var dir,rol;
  4602. switch (e.keyCode){
  4603. case 27: // escape
  4604. this._hide();
  4605. e.preventDefault();
  4606. break;
  4607. case 37: // left
  4608. case 39: // right
  4609. if (!this.o.keyboardNavigation)
  4610. break;//和input 输入有冲突 注释掉
  4611. // dir = e.keyCode === 37 ? 'up' : 'down';
  4612. // rol = 'hour';
  4613. // this._slide(rol,dir);
  4614. break;
  4615. case 38: // up
  4616. case 40: // down
  4617. if (!this.o.keyboardNavigation)
  4618. break;
  4619. // dir = e.keyCode === 38 ? 'up' : 'down';
  4620. // rol = 'minute';
  4621. // this._slide(rol,dir);
  4622. break;
  4623. case 32: // spacebar
  4624. // Spacebar is used in manually typing dates in some formats.
  4625. // As such, its behavior should not be hijacked.
  4626. break;
  4627. case 13: // enter
  4628. this._hide();
  4629. break;
  4630. }
  4631. },
  4632. _place:function(){
  4633. if (this.isInline || this.isInDatepicker)
  4634. return;
  4635. var calendarWidth = this.picker.outerWidth(),
  4636. calendarHeight = this.picker.outerHeight(),
  4637. visualPadding = 10,
  4638. $window = $(window),
  4639. windowWidth = $window.width(),
  4640. windowHeight = $window.height(),
  4641. scrollTop = $window.scrollTop();
  4642. var zIndex = parseInt(this.element.parents().filter(function(){
  4643. return $(this).css('z-index') !== 'auto';
  4644. }).first().css('z-index'))+10;
  4645. var offset = this.component ? this.component.parent().offset() : this.element.offset();
  4646. var height = this.component ? this.component.outerHeight(true) : this.element.outerHeight(false);
  4647. var width = this.component ? this.component.outerWidth(true) : this.element.outerWidth(false);
  4648. var left = offset.left,
  4649. top = offset.top;
  4650. this.picker.removeClass(
  4651. 'datepicker-orient-top datepicker-orient-bottom '+
  4652. 'datepicker-orient-right datepicker-orient-left'
  4653. );
  4654. if (this.o.orientation.x !== 'auto'){
  4655. this.picker.addClass('datepicker-orient-' + this.o.orientation.x);
  4656. if (this.o.orientation.x === 'right')
  4657. left -= calendarWidth - width;
  4658. }
  4659. // auto x orientation is best-placement: if it crosses a window
  4660. // edge, fudge it sideways
  4661. else {
  4662. // Default to left
  4663. this.picker.addClass('datepicker-orient-left');
  4664. if (offset.left < 0)
  4665. left -= offset.left - visualPadding;
  4666. else if (offset.left + calendarWidth > windowWidth)
  4667. left = windowWidth - calendarWidth - visualPadding;
  4668. }
  4669. // auto y orientation is best-situation: top or bottom, no fudging,
  4670. // decision based on which shows more of the calendar
  4671. var yorient = this.o.orientation.y,
  4672. top_overflow, bottom_overflow;
  4673. if (yorient === 'auto'){
  4674. top_overflow = -scrollTop + offset.top - calendarHeight;
  4675. bottom_overflow = scrollTop + windowHeight - (offset.top + height + calendarHeight);
  4676. if (Math.max(top_overflow, bottom_overflow) === bottom_overflow)
  4677. yorient = 'top';
  4678. else
  4679. yorient = 'bottom';
  4680. }
  4681. this.picker.addClass('datepicker-orient-' + yorient);
  4682. if (yorient === 'top')
  4683. top += height + 6;
  4684. else
  4685. top -= calendarHeight + parseInt(this.picker.css('padding-top')) + 6;
  4686. this.picker.css({
  4687. top: top,
  4688. left: left,
  4689. zIndex: zIndex
  4690. });
  4691. },
  4692. // envent method
  4693. _events: [],
  4694. _secondaryEvents: [],
  4695. _applyEvents: function(evs){
  4696. for (var i=0, el, ch, ev; i < evs.length; i++){
  4697. el = evs[i][0];
  4698. if (evs[i].length === 2){
  4699. ch = undefined;
  4700. ev = evs[i][1];
  4701. }
  4702. else if (evs[i].length === 3){
  4703. ch = evs[i][1];
  4704. ev = evs[i][2];
  4705. }
  4706. el.on(ev, ch);
  4707. }
  4708. },
  4709. _unapplyEvents: function(evs){
  4710. for (var i=0, el, ev, ch; i < evs.length; i++){
  4711. el = evs[i][0];
  4712. if (evs[i].length === 2){
  4713. ch = undefined;
  4714. ev = evs[i][1];
  4715. }
  4716. else if (evs[i].length === 3){
  4717. ch = evs[i][1];
  4718. ev = evs[i][2];
  4719. }
  4720. el.off(ev, ch);
  4721. }
  4722. },
  4723. _attachEvents: function(){
  4724. this._detachEvents();
  4725. this._applyEvents(this._events);
  4726. },
  4727. _detachEvents: function(){
  4728. this._unapplyEvents(this._events);
  4729. },
  4730. _attachSecondaryEvents: function(){
  4731. this._detachSecondaryEvents();
  4732. this._applyEvents(this._secondaryEvents);
  4733. this._pickerEvents();
  4734. },
  4735. _detachSecondaryEvents: function(){
  4736. this._unapplyEvents(this._secondaryEvents);
  4737. this.picker.off('click');
  4738. },
  4739. _buildEvents:function(){
  4740. if (this.isInput){ // single input
  4741. this._events = [
  4742. [this.element, {
  4743. focus: $.proxy(this._show, this),
  4744. keyup: $.proxy(function(e){
  4745. if ($.inArray(e.keyCode, [27,37,39,38,40,32,13,9]) === -1)
  4746. this._updateUI();
  4747. }, this),
  4748. keydown: $.proxy(this._keydown, this)
  4749. }]
  4750. ];
  4751. }
  4752. else if (this.component && this.hasInput){ // component: input + button
  4753. this._events = [
  4754. // For components that are not readonly, allow keyboard nav
  4755. [this.element.find('input'), {
  4756. focus: $.proxy(this._show, this),
  4757. keyup: $.proxy(function(e){
  4758. if ($.inArray(e.keyCode, [27,37,39,38,40,32,13,9]) === -1)
  4759. this._updateUI();
  4760. }, this),
  4761. keydown: $.proxy(this._keydown, this)
  4762. }],
  4763. [this.component, {
  4764. click: $.proxy(this._show, this)
  4765. }]
  4766. ];
  4767. }
  4768. else if (this.element.is('div')){ // inline timepicker
  4769. if (this.element.is('.timepicker-container')) {
  4770. this.isInDatepicker = true;
  4771. } else{
  4772. this.isInline = true;
  4773. }
  4774. }
  4775. else {
  4776. this._events = [
  4777. [this.element, {
  4778. click: $.proxy(this._show, this)
  4779. }]
  4780. ];
  4781. }
  4782. this._events.push(
  4783. // Component: listen for blur on element descendants
  4784. [this.element, '*', {
  4785. blur: $.proxy(function(e){
  4786. this._focused_from = e.target;
  4787. }, this)
  4788. }],
  4789. // Input: listen for blur on element
  4790. [this.element, {
  4791. blur: $.proxy(function(e){
  4792. this._focused_from = e.target;
  4793. }, this)
  4794. }]
  4795. );
  4796. this._secondaryEvents = [
  4797. [$(window), {
  4798. resize: $.proxy(this._place, this)
  4799. }],
  4800. [$(document), {
  4801. 'mousedown touchstart': $.proxy(function(e){
  4802. // Clicked outside the datepicker, hide it
  4803. if (!(
  4804. this.element.is(e.target) ||
  4805. this.element.find(e.target).length ||
  4806. this.picker.is(e.target) ||
  4807. this.picker.find(e.target).length
  4808. )){
  4809. this._hide();
  4810. }
  4811. }, this)
  4812. }]
  4813. ];
  4814. },
  4815. _pickerEvents: function(){
  4816. var self = this;
  4817. this.picker.on('click', '.J_up', function(ev){
  4818. var target = ev.currentTarget,
  4819. parentNode = $(target).parent(),
  4820. role = parentNode.attr('data-role');
  4821. self._slide(role, 'up');
  4822. }).on( 'click', '.J_down',function(ev){
  4823. var target = ev.currentTarget,
  4824. parentNode = $(target).parent(),
  4825. role = parentNode.attr('data-role');
  4826. self._slide(role, 'down');
  4827. }).on( 'click', 'span',function(ev){
  4828. var target = ev.currentTarget,
  4829. parentNode = $(target).parent().parent().parent(),
  4830. role = parentNode.attr('data-role'),
  4831. targetNum = target.innerHTML,
  4832. attrs = self[role + 'Attr'],
  4833. step = parseInt(targetNum - attrs.current,10),
  4834. dur;
  4835. if(step > 0){
  4836. self._slideDonw(attrs, step);
  4837. }else{
  4838. self._slideUp(attrs, -step);
  4839. }
  4840. });
  4841. },
  4842. _slide: function(role, direction){
  4843. var attrs = this[role+ 'Attr'];
  4844. if(direction == 'up'){
  4845. this._slideUp(attrs);
  4846. }else if(direction == 'down'){
  4847. this._slideDonw(attrs);
  4848. }
  4849. },
  4850. _slideDonw: function(attrs, step, notSetValue){
  4851. step = step || 1;
  4852. var cp = attrs.cp,
  4853. dur = attrs.ih*step;
  4854. attrs.current += step;
  4855. if(attrs.current > attrs.maxSize){
  4856. attrs.current = 0;
  4857. dur = -attrs.ih * attrs.maxSize;
  4858. }
  4859. attrs.cp -= dur;
  4860. this._animate(attrs.innerPickerCon, attrs.cp);
  4861. $('.current', attrs.innerPickerCon).removeClass('current');
  4862. $('span[data-num="' + attrs.current + '"]', attrs.innerPickerCon).addClass('current');
  4863. if (!notSetValue) {
  4864. this._setValue();
  4865. }
  4866. },
  4867. _slideUp: function(attrs, step ,notSetValue){
  4868. step = step || 1;
  4869. var cp = attrs.cp,
  4870. dur = attrs.ih*step;
  4871. attrs.current -= step;
  4872. if(attrs.current < 0){
  4873. attrs.current = attrs.maxSize;
  4874. dur = -attrs.ih * attrs.maxSize;
  4875. }
  4876. attrs.cp += dur;
  4877. this._animate(attrs.innerPickerCon, attrs.cp);
  4878. $('.current', attrs.innerPickerCon).removeClass('current');
  4879. $('span[data-num="' + attrs.current + '"]', attrs.innerPickerCon).addClass('current');
  4880. if (!notSetValue) {
  4881. this._setValue();
  4882. }
  4883. },
  4884. _updateSlide:function(attrs,step){
  4885. var notSetValue = true;
  4886. if(step&&(step > 0)){
  4887. this._slideDonw(attrs, step, notSetValue);
  4888. }else if(step){
  4889. this._slideUp(attrs, -step, notSetValue);
  4890. }
  4891. },
  4892. _updateUI: function(){
  4893. var oldMimute = this.o.minute,
  4894. oldHour = this.o.hour,
  4895. attrs,role,step;
  4896. this._getInputTime();
  4897. if (oldMimute !== this.o.minute) {
  4898. attrs = this['minuteAttr'];
  4899. step = parseInt(this.o.minute - attrs.current,10);
  4900. this._updateSlide(attrs,step);
  4901. }
  4902. if (oldHour !== this.o.hour) {
  4903. attrs = this['hourAttr'];
  4904. step = parseInt(this.o.hour - attrs.current,10);
  4905. this._updateSlide(attrs,step);
  4906. }
  4907. },
  4908. //将时间设置在input 或者 data-api里
  4909. _doSetValue:function(timeStr,notSetValue){
  4910. var element;
  4911. if (this.isInput){
  4912. element = this.element;
  4913. }
  4914. else if (this.component){
  4915. element = this.element.find('input');
  4916. }
  4917. if (element){
  4918. element.change();
  4919. element.val(timeStr);
  4920. }else if(this.isInDatepicker){
  4921. this.element.data("time",timeStr);
  4922. if (!notSetValue) {
  4923. this.element.trigger('time:change');
  4924. }
  4925. }
  4926. },
  4927. _render: function(){
  4928. this.picker.html('');
  4929. this._getInputTime();
  4930. this._renderHour();
  4931. this._renderMinutes();
  4932. this._renderSplit();
  4933. //form input
  4934. this._setValue();
  4935. },
  4936. _foramtTimeString:function(val){
  4937. var time = {
  4938. minute:0,
  4939. hour:0
  4940. },minute,hour;
  4941. val = val.split(':');
  4942. for (var i = val.length - 1; i >= 0; i--) {
  4943. val[i] = $.trim(val[i]);
  4944. }
  4945. if (val.length === 2) {
  4946. minute = parseInt(val[1],10);
  4947. if (minute >= 0 && minute < 60) {
  4948. time.minute = minute;
  4949. }
  4950. hour = parseInt(val[0],10);
  4951. if (hour >= 0 && hour < 24) {
  4952. time.hour = hour;
  4953. }
  4954. }
  4955. return time;
  4956. },
  4957. _getInputTime: function(){
  4958. if (this.isInline&&this.isInDatepicker) return;
  4959. var element,minute,hour,val,time;
  4960. if (this.isInput||this.isInDatepicker){
  4961. element = this.element;
  4962. }
  4963. else if (this.component){
  4964. element = this.element.find('input');
  4965. }
  4966. if (element){
  4967. if(this.isInDatepicker){
  4968. val = $.trim(element.data('time'));
  4969. }else{
  4970. val = $.trim(element.val());
  4971. }
  4972. time = this._foramtTimeString(val)
  4973. this.o.minute = time.minute;
  4974. this.o.hour = time.hour;
  4975. }
  4976. },
  4977. _juicer: function(current,list){
  4978. var items = '',item;
  4979. for (var i = list.length - 1; i >= 0; i--) {
  4980. if (list[i] == current) {
  4981. item = '<span ' + 'class="current" data-num="' + i + '">' + list[i] + '</span>';
  4982. } else{
  4983. item = '<span ' + 'data-num="' + i + '">' + list[i] + '</span>';
  4984. }
  4985. items = item + items;
  4986. }
  4987. return '<div class="picker-wrap">' +
  4988. '<a href="javascript:;" class="picker-btn up J_up"><b class="arrow"></b><b class="arrow-bg"></b></a>' +
  4989. '<div class="picker-con">'+
  4990. '<div class="picker-innercon">'+
  4991. items +
  4992. '</div>' +
  4993. '</div>' +
  4994. '<a href="javascript:;" class="picker-btn down J_down"><b class="arrow"></b><b class="arrow-bg"></b></a>' +
  4995. '</div>';
  4996. },
  4997. _renderHour: function(){
  4998. var self = this,
  4999. hourRet = [];
  5000. for(var i = 0; i < 24; i++){
  5001. hourRet.push(self._beautifyNum(i));
  5002. }
  5003. var tpl = this._juicer(self.o.hour,hourRet),
  5004. $tpl = $(tpl);
  5005. $tpl.attr('data-role', 'hour');
  5006. this.picker.append($tpl);
  5007. this.hourAttr = this._addPrefixAndSuffix($tpl, 23);
  5008. this.hourAttr.current = this.o.hour;
  5009. this.hourAttr.maxSize = 23;
  5010. },
  5011. _renderMinutes: function(){
  5012. var self = this,
  5013. minuteRet = [];
  5014. for(var i = 0; i < 60; i++){
  5015. minuteRet.push(self._beautifyNum(i));
  5016. }
  5017. var tpl = this._juicer(self.o.minute, minuteRet),
  5018. $tpl = $(tpl);
  5019. $tpl.attr('data-role', 'minute');
  5020. this.picker.append($tpl);
  5021. this.minuteAttr = this._addPrefixAndSuffix($tpl, 59);
  5022. this.minuteAttr.current = this.o.minute;
  5023. this.minuteAttr.maxSize = 59;
  5024. },
  5025. _addPrefixAndSuffix: function(parentNode, maxSize){
  5026. var self = this,
  5027. pickerCon = $('.picker-con', parentNode),
  5028. innerPickerCon = $('.picker-innercon', parentNode),
  5029. currentNode = $('.current', parentNode),
  5030. itemH = currentNode.outerHeight(),
  5031. parentH = pickerCon.outerHeight(),
  5032. fixNum = Math.floor(parentH/itemH) + 1,
  5033. currentNodeOffsetTop,
  5034. currentPosition,
  5035. tpl = '';
  5036. for(var j = maxSize - fixNum; j <= maxSize; j++){
  5037. tpl += '<span>' + self._beautifyNum(j) + '</span>';
  5038. }
  5039. innerPickerCon.prepend($(tpl));
  5040. tpl = '';
  5041. for(var i = 0; i < fixNum; i ++){
  5042. tpl += '<span>' + self._beautifyNum(i) + '</span>';
  5043. }
  5044. innerPickerCon.append($(tpl));
  5045. currentNodeOffsetTop = currentNode.offset().top - pickerCon.offset().top;
  5046. currentPosition = -currentNodeOffsetTop + itemH * 2;
  5047. this._animate(innerPickerCon, currentPosition);
  5048. return {
  5049. ph: parentH,
  5050. cp: currentPosition,
  5051. ih: itemH,
  5052. innerPickerCon: innerPickerCon,
  5053. scrollNum: fixNum - 1
  5054. };
  5055. },
  5056. _renderSplit: function(){
  5057. var tpl = '<div class="timePicker-split">' +
  5058. '<div class="hour-input"></div>' +
  5059. '<div class="split-icon">:</div>' +
  5060. '<div class="minute-input"></div>' +
  5061. '</div>';
  5062. this.picker.append($(tpl));
  5063. },
  5064. _getCurrentTimeStr: function(){
  5065. var text, minute, hour;
  5066. hour = this.hourAttr.current;
  5067. minute = this.minuteAttr.current;
  5068. text = this._beautifyNum(hour)+':'+ this._beautifyNum(minute);
  5069. return text;
  5070. },
  5071. _setValue: function(){
  5072. if (this.isInline) return;
  5073. this._doSetValue(this._getCurrentTimeStr()); //将时间装填在 input 或者 data api 里
  5074. },
  5075. _animate: function(node, dur){
  5076. if ($.support.transition) {
  5077. node.css({
  5078. 'top': dur + 'px',
  5079. });
  5080. }else{
  5081. node.animate({
  5082. top: dur + 'px',
  5083. },300);
  5084. }
  5085. },
  5086. _beautifyNum: function(num){
  5087. num = num.toString();
  5088. if(parseInt(num) < 10){
  5089. return '0' + num;
  5090. }
  5091. return num;
  5092. },
  5093. //通过参数来更新日期
  5094. //timeStr(string): 12:20
  5095. //notSetValue(string): false/true , 是否需要将数值设置在input中. true 的时候只能设置在data-api中,这个参数只用在datepicker中
  5096. update: function(timeStr,notSetValue){
  5097. this._doSetValue(timeStr,notSetValue);
  5098. this._updateUI();
  5099. },
  5100. getTime: function(){
  5101. return this._getCurrentTimeStr();
  5102. }
  5103. }
  5104. /* DROPDOWN PLUGIN DEFINITION
  5105. * ========================== */
  5106. //maincode end
  5107. var old = $.fn.timepicker;
  5108. $.fn.timepicker = function(option){
  5109. var args = Array.apply(null, arguments);
  5110. args.shift();
  5111. var internal_return;
  5112. this.each(function(){
  5113. var $this = $(this)
  5114. , data = $this.data('timepicker')
  5115. if (!data) $this.data('timepicker', (data = new TimePicker(this,option)))
  5116. if (typeof option === 'string' && typeof data[option] === 'function'){
  5117. internal_return = data[option].apply(data, args);
  5118. if (internal_return !== undefined)
  5119. return false;
  5120. }
  5121. });
  5122. if (internal_return !== undefined)
  5123. return internal_return;
  5124. else
  5125. return this;
  5126. }
  5127. /* TIMEPICKER NO CONFLICT
  5128. * =================== */
  5129. $.fn.timepicker.noConflict = function(){
  5130. $.fn.timepicker = old;
  5131. return this;
  5132. };
  5133. /* TIMEPICKER DATA-API
  5134. * ================== */
  5135. $(document).on(
  5136. 'focus.timepicker.data-api click.timepicker.data-api',
  5137. '[data-toggle="timepicker"]',
  5138. function(e){
  5139. var $this = $(this);
  5140. if ($this.data('timepicker'))
  5141. return;
  5142. e.preventDefault();
  5143. // component click requires us to explicitly show it
  5144. $this.timepicker('_show');
  5145. }
  5146. );
  5147. $(function(){
  5148. $('[data-toggle="timepicker-inline"]').timepicker();
  5149. });
  5150. }(window.jQuery)
  5151. },{}],16:[function(require,module,exports){
  5152. /* ===========================================================
  5153. * bootstrap-tooltip.js v2.3.2
  5154. * http://getbootstrap.com/2.3.2/javascript.html#tooltips
  5155. * Inspired by the original jQuery.tipsy by Jason Frame
  5156. * ===========================================================
  5157. * Copyright 2013 Twitter, Inc.
  5158. *
  5159. * Licensed under the Apache License, Version 2.0 (the "License");
  5160. * you may not use this file except in compliance with the License.
  5161. * You may obtain a copy of the License at
  5162. *
  5163. * http://www.apache.org/licenses/LICENSE-2.0
  5164. *
  5165. * Unless required by applicable law or agreed to in writing, software
  5166. * distributed under the License is distributed on an "AS IS" BASIS,
  5167. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  5168. * See the License for the specific language governing permissions and
  5169. * limitations under the License.
  5170. * ========================================================== */
  5171. !function ($) {
  5172. "use strict";
  5173. /* TOOLTIP PUBLIC CLASS DEFINITION
  5174. * =============================== */
  5175. //element为触发元素,如标识文字链
  5176. var Tooltip = function (element, options) {
  5177. this.init('tooltip', element, options)
  5178. }
  5179. Tooltip.prototype = {
  5180. constructor: Tooltip
  5181. , init: function (type, element, options) {
  5182. var eventIn
  5183. , eventOut
  5184. , triggers
  5185. , trigger
  5186. , i
  5187. this.type = type
  5188. this.$element = $(element)
  5189. this.options = this.getOptions(options)
  5190. this.enabled = true
  5191. this.hoverState = 'out'
  5192. triggers = this.options.trigger.split(' ')
  5193. for (i = triggers.length; i--;) {
  5194. trigger = triggers[i]
  5195. if (trigger == 'click') {
  5196. this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this))
  5197. } else if (trigger != 'manual') {
  5198. eventIn = trigger == 'hover' ? 'mouseenter' : 'focus'
  5199. eventOut = trigger == 'hover' ? 'mouseleave' : 'blur'
  5200. this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this))
  5201. this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
  5202. }
  5203. }
  5204. this.options.selector ?
  5205. (this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) :
  5206. this.fixTitle()
  5207. }
  5208. , getOptions: function (options) {
  5209. options = $.extend({}, $.fn[this.type].defaults, this.$element.data(), options)
  5210. var foot = options.type == 'confirm' ? '<div class="tooltip-footer"><button class="sui-btn btn-primary" data-ok="tooltip">确定</button><button class="sui-btn btn-default" data-dismiss="tooltip">取消</button></div>' : ''
  5211. //根据tooltip的type类型构造tip模版
  5212. options.template = '<div class="sui-tooltip ' + options.type + '" style="overflow:visible"><div class="tooltip-arrow"><div class="tooltip-arrow cover"></div></div><div class="tooltip-inner"></div>' + foot + '</div>'
  5213. options.type == 'confirm' && (options.html = true)
  5214. if (options.delay && typeof options.delay == 'number') {
  5215. options.delay = {
  5216. show: options.delay
  5217. , hide: options.delay
  5218. }
  5219. }
  5220. return options
  5221. }
  5222. , enter: function (e) {
  5223. var defaults = $.fn[this.type].defaults
  5224. , options = {}
  5225. , self
  5226. this._options && $.each(this._options, function (key, value) {
  5227. if (defaults[key] != value) options[key] = value
  5228. }, this)
  5229. self = $(e.currentTarget)[this.type](options).data(this.type)
  5230. clearTimeout(self.timeout)
  5231. if (this.hoverState == 'out') {
  5232. this.hoverState = 'in'
  5233. this.tip().off($.support.transition && $.support.transition.end)
  5234. if (!this.options.delay || !this.options.delay.show) return this.show()
  5235. this.timeout = setTimeout(function() {
  5236. if (self.hoverState == 'in') self.show()
  5237. }, self.options.delay.show)
  5238. }
  5239. }
  5240. , leave: function (e) {
  5241. var self = $(e.currentTarget)[this.type](this._options).data(this.type)
  5242. if (this.timeout) clearTimeout(this.timeout)
  5243. if (!self.options.delay || !self.options.delay.hide) return self.hide()
  5244. this.timeout = setTimeout(function() {
  5245. //isHover 为0或undefined,undefined:没有移到tip上过
  5246. if (!self.isTipHover) {
  5247. self.hoverState = 'out'
  5248. }
  5249. if (self.hoverState == 'out') self.hide()
  5250. }, self.options.delay.hide)
  5251. }
  5252. , show: function () {
  5253. var $tip
  5254. , pos
  5255. , actualWidth
  5256. , actualHeight
  5257. , placement
  5258. , tp
  5259. , e = $.Event('show')
  5260. , opt = this.options
  5261. , align = opt.align
  5262. , self = this
  5263. if (this.hasContent() && this.enabled) {
  5264. this.$element.trigger(e)
  5265. if (e.isDefaultPrevented()) return
  5266. $tip = this.tip()
  5267. this.setContent()
  5268. if (opt.animation) {
  5269. $tip.addClass('fade')
  5270. }
  5271. placement = typeof opt.placement == 'function' ?
  5272. opt.placement.call(this, $tip[0], this.$element[0]) :
  5273. opt.placement
  5274. $tip
  5275. .detach()
  5276. .css({ top: 0, left: 0, display: 'block' })
  5277. opt.container ? $tip.appendTo(opt.container) : $tip.insertAfter(this.$element)
  5278. if (/\bhover\b/.test(opt.trigger)) {
  5279. $tip.hover(function(){
  5280. self.isTipHover = 1
  5281. }, function(){
  5282. self.isTipHover = 0
  5283. self.hoverState = 'out'
  5284. $tip.detach()
  5285. })
  5286. }
  5287. this.setWidth()
  5288. pos = this.getPosition()
  5289. actualWidth = $tip[0].offsetWidth
  5290. actualHeight = $tip[0].offsetHeight
  5291. //+ - 7修正,和css对应,勿单独修改
  5292. var d = opt.type == 'attention' ? 5 : 7
  5293. tp = positioning();
  5294. this.applyPlacement(tp, placement)
  5295. this.applyAlign(align, pos)
  5296. this.$element.trigger('shown')
  5297. }
  5298. //确定tooltip布局对齐方式
  5299. function positioning (){
  5300. var _left = pos.left + pos.width / 2 - actualWidth / 2
  5301. , _top = pos.top + pos.height / 2 - actualHeight / 2
  5302. switch (align) {
  5303. case 'left':
  5304. _left = pos.left
  5305. break
  5306. case 'right':
  5307. _left = pos.left - actualWidth + pos.width
  5308. break
  5309. case 'top':
  5310. _top = pos.top
  5311. break
  5312. case 'bottom':
  5313. _top = pos.top - actualHeight + pos.height
  5314. break
  5315. }
  5316. switch (placement) {
  5317. case 'bottom':
  5318. tp = {top: pos.top + pos.height + d, left: _left}
  5319. break
  5320. case 'top':
  5321. tp = {top: pos.top - actualHeight - d, left: _left }
  5322. break
  5323. case 'left':
  5324. tp = {top: _top, left: pos.left - actualWidth - d}
  5325. break
  5326. case 'right':
  5327. tp = {top: _top, left: pos.left + pos.width + d}
  5328. break
  5329. }
  5330. return tp
  5331. }
  5332. }
  5333. , applyPlacement: function(offset, placement){
  5334. var $tip = this.tip()
  5335. , width = $tip[0].offsetWidth
  5336. , height = $tip[0].offsetHeight
  5337. , actualWidth
  5338. , actualHeight
  5339. , delta
  5340. , replace
  5341. $tip
  5342. .offset(offset)
  5343. .addClass(placement)
  5344. .addClass('in')
  5345. actualWidth = $tip[0].offsetWidth
  5346. actualHeight = $tip[0].offsetHeight
  5347. if (placement == 'top' && actualHeight != height) {
  5348. offset.top = offset.top + height - actualHeight
  5349. replace = true
  5350. }
  5351. if (placement == 'bottom' || placement == 'top') {
  5352. delta = 0
  5353. if (offset.left < 0){
  5354. delta = offset.left * -2
  5355. offset.left = 0
  5356. $tip.offset(offset)
  5357. actualWidth = $tip[0].offsetWidth
  5358. actualHeight = $tip[0].offsetHeight
  5359. }
  5360. this.replaceArrow(delta - width + actualWidth, actualWidth, 'left')
  5361. } else {
  5362. this.replaceArrow(actualHeight - height, actualHeight, 'top')
  5363. }
  5364. if (replace) $tip.offset(offset)
  5365. }
  5366. , applyAlign: function(align, tipPos){
  5367. var $tip = this.tip()
  5368. , actualWidth = $tip[0].offsetWidth
  5369. , actualHeight = $tip[0].offsetHeight
  5370. , css = {}
  5371. switch (align) {
  5372. case 'left':
  5373. if (tipPos.width < actualWidth)
  5374. css = {left: tipPos.width / 2}
  5375. break
  5376. case 'right':
  5377. if (tipPos.width < actualWidth)
  5378. css = {left: actualWidth - tipPos.width / 2}
  5379. break
  5380. case 'top':
  5381. if (tipPos.height < actualHeight)
  5382. css = {top: tipPos.height / 2}
  5383. break
  5384. case 'bottom':
  5385. if (tipPos.height < actualHeight)
  5386. css = {top: actualHeight - tipPos.height / 2}
  5387. break
  5388. }
  5389. align != 'center' && $tip.find('.tooltip-arrow').first().css(css)
  5390. }
  5391. , replaceArrow: function(delta, dimension, position){
  5392. this
  5393. .arrow()
  5394. .css(position, delta ? (50 * (1 - delta / dimension) + "%") : '')
  5395. }
  5396. , setWidth: function() {
  5397. var opt = this.options
  5398. , width = opt.width
  5399. , widthLimit = opt.widthlimit
  5400. , $tip = this.tip()
  5401. //人工设置宽度,则忽略最大宽度限制
  5402. if (width) {
  5403. $tip.width(width)
  5404. } else {
  5405. //宽度限制逻辑
  5406. if (widthLimit === true) {
  5407. $tip.css('max-width', '400px')
  5408. } else {
  5409. var val
  5410. widthLimit === false && (val = 'none')
  5411. typeof opt.widthlimit == 'string' && (val = widthLimit)
  5412. $tip.css('max-width', val)
  5413. }
  5414. }
  5415. }
  5416. , setContent: function () {
  5417. var $tip = this.tip()
  5418. , title = this.getTitle()
  5419. $tip.find('.tooltip-inner')[this.options.html ? 'html' : 'text'](title)
  5420. $tip.removeClass('fade in top bottom left right')
  5421. }
  5422. , hide: function () {
  5423. var $tip = this.tip()
  5424. , e = $.Event('hide')
  5425. , self = this
  5426. , opt = this.options
  5427. this.$element.trigger(e)
  5428. if (e.isDefaultPrevented()) return
  5429. $tip.removeClass('in')
  5430. if (typeof opt.hide == 'function') {
  5431. opt.hide.call(self.$element)
  5432. }
  5433. function removeWithAnimation() {
  5434. self.timeout = setTimeout(function () {
  5435. $tip.off($.support.transition.end).detach()
  5436. }, 500)
  5437. $tip.one($.support.transition.end, function () {
  5438. clearTimeout(self.timeout)
  5439. $tip.detach()
  5440. })
  5441. }
  5442. $.support.transition && this.$tip.hasClass('fade') ?
  5443. removeWithAnimation() :
  5444. ($tip.detach())
  5445. this.$element.trigger('hidden')
  5446. return this
  5447. }
  5448. , fixTitle: function () {
  5449. var $e = this.$element
  5450. //只有无js激活方式才处理title属性。同时html属性data-original-title必须附加到触发元素,即使是js调用生成的tooltip。
  5451. if ($e.attr('title') || typeof($e.attr('data-original-title')) != 'string') {
  5452. if ($e.data('toggle') == 'tooltip') {
  5453. $e.attr('data-original-title', $e.attr('title') || '').attr('title', '')
  5454. } else {
  5455. $e.attr('data-original-title', '')
  5456. }
  5457. }
  5458. }
  5459. , hasContent: function () {
  5460. return this.getTitle()
  5461. }
  5462. , getPosition: function () {
  5463. var el = this.$element[0]
  5464. return $.extend({}, (typeof el.getBoundingClientRect == 'function') ? el.getBoundingClientRect() : {
  5465. width: el.offsetWidth
  5466. , height: el.offsetHeight
  5467. }, this.$element.offset())
  5468. }
  5469. , getTitle: function () {
  5470. var title
  5471. , $e = this.$element
  5472. , o = this.options
  5473. title = $e.attr('data-original-title')
  5474. || (typeof o.title == 'function' ? o.title.call($e[0]) : o.title)
  5475. return title
  5476. }
  5477. , tip: function () {
  5478. return this.$tip = this.$tip || $(this.options.template)
  5479. }
  5480. , arrow: function(){
  5481. return this.$arrow = this.$arrow || this.tip().find(".tooltip-arrow")
  5482. }
  5483. , validate: function () {
  5484. if (!this.$element[0].parentNode) {
  5485. this.hide()
  5486. this.$element = null
  5487. this.options = null
  5488. }
  5489. }
  5490. , enable: function () {
  5491. this.enabled = true
  5492. }
  5493. , disable: function () {
  5494. this.enabled = false
  5495. }
  5496. , toggleEnabled: function () {
  5497. this.enabled = !this.enabled
  5498. }
  5499. , toggle: function (e) {
  5500. var self = e ? $(e.currentTarget)[this.type](this._options).data(this.type) : this
  5501. self.tip().hasClass('in') ? self.hide() : self.show()
  5502. }
  5503. , destroy: function () {
  5504. this.hide().$element.off('.' + this.type).removeData(this.type)
  5505. }
  5506. }
  5507. /* TOOLTIP PLUGIN DEFINITION
  5508. * ========================= */
  5509. var old = $.fn.tooltip
  5510. $.fn.tooltip = function ( option ) {
  5511. return this.each(function () {
  5512. var $this = $(this)
  5513. , data = $this.data('tooltip')
  5514. , options = typeof option == 'object' && option
  5515. if (!data) $this.data('tooltip', (data = new Tooltip(this, options)))
  5516. if (typeof option == 'string') data[option]()
  5517. })
  5518. }
  5519. $.fn.tooltip.Constructor = Tooltip
  5520. $.fn.tooltip.defaults = {
  5521. animation: true
  5522. , type: 'default' //tip 类型 {string} 'default'|'attention'|'confirm' ,区别见demo
  5523. , placement: 'top'
  5524. , selector: false //通常要配合调用方法使用,如果tooltip元素很多,用此途径进行事件委托减少事件监听数量: $('body').tooltip({selector: '.tips'})
  5525. , trigger: 'hover focus' //触发方式,多选:click hover focus,如果希望手动触发,则传入'manual'
  5526. , title: 'it is default title' //默认tooltip的内容,如果给html元素添加了title属性则使用该html属性替代此属性
  5527. , delay: {show:0, hide: 200} //如果只传number,则show、hide时都会使用这个延时,若想差异化则传入形如{show:400, hide: 600} 的对象 注:delay参数对manual触发方式的tooltip无效
  5528. , html: true //决定是html()还是text()
  5529. , container: false //将tooltip与输入框组一同使用时,为了避免不必要的影响,需要设置container.他用来将tooltip的dom节点插入到container指定的元素内的最后,可理解为 container.append(tooltipDom)。
  5530. , widthlimit: true // {Boolean|string} tooltip元素最大宽度限制,false不限宽,true限宽300px,也可传入"500px",人工限制宽度
  5531. , align: 'center' // {string} tip元素的布局方式,默认居中:'center' ,'left','right','top','bottom'
  5532. }
  5533. /* TOOLTIP NO CONFLICT
  5534. * =================== */
  5535. $.fn.tooltip.noConflict = function () {
  5536. $.fn.tooltip = old
  5537. return this
  5538. }
  5539. //document ready init
  5540. $(function(){
  5541. $('[data-toggle="tooltip"]').tooltip()
  5542. //mousedown外部可消失tooltip(为了在click回调执行前处理好dom状态)
  5543. $(document).on('mousedown', function(e){
  5544. var tgt = $(e.target)
  5545. , tip = $('.sui-tooltip')
  5546. , switchTgt = tip.prev()
  5547. , tipContainer = tgt.parents('.sui-tooltip')
  5548. /* 逻辑执行条件一次注释:
  5549. * 1、存在tip
  5550. * 2、点击的不是tip内的某区域
  5551. * 3、点击的不是触发元素本身
  5552. * 4、触发元素为复杂HTML结构时,点击的不是触发元素内的区域
  5553. */
  5554. // 这里决定了data-original-title属性必须存在于触发元素上
  5555. if (tip.length && !tipContainer.length && tgt[0] != switchTgt[0] && tgt.parents('[data-original-title]')[0] != switchTgt[0]) {
  5556. switchTgt.trigger('click.tooltip')
  5557. }
  5558. })
  5559. //为confirm类型tooltip增加取消按钮设置默认逻辑
  5560. $(document).on('click', '[data-dismiss=tooltip]', function(e){
  5561. e.preventDefault()
  5562. $(e.target).parents('.sui-tooltip').prev().trigger('click.tooltip')
  5563. })
  5564. $(document).on('click', '[data-ok=tooltip]', function(e){
  5565. e.preventDefault()
  5566. var triggerEle = $(e.target).parents('.sui-tooltip').prev()
  5567. , instance = triggerEle.data('tooltip')
  5568. , okHideCallback = instance.options.okHide
  5569. if (typeof okHideCallback == 'function') {
  5570. okHideCallback.call(triggerEle)
  5571. }
  5572. })
  5573. })
  5574. }(window.jQuery);
  5575. },{}],17:[function(require,module,exports){
  5576. /* ===================================================
  5577. * bootstrap-transition.js v2.3.2
  5578. * http://getbootstrap.com/2.3.2/javascript.html#transitions
  5579. * ===================================================
  5580. * Copyright 2013 Twitter, Inc.
  5581. *
  5582. * Licensed under the Apache License, Version 2.0 (the "License");
  5583. * you may not use this file except in compliance with the License.
  5584. * You may obtain a copy of the License at
  5585. *
  5586. * http://www.apache.org/licenses/LICENSE-2.0
  5587. *
  5588. * Unless required by applicable law or agreed to in writing, software
  5589. * distributed under the License is distributed on an "AS IS" BASIS,
  5590. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  5591. * See the License for the specific language governing permissions and
  5592. * limitations under the License.
  5593. * ========================================================== */
  5594. !function ($) {
  5595. "use strict";
  5596. /* CSS TRANSITION SUPPORT (http://www.modernizr.com/)
  5597. * ======================================================= */
  5598. $(function () {
  5599. $.support.transition = (function () {
  5600. var transitionEnd = (function () {
  5601. var el = document.createElement('bootstrap')
  5602. , transEndEventNames = {
  5603. 'WebkitTransition' : 'webkitTransitionEnd'
  5604. , 'MozTransition' : 'transitionend'
  5605. , 'OTransition' : 'oTransitionEnd otransitionend'
  5606. , 'transition' : 'transitionend'
  5607. }
  5608. , name
  5609. for (name in transEndEventNames){
  5610. if (el.style[name] !== undefined) {
  5611. return transEndEventNames[name]
  5612. }
  5613. }
  5614. }())
  5615. return transitionEnd && {
  5616. end: transitionEnd
  5617. }
  5618. })()
  5619. })
  5620. }(window.jQuery);
  5621. },{}],18:[function(require,module,exports){
  5622. /**
  5623. * Created by huazhi.chz on 14-4-27.
  5624. * tree 2.0.0
  5625. * 由原来的一次性读取数据改为事件性获取数据
  5626. */
  5627. !(function($) {"use strict";
  5628. // 数据缓存处理
  5629. var Redis = function() {
  5630. this.data = {};
  5631. };
  5632. Redis.prototype = {
  5633. constructor : Redis,
  5634. query : function(key) {
  5635. return this.data[key];
  5636. },
  5637. insert : function(key, value) {
  5638. this.data[key] = value;
  5639. },
  5640. clear : function() {
  5641. this.data = {};
  5642. }
  5643. };
  5644. var Tree = function(element, options) {
  5645. this.$element = $(element);
  5646. this.options = options;
  5647. this.redis = new Redis();
  5648. };
  5649. // private methods
  5650. var methods = {
  5651. init : function() {
  5652. this.destory();
  5653. methods.bindChange.call(this);
  5654. methods.bindUpdate.call(this);
  5655. this.$element.trigger('tree:update'); // 触发第一次更新
  5656. },
  5657. getData : function(id, index) {
  5658. var that = this, data = that.redis.query(id); // 先获取缓存数据
  5659. if (!that.options.src) return;
  5660. // 先取缓存数据
  5661. if (data) {
  5662. methods.createDom.apply(that, [data, index])
  5663. } else { // 如果没有就重新获取
  5664. $.ajax(that.options.src, {
  5665. data : that.options.key + '=' + id,
  5666. cache : true,
  5667. dataType : that.options.jsonp ? 'jsonp' : 'json'
  5668. }).success(function(json) {
  5669. if (json.code == 200 && json.data && json.data.length) {
  5670. data = json.data;
  5671. that.redis.insert(id, data); // 将值存放缓存中
  5672. methods.createDom.apply(that, [data, index]);
  5673. }
  5674. })
  5675. }
  5676. },
  5677. createDom : function(list, index) {
  5678. var dom = ['<select>'],
  5679. placeholder = this.options.placeholder,
  5680. val = this.options.val[index];
  5681. placeholder && dom.push('<option value="">' + placeholder + '</option>');
  5682. $.each(list, function(i, n) {
  5683. dom.push('<option data-isleaf="' + n.isleaf + '" value="' + n.id + '" ' + (n.id == val ? 'selected' : '') + '>' + n.value + '</option>')
  5684. });
  5685. dom.push('</select>');
  5686. //return dom.join('');
  5687. dom = $(dom.join('')).appendTo(this.$element).trigger('change');
  5688. },
  5689. bindChange : function() {
  5690. var that = this;
  5691. this.$element.on('change.sui.tree', 'select', function(e) {
  5692. var $this = $(this), v = $this.val();
  5693. $this.nextAll().remove();
  5694. methods.saveValue.call(that);
  5695. if (!v) return; // 选择了placeholder
  5696. if (!$this.find('option:selected').data('isleaf')) methods.getData.apply(that, [v, $this.index() + 1]);
  5697. else that.options.val = []; // 清空初始化的时候设置的值
  5698. })
  5699. },
  5700. bindUpdate : function() {
  5701. var that = this;
  5702. this.$element.on('tree:update', function(e) {
  5703. var $this = $(this);
  5704. $this.empty();
  5705. methods.getData.apply(that, [0, 0]); // 每次重新获取数据的id都为0
  5706. })
  5707. },
  5708. saveValue : function() {
  5709. var _val = [], _opt = [];
  5710. this.$element.find('select').each(function() {
  5711. _val.push(this.value);
  5712. _opt.push($(this).find('option:selected').text());
  5713. });
  5714. this.datas = {text : _opt, value : _val};
  5715. }
  5716. };
  5717. Tree.prototype = {
  5718. constructor : Tree,
  5719. getValue : $.noop, // how ?
  5720. setValue : function(ary) {
  5721. this.options.val = ary;
  5722. this.$element.trigger('tree:update');
  5723. },
  5724. destory : function() {
  5725. this.$element.off('change.sui.tree').empty();
  5726. }
  5727. };
  5728. var old = $.fn.tree;
  5729. $.fn.extend({
  5730. tree : function() {
  5731. var args = Array.prototype.slice.call(arguments),
  5732. arg0 = args.shift();
  5733. return this.each(function() {
  5734. var $this = $(this),
  5735. data = $this.data('tree'),
  5736. options = $.extend({}, $.fn.tree.defaults, $this.data(), typeof arg0 === 'object' && arg0);
  5737. if (!data) $this.data('tree', (data = new Tree(this, options))); // 在每个元素上只保存一个实例
  5738. if (typeof arg0 === 'string' && typeof data[arg0] === 'function') data[arg0].apply(data, args);
  5739. else methods.init.call(data);
  5740. });
  5741. }
  5742. });
  5743. $.fn.tree.Constructor = Tree;
  5744. $.fn.tree.defaults = {
  5745. src : '', // 数据源,json或jsonp
  5746. treeType : 'select', // TODO tree的类型,select或list
  5747. placeholder : '请选择',
  5748. val : [], // update时取的值
  5749. key : 'id' // 默认的参数名
  5750. };
  5751. // NO CONFLICT
  5752. $.fn.tree.noConflict = function () {
  5753. $.fn.tree = old;
  5754. return this;
  5755. };
  5756. // auto handle
  5757. $(function() {
  5758. $('[data-toggle="tree"]').tree();
  5759. });
  5760. })(jQuery);
  5761. },{}],19:[function(require,module,exports){
  5762. // add rules
  5763. !function($) {
  5764. Validate = $.validate;
  5765. trim = function(v) {
  5766. if (!v) return v;
  5767. return v.replace(/^\s+/g, '').replace(/\s+$/g, '')
  5768. };
  5769. var required = function(value, element, param) {
  5770. var $input = $(element)
  5771. return !!trim(value);
  5772. };
  5773. var requiredMsg = function ($input, param) {
  5774. var getWord = function($input) {
  5775. var tagName = $input[0].tagName.toUpperCase();
  5776. var type = $input[0].type.toUpperCase();
  5777. if ( type == 'CHECKBOX' || type == 'RADIO' || tagName == 'SELECT') {
  5778. return '选择'
  5779. }
  5780. return '填写'
  5781. }
  5782. return "请" + getWord($input)
  5783. }
  5784. Validate.setRule("required", required, requiredMsg);
  5785. var prefill = function(value, element, param) {
  5786. var $input = $(element)
  5787. if (param && typeof param === typeof 'a') {
  5788. var $form = $input.parents("form")
  5789. var $required = $form.find("[name='"+param+"']")
  5790. return !!$required.val()
  5791. }
  5792. return true
  5793. }
  5794. Validate.setRule("prefill", prefill, function($input, param) {
  5795. var getWord = function($input) {
  5796. var tagName = $input[0].tagName.toUpperCase();
  5797. var type = $input[0].type.toUpperCase();
  5798. if ( type == 'CHECKBOX' || type == 'RADIO' || tagName == 'SELECT') {
  5799. return '选择'
  5800. }
  5801. return '填写'
  5802. }
  5803. if (param && typeof param === typeof 'a') {
  5804. var $form = $input.parents("form")
  5805. var $required = $form.find("[name='"+param+"']")
  5806. if (!$required.val()) {
  5807. return "请先" + getWord($required) + ($required.attr("title") || $required.attr("name"))
  5808. }
  5809. }
  5810. return '错误'
  5811. });
  5812. var match = function(value, element, param) {
  5813. value = trim(value);
  5814. return value == $(element).parents('form').find("[name='"+param+"']").val()
  5815. };
  5816. Validate.setRule("match", match, '必须与$0相同');
  5817. var number = function(value, element, param) {
  5818. value = trim(value);
  5819. return (/^\d+(.\d*)?$/).test(value)
  5820. };
  5821. Validate.setRule("number", number, '请输入数字');
  5822. var digits = function(value, element, param) {
  5823. value = trim(value);
  5824. return (/^\d+$/).test(value)
  5825. };
  5826. Validate.setRule("digits", digits, '请输入整数');
  5827. var mobile = function(value, element, param) {
  5828. return (/^0?1[3|4|5|7|8][0-9]\d{8,9}$/).test(trim(value));
  5829. };
  5830. Validate.setRule("mobile", mobile, '请填写正确的手机号码');
  5831. var tel = function(value, element, param) {
  5832. return (/^[+]{0,1}(\d){1,3}[ ]?([-]?((\d)|[ ]){1,11})+$/).test(trim(value));
  5833. };
  5834. Validate.setRule("tel", tel, '请填写正确的电话号码');
  5835. var email = function(value, element, param) {
  5836. return (/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/).test(trim(value)); //"
  5837. };
  5838. Validate.setRule("email", email, '请填写正确的email地址');
  5839. var zip = function(value, element, param) {
  5840. return (/^[1-9][0-9]{5}$/).test(trim(value));
  5841. };
  5842. Validate.setRule("zip", zip, '请填写正确的邮编');
  5843. var date = function(value, element, param) {
  5844. param = param || "-";
  5845. var reg = new RegExp("^[1|2]\\d{3}"+param+"[0-2][0-9]"+param+"[0-3][0-9]$");
  5846. return reg.test(trim(value));
  5847. };
  5848. Validate.setRule("date", date, '请填写正确的日期');
  5849. var time = function(value, element, param) {
  5850. return (/^[0-2]\d:[0-6]\d$/).test(trim(value));
  5851. };
  5852. Validate.setRule("time", time, '请填写正确的时间');
  5853. var datetime = function(value, element, param) {
  5854. var reg = new RegExp("^[1|2]\\d{3}-[0-2][0-9]-[0-3][0-9] [0-2]\\d:[0-6]\\d$");
  5855. return reg.test(trim(value));
  5856. };
  5857. Validate.setRule("datetime", datetime, '请填写正确的日期和时间');
  5858. var url = function(value, element, param) {
  5859. var urlPattern;
  5860. value = trim(value);
  5861. urlPattern = /(http|ftp|https):\/\/([\w-]+\.)+[\w-]+\.(com|net|cn|org|me|io|info|xxx)/;
  5862. if (!/^http/.test(value)) {
  5863. value = 'http://' + value;
  5864. }
  5865. return urlPattern.test(value);
  5866. };
  5867. Validate.setRule("url", url, '请填写正确的网址');
  5868. var minlength = function(value, element, param) {
  5869. return trim(value).length >= param;
  5870. };
  5871. Validate.setRule("minlength", minlength, '长度不能少于$0');
  5872. var maxlength = function(value, element, param) {
  5873. return trim(value).length <= param;
  5874. };
  5875. Validate.setRule("maxlength", maxlength, '长度不能超过$0');
  5876. var gt = function(value, element, param) {
  5877. return Number(value) > param;
  5878. };
  5879. Validate.setRule("gt", gt, '必须大于$0');
  5880. var lt = function(value, element, param) {
  5881. return Number(value) < param;
  5882. };
  5883. Validate.setRule("lt", lt, '必须小于$0');
  5884. }(window.jQuery)
  5885. },{}],20:[function(require,module,exports){
  5886. /*
  5887. * validate 核心函数,只提供框架,不提供校验规则
  5888. */
  5889. !function($) {
  5890. 'use strict';
  5891. var Validate = function(form, options) {
  5892. var self = this;
  5893. this.options = $.extend({}, $.fn.validate.defaults, options)
  5894. this.$form = $(form).attr("novalidate", 'novalidate');
  5895. this.$form.submit(function() {
  5896. // Load Layer;
  5897. var layIndex = layer.load(2);
  5898. var flag = onsubmit.call(self);
  5899. if (!flag) {
  5900. layer.close(layIndex);
  5901. }
  5902. return flag;
  5903. });
  5904. this.disabled = false;
  5905. this.$form.on('blur keyup change update', 'input, select, textarea', function(e) {
  5906. if(self.disabled) return;
  5907. var $target = $(e.target);
  5908. if ($target.attr("disabled")) return;
  5909. update.call(self, $target);
  5910. });
  5911. this.errors = {};
  5912. };
  5913. Validate.rules = {};
  5914. Validate.setRule = function(name, method, msg) {
  5915. var oldRule = Validate.rules[name];
  5916. if (oldRule && !method) {
  5917. method = oldRule.method
  5918. }
  5919. Validate.rules[name] = {
  5920. method: method,
  5921. msg: msg
  5922. };
  5923. };
  5924. Validate.setMsg = function(name, msg) {
  5925. Validate.setRule(name, undefined, msg)
  5926. }
  5927. Validate.prototype = {
  5928. disable: function() {
  5929. this.disabled = true;
  5930. this.hideError();
  5931. },
  5932. enable: function() {
  5933. this.disabled = false;
  5934. },
  5935. showError: function($input, errorMsg, errorName) {
  5936. showError.call(this, $input, errorMsg, errorName);
  5937. },
  5938. hideError: function($input, errorName) {
  5939. hideError.call(this, $input, errorName);
  5940. }
  5941. }
  5942. var onsubmit = function() {
  5943. if(this.disabled) return true;
  5944. var hasError, self;
  5945. self = this;
  5946. hasError = false;
  5947. var errorInputs = [];
  5948. this.$form.find("input, select, textarea").each(function() {
  5949. var $input, error;
  5950. $input = $(this);
  5951. error = update.call(self, this);
  5952. if (error && !hasError) {
  5953. $input.focus();
  5954. }
  5955. if (error) {
  5956. errorInputs.push($input);
  5957. return hasError = true;
  5958. }
  5959. });
  5960. if (hasError) {
  5961. this.options.fail.call(this, errorInputs, this.$form);
  5962. } else {
  5963. var result = this.options.success.call(this, this.$form);
  5964. if (result === false) {
  5965. return false;
  5966. }
  5967. }
  5968. return !hasError;
  5969. };
  5970. var update = function(input) {
  5971. var $input = $(input);
  5972. var rules = {};
  5973. var dataRules = ($input.data("rules") || "").split('|');
  5974. var inputName = $input.attr("name");
  5975. for (var i = 0; i < dataRules.length; i++) {
  5976. if (!dataRules[i]) continue;
  5977. var tokens = dataRules[i].split('=');
  5978. tokens[1] = tokens[1] || undefined;
  5979. rules[tokens[0]] = tokens[1];
  5980. }
  5981. var configRules = (this.options.rules && this.options.rules[inputName]) || {};
  5982. rules = $.extend(rules, configRules)
  5983. var error = false;
  5984. var msg = null;
  5985. for (var name in rules) {
  5986. var value = rules[name];
  5987. var currentRule = Validate.rules[name];
  5988. if (!currentRule) { //未定义的rule
  5989. throw new Error("未定义的校验规则:" + name);
  5990. }
  5991. var inputVal = val($input);
  5992. if ((!inputVal) && name !== 'required') { //特殊处理,如果当前输入框没有值,并且当前不是required,则不报错
  5993. error = false;
  5994. hideError.call(this, $input);
  5995. continue
  5996. }
  5997. var result = true
  5998. // 如果规则值是一个函数,则直接用此函数的返回值
  5999. if ($.isFunction(value)) {
  6000. result = value.call(this, $input)
  6001. } else {
  6002. result = currentRule.method.call(this, inputVal, $input, value)
  6003. }
  6004. if (result) {
  6005. error = false;
  6006. hideError.call(this, $input, name);
  6007. } else {
  6008. error = true;
  6009. msg = currentRule.msg;
  6010. if ($.isFunction(msg)) msg = msg($input, value)
  6011. //如果不是required规则,则可以使用自定义错误消息
  6012. if(name !== 'required') {
  6013. if($input.data("error-msg")) {
  6014. msg = $input.data("error-msg")
  6015. }
  6016. if (this.options.messages && this.options.messages[inputName]) {
  6017. msg = this.options.messages[inputName]
  6018. if ($.isFunction(msg)) msg = msg($input, value)
  6019. if ($.isArray(msg)) msg = msg[1]
  6020. }
  6021. }
  6022. //如果是required规则
  6023. if(name === 'required') {
  6024. if($input.data("empty-msg")) {
  6025. msg = $input.data("empty-msg")
  6026. }
  6027. if (this.options.messages && this.options.messages[inputName]) {
  6028. var _msg = this.options.messages[inputName]
  6029. if ($.isFunction(_msg)) _msg = msg($input, value)
  6030. if ($.isArray(_msg)) msg = _msg[0]
  6031. }
  6032. }
  6033. this.showError($input, msg.replace('$0', value), name);
  6034. break;
  6035. }
  6036. }
  6037. return error;
  6038. };
  6039. var showError = function($input, errorMsg, errorName) {
  6040. errorName = errorName || "anonymous" //匿名的,一般是手动调用showError并且没有指定一个名称时候会显示一个匿名的错误
  6041. if (typeof $input === typeof "a") $input = this.$form.find("[name='"+$input+"']");
  6042. $input = $($input);
  6043. var inputName = $input.attr("name")
  6044. var $errors = this.errors[inputName] || (this.errors[inputName] = {});
  6045. var $currentError = $errors[errorName]
  6046. if (!$currentError) {
  6047. $currentError = ($errors[errorName] = $(this.options.errorTpl.replace("$errorMsg", errorMsg)));
  6048. this.options.placeError.call(this, $input, $currentError);
  6049. }
  6050. for (var k in $errors) {
  6051. if (k !== errorName) $errors[k].hide()
  6052. }
  6053. this.options.highlight.call(this, $input, $currentError, this.options.inputErrorClass)
  6054. $input.trigger("highlight");
  6055. };
  6056. var hideError = function($input, errorName) {
  6057. var self = this;
  6058. var hideInputAllError = function($input) {
  6059. var $errors = self.errors[$input.attr('name')];
  6060. for(var k in $errors) {
  6061. self.options.unhighlight.call(self, $input, $errors[k], self.options.inputErrorClass);
  6062. }
  6063. }
  6064. if(!$input) { //没有任何参数,则隐藏所有的错误
  6065. this.$form.find('input, select, textarea').each(function() {
  6066. var $this = $(this);
  6067. if ($this.attr("disabled")) return;
  6068. hideInputAllError($this);
  6069. });
  6070. }
  6071. if (typeof $input === typeof "a") $input = this.$form.find("[name='"+$input+"']");
  6072. $input = $($input);
  6073. var $errors = this.errors[$input.attr('name')];
  6074. if (!$errors) return;
  6075. if (!errorName) {
  6076. //未指定errorName则隐藏所有ErrorMsg
  6077. hideInputAllError($input);
  6078. return;
  6079. }
  6080. var $error = $errors[errorName];
  6081. if (!$error) return;
  6082. this.options.unhighlight.call(this, $input, $error, this.options.inputErrorClass)
  6083. $input.trigger("unhighlight");
  6084. };
  6085. //根据不同的input类型来取值
  6086. var val = function(input) {
  6087. var $input = $(input);
  6088. if (!$input[0]) return undefined;
  6089. var tagName = $input[0].tagName.toUpperCase();
  6090. var type = ($input.attr("type") || 'text').toUpperCase()
  6091. var name = $input.attr("name")
  6092. var $form = $input.parents("form")
  6093. switch(tagName) {
  6094. case 'INPUT':
  6095. switch(type) {
  6096. case 'CHECKBOX':
  6097. case 'RADIO':
  6098. return $form.find("[name='"+name+"']:checked").val()
  6099. default:
  6100. return $input.val()
  6101. }
  6102. break;
  6103. case 'TEXTAREA':
  6104. return $input.val()
  6105. break;
  6106. default:
  6107. return $input.val()
  6108. }
  6109. }
  6110. var old = $.fn.validate;
  6111. $.fn.extend({
  6112. validate: function (options) {
  6113. var args = arguments;
  6114. return this.each(function() {
  6115. var $this = $(this),
  6116. data = $this.data("validate")
  6117. if (!data) $this.data('validate', (data = new Validate(this, options)))
  6118. if (typeof options == 'string') data[options].apply(data, Array.prototype.slice.call(args, 1));
  6119. })
  6120. }
  6121. })
  6122. $.fn.validate.Constructor = Validate
  6123. $.fn.validate.defaults = {
  6124. errorTpl: '<div class="sui-msg msg-error help-inline">\n <div class="msg-con">\n <span>$errorMsg</span>\n </div> <i class="msg-icon"></i>\n \n</div>',
  6125. inputErrorClass: 'input-error',
  6126. placeError: function($input, $error) {
  6127. $input = $($input);
  6128. var $wrap = $input.parents(".controls-wrap");
  6129. if (!$wrap[0]) {
  6130. $wrap = $input.parents(".controls");
  6131. }
  6132. if(!$wrap[0]) {
  6133. $wrap = $input.parent();
  6134. }
  6135. $error.appendTo($wrap[0]);
  6136. },
  6137. highlight: function($input, $error, inputErrorClass) {
  6138. $input.addClass(inputErrorClass)
  6139. //使多控件校验规则错误框可以自动定位出错的控件位置,先将自身移动去该位置附近显示
  6140. //对单体校验控件,因为是自身append到自身的位置,native不会有行为
  6141. $.fn.validate.defaults.placeError($input, $error);
  6142. $error.show()
  6143. },
  6144. unhighlight: function($input, $error, inputErrorClass) {
  6145. if(!$error.is(":visible")) return;
  6146. $input.removeClass(inputErrorClass)
  6147. $error.hide()
  6148. },
  6149. rules: undefined,
  6150. messages: undefined,
  6151. success: $.noop,
  6152. fail: $.noop
  6153. };
  6154. $.fn.validate.noConflict = function () {
  6155. $.fn.validate = old
  6156. return this
  6157. }
  6158. $.validate = Validate;
  6159. //自动加载
  6160. $(function() {
  6161. $(".sui-validate").validate()
  6162. })
  6163. }(window.jQuery);
  6164. },{}]},{},[12])