12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184 |
- /*!
- * DevExtreme
- * Version: 14.1.9-pre
- * Build date: Nov 7, 2014
- *
- * Copyright (c) 2012 - 2014 Developer Express Inc. ALL RIGHTS RESERVED
- * EULA: https://www.devexpress.com/Support/EULAs/DevExtreme.xml
- */
- "use strict";
- if (!window.DevExpress) {
- /*! Module core, file devexpress.js */
- (function($, global, undefined) {
- (function checkjQueryVersion(version) {
- version = version.split(".");
- if (version[0] < 1 || version[0] == 1 && version[1] < 10)
- throw Error("Your version of jQuery is too old. Please upgrade jQuery to 1.10.0 or later.");
- })($.fn.jquery);
- var Class = function() {
- var wrapOverridden = function(baseProto, methodName, method) {
- return function() {
- var prevCallBase = this.callBase;
- this.callBase = baseProto[methodName];
- try {
- return method.apply(this, arguments)
- }
- finally {
- this.callBase = prevCallBase
- }
- }
- };
- var clonePrototype = function(obj) {
- var func = function(){};
- func.prototype = obj.prototype;
- return new func
- };
- var classImpl = function(){};
- var redefine = function(members) {
- var that = this;
- if (!members)
- return that;
- var memberNames = $.map(members, function(_, k) {
- return k
- });
- $.each(["toString", "toLocaleString", "valueOf"], function() {
- if (members[this])
- memberNames.push(this)
- });
- $.each(memberNames, function() {
- var overridden = $.isFunction(that.prototype[this]) && $.isFunction(members[this]);
- that.prototype[this] = overridden ? wrapOverridden(that.parent.prototype, this, members[this]) : members[this]
- });
- return that
- };
- var include = function() {
- var classObj = this;
- $.each(arguments, function() {
- if (this.ctor)
- classObj._includedCtors.push(this.ctor);
- for (var name in this) {
- if (name === "ctor")
- continue;
- if (name in classObj.prototype)
- throw Error("Member name collision: " + name);
- classObj.prototype[name] = this[name]
- }
- });
- return classObj
- };
- var subclassOf = function(parentClass) {
- if (this.parent === parentClass)
- return true;
- if (!this.parent || !this.parent.subclassOf)
- return false;
- return this.parent.subclassOf(parentClass)
- };
- classImpl.inherit = function(members) {
- var inheritor = function() {
- if (!this || this === global || typeof this.constructor !== "function")
- throw Error("A class must be instantiated using the 'new' keyword");
- var instance = this,
- ctor = instance.ctor;
- if (ctor)
- ctor.apply(instance, arguments);
- $.each(instance.constructor._includedCtors, function() {
- this.call(instance)
- })
- };
- inheritor.prototype = clonePrototype(this);
- inheritor.inherit = this.inherit;
- inheritor.redefine = redefine;
- inheritor.include = include;
- inheritor.subclassOf = subclassOf;
- inheritor.parent = this;
- inheritor._includedCtors = this._includedCtors ? this._includedCtors.slice(0) : [];
- inheritor.prototype.constructor = inheritor;
- inheritor.redefine(members);
- return inheritor
- };
- return classImpl
- }();
- function createQueue(discardPendingTasks) {
- var _tasks = [],
- _busy = false;
- function exec() {
- while (_tasks.length) {
- _busy = true;
- var task = _tasks.shift(),
- result = task();
- if (result === undefined)
- continue;
- if (result.then) {
- $.when(result).always(exec);
- return
- }
- throw Error("Queued task returned unexpected result");
- }
- _busy = false
- }
- function add(task, removeTaskCallback) {
- if (!discardPendingTasks)
- _tasks.push(task);
- else {
- if (_tasks[0] && removeTaskCallback)
- removeTaskCallback(_tasks[0]);
- _tasks = [task]
- }
- if (!_busy)
- exec()
- }
- function busy() {
- return _busy
- }
- return {
- add: add,
- busy: busy
- }
- }
- var parseUrl = function() {
- var a = document.createElement("a"),
- props = ["protocol", "hostname", "port", "pathname", "search", "hash"];
- var normalizePath = function(value) {
- if (value.charAt(0) !== "/")
- value = "/" + value;
- return value
- };
- return function(url) {
- a.href = url;
- var result = {};
- $.each(props, function() {
- result[this] = a[this]
- });
- result.pathname = normalizePath(result.pathname);
- return result
- }
- }();
- global.DevExpress = global.DevExpress || {};
- var enqueueAsync = function(task) {
- var deferred = $.Deferred();
- setTimeout(function() {
- deferred.resolve(task())
- }, 60);
- return deferred
- };
- var hideTopOverlayCallback = function() {
- var callbacks = [];
- return {
- add: function(callback) {
- var indexOfCallback = $.inArray(callback, callbacks);
- if (indexOfCallback === -1)
- callbacks.push(callback)
- },
- remove: function(callback) {
- var indexOfCallback = $.inArray(callback, callbacks);
- if (indexOfCallback !== -1)
- callbacks.splice(indexOfCallback, 1)
- },
- fire: function() {
- var callback = callbacks.pop(),
- result = !!callback;
- if (result)
- callback();
- return result
- },
- hasCallback: function() {
- return callbacks.length > 0
- },
- reset: function() {
- callbacks = []
- }
- }
- }();
- var overlayTargetContainer = function() {
- var defaultTargetContainer = "body";
- return function(targetContainer) {
- if (arguments.length)
- defaultTargetContainer = targetContainer;
- return defaultTargetContainer
- }
- }();
- $.extend(global.DevExpress, {
- VERSION: "14.1.8",
- abstract: function() {
- throw Error("Not implemented");
- },
- Class: Class,
- createQueue: createQueue,
- enqueue: createQueue().add,
- enqueueAsync: enqueueAsync,
- parseUrl: parseUrl,
- hideTopOverlayCallback: hideTopOverlayCallback,
- hardwareBackButton: $.Callbacks(),
- overlayTargetContainer: overlayTargetContainer,
- rtlEnabled: false
- })
- })(jQuery, this);
- /*! Module core, file inflector.js */
- (function($, DX, undefined) {
- var _normalize = function(text) {
- if (text === undefined || text === null)
- return "";
- return String(text)
- };
- var _ucfirst = function(text) {
- return _normalize(text).charAt(0).toUpperCase() + text.substr(1)
- };
- var _chop = function(text) {
- return _normalize(text).replace(/([a-z\d])([A-Z])/g, "$1 $2").split(/[\s_-]+/)
- };
- var dasherize = function(text) {
- return $.map(_chop(text), function(p) {
- return p.toLowerCase()
- }).join("-")
- };
- var underscore = function(text) {
- return dasherize(text).replace(/-/g, "_")
- };
- var camelize = function(text, upperFirst) {
- return $.map(_chop(text), function(p, i) {
- p = p.toLowerCase();
- if (upperFirst || i > 0)
- p = _ucfirst(p);
- return p
- }).join("")
- };
- var humanize = function(text) {
- return _ucfirst(dasherize(text).replace(/-/g, " "))
- };
- var titleize = function(text) {
- return $.map(_chop(text), function(p) {
- return _ucfirst(p.toLowerCase())
- }).join(" ")
- };
- DX.inflector = {
- dasherize: dasherize,
- camelize: camelize,
- humanize: humanize,
- titleize: titleize,
- underscore: underscore
- }
- })(jQuery, DevExpress);
- /*! Module core, file utils.common.js */
- (function($, DX, undefined) {
- var isDefined = function(object) {
- return object !== null && object !== undefined
- };
- var isString = function(object) {
- return $.type(object) === 'string'
- };
- var isNumber = function(object) {
- return typeof object === "number" && isFinite(object) || $.isNumeric(object)
- };
- var isObject = function(object) {
- return $.type(object) === 'object'
- };
- var isArray = function(object) {
- return $.type(object) === 'array'
- };
- var isDate = function(object) {
- return $.type(object) === 'date'
- };
- var isFunction = function(object) {
- return $.type(object) === 'function'
- };
- var isExponential = function(value) {
- return isNumber(value) && value.toString().indexOf('e') !== -1
- };
- var extendFromObject = function(target, source, overrideExistingValues) {
- target = target || {};
- for (var prop in source)
- if (source.hasOwnProperty(prop)) {
- var value = source[prop];
- if (!(prop in target) || overrideExistingValues)
- target[prop] = value
- }
- return target
- };
- var clone = function() {
- function Clone(){}
- return function(obj) {
- Clone.prototype = obj;
- return new Clone
- }
- }();
- var executeAsync = function(action, context) {
- var deferred = $.Deferred(),
- normalizedContext = context || this;
- setTimeout(function() {
- var result = action.call(normalizedContext);
- if (result && result.done && $.isFunction(result.done))
- result.done(function() {
- deferred.resolveWith(normalizedContext)
- });
- else
- deferred.resolveWith(normalizedContext)
- }, 0);
- return deferred.promise()
- };
- var stringFormat = function() {
- var s = arguments[0];
- for (var i = 0; i < arguments.length - 1; i++) {
- var reg = new RegExp("\\{" + i + "\\}", "gm");
- s = s.replace(reg, arguments[i + 1])
- }
- return s
- };
- var findBestMatches = function(targetFilter, items, mapFn) {
- var bestMatches = [],
- maxMatchCount = 0;
- $.each(items, function(index, itemSrc) {
- var matchCount = 0,
- item = mapFn ? mapFn(itemSrc) : itemSrc;
- $.each(targetFilter, function(paramName) {
- var value = item[paramName];
- if (value === undefined)
- return;
- if (value === targetFilter[paramName]) {
- matchCount++;
- return
- }
- matchCount = -1;
- return false
- });
- if (matchCount < maxMatchCount)
- return;
- if (matchCount > maxMatchCount) {
- bestMatches.length = 0;
- maxMatchCount = matchCount
- }
- bestMatches.push(itemSrc)
- });
- return bestMatches
- };
- var preg_quote = function(str) {
- return (str + "").replace(/([\+\*\?\\\.\[\^\]\$\(\)\{\}\>\<\|\=\!\:])/g, "\\$1")
- };
- var replaceAll = function(text, searchToken, replacementToken) {
- return text.replace(new RegExp("(" + preg_quote(searchToken) + ")", "gi"), replacementToken)
- };
- var splitPair = function(raw) {
- switch (typeof raw) {
- case"string":
- return raw.split(/\s+/, 2);
- case"object":
- return [raw.x || raw.h, raw.y || raw.v];
- case"number":
- return [raw];
- default:
- return raw
- }
- };
- var stringPairToObject = function(raw) {
- var pair = splitPair(raw),
- x = parseInt(pair && pair[0], 10),
- y = parseInt(pair && pair[1], 10);
- if (!isFinite(x))
- x = 0;
- if (!isFinite(y))
- y = x;
- return {
- x: x,
- y: y
- }
- };
- function icontains(elem, text) {
- var result = false;
- $.each($(elem).contents(), function(index, content) {
- if (content.nodeType === 3 && (content.textContent || content.nodeValue || "").toLowerCase().indexOf((text || "").toLowerCase()) > -1) {
- result = true;
- return false
- }
- });
- return result
- }
- $.expr[":"].dxicontains = $.expr.createPseudo(function(text) {
- return function(elem) {
- return icontains(elem, text)
- }
- });
- function deepExtendArraySafe(target, changes) {
- var prevValue,
- newValue;
- for (var name in changes) {
- prevValue = target[name];
- newValue = changes[name];
- if (target === newValue)
- continue;
- if ($.isPlainObject(newValue) && !(newValue instanceof $.Event))
- target[name] = deepExtendArraySafe($.isPlainObject(prevValue) ? prevValue : {}, newValue);
- else if (newValue !== undefined)
- target[name] = newValue
- }
- return target
- }
- function unwrapObservable(value) {
- if (DX.support.hasKo)
- return ko.utils.unwrapObservable(value);
- return value
- }
- DX.utils = {
- isDefined: isDefined,
- isString: isString,
- isNumber: isNumber,
- isObject: isObject,
- isArray: isArray,
- isDate: isDate,
- isFunction: isFunction,
- isExponential: isExponential,
- extendFromObject: extendFromObject,
- clone: clone,
- executeAsync: executeAsync,
- stringFormat: stringFormat,
- findBestMatches: findBestMatches,
- replaceAll: replaceAll,
- deepExtendArraySafe: deepExtendArraySafe,
- splitPair: splitPair,
- stringPairToObject: stringPairToObject,
- unwrapObservable: unwrapObservable
- }
- })(jQuery, DevExpress);
- /*! Module core, file utils.console.js */
- (function($, DX, undefined) {
- var logger = function() {
- var console = window.console;
- function info(text) {
- if (!console || !$.isFunction(console.info))
- return;
- console.info(text)
- }
- function warn(text) {
- if (!console || !$.isFunction(console.warn))
- return;
- console.warn(text)
- }
- function error(text) {
- if (!console || !$.isFunction(console.error))
- return;
- console.error(text)
- }
- return {
- info: info,
- warn: warn,
- error: error
- }
- }();
- var debug = function() {
- function assert(condition, message) {
- if (!condition)
- throw new Error(message);
- }
- function assertParam(parameter, message) {
- assert(parameter !== null && parameter !== undefined, message)
- }
- return {
- assert: assert,
- assertParam: assertParam
- }
- }();
- $.extend(DX.utils, {
- logger: logger,
- debug: debug
- })
- })(jQuery, DevExpress);
- /*! Module core, file utils.math.js */
- (function($, DX, undefined) {
- var PI = Math.PI,
- LN10 = Math.LN10;
- var cos = Math.cos,
- sin = Math.sin,
- abs = Math.abs,
- log = Math.log,
- floor = Math.floor,
- ceil = Math.ceil,
- max = Math.max,
- min = Math.min,
- isNaN = window.isNaN,
- Number = window.Number,
- NaN = window.NaN;
- var isNumber = DX.utils.isNumber,
- isExponential = DX.utils.isExponential;
- var getPrecision = function(value) {
- var stringFraction,
- stringValue = value.toString(),
- pointIndex = stringValue.indexOf('.'),
- startIndex,
- precision;
- if (isExponential(value)) {
- precision = getDecimalOrder(value);
- if (precision < 0)
- return Math.abs(precision);
- else
- return 0
- }
- if (pointIndex !== -1) {
- startIndex = pointIndex + 1;
- stringFraction = stringValue.substring(startIndex, startIndex + 20);
- return stringFraction.length
- }
- return 0
- };
- var getLog = function(value, base) {
- if (!value)
- return 0;
- return Math.log(value) / Math.log(base)
- };
- var raiseTo = function(power, base) {
- return Math.pow(base, power)
- };
- var sign = function(value) {
- if (value === 0)
- return 0;
- return value / abs(value)
- };
- var normalizeAngle = function(angle) {
- return (angle % 360 + 360) % 360
- };
- var convertAngleToRendererSpace = function(angle) {
- return 90 - angle
- };
- var degreesToRadians = function(value) {
- return PI * value / 180
- };
- var getCosAndSin = function(angle) {
- var angleInRadians = degreesToRadians(angle);
- return {
- cos: cos(angleInRadians),
- sin: sin(angleInRadians)
- }
- };
- var DECIMAL_ORDER_THRESHOLD = 1E-14;
- var getDecimalOrder = function(number) {
- var n = abs(number),
- cn;
- if (!isNaN(n)) {
- if (n > 0) {
- n = log(n) / LN10;
- cn = ceil(n);
- return cn - n < DECIMAL_ORDER_THRESHOLD ? cn : floor(n)
- }
- return 0
- }
- return NaN
- };
- var getAppropriateFormat = function(start, end, count) {
- var order = max(getDecimalOrder(start), getDecimalOrder(end)),
- precision = -getDecimalOrder(abs(end - start) / count),
- format;
- if (!isNaN(order) && !isNaN(precision)) {
- if (abs(order) <= 4) {
- format = 'fixedPoint';
- precision < 0 && (precision = 0);
- precision > 4 && (precision = 4)
- }
- else {
- format = 'exponential';
- precision += order - 1;
- precision > 3 && (precision = 3)
- }
- return {
- format: format,
- precision: precision
- }
- }
- return null
- };
- var getFraction = function(value) {
- var valueString,
- dotIndex;
- if (isNumber(value)) {
- valueString = value.toString();
- dotIndex = valueString.indexOf('.');
- if (dotIndex >= 0)
- if (isExponential(value))
- return valueString.substr(dotIndex + 1, valueString.indexOf('e') - dotIndex - 1);
- else {
- valueString = value.toFixed(20);
- return valueString.substr(dotIndex + 1, valueString.length - dotIndex + 1)
- }
- }
- return ''
- };
- var getSignificantDigitPosition = function(value) {
- var fraction = getFraction(value),
- i;
- if (fraction)
- for (i = 0; i < fraction.length; i++)
- if (fraction.charAt(i) !== '0')
- return i + 1;
- return 0
- };
- var adjustValue = function(value) {
- var fraction = getFraction(value),
- nextValue,
- i;
- if (fraction)
- for (i = 1; i <= fraction.length; i++) {
- nextValue = roundValue(value, i);
- if (nextValue !== 0 && fraction[i - 2] && fraction[i - 1] && fraction[i - 2] === fraction[i - 1])
- return nextValue
- }
- return value
- };
- var roundValue = function(value, precision) {
- if (precision > 20)
- precision = 20;
- if (isNumber(value))
- if (isExponential(value))
- return Number(value.toExponential(precision));
- else
- return Number(value.toFixed(precision))
- };
- var applyPrecisionByMinDelta = function(min, delta, value) {
- var minPrecision = getPrecision(min),
- deltaPrecision = getPrecision(delta);
- return roundValue(value, minPrecision < deltaPrecision ? deltaPrecision : minPrecision)
- };
- $.extend(DX.utils, {
- getLog: getLog,
- raiseTo: raiseTo,
- sign: sign,
- normalizeAngle: normalizeAngle,
- convertAngleToRendererSpace: convertAngleToRendererSpace,
- degreesToRadians: degreesToRadians,
- getCosAndSin: getCosAndSin,
- getDecimalOrder: getDecimalOrder,
- getAppropriateFormat: getAppropriateFormat,
- getFraction: getFraction,
- adjustValue: adjustValue,
- roundValue: roundValue,
- applyPrecisionByMinDelta: applyPrecisionByMinDelta,
- getSignificantDigitPosition: getSignificantDigitPosition
- });
- DX.utils.getPrecision = getPrecision
- })(jQuery, DevExpress);
- /*! Module core, file utils.date.js */
- (function($, DX, undefined) {
- var isObject = DX.utils.isObject,
- isString = DX.utils.isString,
- isDate = DX.utils.isDate,
- isDefined = DX.utils.isDefined;
- var dateUnitIntervals = ['millisecond', 'second', 'minute', 'hour', 'day', 'week', 'month', 'quarter', 'year'];
- var addSubValues = function(value1, value2, isSub) {
- return value1 + (isSub ? -1 : 1) * value2
- };
- var toMilliseconds = function(value) {
- switch (value) {
- case'millisecond':
- return 1;
- case'second':
- return toMilliseconds('millisecond') * 1000;
- case'minute':
- return toMilliseconds('second') * 60;
- case'hour':
- return toMilliseconds('minute') * 60;
- case'day':
- return toMilliseconds('hour') * 24;
- case'week':
- return toMilliseconds('day') * 7;
- case'month':
- return toMilliseconds('day') * 30;
- case'quarter':
- return toMilliseconds('month') * 3;
- case'year':
- return toMilliseconds('day') * 365;
- default:
- return 0
- }
- };
- function parseISO8601(isoString) {
- var result = new Date(0);
- var chunks = isoString.replace("Z", "").split("T"),
- date = String(chunks[0]).split("-"),
- time = String(chunks[1]).split(":");
- var year,
- month,
- day,
- hours,
- minutes,
- seconds,
- milliseconds;
- year = Number(date[0]);
- month = Number(date[1]) - 1;
- day = Number(date[2]);
- result.setDate(day);
- result.setMonth(month);
- result.setFullYear(year);
- if (time.length) {
- hours = Number(time[0]);
- minutes = Number(time[1]);
- seconds = Number(String(time[2]).split(".")[0]);
- milliseconds = Number(String(time[2]).split(".")[1]) || 0;
- result.setHours(hours);
- result.setMinutes(minutes);
- result.setSeconds(seconds);
- result.setMilliseconds(milliseconds)
- }
- return result
- }
- function formatISO8601(date) {
- function pad(n) {
- if (n < 10)
- return "0".concat(n);
- return String(n)
- }
- return [date.getFullYear(), "-", pad(date.getMonth() + 1), "-", pad(date.getDate()), "T", pad(date.getHours()), ":", pad(date.getMinutes()), ":", pad(date.getSeconds()), "Z"].join("")
- }
- var convertMillisecondsToDateUnits = function(value) {
- var i,
- dateUnitCount,
- dateUnitInterval,
- dateUnitIntervals = ['millisecond', 'second', 'minute', 'hour', 'day', 'month', 'year'],
- result = {};
- for (i = dateUnitIntervals.length - 1; i >= 0; i--) {
- dateUnitInterval = dateUnitIntervals[i];
- dateUnitCount = Math.floor(value / toMilliseconds(dateUnitInterval));
- if (dateUnitCount > 0) {
- result[dateUnitInterval + 's'] = dateUnitCount;
- value -= convertDateUnitToMilliseconds(dateUnitInterval, dateUnitCount)
- }
- }
- return result
- };
- var convertDateTickIntervalToMilliseconds = function(tickInterval) {
- var milliseconds = 0;
- if (isObject(tickInterval))
- $.each(tickInterval, function(key, value) {
- milliseconds += convertDateUnitToMilliseconds(key.substr(0, key.length - 1), value)
- });
- if (isString(tickInterval))
- milliseconds = convertDateUnitToMilliseconds(tickInterval, 1);
- return milliseconds
- };
- var convertDateUnitToMilliseconds = function(dateUnit, count) {
- return toMilliseconds(dateUnit) * count
- };
- var getDateUnitInterval = function(tickInterval) {
- var maxInterval = -1,
- i;
- if (isString(tickInterval))
- return tickInterval;
- if (isObject(tickInterval)) {
- $.each(tickInterval, function(key, value) {
- for (i = 0; i < dateUnitIntervals.length; i++)
- if (value && (key === dateUnitIntervals[i] + 's' || key === dateUnitIntervals[i]) && maxInterval < i)
- maxInterval = i
- });
- return dateUnitIntervals[maxInterval]
- }
- return ''
- };
- var correctDateWithUnitBeginning = function(date, dateInterval) {
- var dayMonth,
- firstQuarterMonth,
- dateUnitInterval = getDateUnitInterval(dateInterval);
- switch (dateUnitInterval) {
- case'second':
- date.setMilliseconds(0);
- break;
- case'minute':
- date.setSeconds(0, 0);
- break;
- case'hour':
- date.setMinutes(0, 0, 0);
- break;
- case'year':
- date.setMonth(0);
- case'month':
- date.setDate(1);
- case'day':
- date.setHours(0, 0, 0, 0);
- break;
- case'week':
- dayMonth = date.getDate();
- if (date.getDay() !== 0)
- dayMonth += 7 - date.getDay();
- date.setDate(dayMonth);
- date.setHours(0, 0, 0, 0);
- break;
- case'quarter':
- firstQuarterMonth = DX.formatHelper.getFirstQuarterMonth(date.getMonth());
- if (date.getMonth() !== firstQuarterMonth)
- date.setMonth(firstQuarterMonth);
- date.setDate(1);
- date.setHours(0, 0, 0, 0);
- break
- }
- };
- var getDatesDifferences = function(date1, date2) {
- var differences,
- counter = 0;
- differences = {
- year: date1.getFullYear() !== date2.getFullYear(),
- month: date1.getMonth() !== date2.getMonth(),
- day: date1.getDate() !== date2.getDate(),
- hour: date1.getHours() !== date2.getHours(),
- minute: date1.getMinutes() !== date2.getMinutes(),
- second: date1.getSeconds() !== date2.getSeconds()
- };
- $.each(differences, function(key, value) {
- if (value)
- counter++
- });
- differences.count = counter;
- return differences
- };
- var addInterval = function(value, interval, isNegative) {
- var result = null,
- intervalObject;
- if (isDate(value)) {
- intervalObject = isString(interval) ? getDateIntervalByString(interval.toLowerCase()) : interval;
- result = new Date(value.getTime());
- if (intervalObject.years)
- result.setFullYear(addSubValues(result.getFullYear(), intervalObject.years, isNegative));
- if (intervalObject.quarters)
- result.setMonth(addSubValues(result.getMonth(), 3 * intervalObject.quarters, isNegative));
- if (intervalObject.months)
- result.setMonth(addSubValues(result.getMonth(), intervalObject.months, isNegative));
- if (intervalObject.weeks)
- result.setDate(addSubValues(result.getDate(), 7 * intervalObject.weeks, isNegative));
- if (intervalObject.days)
- result.setDate(addSubValues(result.getDate(), intervalObject.days, isNegative));
- if (intervalObject.hours)
- result.setHours(addSubValues(result.getHours(), intervalObject.hours, isNegative));
- if (intervalObject.minutes)
- result.setMinutes(addSubValues(result.getMinutes(), intervalObject.minutes, isNegative));
- if (intervalObject.seconds)
- result.setSeconds(addSubValues(result.getSeconds(), intervalObject.seconds, isNegative));
- if (intervalObject.milliseconds)
- result.setMilliseconds(addSubValues(value.getMilliseconds(), intervalObject.milliseconds, isNegative))
- }
- else
- result = addSubValues(value, interval, isNegative);
- return result
- };
- var getDateIntervalByString = function(intervalString) {
- var result = {};
- switch (intervalString) {
- case'year':
- result.years = 1;
- break;
- case'month':
- result.months = 1;
- break;
- case'quarter':
- result.months = 3;
- break;
- case'week':
- result.days = 7;
- break;
- case'day':
- result.days = 1;
- break;
- case'hour':
- result.hours = 1;
- break;
- case'minute':
- result.minutes = 1;
- break;
- case'second':
- result.seconds = 1;
- break;
- case'millisecond':
- result.milliseconds = 1;
- break
- }
- return result
- };
- var sameMonthAndYear = function(date1, date2) {
- return date1 && date2 && date1.getFullYear() === date2.getFullYear() && date1.getMonth() === date2.getMonth()
- };
- var getFirstMonthDate = function(date) {
- return new Date(date.getFullYear(), date.getMonth(), 1)
- };
- var dateInRange = function(date, min, max) {
- return normalizeDate(date, min, max) === date
- };
- var normalizeDate = function(date, min, max) {
- var normalizedDate = date;
- if (isDefined(min) && date < min)
- normalizedDate = min;
- if (isDefined(max) && date > max)
- normalizedDate = max;
- return normalizedDate
- };
- var getPower = function(value) {
- return value.toExponential().split("e")[1]
- };
- $.extend(DX.utils, {
- dateUnitIntervals: dateUnitIntervals,
- parseIso8601Date: parseISO8601,
- formatIso8601Date: formatISO8601,
- convertMillisecondsToDateUnits: convertMillisecondsToDateUnits,
- convertDateTickIntervalToMilliseconds: convertDateTickIntervalToMilliseconds,
- convertDateUnitToMilliseconds: convertDateUnitToMilliseconds,
- getDateUnitInterval: getDateUnitInterval,
- getDatesDifferences: getDatesDifferences,
- correctDateWithUnitBeginning: correctDateWithUnitBeginning,
- addInterval: addInterval,
- getDateIntervalByString: getDateIntervalByString,
- sameMonthAndYear: sameMonthAndYear,
- getFirstMonthDate: getFirstMonthDate,
- dateInRange: dateInRange,
- normalizeDate: normalizeDate,
- getPower: getPower
- })
- })(jQuery, DevExpress);
- /*! Module core, file utils.dom.js */
- (function($, DX, undefined) {
- var IOS_APP_BAR_HEIGHT = "20px";
- var timeRedrawOnResize = 100;
- var createResizeHandler = function(callback) {
- var $window = $(window),
- timeout;
- var debug_callback = arguments[1];
- var handler = function() {
- var width = $window.width(),
- height = $window.height();
- clearTimeout(timeout);
- timeout = setTimeout(function() {
- $window.width() === width && $window.height() === height && callback();
- debug_callback && debug_callback()
- }, timeRedrawOnResize)
- };
- handler.stop = function() {
- clearTimeout(timeout);
- return this
- };
- return handler
- };
- var windowResizeCallbacks = function() {
- var prevSize,
- callbacks = $.Callbacks(),
- jqWindow = $(window),
- resizeEventHandlerAttached = false,
- originalCallbacksAdd = callbacks.add,
- originalCallbacksRemove = callbacks.remove;
- var formatSize = function() {
- return [jqWindow.width(), jqWindow.height()].join()
- };
- var handleResize = function() {
- var now = formatSize();
- if (now === prevSize)
- return;
- prevSize = now;
- setTimeout(callbacks.fire)
- };
- prevSize = formatSize();
- callbacks.add = function() {
- var result = originalCallbacksAdd.apply(callbacks, arguments);
- if (!resizeEventHandlerAttached && callbacks.has()) {
- jqWindow.on("resize", handleResize);
- resizeEventHandlerAttached = true
- }
- return result
- };
- callbacks.remove = function() {
- var result = originalCallbacksRemove.apply(callbacks, arguments);
- if (!callbacks.has() && resizeEventHandlerAttached) {
- jqWindow.off("resize", handleResize);
- resizeEventHandlerAttached = false
- }
- return result
- };
- return callbacks
- }();
- var resetActiveElement = function() {
- var activeElement = document.activeElement;
- if (activeElement && activeElement !== document.body && activeElement.blur)
- activeElement.blur()
- };
- var createMarkupFromString = function(str) {
- var tempElement = $("<div />");
- if (window.WinJS)
- WinJS.Utilities.setInnerHTMLUnsafe(tempElement.get(0), str);
- else
- tempElement.append(str);
- return tempElement.contents()
- };
- var initMobileViewport = function(options) {
- options = $.extend({}, options);
- var device = DX.devices.current();
- var realDevice = DX.devices.real();
- var allowZoom = options.allowZoom,
- allowPan = options.allowPan,
- allowSelection = "allowSelection" in options ? options.allowSelection : device.platform == "desktop";
- DX.overlayTargetContainer(".dx-viewport");
- var metaSelector = "meta[name=viewport]";
- if (!$(metaSelector).length)
- $("<meta />").attr("name", "viewport").appendTo("head");
- var metaVerbs = ["width=device-width"],
- msTouchVerbs = [];
- if (allowZoom)
- msTouchVerbs.push("pinch-zoom");
- else
- metaVerbs.push("initial-scale=1.0", "maximum-scale=1.0, user-scalable=no");
- if (allowPan)
- msTouchVerbs.push("pan-x", "pan-y");
- if (!allowPan && !allowZoom)
- $("html, body").css({
- "-ms-content-zooming": "none",
- "-ms-user-select": "none",
- overflow: "hidden"
- });
- else
- $("html").css("-ms-overflow-style", "-ms-autohiding-scrollbar");
- if (!allowSelection) {
- if (realDevice.ios)
- $(document).on("selectstart", function() {
- return false
- });
- $(".dx-viewport").css("user-select", "none")
- }
- $(metaSelector).attr("content", metaVerbs.join());
- $("html").css("-ms-touch-action", msTouchVerbs.join(" ") || "none");
- if (DX.support.touch)
- $(document).off(".dxInitMobileViewport").on("touchmove.dxInitMobileViewport", function(e) {
- var count = e.originalEvent.touches.length,
- zoomDisabled = !allowZoom && count > 1,
- panDisabled = !allowPan && count === 1 && !e.isScrollingEvent;
- if (zoomDisabled || panDisabled)
- e.preventDefault()
- });
- realDevice = DX.devices.real();
- if (realDevice.ios) {
- var isPhoneGap = document.location.protocol === "file:";
- if (!isPhoneGap)
- windowResizeCallbacks.add(function() {
- var windowWidth = $(window).width();
- $("body").width(windowWidth)
- });
- else if (realDevice.version[0] > 6) {
- $(".dx-viewport").css("position", "relative");
- $("body").css({"box-sizing": "border-box"});
- $("body").css("padding-top", IOS_APP_BAR_HEIGHT);
- if (realDevice.version[0] === 7 && realDevice.version[1] < 1) {
- var setDeviceHeight = function() {
- var deviceHeight = "height=device-" + (Math.abs(window.orientation) === 90 ? "width" : "height");
- $(metaSelector).attr("content", metaVerbs.join() + "," + deviceHeight)
- };
- $(window).on("orientationchange", setDeviceHeight);
- setDeviceHeight()
- }
- }
- }
- };
- var triggerVisibilityChangeEvent = function(event) {
- return function(element) {
- $(element || "body").find(".dx-visibility-change-handler").each(function() {
- $(this).triggerHandler(event)
- })
- }
- };
- $.extend(DX.utils, {
- createResizeHandler: createResizeHandler,
- windowResizeCallbacks: windowResizeCallbacks,
- resetActiveElement: resetActiveElement,
- createMarkupFromString: createMarkupFromString,
- triggerShownEvent: triggerVisibilityChangeEvent("dxshown"),
- triggerHidingEvent: triggerVisibilityChangeEvent("dxhiding"),
- initMobileViewport: initMobileViewport
- });
- DX.utils.__timeRedrawOnResize = timeRedrawOnResize
- })(jQuery, DevExpress);
- /*! Module core, file utils.graphics.js */
- (function($, DX, undefined) {
- var isFunction = DX.utils.isFunction,
- iDevice = /iphone|ipad/.test(navigator.userAgent.toLowerCase());
- var processSeriesTemplate = function(seriesTemplate, items) {
- var customizeSeries = isFunction(seriesTemplate.customizeSeries) ? seriesTemplate.customizeSeries : $.noop,
- nameField = seriesTemplate.nameField || 'series',
- generatedSeries = {},
- seriesOrder = [],
- series;
- for (var i = 0, length = items.length; i < length; i++) {
- var data = items[i];
- if (nameField in data) {
- series = generatedSeries[data[nameField]];
- if (!series) {
- series = generatedSeries[data[nameField]] = {
- name: data[nameField],
- data: []
- };
- seriesOrder.push(series.name)
- }
- series.data.push(data)
- }
- }
- return $.map(seriesOrder, function(orderedName) {
- var group = generatedSeries[orderedName],
- seriesOptions = customizeSeries.call(null, group.name);
- return $.extend(group, seriesOptions)
- })
- };
- var getNextDefsSvgId = function() {
- var numDefsSvgElements = 1;
- return function() {
- return 'DevExpress_' + numDefsSvgElements++
- }
- }();
- var getRootOffset = function(renderer) {
- var node,
- result = {
- left: 0,
- top: 0
- },
- pointTransform,
- root = renderer.getRoot();
- if (root) {
- node = root.element;
- if (node.getScreenCTM && !iDevice) {
- var ctm = node.getScreenCTM();
- if (ctm) {
- pointTransform = node.createSVGPoint().matrixTransform(ctm);
- result.left = pointTransform.x + (document.body.scrollLeft || document.documentElement.scrollLeft);
- result.top = pointTransform.y + (document.body.scrollTop || document.documentElement.scrollTop)
- }
- else {
- result.left = document.body.scrollLeft || document.documentElement.scrollLeft;
- result.top = document.body.scrollTop || document.documentElement.scrollTop
- }
- }
- else
- result = $(node).offset()
- }
- return result
- };
- $.extend(DX.utils, {
- processSeriesTemplate: processSeriesTemplate,
- getNextDefsSvgId: getNextDefsSvgId,
- getRootOffset: getRootOffset
- })
- })(jQuery, DevExpress);
- /*! Module core, file utils.arrays.js */
- (function($, DX, undefined) {
- var wrapToArray = function(entity) {
- return $.isArray(entity) ? entity : [entity]
- };
- var removeDublicates = function(from, what) {
- if (!$.isArray(from) || from.length === 0)
- return [];
- if (!$.isArray(what) || what.length === 0)
- return from.slice();
- var result = [];
- $.each(from, function(_, value) {
- var bIndex = $.inArray(value, what);
- if (bIndex === -1)
- result.push(value)
- });
- return result
- };
- $.extend(DX.utils, {
- wrapToArray: wrapToArray,
- removeDublicates: removeDublicates
- })
- })(jQuery, DevExpress);
- /*! Module core, file devices.js */
- (function($, DX, undefined) {
- var KNOWN_UA_TABLE = {
- iPhone: "iPhone",
- iPhone5: "iPhone 5",
- iPad: "iPad",
- iPadMini: "iPad Mini",
- androidPhone: "Android Mobile",
- androidTablet: "Android",
- win8: "MSAppHost",
- win8Phone: "Windows Phone 8",
- msSurface: "MSIE ARM Tablet PC",
- desktop: "desktop",
- tizen: "Tizen Mobile"
- };
- var DEFAULT_DEVICE = {
- deviceType: "",
- platform: "",
- version: [],
- phone: false,
- tablet: false,
- android: false,
- ios: false,
- win8: false,
- tizen: false,
- generic: false
- };
- var GENERIC_DEVICE = $.extend(DEFAULT_DEVICE, {
- platform: "generic",
- deviceType: "desktop",
- generic: true
- });
- var uaParsers = {
- win8: function(userAgent) {
- var isPhone = /windows phone/i.test(userAgent),
- isTablet = !isPhone && /arm(.*)trident/i.test(userAgent),
- isDesktop = !isPhone && !isTablet && /msapphost/i.test(userAgent);
- if (!(isPhone || isTablet || isDesktop))
- return;
- var matches = userAgent.match(/windows phone (\d+).(\d+)/i) || userAgent.match(/windows nt (\d+).(\d+)/i),
- version = matches ? [parseInt(matches[1], 10), parseInt(matches[2], 10)] : [];
- return {
- deviceType: isPhone ? "phone" : isTablet ? "tablet" : "desktop",
- platform: "win8",
- version: version
- }
- },
- ios: function(userAgent) {
- if (!/ip(hone|od|ad)/i.test(userAgent))
- return;
- var isPhone = /ip(hone|od)/i.test(userAgent);
- var matches = userAgent.match(/os (\d+)_(\d+)_?(\d+)?/i);
- var version = matches ? [parseInt(matches[1], 10), parseInt(matches[2], 10), parseInt(matches[3] || 0, 10)] : [];
- return {
- deviceType: isPhone ? "phone" : "tablet",
- platform: "ios",
- version: version
- }
- },
- android: function(userAgent) {
- if (!/android|htc_|silk/i.test(userAgent))
- return;
- var isPhone = /mobile/i.test(userAgent);
- var matches = userAgent.match(/android (\d+)\.(\d+)\.?(\d+)?/i);
- var version = matches ? [parseInt(matches[1], 10), parseInt(matches[2], 10), parseInt(matches[3] || 0, 10)] : [];
- return {
- deviceType: isPhone ? "phone" : "tablet",
- platform: "android",
- version: version
- }
- },
- tizen: function(userAgent) {
- if (!/tizen/i.test(userAgent))
- return;
- var isPhone = /mobile/i.test(userAgent);
- var matches = userAgent.match(/tizen (\d+)\.(\d+)/i);
- var version = matches ? [parseInt(matches[1], 10), parseInt(matches[2], 10)] : [];
- return {
- deviceType: isPhone ? "phone" : "tablet",
- platform: "tizen",
- version: version
- }
- }
- };
- DX.Devices = DX.Class.inherit({
- ctor: function(options) {
- this._window = options && options.window || window;
- this._realDevice = this._getDevice();
- this._currentDevice = undefined;
- this._currentOrientation = undefined;
- this.orientationChanged = $.Callbacks();
- this._recalculateOrientation();
- DX.utils.windowResizeCallbacks.add($.proxy(this._recalculateOrientation, this))
- },
- current: function(deviceOrName) {
- if (deviceOrName) {
- this._currentDevice = this._getDevice(deviceOrName);
- DX.ui.themes.init({_autoInit: true})
- }
- else {
- if (!this._currentDevice) {
- deviceOrName = undefined;
- try {
- deviceOrName = this._getDeviceOrNameFromWindowScope()
- }
- catch(e) {
- deviceOrName = this._getDeviceNameFromSessionStorage()
- }
- finally {
- if (!deviceOrName)
- deviceOrName = this._getDeviceNameFromSessionStorage()
- }
- this._currentDevice = this._getDevice(deviceOrName)
- }
- return this._currentDevice
- }
- },
- real: function() {
- var forceDevice = arguments[0];
- if ($.isPlainObject(forceDevice)) {
- $.extend(this._realDevice, forceDevice);
- return
- }
- return $.extend({}, this._realDevice)
- },
- orientation: function() {
- return this._currentOrientation
- },
- isRippleEmulator: function() {
- return !!this._window.tinyHippos
- },
- attachCssClasses: function(element, device) {
- var realDevice = this._realDevice,
- $element = $(element);
- device = device || this.current();
- if (device.deviceType)
- $element.addClass("dx-device-" + device.deviceType);
- $element.addClass("dx-device-" + realDevice.platform);
- if (realDevice.version && realDevice.version.length)
- $element.addClass("dx-device-" + realDevice.platform + "-" + realDevice.version[0]);
- if (DX.devices.isSimulator())
- $element.addClass("dx-simulator");
- if (DX.rtlEnabled)
- $element.addClass("dx-rtl")
- },
- isSimulator: function() {
- try {
- return this._isSimulator || this._window.top !== this._window.self && this._window.top["dx-force-device"] || this.isRippleEmulator()
- }
- catch(e) {
- return false
- }
- },
- forceSimulator: function() {
- this._isSimulator = true
- },
- _getDevice: function(deviceName) {
- if (deviceName === "genericPhone")
- deviceName = {
- deviceType: "phone",
- platform: "generic",
- generic: true
- };
- if ($.isPlainObject(deviceName))
- return this._fromConfig(deviceName);
- else {
- var ua;
- if (deviceName) {
- ua = KNOWN_UA_TABLE[deviceName];
- if (!ua)
- throw Error("Unknown device");
- }
- else
- ua = navigator.userAgent;
- return this._fromUA(ua)
- }
- },
- _getDeviceOrNameFromWindowScope: function() {
- var result;
- if (this._window.top["dx-force-device-object"] || this._window.top["dx-force-device"])
- result = this._window.top["dx-force-device-object"] || this._window.top["dx-force-device"];
- return result
- },
- _getDeviceNameFromSessionStorage: function() {
- return this._window.sessionStorage && (sessionStorage.getItem("dx-force-device") || sessionStorage.getItem("dx-simulator-device"))
- },
- _fromConfig: function(config) {
- var shortcuts = {
- phone: config.deviceType === "phone",
- tablet: config.deviceType === "tablet",
- android: config.platform === "android",
- ios: config.platform === "ios",
- win8: config.platform === "win8",
- tizen: config.platform === "tizen",
- generic: config.platform === "generic"
- };
- return $.extend({}, DEFAULT_DEVICE, this._currentDevice, shortcuts, config)
- },
- _fromUA: function(ua) {
- var config;
- $.each(uaParsers, function(platform, parser) {
- config = parser(ua);
- return !config
- });
- if (config)
- return this._fromConfig(config);
- return GENERIC_DEVICE
- },
- _changeOrientation: function() {
- var $window = $(this._window),
- orientation = $window.height() > $window.width() ? "portrait" : "landscape";
- if (this._currentOrientation === orientation)
- return;
- this._currentOrientation = orientation;
- this.orientationChanged.fire({orientation: orientation})
- },
- _recalculateOrientation: function() {
- var windowWidth = $(this._window).width();
- if (this._currentWidth === windowWidth)
- return;
- this._currentWidth = windowWidth;
- this._changeOrientation()
- }
- });
- DX.devices = new DX.Devices
- })(jQuery, DevExpress);
- /*! Module core, file browser.js */
- (function($, DX, global, undefined) {
- var webkitRegExp = /(webkit)[ \/]([\w.]+)/,
- operaRegExp = /(opera)(?:.*version)?[ \/]([\w.]+)/,
- ieRegExp = /(msie) (\d{1,2}\.\d)/,
- ie11RegExp = /(trident).*rv:(\d{1,2}\.\d)/,
- mozillaRegExp = /(mozilla)(?:.*? rv:([\w.]+))?/;
- var ua = navigator.userAgent.toLowerCase();
- var browser = function() {
- var result = {},
- matches = webkitRegExp.exec(ua) || operaRegExp.exec(ua) || ieRegExp.exec(ua) || ie11RegExp.exec(ua) || ua.indexOf("compatible") < 0 && mozillaRegExp.exec(ua) || [],
- browserName = matches[1],
- browserVersion = matches[2];
- if (browserName === "trident")
- browserName = "msie";
- if (browserName) {
- result[browserName] = true;
- result.version = browserVersion
- }
- return result
- }();
- DX.browser = browser
- })(jQuery, DevExpress, this);
- /*! Module core, file support.js */
- (function($, DX, window) {
- var cssPrefixes = ["", "Webkit", "Moz", "O", "ms"],
- styles = document.createElement("dx").style;
- var transitionEndEventNames = {
- WebkitTransition: 'webkitTransitionEnd',
- MozTransition: 'transitionend',
- OTransition: 'oTransitionEnd',
- msTransition: 'MsTransitionEnd',
- transition: 'transitionend'
- };
- var styleProp = function(prop) {
- prop = DX.inflector.camelize(prop, true);
- for (var i = 0, cssPrefixesCount = cssPrefixes.length; i < cssPrefixesCount; i++) {
- var specific = cssPrefixes[i] + prop;
- if (specific in styles)
- return specific
- }
- };
- var supportProp = function(prop) {
- return !!styleProp(prop)
- };
- var isNativeScrollingSupported = function(device) {
- var realDevice = DX.devices.real(),
- realPlatform = realDevice.platform,
- realVersion = realDevice.version,
- isObsoleteAndroid = realVersion && realVersion[0] < 4 && realPlatform === "android",
- isNativeScrollDevice = !isObsoleteAndroid && $.inArray(realPlatform, ["ios", "android", "win8"]) > -1;
- return isNativeScrollDevice
- };
- DX.support = {
- touch: "ontouchstart" in window || !!window.navigator.msMaxTouchPoints,
- pointer: window.navigator.pointerEnabled || window.navigator.msPointerEnabled,
- transform3d: supportProp("transform"),
- transition: supportProp("transition"),
- transitionEndEventName: transitionEndEventNames[styleProp("transition")],
- animation: supportProp("animation"),
- nativeScrolling: isNativeScrollingSupported(),
- winJS: "WinJS" in window,
- styleProp: styleProp,
- supportProp: supportProp,
- hasKo: !!window.ko,
- hasNg: !window.ko && !!window.angular,
- inputType: function(type) {
- if (type === "text")
- return true;
- var input = document.createElement("input");
- try {
- input.setAttribute("type", type);
- input.value = "wrongValue";
- return !input.value
- }
- catch(e) {
- return false
- }
- }
- }
- })(jQuery, DevExpress, this);
- /*! Module core, file position.js */
- (function($, DX, undefined) {
- var horzRe = /left|right/,
- vertRe = /top|bottom/,
- collisionRe = /fit|flip|none/;
- var normalizeAlign = function(raw) {
- var result = {
- h: "center",
- v: "center"
- };
- var pair = DX.utils.splitPair(raw);
- if (pair)
- $.each(pair, function() {
- var w = String(this).toLowerCase();
- if (horzRe.test(w))
- result.h = w;
- else if (vertRe.test(w))
- result.v = w
- });
- return result
- };
- var normalizeOffset = function(raw) {
- var values = DX.utils.stringPairToObject(raw);
- return {
- h: values.x,
- v: values.y
- }
- };
- var normalizeCollision = function(raw) {
- var pair = DX.utils.splitPair(raw),
- h = String(pair && pair[0]).toLowerCase(),
- v = String(pair && pair[1]).toLowerCase();
- if (!collisionRe.test(h))
- h = "none";
- if (!collisionRe.test(v))
- v = h;
- return {
- h: h,
- v: v
- }
- };
- var getAlignFactor = function(align) {
- switch (align) {
- case"center":
- return 0.5;
- case"right":
- case"bottom":
- return 1;
- default:
- return 0
- }
- };
- var inverseAlign = function(align) {
- switch (align) {
- case"left":
- return "right";
- case"right":
- return "left";
- case"top":
- return "bottom";
- case"bottom":
- return "top";
- default:
- return align
- }
- };
- var calculateOversize = function(data, bounds) {
- var oversize = 0;
- if (data.myLocation < bounds.min)
- oversize += bounds.min - data.myLocation;
- if (data.myLocation > bounds.max)
- oversize += data.myLocation - bounds.max;
- return oversize
- };
- var initMyLocation = function(data) {
- data.myLocation = data.atLocation + getAlignFactor(data.atAlign) * data.atSize - getAlignFactor(data.myAlign) * data.mySize + data.offset
- };
- var decolliders = {
- fit: function(data, bounds) {
- var result = false;
- if (data.myLocation > bounds.max) {
- data.myLocation = bounds.max;
- result = true
- }
- if (data.myLocation < bounds.min) {
- data.myLocation = bounds.min;
- result = true
- }
- return result
- },
- flip: function(data, bounds) {
- if (data.myAlign === "center" && data.atAlign === "center")
- return false;
- if (data.myLocation < bounds.min || data.myLocation > bounds.max) {
- var inverseData = $.extend({}, data, {
- myAlign: inverseAlign(data.myAlign),
- atAlign: inverseAlign(data.atAlign),
- offset: -data.offset
- });
- initMyLocation(inverseData);
- inverseData.oversize = calculateOversize(inverseData, bounds);
- if (inverseData.myLocation >= bounds.min && inverseData.myLocation <= bounds.max || inverseData.myLocation > data.myLocation || inverseData.oversize < data.oversize) {
- data.myLocation = inverseData.myLocation;
- data.oversize = inverseData.oversize;
- return true
- }
- }
- return false
- }
- };
- var scrollbarWidth;
- var defaultPositionResult = {
- h: {
- location: 0,
- flip: false,
- fit: false,
- oversize: 0
- },
- v: {
- location: 0,
- flip: false,
- fit: false,
- oversize: 0
- }
- };
- var calculatePosition = function(what, options) {
- var $what = $(what),
- currentOffset = $what.offset(),
- result = $.extend(true, {}, defaultPositionResult, {
- h: {location: currentOffset.left},
- v: {location: currentOffset.top}
- });
- if (!options)
- return result;
- var my = normalizeAlign(options.my),
- at = normalizeAlign(options.at),
- of = options.of || window,
- offset = normalizeOffset(options.offset),
- collision = normalizeCollision(options.collision),
- boundaryOffset = normalizeOffset(options.boundaryOffset);
- var h = {
- mySize: $what.outerWidth(),
- myAlign: my.h,
- atAlign: at.h,
- offset: offset.h,
- collision: collision.h,
- boundaryOffset: boundaryOffset.h
- };
- var v = {
- mySize: $what.outerHeight(),
- myAlign: my.v,
- atAlign: at.v,
- offset: offset.v,
- collision: collision.v,
- boundaryOffset: boundaryOffset.v
- };
- if (of.preventDefault) {
- h.atLocation = of.pageX;
- v.atLocation = of.pageY;
- h.atSize = 0;
- v.atSize = 0
- }
- else {
- of = $(of);
- if ($.isWindow(of[0])) {
- h.atLocation = of.scrollLeft();
- v.atLocation = of.scrollTop();
- h.atSize = of.width();
- v.atSize = of.height()
- }
- else if (of[0].nodeType === 9) {
- h.atLocation = 0;
- v.atLocation = 0;
- h.atSize = of.width();
- v.atSize = of.height()
- }
- else {
- var o = of.offset();
- h.atLocation = o.left;
- v.atLocation = o.top;
- h.atSize = of.outerWidth();
- v.atSize = of.outerHeight()
- }
- }
- initMyLocation(h);
- initMyLocation(v);
- var bounds = function() {
- var win = $(window),
- windowWidth = win.width(),
- windowHeight = win.height(),
- left = win.scrollLeft(),
- top = win.scrollTop(),
- hScrollbar = document.width > document.documentElement.clientWidth,
- vScrollbar = document.height > document.documentElement.clientHeight,
- hZoomLevel = DX.support.touch ? document.documentElement.clientWidth / (vScrollbar ? windowWidth - scrollbarWidth : windowWidth) : 1,
- vZoomLevel = DX.support.touch ? document.documentElement.clientHeight / (hScrollbar ? windowHeight - scrollbarWidth : windowHeight) : 1;
- if (scrollbarWidth === undefined)
- scrollbarWidth = calculateScrollbarWidth();
- return {
- h: {
- min: left + h.boundaryOffset,
- max: left + windowWidth / hZoomLevel - h.mySize - h.boundaryOffset
- },
- v: {
- min: top + v.boundaryOffset,
- max: top + windowHeight / vZoomLevel - v.mySize - v.boundaryOffset
- }
- }
- }();
- h.oversize = calculateOversize(h, bounds.h);
- v.oversize = calculateOversize(v, bounds.v);
- if (decolliders[h.collision])
- result.h[h.collision] = decolliders[h.collision](h, bounds.h);
- if (decolliders[v.collision])
- result.v[v.collision] = decolliders[v.collision](v, bounds.v);
- $.extend(true, result, {
- h: {
- location: Math.round(h.myLocation),
- oversize: Math.round(h.oversize)
- },
- v: {
- location: Math.round(v.myLocation),
- oversize: Math.round(v.oversize)
- }
- });
- return result
- };
- var position = function(what, options) {
- var $what = $(what);
- if (!options)
- return $what.offset();
- DX.translator.resetPosition($what);
- var offset = $what.offset(),
- targetPosition = options.h && options.v ? options : calculatePosition($what, options);
- DX.translator.move($what, {
- left: Math.round(targetPosition.h.location - offset.left),
- top: Math.round(targetPosition.v.location - offset.top)
- });
- return targetPosition
- };
- $.extend(DX, {
- calculatePosition: calculatePosition,
- position: position,
- inverseAlign: inverseAlign
- });
- var calculateScrollbarWidth = function() {
- var $scrollDiv = $("<div>").css({
- width: 100,
- height: 100,
- overflow: "scroll",
- position: "absolute",
- top: -9999
- }).appendTo($("body")),
- result = $scrollDiv.get(0).offsetWidth - $scrollDiv.get(0).clientWidth;
- $scrollDiv.remove();
- return result
- }
- })(jQuery, DevExpress);
- /*! Module core, file action.js */
- (function($, DX, undefined) {
- var actionExecutors = {};
- var registerExecutor = function(name, executor) {
- if ($.isPlainObject(name)) {
- $.each(name, registerExecutor);
- return
- }
- actionExecutors[name] = executor
- };
- var unregisterExecutor = function(name) {
- var args = $.makeArray(arguments);
- $.each(args, function() {
- delete actionExecutors[this]
- })
- };
- registerExecutor({
- func: {execute: function(e) {
- if ($.isFunction(e.action)) {
- e.result = e.action.apply(e.context, e.args);
- e.handled = true
- }
- }},
- url: {execute: function(e) {
- if (typeof e.action === "string" && e.action.charAt(0) !== "#")
- document.location = e.action
- }},
- hash: {execute: function(e) {
- if (typeof e.action === "string" && e.action.charAt(0) === "#")
- document.location.hash = e.action
- }}
- });
- var Action = DX.Class.inherit({
- ctor: function(action, config) {
- config = config || {};
- this._action = action || $.noop;
- this._context = config.context || window;
- this._beforeExecute = config.beforeExecute || $.noop;
- this._afterExecute = config.afterExecute || $.noop;
- this._component = config.component;
- this._excludeValidators = config.excludeValidators;
- this._validatingTargetName = config.validatingTargetName
- },
- execute: function() {
- var e = {
- action: this._action,
- args: Array.prototype.slice.call(arguments),
- context: this._context,
- component: this._component,
- validatingTargetName: this._validatingTargetName,
- cancel: false,
- handled: false
- };
- if (!this._validateAction(e))
- return;
- this._beforeExecute.call(this._context, e);
- if (e.cancel)
- return;
- var result = this._executeAction(e);
- this._afterExecute.call(this._context, e);
- return result
- },
- _validateAction: function(e) {
- var excludeValidators = this._excludeValidators;
- $.each(actionExecutors, function(name, executor) {
- if (excludeValidators && $.inArray(name, excludeValidators) > -1)
- return;
- if (executor.validate)
- executor.validate(e);
- if (e.cancel)
- return false
- });
- return !e.cancel
- },
- _executeAction: function(e) {
- var result;
- $.each(actionExecutors, function(index, executor) {
- if (executor.execute)
- executor.execute(e);
- if (e.handled) {
- result = e.result;
- return false
- }
- });
- return result
- }
- });
- $.extend(DX, {
- registerActionExecutor: registerExecutor,
- unregisterActionExecutor: unregisterExecutor,
- Action: Action
- });
- DX.__internals = {actionExecutors: actionExecutors}
- })(jQuery, DevExpress);
- /*! Module core, file translator.js */
- (function($, DX, undefined) {
- var support = DX.support,
- TRANSLATOR_DATA_KEY = "dxTranslator",
- TRANSFORM_MATRIX_REGEX = /matrix(3d)?\((.+?)\)/,
- TRANSLATE_REGEX = /translate(?:3d)?\((.+?)\)/;
- var locate = function($element) {
- var result,
- position,
- finalPosition;
- if (support.transform3d) {
- var translate = getTranslate($element);
- result = {
- left: translate.x,
- top: translate.y
- }
- }
- else {
- var originalTop = $element.css("top"),
- originalLeft = $element.css("left");
- position = $element.position();
- $element.css({
- transform: "none",
- top: 0,
- left: 0
- });
- clearCache($element);
- finalPosition = $element.position();
- result = {
- left: position.left - finalPosition.left || parseInt(originalLeft) || 0,
- top: position.top - finalPosition.top || parseInt(originalTop) || 0
- };
- $element.css({
- top: originalTop,
- left: originalLeft
- })
- }
- return result
- };
- var move = function($element, position) {
- if (!support.transform3d) {
- $element.css(position);
- return
- }
- var translate = getTranslate($element),
- left = position.left,
- top = position.top;
- if (left !== undefined)
- translate.x = left || 0;
- if (top !== undefined)
- translate.y = top || 0;
- $element.css({transform: getTranslateCss(translate)});
- if (isPersentValue(left) || isPersentValue(top))
- clearCache($element)
- };
- var isPersentValue = function(value) {
- return $.type(value) === "string" && value[value.length - 1] === "%"
- };
- var getTranslate = function($element) {
- var result = $element.data(TRANSLATOR_DATA_KEY);
- if (!result) {
- var transformValue = $element.css("transform") || getTranslateCss({
- x: 0,
- y: 0
- }),
- matrix = transformValue.match(TRANSFORM_MATRIX_REGEX),
- is3D = matrix && matrix[1];
- if (matrix) {
- matrix = matrix[2].split(",");
- if (is3D === "3d")
- matrix = matrix.slice(12, 15);
- else {
- matrix.push(0);
- matrix = matrix.slice(4, 7)
- }
- }
- else
- matrix = [0, 0, 0];
- result = {
- x: parseFloat(matrix[0]),
- y: parseFloat(matrix[1]),
- z: parseFloat(matrix[2])
- };
- cacheTranslate($element, result)
- }
- return result
- };
- var cacheTranslate = function($element, translate) {
- $element.data(TRANSLATOR_DATA_KEY, translate)
- };
- var clearCache = function($element) {
- $element.removeData(TRANSLATOR_DATA_KEY)
- };
- var resetPosition = function($element) {
- $element.css({
- left: 0,
- top: 0,
- transform: "none"
- });
- clearCache($element)
- };
- var parseTranslate = function(translateString) {
- var result = translateString.match(TRANSLATE_REGEX);
- if (!result || !result[1])
- return;
- result = result[1].split(",");
- result = {
- x: parseFloat(result[0]),
- y: parseFloat(result[1]),
- z: parseFloat(result[2])
- };
- return result
- };
- var getTranslateCss = function(translate) {
- translate.x = translate.x || 0;
- translate.y = translate.y || 0;
- var xValueString = isPersentValue(translate.x) ? translate.x : translate.x + "px";
- var yValueString = isPersentValue(translate.y) ? translate.y : translate.y + "px";
- return "translate(" + xValueString + ", " + yValueString + ")"
- };
- DX.translator = {
- move: move,
- locate: locate,
- clearCache: clearCache,
- parseTranslate: parseTranslate,
- getTranslate: getTranslate,
- getTranslateCss: getTranslateCss,
- resetPosition: resetPosition
- }
- })(jQuery, DevExpress);
- /*! Module core, file animationFrame.js */
- (function($, DX, undefined) {
- var FRAME_ANIMATION_STEP_TIME = 1000 / 60,
- requestAnimationFrame = function(callback, element) {
- return this.setTimeout(callback, FRAME_ANIMATION_STEP_TIME)
- },
- cancelAnimationFrame = function(requestID) {
- return this.clearTimeout(requestID)
- },
- nativeRequestAnimationFrame = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame,
- nativeCancelAnimationFrame = window.cancelAnimationFrame || window.webkitCancelAnimationFrame || window.mozCancelAnimationFrame || window.oCancelAnimationFrame || window.msCancelAnimationFrame;
- if (nativeRequestAnimationFrame && nativeCancelAnimationFrame) {
- requestAnimationFrame = nativeRequestAnimationFrame;
- cancelAnimationFrame = nativeCancelAnimationFrame
- }
- if (nativeRequestAnimationFrame && !nativeCancelAnimationFrame) {
- var cancelledRequests = {};
- requestAnimationFrame = function(callback) {
- var requestId = nativeRequestAnimationFrame.call(window, function() {
- try {
- if (requestId in cancelledRequests)
- return;
- callback.apply(this, arguments)
- }
- finally {
- delete cancelledRequests[requestId]
- }
- });
- return requestId
- };
- cancelAnimationFrame = function(requestId) {
- cancelledRequests[requestId] = true
- }
- }
- requestAnimationFrame = $.proxy(requestAnimationFrame, window);
- cancelAnimationFrame = $.proxy(cancelAnimationFrame, window);
- $.extend(DX, {
- requestAnimationFrame: requestAnimationFrame,
- cancelAnimationFrame: cancelAnimationFrame
- })
- })(jQuery, DevExpress);
- /*! Module core, file animator.js */
- (function($, DX, undefined) {
- DX.Animator = DX.Class.inherit({
- ctor: function() {
- this._finished = true;
- this._stopped = false
- },
- start: function() {
- this._stopped = false;
- this._finished = false;
- this._stepCore()
- },
- stop: function() {
- this._stopped = true
- },
- _stepCore: function() {
- if (this._isStopped()) {
- this._stop();
- return
- }
- if (this._isFinished()) {
- this._finished = true;
- this._complete();
- return
- }
- this._step();
- DX.requestAnimationFrame.call(window, $.proxy(this._stepCore, this))
- },
- _step: DX.abstract,
- _isFinished: $.noop,
- _stop: $.noop,
- _complete: $.noop,
- _isStopped: function() {
- return this._stopped
- },
- inProgress: function() {
- return !(this._stopped || this._finished)
- }
- })
- })(jQuery, DevExpress);
- /*! Module core, file fx.js */
- (function($, DX, undefined) {
- var translator = DX.translator,
- support = DX.support,
- transitionEndEventName = support.transitionEndEventName + ".dxFX";
- var CSS_TRANSITION_EASING_REGEX = /cubic-bezier\((\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\)/,
- RELATIVE_VALUE_REGEX = /^([+-])=(.*)/i,
- ANIM_DATA_KEY = "dxAnimData",
- ANIM_QUEUE_KEY = "dxAnimQueue",
- TRANSFORM_PROP = "transform";
- var TransitionAnimationStrategy = {
- animate: function($element, config) {
- var that = this,
- deferred = $.Deferred();
- config.transitionAnimation = {finish: function() {
- that._cleanup($element, config);
- deferred.resolveWith($element, [config, $element])
- }};
- this._startAnimation($element, config);
- this._completeAnimationCallback($element, config).done(function() {
- config.transitionAnimation.finish()
- });
- if (!config.duration)
- config.transitionAnimation.finish();
- return deferred.promise()
- },
- _completeAnimationCallback: function($element, config) {
- var startTime = $.now() + config.delay,
- deferred = $.Deferred(),
- transitionEndFired = $.Deferred(),
- simulatedTransitionEndFired = $.Deferred();
- $element.one(transitionEndEventName, function(e) {
- if ($.now() - startTime >= config.duration)
- transitionEndFired.reject()
- });
- config.transitionAnimation.simulatedEndEventTimer = setTimeout(function() {
- simulatedTransitionEndFired.reject()
- }, config.duration + config.delay);
- $.when(transitionEndFired, simulatedTransitionEndFired).fail($.proxy(function() {
- deferred.resolve()
- }, this));
- return deferred.promise()
- },
- _startAnimation: function($element, config) {
- $element.css("transform");
- $element.css({
- transitionProperty: "all",
- transitionDelay: config.delay + "ms",
- transitionDuration: config.duration + "ms",
- transitionTimingFunction: config.easing
- });
- setProps($element, config.to)
- },
- _cleanup: function($element, config) {
- $element.css("transition", "none").off(transitionEndEventName);
- clearTimeout(config.transitionAnimation.simulatedEndEventTimer)
- },
- stop: function($element, config, jumpToEnd) {
- if (!config)
- return;
- if (jumpToEnd)
- config.transitionAnimation.finish();
- else {
- $.each(config.to, function(key) {
- $element.css(key, $element.css(key))
- });
- this._cleanup($element, config)
- }
- }
- };
- var FrameAnimationStrategy = {
- animate: function($element, config) {
- var deferred = $.Deferred(),
- that = this;
- if (!config)
- return deferred.reject().promise();
- $.each(config.to, function(prop) {
- if (config.from[prop] === undefined)
- config.from[prop] = that._normalizeValue($element.css(prop))
- });
- if (config.to[TRANSFORM_PROP]) {
- config.from[TRANSFORM_PROP] = that._parseTransform(config.from[TRANSFORM_PROP]);
- config.to[TRANSFORM_PROP] = that._parseTransform(config.to[TRANSFORM_PROP])
- }
- config.frameAnimation = {
- to: config.to,
- from: config.from,
- currentValue: config.from,
- easing: convertTransitionTimingFuncToJQueryEasing(config.easing),
- duration: config.duration,
- startTime: (new Date).valueOf(),
- finish: function() {
- this.currentValue = this.to;
- this.draw();
- deferred.resolve()
- },
- draw: function() {
- var currentValue = $.extend({}, this.currentValue);
- if (currentValue[TRANSFORM_PROP])
- currentValue[TRANSFORM_PROP] = $.map(currentValue[TRANSFORM_PROP], function(value, prop) {
- if (prop === "translate")
- return translator.getTranslateCss(value);
- else if (prop === "scale")
- return "scale(" + value + ")";
- else if (prop.substr(0, prop.length - 1) === "rotate")
- return prop + "(" + value + "deg)"
- }).join(" ");
- $element.css(currentValue)
- }
- };
- if (config.delay) {
- config.frameAnimation.startTime += config.delay;
- config.frameAnimation.delayTimeout = setTimeout(function() {
- that._animationStep($element, config)
- }, config.delay)
- }
- else
- that._animationStep($element, config);
- return deferred.promise()
- },
- _parseTransform: function(transformString) {
- var result = {};
- $.each(transformString.match(/(\w|\d)+\([^\)]*\)\s*/g), function(i, part) {
- var translateData = translator.parseTranslate(part),
- scaleData = part.match(/scale\((.+?)\)/),
- rotateData = part.match(/(rotate.)\((.+)deg\)/);
- if (translateData)
- result.translate = translateData;
- if (scaleData && scaleData[1])
- result.scale = parseFloat(scaleData[1]);
- if (rotateData && rotateData[1])
- result[rotateData[1]] = parseFloat(rotateData[2])
- });
- return result
- },
- stop: function($element, config, jumpToEnd) {
- var frameAnimation = config && config.frameAnimation;
- if (!frameAnimation)
- return;
- clearTimeout(frameAnimation.delayTimeout);
- if (jumpToEnd)
- frameAnimation.finish();
- delete config.frameAnimation
- },
- _animationStep: function($element, config) {
- var frameAnimation = config && config.frameAnimation;
- if (!frameAnimation)
- return;
- var now = (new Date).valueOf();
- if (now >= frameAnimation.startTime + frameAnimation.duration) {
- frameAnimation.finish();
- return
- }
- frameAnimation.currentValue = this._calcStepValue(frameAnimation, now - frameAnimation.startTime);
- frameAnimation.draw();
- DX.requestAnimationFrame($.proxy(function() {
- this._animationStep($element, config)
- }, this))
- },
- _calcStepValue: function(frameAnimation, currentDuration) {
- var calcValueRecursively = function(from, to) {
- var result = $.isArray(to) ? [] : {};
- var calcEasedValue = function(propName) {
- var x = currentDuration / frameAnimation.duration,
- t = currentDuration,
- b = 1 * from[propName],
- c = to[propName] - from[propName],
- d = frameAnimation.duration;
- return $.easing[frameAnimation.easing](x, t, b, c, d)
- };
- $.each(to, function(propName, endPropValue) {
- if (typeof endPropValue === "string" && parseFloat(endPropValue, 10) === false)
- return true;
- result[propName] = typeof endPropValue === "object" ? calcValueRecursively(from[propName], endPropValue) : calcEasedValue(propName)
- });
- return result
- };
- return calcValueRecursively(frameAnimation.from, frameAnimation.to)
- },
- _normalizeValue: function(value) {
- var numericValue = parseFloat(value, 10);
- if (numericValue === false)
- return value;
- return numericValue
- }
- };
- var animationStrategies = {
- transition: support.transition ? TransitionAnimationStrategy : FrameAnimationStrategy,
- frame: FrameAnimationStrategy
- };
- var getAnimationStrategy = function(config) {
- return animationStrategies[config && config.strategy || "transition"]
- };
- var TransitionTimingFuncMap = {
- linear: "cubic-bezier(0, 0, 1, 1)",
- ease: "cubic-bezier(0.25, 0.1, 0.25, 1)",
- "ease-in": "cubic-bezier(0.42, 0, 1, 1)",
- "ease-out": "cubic-bezier(0, 0, 0.58, 1)",
- "ease-in-out": "cubic-bezier(0.42, 0, 0.58, 1)"
- };
- var convertTransitionTimingFuncToJQueryEasing = function(cssTransitionEasing) {
- cssTransitionEasing = TransitionTimingFuncMap[cssTransitionEasing] || cssTransitionEasing;
- var bezCoeffs = cssTransitionEasing.match(CSS_TRANSITION_EASING_REGEX);
- if (!bezCoeffs)
- return "linear";
- bezCoeffs = bezCoeffs.slice(1, 5);
- $.each(bezCoeffs, function(index, value) {
- bezCoeffs[index] = parseFloat(value)
- });
- var easingName = "cubicbezier_" + bezCoeffs.join("_").replace(/\./g, "p");
- if (!$.isFunction($.easing[easingName])) {
- var polynomBezier = function(x1, y1, x2, y2) {
- var Cx = 3 * x1,
- Bx = 3 * (x2 - x1) - Cx,
- Ax = 1 - Cx - Bx,
- Cy = 3 * y1,
- By = 3 * (y2 - y1) - Cy,
- Ay = 1 - Cy - By;
- var bezierX = function(t) {
- return t * (Cx + t * (Bx + t * Ax))
- };
- var bezierY = function(t) {
- return t * (Cy + t * (By + t * Ay))
- };
- var findXfor = function(t) {
- var x = t,
- i = 0,
- z;
- while (i < 14) {
- z = bezierX(x) - t;
- if (Math.abs(z) < 1e-3)
- break;
- x = x - z / derivativeX(x);
- i++
- }
- return x
- };
- var derivativeX = function(t) {
- return Cx + t * (2 * Bx + t * 3 * Ax)
- };
- return function(t) {
- return bezierY(findXfor(t))
- }
- };
- $.easing[easingName] = function(x, t, b, c, d) {
- return c * polynomBezier(bezCoeffs[0], bezCoeffs[1], bezCoeffs[2], bezCoeffs[3])(t / d) + b
- }
- }
- return easingName
- };
- var baseConfigValidator = function(config, animationType) {
- $.each(["from", "to"], function() {
- if (!$.isPlainObject(config[this]))
- throw Error("Animation with the '" + animationType + "' type requires '" + this + "' configuration as an plain object.");
- })
- };
- var CustomAnimationConfigurator = {setup: function($element, config){}};
- var SlideAnimationConfigurator = {
- validateConfig: function(config) {
- baseConfigValidator(config, "slide")
- },
- setup: function($element, config) {
- var location = translator.locate($element);
- this._setUpConfig(location, config.from);
- this._setUpConfig(location, config.to);
- translator.clearCache($element);
- if (!support.transform3d && $element.css("position") === "static")
- $element.css("position", "relative")
- },
- _setUpConfig: function(location, config) {
- config.left = "left" in config ? config.left : "+=0";
- config.top = "top" in config ? config.top : "+=0";
- this._initNewPosition(location, config)
- },
- _initNewPosition: function(location, config) {
- var position = {
- left: config.left,
- top: config.top
- };
- delete config.left;
- delete config.top;
- var relativeValue = this._getRelativeValue(position.left);
- if (relativeValue !== undefined)
- position.left = relativeValue + location.left;
- else
- config.left = 0;
- relativeValue = this._getRelativeValue(position.top);
- if (relativeValue !== undefined)
- position.top = relativeValue + location.top;
- else
- config.top = 0;
- var translate = {
- x: 0,
- y: 0
- };
- if (support.transform3d)
- translate = {
- x: position.left,
- y: position.top
- };
- else {
- config.left = position.left;
- config.top = position.top
- }
- config[TRANSFORM_PROP] = translator.getTranslateCss(translate)
- },
- _getRelativeValue: function(value) {
- var relativeValue;
- if (typeof value === "string" && (relativeValue = RELATIVE_VALUE_REGEX.exec(value)))
- return parseInt(relativeValue[1] + "1") * relativeValue[2]
- }
- };
- var FadeAnimationConfigurator = {setup: function($element, config) {
- var from = config.from,
- fromOpacity = $.isPlainObject(from) ? $element.css("opacity") : String(from),
- toOpacity = String(config.to);
- config.from = {opacity: fromOpacity};
- config.to = {opacity: toOpacity}
- }};
- var PopAnimationConfigurator = {
- validateConfig: function(config) {
- baseConfigValidator(config, "pop")
- },
- setup: function($element, config) {
- var from = config.from,
- to = config.to,
- fromOpacity = "opacity" in from ? from.opacity : $element.css("opacity"),
- toOpacity = "opacity" in to ? to.opacity : 1,
- fromScale = "scale" in from ? from.scale : 0,
- toScale = "scale" in to ? to.scale : 1;
- config.from = {opacity: fromOpacity};
- var translate = translator.getTranslate($element);
- config.from[TRANSFORM_PROP] = this._getCssTransform(translate, fromScale);
- config.to = {opacity: toOpacity};
- config.to[TRANSFORM_PROP] = this._getCssTransform(translate, toScale)
- },
- _getCssTransform: function(translate, scale) {
- return translator.getTranslateCss(translate) + "scale(" + scale + ")"
- }
- };
- var animationConfigurators = {
- custom: CustomAnimationConfigurator,
- slide: SlideAnimationConfigurator,
- fade: FadeAnimationConfigurator,
- pop: PopAnimationConfigurator
- };
- var getAnimationConfigurator = function(type) {
- var result = animationConfigurators[type];
- if (!result)
- throw Error("Unknown animation type \"" + type + "\"");
- return result
- };
- var defaultConfig = {
- type: "custom",
- from: {},
- to: {},
- duration: 400,
- start: $.noop,
- complete: $.noop,
- easing: "ease",
- delay: 0
- };
- var animate = function(element, config) {
- var $element = $(element);
- config = $.extend(true, {}, defaultConfig, config);
- if (!$element.length)
- return $.Deferred().resolve().promise();
- var configurator = getAnimationConfigurator(config.type);
- if ($.isFunction(configurator.validateConfig))
- configurator.validateConfig(config);
- return pushInAnimationQueue($element, config)
- };
- var pushInAnimationQueue = function($element, config) {
- config.deferred = config.deferred || $.Deferred();
- var queueData = getAnimQueueData($element);
- writeAnimQueueData($element, queueData);
- queueData.push(config);
- if (!isAnimating($element))
- shiftFromAnimationQueue($element, queueData);
- return config.deferred.promise()
- };
- var getAnimQueueData = function($element) {
- return $element.data(ANIM_QUEUE_KEY) || []
- };
- var writeAnimQueueData = function($element, queueData) {
- $element.data(ANIM_QUEUE_KEY, queueData)
- };
- var destroyAnimQueueData = function($element) {
- $element.removeData(ANIM_QUEUE_KEY)
- };
- var isAnimating = function($element) {
- return !!$element.data(ANIM_DATA_KEY)
- };
- var shiftFromAnimationQueue = function($element, queueData) {
- var queueData = getAnimQueueData($element);
- if (!queueData.length)
- return;
- var config = queueData.shift();
- if (queueData.length === 0)
- destroyAnimQueueData($element);
- executeAnimation($element, config).done(function() {
- shiftFromAnimationQueue($element)
- })
- };
- var executeAnimation = function($element, config) {
- setupPosition($element, config.from);
- setupPosition($element, config.to);
- var configurator = getAnimationConfigurator(config.type);
- configurator.setup($element, config);
- $element.data(ANIM_DATA_KEY, config);
- if (DX.fx.off)
- config.duration = 0;
- setProps($element, config.from);
- config.start.apply(this, [$element, config]);
- return getAnimationStrategy(config).animate($element, config).done(function() {
- $element.removeData(ANIM_DATA_KEY);
- config.complete.apply(this, [$element, config]);
- config.deferred.resolveWith(this, [$element, config])
- })
- };
- var setupPosition = function($element, config) {
- if (!config.position)
- return;
- var position = DX.calculatePosition($element, config.position),
- offset = $element.offset(),
- currentPosition = $element.position();
- $.extend(config, {
- left: position.h.location - offset.left + currentPosition.left,
- top: position.v.location - offset.top + currentPosition.top
- });
- delete config.position
- };
- var setProps = function($element, props) {
- $.each(props, function(key, value) {
- $element.css(key, value)
- })
- };
- var stop = function(element, jumpToEnd) {
- var $element = $(element),
- queueData = getAnimQueueData($element);
- $.each(queueData, function(_, config) {
- config.duration = 0
- });
- var config = $element.data(ANIM_DATA_KEY);
- getAnimationStrategy(config).stop($element, config, jumpToEnd);
- $element.removeData(ANIM_DATA_KEY);
- destroyAnimQueueData($element)
- };
- DX.fx = {
- off: false,
- animationTypes: animationConfigurators,
- animate: animate,
- isAnimating: isAnimating,
- stop: stop
- };
- DX.fx.__internals = {convertTransitionTimingFuncToJQueryEasing: convertTransitionTimingFuncToJQueryEasing}
- })(jQuery, DevExpress);
- /*! Module core, file endpointSelector.js */
- (function($, DX, undefined) {
- var location = window.location,
- DXPROXY_HOST = "dxproxy.devexpress.com:8000",
- WIN_JS = location.protocol === "ms-appx:",
- IS_DXPROXY = location.host === DXPROXY_HOST,
- IS_LOCAL = isLocalHostName(location.hostname);
- function isLocalHostName(url) {
- return /^(localhost$|127\.)/i.test(url)
- }
- var extractProxyAppId = function() {
- return location.pathname.split("/")[1]
- };
- var formatProxyUrl = function(localUrl) {
- var urlData = DX.parseUrl(localUrl);
- if (!isLocalHostName(urlData.hostname))
- return localUrl;
- return "http://" + DXPROXY_HOST + "/" + extractProxyAppId() + "_" + urlData.port + urlData.pathname + urlData.search
- };
- var EndpointSelector = DX.EndpointSelector = function(config) {
- this.config = config
- };
- EndpointSelector.prototype = {urlFor: function(key) {
- var bag = this.config[key];
- if (!bag)
- throw Error("Unknown endpoint key");
- if (IS_DXPROXY)
- return formatProxyUrl(bag.local);
- if (bag.production)
- if (WIN_JS && !Debug.debuggerEnabled || !WIN_JS && !IS_LOCAL)
- return bag.production;
- return bag.local
- }}
- })(jQuery, DevExpress);
- /*! Module core, file formatHelper.js */
- (function($, DX, undefined) {
- var utils = DX.utils;
- DX.NumericFormat = {
- currency: 'C',
- fixedpoint: 'N',
- exponential: '',
- percent: 'P',
- decimal: 'D'
- };
- DX.LargeNumberFormatPostfixes = {
- 1: 'K',
- 2: 'M',
- 3: 'B',
- 4: 'T'
- };
- var MAX_LARGE_NUMBER_POWER = 4,
- DECIMAL_BASE = 10;
- DX.LargeNumberFormatPowers = {
- largenumber: 'auto',
- thousands: 1,
- millions: 2,
- billions: 3,
- trillions: 4
- };
- DX.DateTimeFormat = {
- longdate: 'D',
- longtime: 'T',
- monthandday: 'M',
- monthandyear: 'Y',
- quarterandyear: 'qq',
- shortdate: 'd',
- shorttime: 't',
- millisecond: 'fff',
- second: 'T',
- minute: 't',
- hour: 't',
- day: 'dd',
- week: 'dd',
- month: 'MMMM',
- quarter: 'qq',
- year: 'yyyy',
- longdatelongtime: 'D',
- shortdateshorttime: 'd'
- };
- DX.formatHelper = {
- defaultQuarterFormat: 'Q{0}',
- romanDigits: ['I', 'II', 'III', 'IV'],
- _addFormatSeparator: function(format1, format2) {
- var separator = ' ';
- if (format2)
- return format1 + separator + format2;
- return format1
- },
- _getDateTimeFormatPattern: function(dateTimeFormat) {
- return Globalize.findClosestCulture().calendar.patterns[DX.DateTimeFormat[dateTimeFormat.toLowerCase()]]
- },
- _isDateFormatContains: function(format) {
- var result = false;
- $.each(DX.DateTimeFormat, function(key, value) {
- result = key === format.toLowerCase();
- return !result
- });
- return result
- },
- getQuarter: function(month) {
- return Math.floor(month / 3)
- },
- getFirstQuarterMonth: function(month) {
- return this.getQuarter(month) * 3
- },
- _getQuarterString: function(date, format) {
- var quarter = this.getQuarter(date.getMonth());
- switch (format) {
- case'q':
- return this.romanDigits[quarter];
- case'qq':
- return utils.stringFormat(this.defaultQuarterFormat, this.romanDigits[quarter]);
- case'Q':
- return (quarter + 1).toString();
- case'QQ':
- return utils.stringFormat(this.defaultQuarterFormat, (quarter + 1).toString())
- }
- return ''
- },
- _formatCustomString: function(value, format) {
- var regExp = /qq|q|QQ|Q/g,
- quarterFormat,
- result = '',
- index = 0;
- regExp.lastIndex = 0;
- while (index < format.length) {
- quarterFormat = regExp.exec(format);
- if (!quarterFormat || quarterFormat.index > index)
- result += Globalize.format(value, format.substring(index, quarterFormat ? quarterFormat.index : format.length));
- if (quarterFormat) {
- result += this._getQuarterString(value, quarterFormat[0]);
- index = quarterFormat.index + quarterFormat[0].length
- }
- else
- index = format.length
- }
- return result
- },
- _parseNumberFormatString: function(format) {
- var formatList,
- formatObject = {};
- if (!format || typeof format !== 'string')
- return;
- formatList = format.toLowerCase().split(' ');
- $.each(formatList, function(index, value) {
- if (value in DX.NumericFormat)
- formatObject.formatType = value;
- else if (value in DX.LargeNumberFormatPowers)
- formatObject.power = DX.LargeNumberFormatPowers[value]
- });
- if (formatObject.power && !formatObject.formatType)
- formatObject.formatType = 'fixedpoint';
- if (formatObject.formatType)
- return formatObject
- },
- _calculateNumberPower: function(value, base, minPower, maxPower) {
- var number = Math.abs(value);
- var power = 0;
- if (number > 1)
- while (number && number >= base && (maxPower === undefined || power < maxPower)) {
- power++;
- number = number / base
- }
- else if (number > 0 && number < 1)
- while (number < 1 && (minPower === undefined || power > minPower)) {
- power--;
- number = number * base
- }
- return power
- },
- _getNumberByPower: function(number, power, base) {
- var result = number;
- while (power > 0) {
- result = result / base;
- power--
- }
- while (power < 0) {
- result = result * base;
- power++
- }
- return result
- },
- _formatNumber: function(value, formatObject, precision) {
- var powerPostfix;
- if (formatObject.power === 'auto')
- formatObject.power = this._calculateNumberPower(value, 1000, 0, MAX_LARGE_NUMBER_POWER);
- if (formatObject.power)
- value = this._getNumberByPower(value, formatObject.power, 1000);
- powerPostfix = DX.LargeNumberFormatPostfixes[formatObject.power] || '';
- return this._formatNumberCore(value, formatObject.formatType, precision) + powerPostfix
- },
- _formatNumberExponential: function(value, precision) {
- var power = this._calculateNumberPower(value, DECIMAL_BASE),
- number = this._getNumberByPower(value, power, DECIMAL_BASE),
- powString;
- precision = precision === undefined ? 1 : precision;
- if (number.toFixed(precision || 0) >= DECIMAL_BASE) {
- power++;
- number = number / DECIMAL_BASE
- }
- powString = (power >= 0 ? '+' : '') + power.toString();
- return this._formatNumberCore(number, 'fixedpoint', precision) + 'E' + powString
- },
- _formatNumberCore: function(value, format, precision) {
- if (format === 'exponential')
- return this._formatNumberExponential(value, precision);
- else
- return Globalize.format(value, DX.NumericFormat[format] + (utils.isNumber(precision) ? precision : 0))
- },
- _formatDate: function(date, format, formatString) {
- var resultFormat = DX.DateTimeFormat[format.toLowerCase()];
- format = format.toLowerCase();
- if (format === 'quarterandyear')
- resultFormat = this._getQuarterString(date, resultFormat) + ' yyyy';
- if (format === 'quarter')
- return this._getQuarterString(date, resultFormat);
- if (format === 'longdatelongtime')
- return this._formatDate(date, 'longdate') + ' ' + this._formatDate(date, 'longtime');
- if (format === 'shortdateshorttime')
- return this._formatDate(date, 'shortDate') + ' ' + this._formatDate(date, 'shortTime');
- return Globalize.format(date, resultFormat)
- },
- format: function(value, format, precision) {
- if (format && format.format)
- if (format.dateType)
- return this._formatDateEx(value, format);
- else if (utils.isNumber(value) && isFinite(value))
- return this._formatNumberEx(value, format);
- return this._format(value, format, precision)
- },
- _format: function(value, format, precision) {
- var numberFormatObject;
- if (!utils.isString(format) || format === '' || !utils.isNumber(value) && !utils.isDate(value))
- return utils.isDefined(value) ? value.toString() : '';
- numberFormatObject = this._parseNumberFormatString(format);
- if (utils.isNumber(value) && numberFormatObject)
- return this._formatNumber(value, numberFormatObject, precision);
- if (utils.isDate(value) && this._isDateFormatContains(format))
- return this._formatDate(value, format);
- if (!numberFormatObject && !this._isDateFormatContains(format))
- return this._formatCustomString(value, format)
- },
- _formatNumberEx: function(value, formatInfo) {
- var that = this,
- numericFormatType = DX.NumericFormat[formatInfo.format.toLowerCase()],
- numberFormat = Globalize.culture().numberFormat,
- currencyFormat = formatInfo.currencyCulture && Globalize.cultures[formatInfo.currencyCulture] ? Globalize.cultures[formatInfo.currencyCulture].numberFormat.currency : numberFormat.currency,
- percentFormat = numberFormat.percent,
- formatSettings = that._getUnitFormatSettings(value, formatInfo),
- unit = formatSettings.unit,
- precision = formatSettings.precision,
- showTrailingZeros = formatSettings.showTrailingZeros,
- includeGroupSeparator = formatSettings.includeGroupSeparator,
- groupSymbol = numberFormat[","],
- floatingSymbol = numberFormat["."],
- number,
- isNegative,
- pattern,
- currentFormat,
- regexParts = /n|\$|-|%/g,
- result = "";
- if (!utils.isDefined(value))
- return '';
- value = that._applyUnitToValue(value, unit);
- number = Math.abs(value);
- isNegative = value < 0;
- switch (numericFormatType) {
- case DX.NumericFormat.decimal:
- pattern = "n";
- number = Math[isNegative ? "ceil" : "floor"](number);
- if (precision > 0) {
- var str = "" + number;
- for (var i = str.length; i < precision; i += 1)
- str = "0" + str;
- number = str
- }
- if (isNegative)
- number = "-" + number;
- break;
- case DX.NumericFormat.fixedpoint:
- currentFormat = numberFormat;
- case DX.NumericFormat.currency:
- currentFormat = currentFormat || currencyFormat;
- case DX.NumericFormat.percent:
- currentFormat = currentFormat || percentFormat;
- pattern = isNegative ? currentFormat.pattern[0] : currentFormat.pattern[1] || "n";
- number = Globalize.format(number * (numericFormatType === DX.NumericFormat.percent ? 100 : 1), "N" + precision);
- if (!showTrailingZeros)
- number = that._excludeTrailingZeros(number, floatingSymbol);
- if (!includeGroupSeparator)
- number = number.replace(new RegExp('\\' + groupSymbol, 'g'), '');
- break;
- case DX.NumericFormat.exponential:
- return that._formatNumberExponential(value, precision);
- default:
- throw"Illegal numeric format: '" + numericFormatType + "'";
- }
- for (; ; ) {
- var lastIndex = regexParts.lastIndex,
- matches = regexParts.exec(pattern);
- result += pattern.slice(lastIndex, matches ? matches.index : pattern.length);
- if (matches)
- switch (matches[0]) {
- case"-":
- if (/[1-9]/.test(number))
- result += numberFormat["-"];
- break;
- case"$":
- result += currencyFormat.symbol;
- break;
- case"%":
- result += percentFormat.symbol;
- break;
- case"n":
- result += number + unit;
- break
- }
- else
- break
- }
- return (formatInfo.plus && value > 0 ? "+" : '') + result
- },
- _excludeTrailingZeros: function(strValue, floatingSymbol) {
- var floatingIndex = strValue.indexOf(floatingSymbol),
- stopIndex,
- i;
- if (floatingIndex < 0)
- return strValue;
- stopIndex = strValue.length;
- for (i = stopIndex - 1; i >= floatingIndex && (strValue[i] === '0' || i === floatingIndex); i--)
- stopIndex--;
- return strValue.substring(0, stopIndex)
- },
- _getUnitFormatSettings: function(value, formatInfo) {
- var unit = formatInfo.unit || '',
- precision = formatInfo.precision || 0,
- includeGroupSeparator = formatInfo.includeGroupSeparator || false,
- showTrailingZeros = formatInfo.showTrailingZeros === undefined ? true : formatInfo.showTrailingZeros,
- significantDigits = formatInfo.significantDigits || 1,
- absValue;
- if (unit.toLowerCase() === 'auto') {
- showTrailingZeros = false;
- absValue = Math.abs(value);
- if (significantDigits < 1)
- significantDigits = 1;
- if (absValue >= 1000000000) {
- unit = 'B';
- absValue /= 1000000000
- }
- else if (absValue >= 1000000) {
- unit = 'M';
- absValue /= 1000000
- }
- else if (absValue >= 1000) {
- unit = 'K';
- absValue /= 1000
- }
- else
- unit = '';
- if (absValue == 0)
- precision = 0;
- else if (absValue < 1) {
- precision = significantDigits;
- var smallValue = Math.pow(10, -significantDigits);
- while (absValue < smallValue) {
- smallValue /= 10;
- precision++
- }
- }
- else if (absValue >= 100)
- precision = significantDigits - 3;
- else if (absValue >= 10)
- precision = significantDigits - 2;
- else
- precision = significantDigits - 1
- }
- if (precision < 0)
- precision = 0;
- return {
- unit: unit,
- precision: precision,
- showTrailingZeros: showTrailingZeros,
- includeGroupSeparator: includeGroupSeparator
- }
- },
- _applyUnitToValue: function(value, unit) {
- if (unit == 'B')
- return value.toFixed(1) / 1000000000;
- if (unit == 'M')
- return value / 1000000;
- if (unit == 'K')
- return value / 1000;
- return value
- },
- _formatDateEx: function(value, formatInfo) {
- var that = this,
- format = formatInfo.format,
- dateType = formatInfo.dateType,
- calendar = Globalize.culture().calendars.standard,
- time = undefined,
- index,
- dateStr;
- format = format.toLowerCase();
- if (!utils.isDefined(value))
- return '';
- if (dateType !== 'num' || format === 'dayofweek')
- switch (format) {
- case'monthyear':
- return that._formatDate(value, 'monthandyear');
- case'quarteryear':
- return that._getQuarterString(value, 'QQ') + ' ' + value.getFullYear();
- case'daymonthyear':
- return that._formatDate(value, dateType + 'Date');
- case'datehour':
- time = new Date(value.getTime());
- time.setMinutes(0);
- dateStr = dateType === 'timeOnly' ? '' : that._formatDate(value, dateType + 'Date');
- return dateType === 'timeOnly' ? that._formatDate(time, 'shorttime') : dateStr + ' ' + that._formatDate(time, 'shorttime');
- case'datehourminute':
- dateStr = dateType === 'timeOnly' ? '' : that._formatDate(value, dateType + 'Date');
- return dateType === 'timeOnly' ? that._formatDate(value, 'shorttime') : dateStr + ' ' + that._formatDate(value, 'shorttime');
- case'datehourminutesecond':
- dateStr = dateType === 'timeOnly' ? '' : that._formatDate(value, dateType + 'Date');
- return dateType === 'timeOnly' ? that._formatDate(value, 'longtime') : dateStr + ' ' + that._formatDate(value, 'longtime');
- case'year':
- dateStr = value.toString();
- return dateType === 'abbr' ? dateStr.slice(2, 4) : dateStr;
- case'quarter':
- return utils.stringFormat(that.defaultQuarterFormat, value.toString());
- case'month':
- index = value - 1;
- return dateType === 'abbr' ? calendar.months.namesAbbr[index] : calendar.months.names[index];
- case'hour':
- if (dateType === 'long') {
- time = new Date;
- time.setHours(value);
- time.setMinutes(0);
- return that._formatDate(time, 'shorttime')
- }
- else
- return value.toString();
- case'dayofweek':
- index = utils.isString(value) ? $.inArray(value, ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']) : value;
- if (dateType !== 'num')
- return dateType === 'abbr' ? calendar.days.namesAbbr[index] : calendar.days.names[index];
- else
- return ((index - calendar.firstDay + 1 + 7) % 8).toString();
- default:
- return value.toString()
- }
- else
- return value.toString()
- },
- getTimeFormat: function(showSecond) {
- if (showSecond)
- return this._getDateTimeFormatPattern('longtime');
- return this._getDateTimeFormatPattern('shorttime')
- },
- getDateFormatByDifferences: function(dateDifferences) {
- var resultFormat = '';
- if (dateDifferences.millisecond)
- resultFormat = DX.DateTimeFormat.millisecond;
- if (dateDifferences.hour || dateDifferences.minute || dateDifferences.second)
- resultFormat = this._addFormatSeparator(this.getTimeFormat(dateDifferences.second), resultFormat);
- if (dateDifferences.year && dateDifferences.month && dateDifferences.day)
- return this._addFormatSeparator(this._getDateTimeFormatPattern('shortdate'), resultFormat);
- if (dateDifferences.year && dateDifferences.month)
- return DX.DateTimeFormat['monthandyear'];
- if (dateDifferences.year)
- return DX.DateTimeFormat['year'];
- if (dateDifferences.month && dateDifferences.day)
- return this._addFormatSeparator(this._getDateTimeFormatPattern('monthandday'), resultFormat);
- if (dateDifferences.month)
- return DX.DateTimeFormat['month'];
- if (dateDifferences.day)
- return this._addFormatSeparator('dddd, dd', resultFormat);
- return resultFormat
- },
- getDateFormatByTicks: function(ticks) {
- var resultFormat,
- maxDif,
- currentDif,
- i,
- dateUnitInterval;
- if (ticks.length > 1) {
- maxDif = utils.getDatesDifferences(ticks[0], ticks[1]);
- for (i = 1; i < ticks.length - 1; i++) {
- currentDif = utils.getDatesDifferences(ticks[i], ticks[i + 1]);
- if (maxDif.count < currentDif.count)
- maxDif = currentDif
- }
- }
- else
- maxDif = {
- year: true,
- month: true,
- day: true,
- hour: ticks[0].getHours() > 0,
- minute: ticks[0].getMinutes() > 0,
- second: ticks[0].getSeconds() > 0
- };
- resultFormat = this.getDateFormatByDifferences(maxDif);
- return resultFormat
- },
- getDateFormatByTickInterval: function(startValue, endValue, tickInterval) {
- var resultFormat,
- dateDifferences,
- dateUnitInterval,
- dateDifferencesConverter = {
- quarter: 'month',
- week: 'day'
- },
- correctDateDifferences = function(dateDifferences, tickInterval, value) {
- switch (tickInterval) {
- case'year':
- dateDifferences.month = value;
- case'quarter':
- case'month':
- dateDifferences.day = value;
- case'week':
- case'day':
- dateDifferences.hour = value;
- case'hour':
- dateDifferences.minute = value;
- case'minute':
- dateDifferences.second = value;
- case'second':
- dateDifferences.millisecond = value
- }
- },
- correctDifferencesByMaxDate = function(differences, minDate, maxDate) {
- if (!maxDate.getMilliseconds() && maxDate.getSeconds()) {
- if (maxDate.getSeconds() - minDate.getSeconds() === 1) {
- differences.millisecond = true;
- differences.second = false
- }
- }
- else if (!maxDate.getSeconds() && maxDate.getMinutes()) {
- if (maxDate.getMinutes() - minDate.getMinutes() === 1) {
- differences.second = true;
- differences.minute = false
- }
- }
- else if (!maxDate.getMinutes() && maxDate.getHours()) {
- if (maxDate.getHours() - minDate.getHours() === 1) {
- differences.minute = true;
- differences.hour = false
- }
- }
- else if (!maxDate.getHours() && maxDate.getDate() > 1) {
- if (maxDate.getDate() - minDate.getDate() === 1) {
- differences.hour = true;
- differences.day = false
- }
- }
- else if (maxDate.getDate() === 1 && maxDate.getMonth()) {
- if (maxDate.getMonth() - minDate.getMonth() === 1) {
- differences.day = true;
- differences.month = false
- }
- }
- else if (!maxDate.getMonth() && maxDate.getFullYear())
- if (maxDate.getFullYear() - minDate.getFullYear() === 1) {
- differences.month = true;
- differences.year = false
- }
- };
- tickInterval = utils.isString(tickInterval) ? tickInterval.toLowerCase() : tickInterval;
- dateDifferences = utils.getDatesDifferences(startValue, endValue);
- if (startValue !== endValue)
- correctDifferencesByMaxDate(dateDifferences, startValue > endValue ? endValue : startValue, startValue > endValue ? startValue : endValue);
- dateUnitInterval = utils.getDateUnitInterval(dateDifferences);
- correctDateDifferences(dateDifferences, dateUnitInterval, true);
- dateUnitInterval = utils.getDateUnitInterval(tickInterval || 'second');
- correctDateDifferences(dateDifferences, dateUnitInterval, false);
- dateDifferences[dateDifferencesConverter[dateUnitInterval] || dateUnitInterval] = true;
- resultFormat = this.getDateFormatByDifferences(dateDifferences);
- return resultFormat
- }
- }
- })(jQuery, DevExpress);
- /*! Module core, file color.js */
- (function(DX, undefined) {
- var standardColorNames = {
- aliceblue: 'f0f8ff',
- antiquewhite: 'faebd7',
- aqua: '00ffff',
- aquamarine: '7fffd4',
- azure: 'f0ffff',
- beige: 'f5f5dc',
- bisque: 'ffe4c4',
- black: '000000',
- blanchedalmond: 'ffebcd',
- blue: '0000ff',
- blueviolet: '8a2be2',
- brown: 'a52a2a',
- burlywood: 'deb887',
- cadetblue: '5f9ea0',
- chartreuse: '7fff00',
- chocolate: 'd2691e',
- coral: 'ff7f50',
- cornflowerblue: '6495ed',
- cornsilk: 'fff8dc',
- crimson: 'dc143c',
- cyan: '00ffff',
- darkblue: '00008b',
- darkcyan: '008b8b',
- darkgoldenrod: 'b8860b',
- darkgray: 'a9a9a9',
- darkgreen: '006400',
- darkkhaki: 'bdb76b',
- darkmagenta: '8b008b',
- darkolivegreen: '556b2f',
- darkorange: 'ff8c00',
- darkorchid: '9932cc',
- darkred: '8b0000',
- darksalmon: 'e9967a',
- darkseagreen: '8fbc8f',
- darkslateblue: '483d8b',
- darkslategray: '2f4f4f',
- darkturquoise: '00ced1',
- darkviolet: '9400d3',
- deeppink: 'ff1493',
- deepskyblue: '00bfff',
- dimgray: '696969',
- dodgerblue: '1e90ff',
- feldspar: 'd19275',
- firebrick: 'b22222',
- floralwhite: 'fffaf0',
- forestgreen: '228b22',
- fuchsia: 'ff00ff',
- gainsboro: 'dcdcdc',
- ghostwhite: 'f8f8ff',
- gold: 'ffd700',
- goldenrod: 'daa520',
- gray: '808080',
- green: '008000',
- greenyellow: 'adff2f',
- honeydew: 'f0fff0',
- hotpink: 'ff69b4',
- indianred: 'cd5c5c',
- indigo: '4b0082',
- ivory: 'fffff0',
- khaki: 'f0e68c',
- lavender: 'e6e6fa',
- lavenderblush: 'fff0f5',
- lawngreen: '7cfc00',
- lemonchiffon: 'fffacd',
- lightblue: 'add8e6',
- lightcoral: 'f08080',
- lightcyan: 'e0ffff',
- lightgoldenrodyellow: 'fafad2',
- lightgrey: 'd3d3d3',
- lightgreen: '90ee90',
- lightpink: 'ffb6c1',
- lightsalmon: 'ffa07a',
- lightseagreen: '20b2aa',
- lightskyblue: '87cefa',
- lightslateblue: '8470ff',
- lightslategray: '778899',
- lightsteelblue: 'b0c4de',
- lightyellow: 'ffffe0',
- lime: '00ff00',
- limegreen: '32cd32',
- linen: 'faf0e6',
- magenta: 'ff00ff',
- maroon: '800000',
- mediumaquamarine: '66cdaa',
- mediumblue: '0000cd',
- mediumorchid: 'ba55d3',
- mediumpurple: '9370d8',
- mediumseagreen: '3cb371',
- mediumslateblue: '7b68ee',
- mediumspringgreen: '00fa9a',
- mediumturquoise: '48d1cc',
- mediumvioletred: 'c71585',
- midnightblue: '191970',
- mintcream: 'f5fffa',
- mistyrose: 'ffe4e1',
- moccasin: 'ffe4b5',
- navajowhite: 'ffdead',
- navy: '000080',
- oldlace: 'fdf5e6',
- olive: '808000',
- olivedrab: '6b8e23',
- orange: 'ffa500',
- orangered: 'ff4500',
- orchid: 'da70d6',
- palegoldenrod: 'eee8aa',
- palegreen: '98fb98',
- paleturquoise: 'afeeee',
- palevioletred: 'd87093',
- papayawhip: 'ffefd5',
- peachpuff: 'ffdab9',
- peru: 'cd853f',
- pink: 'ffc0cb',
- plum: 'dda0dd',
- powderblue: 'b0e0e6',
- purple: '800080',
- red: 'ff0000',
- rosybrown: 'bc8f8f',
- royalblue: '4169e1',
- saddlebrown: '8b4513',
- salmon: 'fa8072',
- sandybrown: 'f4a460',
- seagreen: '2e8b57',
- seashell: 'fff5ee',
- sienna: 'a0522d',
- silver: 'c0c0c0',
- skyblue: '87ceeb',
- slateblue: '6a5acd',
- slategray: '708090',
- snow: 'fffafa',
- springgreen: '00ff7f',
- steelblue: '4682b4',
- tan: 'd2b48c',
- teal: '008080',
- thistle: 'd8bfd8',
- tomato: 'ff6347',
- turquoise: '40e0d0',
- violet: 'ee82ee',
- violetred: 'd02090',
- wheat: 'f5deb3',
- white: 'ffffff',
- whitesmoke: 'f5f5f5',
- yellow: 'ffff00',
- yellowgreen: '9acd32'
- };
- var standardColorTypes = [{
- re: /^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/,
- process: function(colorString) {
- return [parseInt(colorString[1], 10), parseInt(colorString[2], 10), parseInt(colorString[3], 10)]
- }
- }, {
- re: /^rgba\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3}),\s*(\d*\.*\d+)\)$/,
- process: function(colorString) {
- return [parseInt(colorString[1], 10), parseInt(colorString[2], 10), parseInt(colorString[3], 10), parseFloat(colorString[4])]
- }
- }, {
- re: /^#(\w{2})(\w{2})(\w{2})$/,
- process: function(colorString) {
- return [parseInt(colorString[1], 16), parseInt(colorString[2], 16), parseInt(colorString[3], 16)]
- }
- }, {
- re: /^#(\w{1})(\w{1})(\w{1})$/,
- process: function(colorString) {
- return [parseInt(colorString[1] + colorString[1], 16), parseInt(colorString[2] + colorString[2], 16), parseInt(colorString[3] + colorString[3], 16)]
- }
- }, {
- re: /^hsv\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/,
- process: function(colorString) {
- var h = parseInt(colorString[1], 10),
- s = parseInt(colorString[2], 10),
- v = parseInt(colorString[3], 10),
- rgb = hsvToRgb(h, s, v);
- return [rgb[0], rgb[1], rgb[2], 1, [h, s, v]]
- }
- }, {
- re: /^hsl\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/,
- process: function(colorString) {
- var h = parseInt(colorString[1], 10),
- s = parseInt(colorString[2], 10),
- l = parseInt(colorString[3], 10),
- rgb = hslToRgb(h, s, l);
- return [rgb[0], rgb[1], rgb[2], 1, null, [h, s, l]]
- }
- }];
- function Color(value) {
- this.baseColor = value;
- var color;
- if (value) {
- color = String(value).toLowerCase().replace(/ /g, '');
- color = standardColorNames[color] ? '#' + standardColorNames[color] : color;
- color = parseColor(color)
- }
- if (!color)
- this.colorIsInvalid = true;
- color = color || {};
- this.r = normalize(color[0]);
- this.g = normalize(color[1]);
- this.b = normalize(color[2]);
- this.a = normalize(color[3], 1, 1);
- if (color[4])
- this.hsv = {
- h: color[4][0],
- s: color[4][1],
- v: color[4][2]
- };
- else
- this.hsv = toHsvFromRgb(this.r, this.g, this.b);
- if (color[5])
- this.hsl = {
- h: color[5][0],
- s: color[5][1],
- l: color[5][2]
- };
- else
- this.hsl = toHslFromRgb(this.r, this.g, this.b)
- }
- function parseColor(color) {
- if (color === "transparent")
- return [0, 0, 0, 0];
- var result,
- i = 0,
- ii = standardColorTypes.length,
- str;
- for (; i < ii; ++i) {
- str = standardColorTypes[i].re.exec(color);
- if (str)
- return standardColorTypes[i].process(str)
- }
- return null
- }
- function normalize(colorComponent, def, max) {
- def = def || 0;
- max = max || 255;
- return colorComponent < 0 || isNaN(colorComponent) ? def : colorComponent > max ? max : colorComponent
- }
- function toHexFromRgb(r, g, b) {
- return '#' + (0X01000000 | r << 16 | g << 8 | b).toString(16).slice(1)
- }
- function toHsvFromRgb(r, g, b) {
- var max = Math.max(r, g, b),
- min = Math.min(r, g, b),
- delta = max - min,
- H,
- S,
- V;
- V = max;
- S = max === 0 ? 0 : 1 - min / max;
- if (max === min)
- H = 0;
- else
- switch (max) {
- case r:
- H = 60 * ((g - b) / delta);
- if (g < b)
- H = H + 360;
- break;
- case g:
- H = 60 * ((b - r) / delta) + 120;
- break;
- case b:
- H = 60 * ((r - g) / delta) + 240;
- break
- }
- S *= 100;
- V *= 100 / 255;
- return {
- h: Math.round(H),
- s: Math.round(S),
- v: Math.round(V)
- }
- }
- function hsvToRgb(h, s, v) {
- var Vdec,
- Vinc,
- Vmin,
- Hi,
- a,
- r,
- g,
- b;
- Hi = Math.floor(h / 60);
- Vmin = (100 - s) * v / 100;
- a = (v - Vmin) * (h % 60 / 60);
- Vinc = Vmin + a;
- Vdec = v - a;
- switch (Hi) {
- case 0:
- r = v;
- g = Vinc;
- b = Vmin;
- break;
- case 1:
- r = Vdec;
- g = v;
- b = Vmin;
- break;
- case 2:
- r = Vmin;
- g = v;
- b = Vinc;
- break;
- case 3:
- r = Vmin;
- g = Vdec;
- b = v;
- break;
- case 4:
- r = Vinc;
- g = Vmin;
- b = v;
- break;
- case 5:
- r = v;
- g = Vmin;
- b = Vdec;
- break
- }
- return [Math.round(r * 2.55), Math.round(g * 2.55), Math.round(b * 2.55)]
- }
- function calculateHue(r, g, b, delta) {
- var max = Math.max(r, g, b);
- switch (max) {
- case r:
- return (g - b) / delta + (g < b ? 6 : 0);
- case g:
- return (b - r) / delta + 2;
- case b:
- return (r - g) / delta + 4
- }
- }
- function toHslFromRgb(r, g, b) {
- r = convertTo01Bounds(r, 255);
- g = convertTo01Bounds(g, 255);
- b = convertTo01Bounds(b, 255);
- var max = Math.max(r, g, b),
- min = Math.min(r, g, b),
- maxMinSumm = max + min,
- h,
- s,
- l = maxMinSumm / 2;
- if (max === min)
- h = s = 0;
- else {
- var delta = max - min;
- if (l > 0.5)
- s = delta / (2 - maxMinSumm);
- else
- s = delta / maxMinSumm;
- h = calculateHue(r, g, b, delta);
- h /= 6
- }
- return {
- h: _round(h * 360),
- s: _round(s * 100),
- l: _round(l * 100)
- }
- }
- function makeTc(colorPart, h) {
- var Tc = h;
- if (colorPart === "r")
- Tc = h + 1 / 3;
- if (colorPart === "b")
- Tc = h - 1 / 3;
- return Tc
- }
- function modifyTc(Tc) {
- if (Tc < 0)
- Tc += 1;
- if (Tc > 1)
- Tc -= 1;
- return Tc
- }
- function hueToRgb(p, q, Tc) {
- Tc = modifyTc(Tc);
- if (Tc < 1 / 6)
- return p + (q - p) * 6 * Tc;
- if (Tc < 1 / 2)
- return q;
- if (Tc < 2 / 3)
- return p + (q - p) * (2 / 3 - Tc) * 6;
- return p
- }
- function hslToRgb(h, s, l) {
- var r,
- g,
- b,
- h = convertTo01Bounds(h, 360),
- s = convertTo01Bounds(s, 100),
- l = convertTo01Bounds(l, 100);
- if (s === 0)
- r = g = b = l;
- else {
- var q = l < 0.5 ? l * (1 + s) : l + s - l * s,
- p = 2 * l - q;
- r = hueToRgb(p, q, makeTc("r", h));
- g = hueToRgb(p, q, makeTc("g", h));
- b = hueToRgb(p, q, makeTc("b", h))
- }
- return [_round(r * 255), _round(g * 255), _round(b * 255)]
- }
- function convertTo01Bounds(n, max) {
- n = Math.min(max, Math.max(0, parseFloat(n)));
- if (Math.abs(n - max) < 0.000001)
- return 1;
- return n % max / parseFloat(max)
- }
- function isIntegerBtwMinAndMax(number, min, max) {
- min = min || 0;
- max = max || 255;
- if (number % 1 !== 0 || number < min || number > max || typeof number !== 'number' || isNaN(number))
- return false;
- return true
- }
- var _round = Math.round;
- Color.prototype = {
- constructor: Color,
- highlight: function(step) {
- step = step || 10;
- return this.alter(step).toHex()
- },
- darken: function(step) {
- step = step || 10;
- return this.alter(-step).toHex()
- },
- alter: function(step) {
- var result = new Color;
- result.r = normalize(this.r + step);
- result.g = normalize(this.g + step);
- result.b = normalize(this.b + step);
- return result
- },
- blend: function(blendColor, opacity) {
- var other = blendColor instanceof Color ? blendColor : new Color(blendColor),
- result = new Color;
- result.r = normalize(_round(this.r * (1 - opacity) + other.r * opacity));
- result.g = normalize(_round(this.g * (1 - opacity) + other.g * opacity));
- result.b = normalize(_round(this.b * (1 - opacity) + other.b * opacity));
- return result
- },
- toHex: function() {
- return toHexFromRgb(this.r, this.g, this.b)
- },
- getPureColor: function() {
- var rgb = hsvToRgb(this.hsv.h, 100, 100);
- return new Color("rgb(" + rgb.join(",") + ")")
- },
- isValidHex: function(hex) {
- return /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(hex)
- },
- isValidRGB: function(r, g, b) {
- if (!isIntegerBtwMinAndMax(r) || !isIntegerBtwMinAndMax(g) || !isIntegerBtwMinAndMax(b))
- return false;
- return true
- },
- isValidAlpha: function(a) {
- if (isNaN(a) || a < 0 || a > 1 || typeof a !== 'number')
- return false;
- return true
- },
- colorIsInvalid: false
- };
- DX.Color = Color
- })(DevExpress);
- /*! Module core, file localization.js */
- (function($, DX, undefined) {
- Globalize.localize = function(key, cultureSelector) {
- var neutral = (cultureSelector || this.cultureSelector || "").substring(0, 2);
- return this.findClosestCulture(cultureSelector).messages[key] || this.findClosestCulture(neutral).messages[key] || this.cultures["default"].messages[key]
- };
- var localization = function() {
- var newMessages = {};
- return {
- setup: function(localizablePrefix) {
- this.localizeString = function(text) {
- var regex = new RegExp("(^|[^a-zA-Z_0-9" + localizablePrefix + "-]+)(" + localizablePrefix + "{1,2})([a-zA-Z_0-9-]+)", "g"),
- escapeString = localizablePrefix + localizablePrefix;
- return text.replace(regex, function(str, prefix, escape, localizationKey) {
- var result = prefix + localizablePrefix + localizationKey;
- if (escape !== escapeString)
- if (Globalize.cultures["default"].messages[localizationKey])
- result = prefix + Globalize.localize(localizationKey);
- else
- newMessages[localizationKey] = DX.inflector.humanize(localizationKey);
- return result
- })
- }
- },
- localizeNode: function(node) {
- var that = this;
- $(node).each(function(index, nodeItem) {
- if (!nodeItem.nodeType)
- return;
- if (nodeItem.nodeType === 3)
- nodeItem.nodeValue = that.localizeString(nodeItem.nodeValue);
- else {
- $.each(nodeItem.attributes || [], function(index, attr) {
- if (typeof attr.value === "string") {
- var localizedValue = that.localizeString(attr.value);
- if (attr.value !== localizedValue)
- attr.value = localizedValue
- }
- });
- $(nodeItem).contents().each(function(index, node) {
- that.localizeNode(node)
- })
- }
- })
- },
- getDictionary: function(onlyNew) {
- if (onlyNew)
- return newMessages;
- return $.extend({}, newMessages, Globalize.cultures["default"].messages)
- }
- }
- }();
- localization.setup("@");
- DX.localization = localization
- })(jQuery, DevExpress);
- /*! Module core, file localization.en.js */
- Globalize.addCultureInfo("default", {messages: {
- Yes: "Yes",
- No: "No",
- Cancel: "Cancel",
- Clear: "Clear",
- Done: "Done",
- Loading: "Loading...",
- Select: "Select...",
- Search: "Search",
- Back: "Back",
- OK: "OK",
- "dxLookup-searchPlaceholder": "Minimum character number: {0}",
- "dxCollectionContainerWidget-noDataText": "No data to display",
- "dxList-pullingDownText": "Pull down to refresh...",
- "dxList-pulledDownText": "Release to refresh...",
- "dxList-refreshingText": "Refreshing...",
- "dxList-pageLoadingText": "Loading...",
- "dxList-nextButtonText": "More",
- "dxListEditDecorator-delete": "Delete",
- "dxListEditDecorator-more": "More",
- "dxScrollView-pullingDownText": "Pull down to refresh...",
- "dxScrollView-pulledDownText": "Release to refresh...",
- "dxScrollView-refreshingText": "Refreshing...",
- "dxScrollView-reachBottomText": "Loading...",
- "dxSwitch-onText": "ON",
- "dxSwitch-offText": "OFF",
- "dxDateBox-simulatedDataPickerTitleTime": "Select time",
- "dxDateBox-simulatedDataPickerTitleDate": "Select date",
- "dxDateBox-simulatedDataPickerTitleDateTime": "Select date and time",
- "dxDataGrid-columnChooserTitle": "Column Chooser",
- "dxDataGrid-columnChooserEmptyText": "Drag a column here to hide it",
- "dxDataGrid-groupContinuesMessage": "Continues on the next page",
- "dxDataGrid-groupContinuedMessage": "Continued from the previous page",
- "dxDataGrid-editingEditRow": "Edit",
- "dxDataGrid-editingSaveRowChanges": "Save",
- "dxDataGrid-editingCancelRowChanges": "Cancel",
- "dxDataGrid-editingDeleteRow": "Delete",
- "dxDataGrid-editingUndeleteRow": "Undelete",
- "dxDataGrid-editingConfirmDeleteMessage": "Are you sure you want to delete this record?",
- "dxDataGrid-editingConfirmDeleteTitle": "",
- "dxDataGrid-groupPanelEmptyText": "Drag a column header here to group by that column",
- "dxDataGrid-noDataText": "No data",
- "dxDataGrid-searchPanelPlaceholder": "Search...",
- "dxDataGrid-filterRowShowAllText": "(All)",
- "dxDataGrid-filterRowResetOperationText": "Reset",
- "dxDataGrid-filterRowOperationEquals": "Equals",
- "dxDataGrid-filterRowOperationNotEquals": "Does not equal",
- "dxDataGrid-filterRowOperationLess": "Less than",
- "dxDataGrid-filterRowOperationLessOrEquals": "Less than or equal to",
- "dxDataGrid-filterRowOperationGreater": "Greater than",
- "dxDataGrid-filterRowOperationGreaterOrEquals": "Greater than or equal to",
- "dxDataGrid-filterRowOperationStartsWith": "Starts with",
- "dxDataGrid-filterRowOperationContains": "Contains",
- "dxDataGrid-filterRowOperationNotContains": "Does not contain",
- "dxDataGrid-filterRowOperationEndsWith": "Ends with",
- "dxDataGrid-trueText": "true",
- "dxDataGrid-falseText": "false",
- "dxDataGrid-sortingAscendingText": "Sort Ascending",
- "dxDataGrid-sortingDescendingText": "Sort Descending",
- "dxDataGrid-sortingClearText": "Clear Sorting"
- }});
- /*! Module core, file data.js */
- (function($, DX, undefined) {
- var bracketsToDots = function(expr) {
- return expr.replace(/\[/g, ".").replace(/\]/g, "")
- };
- var unwrapObservable = DX.utils.unwrapObservable;
- var isObservable = function(value) {
- return DX.support.hasKo && ko.isObservable(value)
- };
- var readPropValue = function(obj, propName) {
- if (propName === "this")
- return obj;
- return obj[propName]
- };
- var assignPropValue = function(obj, propName, value) {
- if (propName === "this")
- throw Error("Cannot assign to self");
- var propValue = obj[propName];
- if (isObservable(propValue))
- propValue(value);
- else
- obj[propName] = value
- };
- var compileGetter = function(expr) {
- if (arguments.length > 1)
- expr = $.makeArray(arguments);
- if (!expr || expr === "this")
- return function(obj) {
- return obj
- };
- if ($.isFunction(expr))
- return expr;
- if ($.isArray(expr))
- return combineGetters(expr);
- expr = bracketsToDots(expr);
- var path = expr.split(".");
- return function(obj, options) {
- options = options || {};
- var current = unwrapObservable(obj);
- $.each(path, function() {
- if (!current)
- return false;
- var next = unwrapObservable(current[this]);
- if ($.isFunction(next) && !options.functionsAsIs)
- next = next.call(current);
- current = next
- });
- return current
- }
- };
- var combineGetters = function(getters) {
- var compiledGetters = {};
- $.each(getters, function() {
- compiledGetters[this] = compileGetter(this)
- });
- return function(obj, options) {
- var result = {};
- $.each(compiledGetters, function(name) {
- var value = this(obj, options),
- current,
- path,
- last,
- i;
- if (value === undefined)
- return;
- current = result;
- path = name.split(".");
- last = path.length - 1;
- for (i = 0; i < last; i++)
- current = current[path[i]] = {};
- current[path[i]] = value
- });
- return result
- }
- };
- var compileSetter = function(expr) {
- expr = expr || "this";
- expr = bracketsToDots(expr);
- var pos = expr.lastIndexOf("."),
- targetGetter = compileGetter(expr.substr(0, pos)),
- targetPropName = expr.substr(1 + pos);
- return function(obj, value, options) {
- options = options || {};
- var target = targetGetter(obj, {functionsAsIs: options.functionsAsIs}),
- prevTargetValue = readPropValue(target, targetPropName);
- if (!options.functionsAsIs && $.isFunction(prevTargetValue) && !isObservable(prevTargetValue))
- target[targetPropName](value);
- else {
- prevTargetValue = unwrapObservable(prevTargetValue);
- if (options.merge && $.isPlainObject(value) && (prevTargetValue === undefined || $.isPlainObject(prevTargetValue)) && !(value instanceof $.Event)) {
- if (!prevTargetValue)
- assignPropValue(target, targetPropName, {});
- DX.utils.deepExtendArraySafe(unwrapObservable(readPropValue(target, targetPropName)), value)
- }
- else
- assignPropValue(target, targetPropName, value)
- }
- }
- };
- var normalizeBinaryCriterion = function(crit) {
- return [crit[0], crit.length < 3 ? "=" : String(crit[1]).toLowerCase(), crit.length < 2 ? true : crit[crit.length - 1]]
- };
- var normalizeSortingInfo = function(info) {
- if (!$.isArray(info))
- info = [info];
- return $.map(info, function(i) {
- return {
- selector: $.isFunction(i) || typeof i === "string" ? i : i.getter || i.field || i.selector,
- desc: !!(i.desc || String(i.dir).charAt(0).toLowerCase() === "d")
- }
- })
- };
- var Guid = DX.Class.inherit({
- ctor: function(value) {
- if (value)
- value = String(value);
- this._value = this._normalize(value || this._generate())
- },
- _normalize: function(value) {
- value = value.replace(/[^a-f0-9]/ig, "").toLowerCase();
- while (value.length < 32)
- value += "0";
- return [value.substr(0, 8), value.substr(8, 4), value.substr(12, 4), value.substr(16, 4), value.substr(20, 12)].join("-")
- },
- _generate: function() {
- var value = "";
- for (var i = 0; i < 32; i++)
- value += Math.round(Math.random() * 15).toString(16);
- return value
- },
- toString: function() {
- return this._value
- },
- valueOf: function() {
- return this._value
- },
- toJSON: function() {
- return this._value
- }
- });
- var toComparable = function(value, caseSensitive) {
- if (value instanceof Date)
- return value.getTime();
- if (value instanceof Guid)
- return value.valueOf();
- if (!caseSensitive && typeof value === "string")
- return value.toLowerCase();
- return value
- };
- var keysEqual = function(keyExpr, key1, key2) {
- if ($.isArray(keyExpr)) {
- var names = $.map(key1, function(v, k) {
- return k
- }),
- name;
- for (var i = 0; i < names.length; i++) {
- name = names[i];
- if (toComparable(key1[name], true) != toComparable(key2[name], true))
- return false
- }
- return true
- }
- return toComparable(key1, true) == toComparable(key2, true)
- };
- var BASE64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
- var base64_encode = function(input) {
- if (!$.isArray(input))
- input = stringToByteArray(String(input));
- var result = "";
- for (var i = 0; i < input.length; i += 3) {
- var octet1 = input[i],
- octet2 = input[i + 1],
- octet3 = input[i + 2];
- result += $.map([octet1 >> 2, (octet1 & 3) << 4 | octet2 >> 4, isNaN(octet2) ? 64 : (octet2 & 15) << 2 | octet3 >> 6, isNaN(octet3) ? 64 : octet3 & 63], function(item) {
- return BASE64_CHARS.charAt(item)
- }).join("")
- }
- return result
- };
- var stringToByteArray = function(str) {
- var bytes = [],
- code,
- i;
- for (i = 0; i < str.length; i++) {
- code = str.charCodeAt(i);
- if (code < 128)
- bytes.push(code);
- else if (code < 2048)
- bytes.push(192 + (code >> 6), 128 + (code & 63));
- else if (code < 65536)
- bytes.push(224 + (code >> 12), 128 + (code >> 6 & 63), 128 + (code & 63));
- else if (code < 2097152)
- bytes.push(240 + (code >> 18), 128 + (code >> 12 & 63), 128 + (code >> 6 & 63), 128 + (code & 63))
- }
- return bytes
- };
- var errorMessageFromXhr = function() {
- var textStatusMessages = {
- timeout: "Network connection timeout",
- error: "Unspecified network error",
- parsererror: "Unexpected server response"
- };
- var textStatusDetails = {
- timeout: "possible causes: the remote host is not accessible, overloaded or is not included into the domain white-list when being run in the native container",
- error: "if the remote host is located on another domain, make sure it properly supports cross-origin resource sharing (CORS), or use the JSONP approach instead",
- parsererror: "the remote host did not respond with valid JSON data"
- };
- var explainTextStatus = function(textStatus) {
- var result = textStatusMessages[textStatus];
- if (!result)
- return textStatus;
- result += " (" + textStatusDetails[textStatus] + ")";
- return result
- };
- return function(xhr, textStatus) {
- if (xhr.status < 400)
- return explainTextStatus(textStatus);
- return xhr.statusText
- }
- }();
- var data = DX.data = {
- utils: {
- compileGetter: compileGetter,
- compileSetter: compileSetter,
- normalizeBinaryCriterion: normalizeBinaryCriterion,
- normalizeSortingInfo: normalizeSortingInfo,
- toComparable: toComparable,
- keysEqual: keysEqual,
- errorMessageFromXhr: errorMessageFromXhr
- },
- Guid: Guid,
- base64_encode: base64_encode,
- queryImpl: {},
- queryAdapters: {},
- query: function() {
- var impl = $.isArray(arguments[0]) ? "array" : "remote";
- return data.queryImpl[impl].apply(this, arguments)
- },
- errorHandler: null,
- _handleError: function(error) {
- if (window.console)
- console.warn("[DevExpress.data]: " + error);
- if (data.errorHandler)
- data.errorHandler(error)
- }
- }
- })(jQuery, DevExpress);
- /*! Module core, file data.query.array.js */
- (function($, DX, undefined) {
- var Class = DX.Class,
- data = DX.data,
- queryImpl = data.queryImpl,
- compileGetter = data.utils.compileGetter,
- toComparable = data.utils.toComparable;
- var Iterator = Class.inherit({
- toArray: function() {
- var result = [];
- this.reset();
- while (this.next())
- result.push(this.current());
- return result
- },
- countable: function() {
- return false
- }
- });
- var ArrayIterator = Iterator.inherit({
- ctor: function(array) {
- this.array = array;
- this.index = -1
- },
- next: function() {
- if (this.index + 1 < this.array.length) {
- this.index++;
- return true
- }
- return false
- },
- current: function() {
- return this.array[this.index]
- },
- reset: function() {
- this.index = -1
- },
- toArray: function() {
- return this.array.slice(0)
- },
- countable: function() {
- return true
- },
- count: function() {
- return this.array.length
- }
- });
- var WrappedIterator = Iterator.inherit({
- ctor: function(iter) {
- this.iter = iter
- },
- next: function() {
- return this.iter.next()
- },
- current: function() {
- return this.iter.current()
- },
- reset: function() {
- return this.iter.reset()
- }
- });
- var MapIterator = WrappedIterator.inherit({
- ctor: function(iter, mapper) {
- this.callBase(iter);
- this.index = -1;
- this.mapper = mapper
- },
- current: function() {
- return this.mapper(this.callBase(), this.index)
- },
- next: function() {
- var hasNext = this.callBase();
- if (hasNext)
- this.index++;
- return hasNext
- }
- });
- var SortIterator = Iterator.inherit({
- ctor: function(iter, getter, desc) {
- if (!(iter instanceof MapIterator))
- iter = new MapIterator(iter, this._wrap);
- this.iter = iter;
- this.rules = [{
- getter: getter,
- desc: desc
- }]
- },
- thenBy: function(getter, desc) {
- var result = new SortIterator(this.sortedIter || this.iter, getter, desc);
- if (!this.sortedIter)
- result.rules = this.rules.concat(result.rules);
- return result
- },
- next: function() {
- this._ensureSorted();
- return this.sortedIter.next()
- },
- current: function() {
- this._ensureSorted();
- return this.sortedIter.current()
- },
- reset: function() {
- delete this.sortedIter
- },
- countable: function() {
- return this.sortedIter || this.iter.countable()
- },
- count: function() {
- if (this.sortedIter)
- return this.sortedIter.count();
- return this.iter.count()
- },
- _ensureSorted: function() {
- if (this.sortedIter)
- return;
- $.each(this.rules, function() {
- this.getter = compileGetter(this.getter)
- });
- this.sortedIter = new MapIterator(new ArrayIterator(this.iter.toArray().sort($.proxy(this._compare, this))), this._unwrap)
- },
- _wrap: function(record, index) {
- return {
- index: index,
- value: record
- }
- },
- _unwrap: function(wrappedItem) {
- return wrappedItem.value
- },
- _compare: function(x, y) {
- var xIndex = x.index,
- yIndex = y.index;
- x = x.value;
- y = y.value;
- if (x === y)
- return xIndex - yIndex;
- for (var i = 0, rulesCount = this.rules.length; i < rulesCount; i++) {
- var rule = this.rules[i],
- xValue = toComparable(rule.getter(x)),
- yValue = toComparable(rule.getter(y)),
- factor = rule.desc ? -1 : 1;
- if (xValue < yValue)
- return -factor;
- if (xValue > yValue)
- return factor;
- if (xValue !== yValue)
- return !xValue ? -factor : factor
- }
- return xIndex - yIndex
- }
- });
- var compileCriteria = function() {
- var compileGroup = function(crit) {
- var operands = [],
- bag = ["return function(d) { return "],
- index = 0,
- pushAnd = false;
- $.each(crit, function() {
- if ($.isArray(this) || $.isFunction(this)) {
- if (pushAnd)
- bag.push(" && ");
- operands.push(compileCriteria(this));
- bag.push("op[", index, "](d)");
- index++;
- pushAnd = true
- }
- else {
- bag.push(/and|&/i.test(this) ? " && " : " || ");
- pushAnd = false
- }
- });
- bag.push(" }");
- return new Function("op", bag.join(""))(operands)
- };
- var toString = function(value) {
- return DX.utils.isDefined(value) ? value.toString() : ''
- };
- var compileBinary = function(crit) {
- crit = data.utils.normalizeBinaryCriterion(crit);
- var getter = compileGetter(crit[0]),
- op = crit[1],
- value = crit[2];
- value = toComparable(value);
- switch (op.toLowerCase()) {
- case"=":
- return compileEquals(getter, value);
- case"<>":
- return compileEquals(getter, value, true);
- case">":
- return function(obj) {
- return toComparable(getter(obj)) > value
- };
- case"<":
- return function(obj) {
- return toComparable(getter(obj)) < value
- };
- case">=":
- return function(obj) {
- return toComparable(getter(obj)) >= value
- };
- case"<=":
- return function(obj) {
- return toComparable(getter(obj)) <= value
- };
- case"startswith":
- return function(obj) {
- return toComparable(toString(getter(obj))).indexOf(value) === 0
- };
- case"endswith":
- return function(obj) {
- var getterValue = toComparable(toString(getter(obj)));
- return getterValue.lastIndexOf(value) === getterValue.length - toString(value).length
- };
- case"contains":
- return function(obj) {
- return toComparable(toString(getter(obj))).indexOf(value) > -1
- };
- case"notcontains":
- return function(obj) {
- return toComparable(toString(getter(obj))).indexOf(value) === -1
- }
- }
- throw Error("Unknown filter operation: " + op);
- };
- function compileEquals(getter, value, negate) {
- return function(obj) {
- obj = toComparable(getter(obj));
- var result = useStrictComparison(value) ? obj === value : obj == value;
- if (negate)
- result = !result;
- return result
- }
- }
- function useStrictComparison(value) {
- return value === "" || value === 0 || value === null || value === false || value === undefined
- }
- return function(crit) {
- if ($.isFunction(crit))
- return crit;
- if ($.isArray(crit[0]))
- return compileGroup(crit);
- return compileBinary(crit)
- }
- }();
- var FilterIterator = WrappedIterator.inherit({
- ctor: function(iter, criteria) {
- this.callBase(iter);
- this.criteria = compileCriteria(criteria)
- },
- next: function() {
- while (this.iter.next())
- if (this.criteria(this.current()))
- return true;
- return false
- }
- });
- var GroupIterator = Iterator.inherit({
- ctor: function(iter, getter) {
- this.iter = iter;
- this.getter = getter
- },
- next: function() {
- this._ensureGrouped();
- return this.groupedIter.next()
- },
- current: function() {
- this._ensureGrouped();
- return this.groupedIter.current()
- },
- reset: function() {
- delete this.groupedIter
- },
- countable: function() {
- return !!this.groupedIter
- },
- count: function() {
- return this.groupedIter.count()
- },
- _ensureGrouped: function() {
- if (this.groupedIter)
- return;
- var hash = {},
- keys = [],
- iter = this.iter,
- getter = compileGetter(this.getter);
- iter.reset();
- while (iter.next()) {
- var current = iter.current(),
- key = getter(current);
- if (key in hash)
- hash[key].push(current);
- else {
- hash[key] = [current];
- keys.push(key)
- }
- }
- this.groupedIter = new ArrayIterator($.map(keys, function(key) {
- return {
- key: key,
- items: hash[key]
- }
- }))
- }
- });
- var SelectIterator = WrappedIterator.inherit({
- ctor: function(iter, getter) {
- this.callBase(iter);
- this.getter = compileGetter(getter)
- },
- current: function() {
- return this.getter(this.callBase())
- },
- countable: function() {
- return this.iter.countable()
- },
- count: function() {
- return this.iter.count()
- }
- });
- var SliceIterator = WrappedIterator.inherit({
- ctor: function(iter, skip, take) {
- this.callBase(iter);
- this.skip = Math.max(0, skip);
- this.take = Math.max(0, take);
- this.pos = 0
- },
- next: function() {
- if (this.pos >= this.skip + this.take)
- return false;
- while (this.pos < this.skip && this.iter.next())
- this.pos++;
- this.pos++;
- return this.iter.next()
- },
- reset: function() {
- this.callBase();
- this.pos = 0
- },
- countable: function() {
- return this.iter.countable()
- },
- count: function() {
- return Math.min(this.iter.count() - this.skip, this.take)
- }
- });
- queryImpl.array = function(iter, queryOptions) {
- queryOptions = queryOptions || {};
- if (!(iter instanceof Iterator))
- iter = new ArrayIterator(iter);
- var handleError = function(error) {
- var handler = queryOptions.errorHandler;
- if (handler)
- handler(error);
- data._handleError(error)
- };
- var aggregate = function(seed, step, finalize) {
- var d = $.Deferred().fail(handleError);
- try {
- iter.reset();
- if (arguments.length < 2) {
- step = arguments[0];
- seed = iter.next() ? iter.current() : undefined
- }
- var accumulator = seed;
- while (iter.next())
- accumulator = step(accumulator, iter.current());
- d.resolve(finalize ? finalize(accumulator) : accumulator)
- }
- catch(x) {
- d.reject(x)
- }
- return d.promise()
- };
- var select = function(getter) {
- if (!$.isFunction(getter) && !$.isArray(getter))
- getter = $.makeArray(arguments);
- return chainQuery(new SelectIterator(iter, getter))
- };
- var selectProp = function(name) {
- return select(compileGetter(name))
- };
- var chainQuery = function(iter) {
- return queryImpl.array(iter, queryOptions)
- };
- return {
- toArray: function() {
- return iter.toArray()
- },
- enumerate: function() {
- var d = $.Deferred().fail(handleError);
- try {
- d.resolve(iter.toArray())
- }
- catch(x) {
- d.reject(x)
- }
- return d.promise()
- },
- sortBy: function(getter, desc) {
- return chainQuery(new SortIterator(iter, getter, desc))
- },
- thenBy: function(getter, desc) {
- if (iter instanceof SortIterator)
- return chainQuery(iter.thenBy(getter, desc));
- throw Error();
- },
- filter: function(criteria) {
- if (!$.isArray(criteria))
- criteria = $.makeArray(arguments);
- return chainQuery(new FilterIterator(iter, criteria))
- },
- slice: function(skip, take) {
- if (take === undefined)
- take = Number.MAX_VALUE;
- return chainQuery(new SliceIterator(iter, skip, take))
- },
- select: select,
- groupBy: function(getter) {
- return chainQuery(new GroupIterator(iter, getter))
- },
- aggregate: aggregate,
- count: function() {
- if (iter.countable()) {
- var d = $.Deferred().fail(handleError);
- try {
- d.resolve(iter.count())
- }
- catch(x) {
- d.reject(x)
- }
- return d.promise()
- }
- return aggregate(0, function(count) {
- return 1 + count
- })
- },
- sum: function(getter) {
- if (getter)
- return selectProp(getter).sum();
- return aggregate(0, function(sum, item) {
- return sum + item
- })
- },
- min: function(getter) {
- if (getter)
- return selectProp(getter).min();
- return aggregate(function(min, item) {
- return item < min ? item : min
- })
- },
- max: function(getter) {
- if (getter)
- return selectProp(getter).max();
- return aggregate(function(max, item) {
- return item > max ? item : max
- })
- },
- avg: function(getter) {
- if (getter)
- return selectProp(getter).avg();
- var count = 0;
- return aggregate(0, function(sum, item) {
- count++;
- return sum + item
- }, function(sum) {
- return count ? sum / count : undefined
- })
- }
- }
- }
- })(jQuery, DevExpress);
- /*! Module core, file data.query.remote.js */
- (function($, DX, undefined) {
- var data = DX.data,
- queryImpl = data.queryImpl;
- queryImpl.remote = function(url, queryOptions, tasks) {
- tasks = tasks || [];
- queryOptions = queryOptions || {};
- var createTask = function(name, args) {
- return {
- name: name,
- args: args
- }
- };
- var exec = function(executorTask) {
- var d = $.Deferred(),
- adapterFactory,
- adapter,
- taskQueue,
- currentTask;
- var rejectWithNotify = function(error) {
- var handler = queryOptions.errorHandler;
- if (handler)
- handler(error);
- data._handleError(error);
- d.reject(error)
- };
- try {
- adapterFactory = queryOptions.adapter || "odata";
- if (!$.isFunction(adapterFactory))
- adapterFactory = data.queryAdapters[adapterFactory];
- adapter = adapterFactory(queryOptions);
- taskQueue = [].concat(tasks).concat(executorTask);
- while (taskQueue.length) {
- currentTask = taskQueue[0];
- if (String(currentTask.name) !== "enumerate")
- if (!adapter[currentTask.name] || adapter[currentTask.name].apply(adapter, currentTask.args) === false)
- break;
- taskQueue.shift()
- }
- adapter.exec(url).done(function(result, extra) {
- if (!taskQueue.length)
- d.resolve(result, extra);
- else {
- var clientChain = queryImpl.array(result, {errorHandler: queryOptions.errorHandler});
- $.each(taskQueue, function() {
- clientChain = clientChain[this.name].apply(clientChain, this.args)
- });
- clientChain.done($.proxy(d.resolve, d)).fail($.proxy(d.reject, d))
- }
- }).fail(rejectWithNotify)
- }
- catch(x) {
- rejectWithNotify(x)
- }
- return d.promise()
- };
- var query = {};
- $.each(["sortBy", "thenBy", "filter", "slice", "select", "groupBy"], function() {
- var name = this;
- query[name] = function() {
- return queryImpl.remote(url, queryOptions, tasks.concat(createTask(name, arguments)))
- }
- });
- $.each(["count", "min", "max", "sum", "avg", "aggregate", "enumerate"], function() {
- var name = this;
- query[name] = function() {
- return exec.call(this, createTask(name, arguments))
- }
- });
- return query
- }
- })(jQuery, DevExpress);
- /*! Module core, file data.odata.js */
- (function($, DX, undefined) {
- var data = DX.data,
- utils = DX.utils,
- Guid = data.Guid;
- var GUID_REGEX = /^(\{{0,1}([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12}\}{0,1})$/;
- var VERBOSE_DATE_REGEX = /^\/Date\((-?\d+)((\+|-)?(\d+)?)\)\/$/;
- var ISO8601_DATE_REGEX = /^(\d{4})(?:-?W(\d+)(?:-?(\d+)D?)?|(?:-(\d+))?-(\d+))(?:[T ](\d+):(\d+)(?::(\d+)(?:\.(\d+))?)?)?(?:Z(-?\d*))?$/;
- var TIMEZONE_OFFSET = (new Date).getTimezoneOffset() * 60 * 1000;
- var JSON_VERBOSE_MIME_TYPE = "application/json;odata=verbose";
- function stringify(object) {
- return JSON.stringify(object, replacer);
- function replacer(key, value) {
- if (this[key] instanceof Date)
- return utils.formatIso8601Date(this[key]);
- return value
- }
- }
- var ajaxOptionsForRequest = function(request, requestOptions) {
- request = $.extend({
- method: "get",
- url: "",
- params: {},
- payload: null,
- headers: {}
- }, request);
- requestOptions = requestOptions || {};
- var beforeSend = requestOptions.beforeSend;
- if (beforeSend)
- beforeSend(request);
- var method = (request.method || "get").toLowerCase(),
- isGet = method === "get",
- useJsonp = isGet && requestOptions.jsonp,
- params = $.extend({}, request.params),
- ajaxData = isGet ? params : stringify(request.payload),
- qs = !isGet && $.param(params),
- url = request.url,
- contentType = !isGet && JSON_VERBOSE_MIME_TYPE;
- if (qs)
- url += (url.indexOf("?") > -1 ? "&" : "?") + qs;
- if (useJsonp)
- ajaxData["$format"] = "json";
- return {
- url: url,
- data: ajaxData,
- dataType: useJsonp ? "jsonp" : "json",
- jsonp: useJsonp && "$callback",
- type: method,
- timeout: 30000,
- headers: request.headers,
- contentType: contentType,
- accepts: {json: [JSON_VERBOSE_MIME_TYPE, "text/plain"].join()},
- xhrFields: {withCredentials: requestOptions.withCredentials}
- }
- };
- var sendRequest = function(request, requestOptions) {
- var d = $.Deferred();
- $.ajax(ajaxOptionsForRequest(request, requestOptions)).always(function(obj, textStatus) {
- var tuplet = interpretJsonFormat(obj, textStatus),
- error = tuplet.error,
- data = tuplet.data,
- nextUrl = tuplet.nextUrl,
- extra;
- if (error)
- d.reject(error);
- else if (requestOptions.countOnly)
- d.resolve(tuplet.count);
- else if (nextUrl)
- sendRequest({url: nextUrl}, requestOptions).fail($.proxy(d.reject, d)).done(function(nextData) {
- d.resolve(data.concat(nextData))
- });
- else {
- if (isFinite(tuplet.count))
- extra = {totalCount: tuplet.count};
- d.resolve(data, extra)
- }
- });
- return d.promise()
- };
- var formatDotNetError = function(errorObj) {
- var message,
- currentError = errorObj;
- if ("message" in errorObj)
- if (errorObj.message.value)
- message = errorObj.message.value;
- else
- message = errorObj.message;
- while (currentError = currentError.innererror || currentError.internalexception) {
- message = currentError.message;
- if (currentError.internalexception && message.indexOf("inner exception") === -1)
- break
- }
- return message
- };
- var errorFromResponse = function(obj, textStatus) {
- if (textStatus === "nocontent")
- return null;
- var httpStatus = 200,
- message = "Unknown error",
- response = obj;
- if (textStatus !== "success") {
- httpStatus = obj.status;
- message = data.utils.errorMessageFromXhr(obj, textStatus);
- try {
- response = $.parseJSON(obj.responseText)
- }
- catch(x) {}
- }
- var errorObj = response && (response.error || response["@odata.error"]);
- if (errorObj) {
- message = formatDotNetError(errorObj) || message;
- if (httpStatus === 200)
- httpStatus = 500;
- if (errorObj.code)
- httpStatus = Number(errorObj.code);
- return $.extend(Error(message), {
- httpStatus: httpStatus,
- errorDetails: errorObj
- })
- }
- else if (httpStatus !== 200)
- return $.extend(Error(message), {httpStatus: httpStatus})
- };
- var interpretJsonFormat = function(obj, textStatus) {
- var error = errorFromResponse(obj, textStatus),
- value;
- if (error)
- return {error: error};
- if (!$.isPlainObject(obj))
- return {data: obj};
- if ("d" in obj && (utils.isArray(obj.d) || utils.isObject(obj.d)))
- value = interpretVerboseJsonFormat(obj, textStatus);
- else
- value = interpretLightJsonFormat(obj, textStatus);
- transformTypes(value);
- return value
- };
- var interpretVerboseJsonFormat = function(obj, textStatus) {
- var data = obj.d;
- if (!data)
- return {error: Error("Malformed or unsupported JSON response received")};
- data = data.results || data;
- return {
- data: data,
- nextUrl: obj.d.__next,
- count: parseInt(obj.d.__count, 10)
- }
- };
- var interpretLightJsonFormat = function(obj, textStatus) {
- var data = obj.value || obj;
- if (!data)
- return {error: Error("Malformed or unsupported JSON response received")};
- return {
- data: data,
- nextUrl: obj["@odata.nextLink"],
- count: parseInt(obj["@odata.count"], 10)
- }
- };
- var EdmLiteral = DX.Class.inherit({
- ctor: function(value) {
- this._value = value
- },
- valueOf: function() {
- return this._value
- }
- });
- var transformTypes = function(obj) {
- $.each(obj, function(key, value) {
- if (value !== null && typeof value === "object")
- transformTypes(value);
- else if (typeof value === "string")
- if (GUID_REGEX.test(value))
- obj[key] = new Guid(value);
- else if (value.match(VERBOSE_DATE_REGEX))
- obj[key] = new Date(TIMEZONE_OFFSET + Number(RegExp.$1) + RegExp.$2 * 60000);
- else if (ISO8601_DATE_REGEX.test(value))
- obj[key] = new Date(utils.parseIso8601Date(obj[key]).valueOf())
- })
- };
- var serializeDate = function() {
- var pad = function(part) {
- part = String(part);
- if (part.length < 2)
- part = "0" + part;
- return part
- };
- return function(date) {
- var result = ["datetime'", date.getFullYear(), "-", pad(date.getMonth() + 1), "-", pad(date.getDate())];
- if (date.getHours() || date.getMinutes() || date.getSeconds() || date.getMilliseconds()) {
- result.push("T", pad(date.getHours()), ":", pad(date.getMinutes()), ":", pad(date.getSeconds()));
- if (date.getMilliseconds())
- result.push(".", date.getMilliseconds())
- }
- result.push("'");
- return result.join("")
- }
- }();
- var serializeString = function(value) {
- return "'" + value.replace(/</g, "%26lt").replace(/'/g, "''") + "'"
- };
- var serializePropName = function(propName) {
- if (propName instanceof EdmLiteral)
- return propName.valueOf();
- return propName.replace(/\./g, "/")
- };
- var serializeValueV4 = function(value) {
- if (value instanceof Date)
- return utils.formatIso8601Date(value);
- return serializeValueV2(value)
- };
- var serializeValueV2 = function(value) {
- if (value instanceof Date)
- return serializeDate(value);
- if (value instanceof Guid)
- return "guid'" + value + "'";
- if (value instanceof EdmLiteral)
- return value.valueOf();
- if (typeof value === "string")
- return serializeString(value);
- return String(value)
- };
- var DEFAULT_PROTOCOL_VERSION = 2;
- var serializeValue = function(value, protocolVersion) {
- protocolVersion = protocolVersion || DEFAULT_PROTOCOL_VERSION;
- switch (protocolVersion) {
- case 2:
- case 3:
- return serializeValueV2(value);
- case 4:
- return serializeValueV4(value);
- default:
- throw new Error("Unknown OData protocol version");
- }
- };
- var serializeKey = function(key, protocolVersion) {
- if ($.isPlainObject(key)) {
- var parts = [];
- $.each(key, function(k, v) {
- parts.push(serializePropName(k) + "=" + serializeValue(v, protocolVersion))
- });
- return parts.join()
- }
- return serializeValue(key)
- };
- var keyConverters = {
- String: function(value) {
- return value + ""
- },
- Int32: function(value) {
- return Math.floor(value)
- },
- Int64: function(value) {
- if (value instanceof EdmLiteral)
- return value;
- return new EdmLiteral(value + "L")
- },
- Guid: function(value) {
- if (value instanceof Guid)
- return value;
- return new Guid(value)
- },
- Boolean: function(value) {
- return !!value
- },
- Single: function(value) {
- if (value instanceof EdmLiteral)
- return value;
- return new EdmLiteral(value + "f")
- },
- Decimal: function(value) {
- if (value instanceof EdmLiteral)
- return value;
- return new EdmLiteral(value + "m")
- }
- };
- var compileCriteria = function() {
- var createBinaryOperationFormatter = function(op) {
- return function(prop, val, bag) {
- bag.push(prop, " ", op, " ", val)
- }
- };
- var createStringFuncFormatter = function(op, reverse) {
- return function(prop, val, bag) {
- if (reverse)
- bag.push(op, "(", val, ",", prop, ")");
- else
- bag.push(op, "(", prop, ",", val, ")")
- }
- };
- var formatters = {
- "=": createBinaryOperationFormatter("eq"),
- "<>": createBinaryOperationFormatter("ne"),
- ">": createBinaryOperationFormatter("gt"),
- ">=": createBinaryOperationFormatter("ge"),
- "<": createBinaryOperationFormatter("lt"),
- "<=": createBinaryOperationFormatter("le"),
- startswith: createStringFuncFormatter("startswith"),
- endswith: createStringFuncFormatter("endswith"),
- // yo2dh : 2015-02-11 여기서 변환하지 않고 ODATA URI를 직접 입력
- passby: function(prop, val, bag) {
- bag.push(prop);
- }
- };
- var formattersV2 = $.extend({}, formatters, {
- contains: createStringFuncFormatter("substringof", true),
- notcontains: createStringFuncFormatter("not substringof", true)
- });
- var formattersV4 = $.extend({}, formatters, {
- contains: createStringFuncFormatter("contains"),
- notcontains: createStringFuncFormatter("not contains")
- });
- var compileBinary = function(criteria, bag, protocolVersion) {
- criteria = data.utils.normalizeBinaryCriterion(criteria);
- var op = criteria[1],
- formatters = protocolVersion === 4 ? formattersV4 : formattersV2,
- formatter = formatters[op.toLowerCase()];
- if (!formatter)
- throw Error("Unknown filter operation: " + op);
- formatter(serializePropName(criteria[0]), serializeValue(criteria[2], protocolVersion), bag)
- };
- var compileGroup = function(criteria, bag, protocolVersion) {
- var pushAnd = false;
- $.each(criteria, function() {
- if ($.isArray(this)) {
- if (pushAnd)
- bag.push(" and ");
- bag.push("(");
- compileCore(this, bag, protocolVersion);
- bag.push(")");
- pushAnd = true
- }
- else {
- bag.push(/and|&/i.test(this) ? " and " : " or ");
- pushAnd = false
- }
- })
- };
- var compileCore = function(criteria, bag, protocolVersion) {
- if ($.isArray(criteria[0]))
- compileGroup(criteria, bag, protocolVersion);
- else
- compileBinary(criteria, bag, protocolVersion)
- };
- return function(criteria, protocolVersion) {
- var bag = [];
- compileCore(criteria, bag, protocolVersion);
- return bag.join("")
- }
- }();
- var createODataQueryAdapter = function(queryOptions) {
- var sorting = [],
- criteria = [],
- select,
- skip,
- take,
- countQuery;
- var hasSlice = function() {
- return skip || take !== undefined
- };
- var sortCore = function(getter, desc, reset) {
- if (hasSlice() || typeof getter !== "string")
- return false;
- if (reset)
- sorting = [];
- var rule = serializePropName(getter);
- if (desc)
- rule += " desc";
- sorting.push(rule)
- };
- var generateExpand = function() {
- var hash = {};
- if (queryOptions.expand)
- $.each($.makeArray(queryOptions.expand), function() {
- hash[serializePropName(this)] = 1
- });
- if (select)
- $.each(select, function() {
- var path = this.split(".");
- if (path.length < 2)
- return;
- path.pop();
- hash[serializePropName(path.join("."))] = 1
- });
- return $.map(hash, function(k, v) {
- return v
- }).join() || undefined
- };
- var requestData = function() {
- var result = {};
- if (!countQuery) {
- if (sorting.length)
- result["$orderby"] = sorting.join(",");
- if (skip)
- result["$skip"] = skip;
- if (take !== undefined)
- result["$top"] = take;
- if (select)
- result["$select"] = serializePropName(select.join());
- result["$expand"] = generateExpand()
- }
- if (criteria.length)
- result["$filter"] = compileCriteria(criteria.length < 2 ? criteria[0] : criteria, queryOptions.version);
- if (countQuery)
- result["$top"] = 0;
- if (queryOptions.requireTotalCount || countQuery)
- if (queryOptions.version !== 4)
- result["$inlinecount"] = "allpages";
- else
- result["$count"] = "true";
- return result
- };
- return {
- exec: function(url) {
- return sendRequest({
- url: url,
- params: $.extend(requestData(), queryOptions && queryOptions.params)
- }, {
- beforeSend: queryOptions.beforeSend,
- jsonp: queryOptions.jsonp,
- withCredentials: queryOptions.withCredentials,
- countOnly: countQuery
- })
- },
- sortBy: function(getter, desc) {
- return sortCore(getter, desc, true)
- },
- thenBy: function(getter, desc) {
- return sortCore(getter, desc, false)
- },
- slice: function(skipCount, takeCount) {
- if (hasSlice())
- return false;
- skip = skipCount;
- take = takeCount
- },
- filter: function(criterion) {
- if (hasSlice() || $.isFunction(criterion))
- return false;
- if (!$.isArray(criterion))
- criterion = $.makeArray(arguments);
- if (criteria.length)
- criteria.push("and");
- criteria.push(criterion)
- },
- select: function(expr) {
- if (select || $.isFunction(expr))
- return false;
- if (!$.isArray(expr))
- expr = $.makeArray(arguments);
- select = expr
- },
- count: function() {
- countQuery = true
- }
- }
- };
- $.extend(true, data, {
- EdmLiteral: EdmLiteral,
- utils: {odata: {
- sendRequest: sendRequest,
- serializePropName: serializePropName,
- serializeValue: serializeValue,
- serializeKey: serializeKey,
- keyConverters: keyConverters
- }},
- queryAdapters: {odata: createODataQueryAdapter}
- });
- data.OData__internals = {interpretJsonFormat: interpretJsonFormat}
- })(jQuery, DevExpress);
- /*! Module core, file data.store.abstract.js */
- (function($, DX, undefined) {
- var Class = DX.Class,
- abstract = DX.abstract,
- data = DX.data,
- normalizeSortingInfo = data.utils.normalizeSortingInfo;
- var STORE_CALLBACK_NAMES = ["loading", "loaded", "modifying", "modified", "inserting", "inserted", "updating", "updated", "removing", "removed"];
- function multiLevelGroup(query, groupInfo) {
- query = query.groupBy(groupInfo[0].selector);
- if (groupInfo.length > 1)
- query = query.select(function(g) {
- return $.extend({}, g, {items: multiLevelGroup(data.query(g.items), groupInfo.slice(1)).toArray()})
- });
- return query
- }
- data.utils.multiLevelGroup = multiLevelGroup;
- function arrangeSortingInfo(groupInfo, sortInfo) {
- var filteredGroup = [];
- $.each(groupInfo, function(_, group) {
- var collision = $.grep(sortInfo, function(sort) {
- return group.selector == sort.selector
- });
- if (collision.length < 1)
- filteredGroup.push(group)
- });
- return filteredGroup.concat(sortInfo)
- }
- data.Store = Class.inherit({
- ctor: function(options) {
- var that = this;
- options = options || {};
- $.each(STORE_CALLBACK_NAMES, function() {
- var callbacks = that[this] = $.Callbacks();
- if (this in options)
- callbacks.add(options[this])
- });
- this._key = options.key;
- this._errorHandler = options.errorHandler;
- this._useDefaultSearch = true
- },
- _customLoadOptions: function() {
- return null
- },
- key: function() {
- return this._key
- },
- keyOf: function(obj) {
- if (!this._keyGetter)
- this._keyGetter = data.utils.compileGetter(this.key());
- return this._keyGetter(obj)
- },
- _requireKey: function() {
- if (!this.key())
- throw Error("Key expression is required for this operation");
- },
- load: function(options) {
- var that = this;
- options = options || {};
- this.loading.fire(options);
- return this._loadImpl(options).done(function(result, extra) {
- that.loaded.fire(result, extra)
- })
- },
- _loadImpl: function(options) {
- var filter = options.filter,
- sort = options.sort,
- select = options.select,
- group = options.group,
- skip = options.skip,
- take = options.take,
- q = this.createQuery(options);
- if (filter)
- q = q.filter(filter);
- if (group)
- group = normalizeSortingInfo(group);
- if (sort || group) {
- sort = normalizeSortingInfo(sort || []);
- if (group)
- sort = arrangeSortingInfo(group, sort);
- $.each(sort, function(index) {
- q = q[index ? "thenBy" : "sortBy"](this.selector, this.desc)
- })
- }
- if (select)
- q = q.select(select);
- if (group)
- q = multiLevelGroup(q, group);
- if (take || skip)
- q = q.slice(skip || 0, take);
- return q.enumerate()
- },
- createQuery: abstract,
- totalCount: function(options) {
- return this._addFailHandlers(this._totalCountImpl(options))
- },
- _totalCountImpl: function(options) {
- options = options || {};
- var q = this.createQuery(),
- group = options.group,
- filter = options.filter;
- if (filter)
- q = q.filter(filter);
- if (group) {
- group = normalizeSortingInfo(group);
- q = multiLevelGroup(q, group)
- }
- return q.count()
- },
- byKey: function(key, extraOptions) {
- return this._addFailHandlers(this._byKeyImpl(key, extraOptions))
- },
- _byKeyImpl: abstract,
- insert: function(values) {
- var that = this;
- that.modifying.fire();
- that.inserting.fire(values);
- return that._addFailHandlers(that._insertImpl(values).done(function(callbackValues, callbackKey) {
- that.inserted.fire(callbackValues, callbackKey);
- that.modified.fire()
- }))
- },
- _insertImpl: abstract,
- update: function(key, values) {
- var that = this;
- that.modifying.fire();
- that.updating.fire(key, values);
- return that._addFailHandlers(that._updateImpl(key, values).done(function(callbackKey, callbackValues) {
- that.updated.fire(callbackKey, callbackValues);
- that.modified.fire()
- }))
- },
- _updateImpl: abstract,
- remove: function(key) {
- var that = this;
- that.modifying.fire();
- that.removing.fire(key);
- return that._addFailHandlers(that._removeImpl(key).done(function(callbackKey) {
- that.removed.fire(callbackKey);
- that.modified.fire()
- }))
- },
- _removeImpl: abstract,
- _addFailHandlers: function(deferred) {
- return deferred.fail(this._errorHandler, data._handleError)
- }
- })
- })(jQuery, DevExpress);
- /*! Module core, file data.store.array.js */
- (function($, DX, undefined) {
- var data = DX.data,
- Guid = data.Guid;
- var trivialPromise = function(_) {
- var d = $.Deferred();
- return d.resolve.apply(d, arguments).promise()
- };
- var rejectedPromise = function(_) {
- var d = $.Deferred();
- return d.reject.apply(d, arguments).promise()
- };
- data.ArrayStore = data.Store.inherit({
- ctor: function(options) {
- if ($.isArray(options))
- options = {data: options};
- else
- options = options || {};
- this.callBase(options);
- var initialArray = options.data;
- if (initialArray && !$.isArray(initialArray))
- throw Error("Invalid 'data' option value");
- this._array = initialArray || []
- },
- createQuery: function() {
- return data.query(this._array, {errorHandler: this._errorHandler})
- },
- _byKeyImpl: function(key) {
- return trivialPromise(this._array[this._indexByKey(key)])
- },
- _insertImpl: function(values) {
- var keyExpr = this.key(),
- keyValue,
- obj = {};
- $.extend(obj, values);
- if (keyExpr) {
- keyValue = this.keyOf(obj);
- if (keyValue === undefined || typeof keyValue === "object" && $.isEmptyObject(keyValue)) {
- if ($.isArray(keyExpr))
- throw Error("Compound keys cannot be auto-generated");
- keyValue = obj[keyExpr] = String(new Guid)
- }
- else if (this._array[this._indexByKey(keyValue)] !== undefined)
- return rejectedPromise(Error("Attempt to insert an item with the duplicate key"))
- }
- else
- keyValue = obj;
- this._array.push(obj);
- return trivialPromise(values, keyValue)
- },
- _updateImpl: function(key, values) {
- var target;
- if (this.key()) {
- var index = this._indexByKey(key);
- if (index < 0)
- return rejectedPromise(Error("Data item not found"));
- target = this._array[index]
- }
- else
- target = key;
- DX.utils.deepExtendArraySafe(target, values);
- return trivialPromise(key, values)
- },
- _removeImpl: function(key) {
- var index = this._indexByKey(key);
- if (index > -1)
- this._array.splice(index, 1);
- return trivialPromise(key)
- },
- _indexByKey: function(key) {
- for (var i = 0, arrayLength = this._array.length; i < arrayLength; i++)
- if (data.utils.keysEqual(this.key(), this.keyOf(this._array[i]), key))
- return i;
- return -1
- },
- clear: function() {
- this._array = []
- }
- })
- })(jQuery, DevExpress);
- /*! Module core, file data.store.local.js */
- (function($, DX, undefined) {
- var Class = DX.Class,
- abstract = DX.abstract,
- data = DX.data;
- var LocalStoreBackend = Class.inherit({
- ctor: function(store, storeOptions) {
- this._store = store;
- this._dirty = false;
- var immediate = this._immediate = storeOptions.immediate;
- var flushInterval = Math.max(100, storeOptions.flushInterval || 10 * 1000);
- if (!immediate) {
- var saveProxy = $.proxy(this.save, this);
- setInterval(saveProxy, flushInterval);
- $(window).on("beforeunload", saveProxy);
- if (window.cordova)
- document.addEventListener("pause", saveProxy, false)
- }
- },
- notifyChanged: function() {
- this._dirty = true;
- if (this._immediate)
- this.save()
- },
- load: function() {
- this._store._array = this._loadImpl();
- this._dirty = false
- },
- save: function() {
- if (!this._dirty)
- return;
- this._saveImpl(this._store._array);
- this._dirty = false
- },
- _loadImpl: abstract,
- _saveImpl: abstract
- });
- var DomLocalStoreBackend = LocalStoreBackend.inherit({
- ctor: function(store, storeOptions) {
- this.callBase(store, storeOptions);
- var name = storeOptions.name;
- if (!name)
- throw Error("Name is required");
- this._key = "dx-data-localStore-" + name
- },
- _loadImpl: function() {
- var raw = localStorage.getItem(this._key);
- if (raw)
- return JSON.parse(raw);
- return []
- },
- _saveImpl: function(array) {
- if (!array.length)
- localStorage.removeItem(this._key);
- else
- localStorage.setItem(this._key, JSON.stringify(array))
- }
- });
- var localStoreBackends = {dom: DomLocalStoreBackend};
- data.LocalStore = data.ArrayStore.inherit({
- ctor: function(options) {
- if (typeof options === "string")
- options = {name: options};
- else
- options = options || {};
- this.callBase(options);
- this._backend = new localStoreBackends[options.backend || "dom"](this, options);
- this._backend.load()
- },
- clear: function() {
- this.callBase();
- this._backend.notifyChanged()
- },
- _insertImpl: function(values) {
- var b = this._backend;
- return this.callBase(values).done($.proxy(b.notifyChanged, b))
- },
- _updateImpl: function(key, values) {
- var b = this._backend;
- return this.callBase(key, values).done($.proxy(b.notifyChanged, b))
- },
- _removeImpl: function(key) {
- var b = this._backend;
- return this.callBase(key).done($.proxy(b.notifyChanged, b))
- }
- })
- })(jQuery, DevExpress);
- /*! Module core, file data.store.odata.js */
- (function($, DX, undefined) {
- var Class = DX.Class,
- data = DX.data,
- utils = DX.utils,
- odataUtils = data.utils.odata;
- var escapeServiceOperationParams = function(params, version) {
- if (!params)
- return params;
- var result = {};
- $.each(params, function(k, v) {
- result[k] = odataUtils.serializeValue(v, version)
- });
- return result
- };
- var convertSimpleKey = function(keyType, keyValue) {
- var converter = odataUtils.keyConverters[keyType];
- if (!converter)
- throw Error("Unknown key type: " + keyType);
- return converter(keyValue)
- };
- var SharedMethods = {
- _extractServiceOptions: function(options) {
- options = options || {};
- this._url = String(options.url).replace(/\/+$/, "");
- this._beforeSend = options.beforeSend;
- this._jsonp = options.jsonp;
- this._version = options.version;
- this._withCredentials = options.withCredentials
- },
- _sendRequest: function(url, method, params, payload) {
- return odataUtils.sendRequest({
- url: url,
- method: method,
- params: params || {},
- payload: payload
- }, {
- beforeSend: this._beforeSend,
- jsonp: this._jsonp,
- withCredentials: this._withCredentials
- })
- },
- version: function() {
- return this._version
- }
- };
- var ODataStore = data.Store.inherit({
- ctor: function(options) {
- this.callBase(options);
- this._extractServiceOptions(options);
- this._keyType = options.keyType
- },
- _customLoadOptions: function() {
- return ["expand", "customQueryParams"]
- },
- _byKeyImpl: function(key, extraOptions) {
- var params = {};
- if (extraOptions)
- if (extraOptions.expand)
- params["$expand"] = $.map($.makeArray(extraOptions.expand), odataUtils.serializePropName).join();
- return this._sendRequest(this._byKeyUrl(key), "GET", params)
- },
- createQuery: function(loadOptions) {
- loadOptions = loadOptions || {};
- return data.query(this._url, {
- beforeSend: this._beforeSend,
- errorHandler: this._errorHandler,
- jsonp: this._jsonp,
- version: this._version,
- withCredentials: this._withCredentials,
- params: escapeServiceOperationParams(loadOptions.customQueryParams, this._version),
- expand: loadOptions.expand,
- requireTotalCount: loadOptions.requireTotalCount
- })
- },
- _insertImpl: function(values) {
- this._requireKey();
- var that = this,
- d = $.Deferred();
- $.when(this._sendRequest(this._url, "POST", null, values)).done(function(serverResponse) {
- d.resolve(values, that.keyOf(serverResponse))
- }).fail($.proxy(d.reject, d));
- return d.promise()
- },
- _updateImpl: function(key, values) {
- var d = $.Deferred();
- $.when(this._sendRequest(this._byKeyUrl(key), "MERGE", null, values)).done(function() {
- d.resolve(key, values)
- }).fail($.proxy(d.reject, d));
- return d.promise()
- },
- _removeImpl: function(key) {
- var d = $.Deferred();
- $.when(this._sendRequest(this._byKeyUrl(key), "DELETE")).done(function() {
- d.resolve(key)
- }).fail($.proxy(d.reject, d));
- return d.promise()
- },
- _byKeyUrl: function(key) {
- var keyType = this._keyType;
- if ($.isPlainObject(keyType))
- $.each(keyType, function(subKeyName, subKeyType) {
- key[subKeyName] = convertSimpleKey(subKeyType, key[subKeyName])
- });
- else if (keyType)
- key = convertSimpleKey(keyType, key);
- return this._url + "(" + encodeURIComponent(odataUtils.serializeKey(key, this._version)) + ")"
- }
- }).include(SharedMethods);
- var ODataContext = Class.inherit({
- ctor: function(options) {
- var that = this;
- that._extractServiceOptions(options);
- that._errorHandler = options.errorHandler;
- $.each(options.entities || [], function(entityAlias, entityOptions) {
- that[entityAlias] = new ODataStore($.extend({}, options, {url: that._url + "/" + encodeURIComponent(entityOptions.name || entityAlias)}, entityOptions))
- })
- },
- get: function(operationName, params) {
- return this.invoke(operationName, params, "GET")
- },
- invoke: function(operationName, params, httpMethod) {
- httpMethod = httpMethod || "POST";
- var d = $.Deferred();
- $.when(this._sendRequest(this._url + "/" + encodeURIComponent(operationName), httpMethod, escapeServiceOperationParams(params, this._version))).done(function(r) {
- if (r && operationName in r)
- r = r[operationName];
- d.resolve(r)
- }).fail([this._errorHandler, data._handleError, $.proxy(d.reject, d)]);
- return d.promise()
- },
- objectLink: function(entityAlias, key) {
- var store = this[entityAlias];
- if (!store)
- throw Error("Unknown entity name or alias: " + entityAlias);
- if (!utils.isDefined(key))
- return null;
- return {__metadata: {uri: store._byKeyUrl(key)}}
- }
- }).include(SharedMethods);
- $.extend(data, {
- ODataStore: ODataStore,
- ODataContext: ODataContext
- })
- })(jQuery, DevExpress);
- /*! Module core, file data.store.rest.js */
- (function($, DX, undefined) {
- var data = DX.data;
- function createAjaxFailureHandler(deferred) {
- return function(xhr, textStatus) {
- if (!xhr || !xhr.getResponseHeader)
- deferred.reject.apply(deferred, arguments);
- else
- deferred.reject(Error(data.utils.errorMessageFromXhr(xhr, textStatus)))
- }
- }
- function operationCustomizerPropName(operationName) {
- return "_customize" + DX.inflector.camelize(operationName, true)
- }
- function pathPropName(operationName) {
- return "_" + operationName + "Path"
- }
- data.RestStore = data.Store.inherit({
- ctor: function(options) {
- DX.utils.logger.warn("RestStore is deprecated, use CustomStore instead");
- var that = this;
- that.callBase(options);
- options = options || {};
- that._url = String(options.url).replace(/\/+$/, "");
- that._jsonp = options.jsonp;
- that._withCredentials = options.withCredentials;
- $.each(["Load", "Insert", "Update", "Remove", "ByKey", "Operation"], function() {
- var value = options["customize" + this];
- if (value)
- that[operationCustomizerPropName(this)] = value
- });
- $.each(["load", "insert", "update", "remove", "byKey"], function() {
- var value = options[this + "Path"];
- if (value)
- that[pathPropName(this)] = value
- })
- },
- _loadImpl: function(options) {
- var d = $.Deferred(),
- ajaxOptions = {
- url: this._formatUrlNoKey("load"),
- type: "GET"
- };
- $.when(this._createAjax(ajaxOptions, "load", options)).done($.proxy(d.resolve, d)).fail(createAjaxFailureHandler(d));
- return this._addFailHandlers(d.promise())
- },
- createQuery: function() {
- throw Error("Not supported");
- },
- _insertImpl: function(values) {
- var d = $.Deferred(),
- that = this,
- ajaxOptions = {
- url: this._formatUrlNoKey("insert"),
- type: "POST",
- contentType: "application/json",
- data: JSON.stringify(values)
- };
- $.when(this._createAjax(ajaxOptions, "insert")).done(function(serverResponse) {
- d.resolve(values, that.key() && that.keyOf(serverResponse))
- }).fail(createAjaxFailureHandler(d));
- return d.promise()
- },
- _updateImpl: function(key, values) {
- var d = $.Deferred(),
- ajaxOptions = {
- url: this._formatUrlWithKey("update", key),
- type: "PUT",
- contentType: "application/json",
- data: JSON.stringify(values)
- };
- $.when(this._createAjax(ajaxOptions, "update")).done(function() {
- d.resolve(key, values)
- }).fail(createAjaxFailureHandler(d));
- return d.promise()
- },
- _removeImpl: function(key) {
- var d = $.Deferred(),
- ajaxOptions = {
- url: this._formatUrlWithKey("remove", key),
- type: "DELETE"
- };
- $.when(this._createAjax(ajaxOptions, "remove")).done(function() {
- d.resolve(key)
- }).fail(createAjaxFailureHandler(d));
- return d.promise()
- },
- _byKeyImpl: function(key) {
- var d = $.Deferred(),
- ajaxOptions = {
- url: this._formatUrlWithKey("byKey", key),
- type: "GET"
- };
- $.when(this._createAjax(ajaxOptions, "byKey")).done(function(data) {
- d.resolve(data)
- }).fail(createAjaxFailureHandler(d));
- return d.promise()
- },
- _createAjax: function(ajaxOptions, operationName, extra) {
- var customizationFunc,
- customizationResult;
- function isDeferred(obj) {
- return "done" in obj && "fail" in obj
- }
- if (this._jsonp && ajaxOptions.type === "GET")
- ajaxOptions.dataType = "jsonp";
- else
- $.extend(true, ajaxOptions, {xhrFields: {withCredentials: this._withCredentials}});
- customizationFunc = this[operationCustomizerPropName("operation")];
- if (customizationFunc) {
- customizationResult = customizationFunc(ajaxOptions, operationName, extra);
- if (customizationResult) {
- if (isDeferred(customizationResult))
- return customizationResult;
- ajaxOptions = customizationResult
- }
- }
- customizationFunc = this[operationCustomizerPropName(operationName)];
- if (customizationFunc) {
- customizationResult = customizationFunc(ajaxOptions, extra);
- if (customizationResult) {
- if (isDeferred(customizationResult))
- return customizationResult;
- ajaxOptions = customizationResult
- }
- }
- return $.ajax(ajaxOptions)
- },
- _formatUrlNoKey: function(operationName) {
- var url = this._url,
- path = this[pathPropName(operationName)];
- if (!path)
- return url;
- if ($.isFunction(path))
- return path(url);
- return url + "/" + path
- },
- _formatUrlWithKey: function(operationName, key) {
- var url = this._url,
- path = this[pathPropName(operationName)];
- if (!path)
- return url + "/" + encodeURIComponent(key);
- if ($.isFunction(path))
- return path(url, key);
- return url + "/" + path + "/" + encodeURIComponent(key)
- }
- })
- })(jQuery, DevExpress);
- /*! Module core, file data.store.custom.js */
- (function($, DX, undefined) {
- var data = DX.data;
- var ERROR_QUERY_NOT_SUPPORTED = "CustomStore does not support creating queries",
- ERROR_MISSING_USER_FUNC = "Required option is not specified or is not a function: ",
- ERROR_INVALID_RETURN = "Invalid return value: ";
- var TOTAL_COUNT = "totalCount",
- LOAD = "load",
- BY_KEY = "byKey",
- INSERT = "insert",
- UPDATE = "update",
- REMOVE = "remove";
- function isPromise(obj) {
- return obj && $.isFunction(obj.done) && $.isFunction(obj.fail) && $.isFunction(obj.promise)
- }
- function trivialPromise(value) {
- return $.Deferred().resolve(value).promise()
- }
- function ensureRequiredFuncOption(name, obj) {
- if (!$.isFunction(obj))
- throw Error(ERROR_MISSING_USER_FUNC + name);
- }
- function throwInvalidUserFuncResult(name) {
- throw Error(ERROR_INVALID_RETURN + name);
- }
- function createUserFuncFailureHandler(pendingDeferred) {
- function errorMessageFromXhr(promiseArguments) {
- var xhr = promiseArguments[0],
- textStatus = promiseArguments[1];
- if (!xhr || !xhr.getResponseHeader)
- return null;
- return data.utils.errorMessageFromXhr(xhr, textStatus)
- }
- return function(arg) {
- var error;
- if (arg instanceof Error)
- error = arg;
- else
- error = Error(errorMessageFromXhr(arguments) || arg && String(arg) || "Unknown error");
- pendingDeferred.reject(error)
- }
- }
- data.CustomStore = data.Store.inherit({
- ctor: function(options) {
- options = options || {};
- this.callBase(options);
- this._useDefaultSearch = false;
- this._loadFunc = options[LOAD];
- this._totalCountFunc = options[TOTAL_COUNT];
- this._byKeyFunc = options[BY_KEY] || options.lookup;
- this._insertFunc = options[INSERT];
- this._updateFunc = options[UPDATE];
- this._removeFunc = options[REMOVE]
- },
- createQuery: function() {
- throw Error(ERROR_QUERY_NOT_SUPPORTED);
- },
- _totalCountImpl: function(options) {
- var userFunc = this._totalCountFunc,
- userResult,
- d = $.Deferred();
- ensureRequiredFuncOption(TOTAL_COUNT, userFunc);
- userResult = userFunc(options);
- if (!isPromise(userResult)) {
- userResult = Number(userResult);
- if (!isFinite(userResult))
- throwInvalidUserFuncResult(TOTAL_COUNT);
- userResult = trivialPromise(userResult)
- }
- userResult.done(function(count) {
- d.resolve(Number(count))
- }).fail(createUserFuncFailureHandler(d));
- return d.promise()
- },
- _loadImpl: function(options) {
- var userFunc = this._loadFunc,
- userResult,
- d = $.Deferred();
- ensureRequiredFuncOption(LOAD, userFunc);
- userResult = userFunc(options);
- if ($.isArray(userResult))
- userResult = trivialPromise(userResult);
- else if (userResult === null || userResult === undefined)
- userResult = trivialPromise([]);
- else if (!isPromise(userResult))
- throwInvalidUserFuncResult(LOAD);
- userResult.done(function(data, extra) {
- d.resolve(data, extra)
- }).fail(createUserFuncFailureHandler(d));
- return this._addFailHandlers(d.promise())
- },
- _byKeyImpl: function(key) {
- var userFunc = this._byKeyFunc,
- userResult,
- d = $.Deferred();
- ensureRequiredFuncOption(BY_KEY, userFunc);
- userResult = userFunc(key);
- if (!isPromise(userResult))
- userResult = trivialPromise(userResult);
- userResult.done(function(obj) {
- d.resolve(obj)
- }).fail(createUserFuncFailureHandler(d));
- return d.promise()
- },
- _insertImpl: function(values) {
- var userFunc = this._insertFunc,
- userResult,
- d = $.Deferred();
- ensureRequiredFuncOption(INSERT, userFunc);
- userResult = userFunc(values);
- if (!isPromise(userResult))
- userResult = trivialPromise(userResult);
- userResult.done(function(newKey) {
- d.resolve(values, newKey)
- }).fail(createUserFuncFailureHandler(d));
- return d.promise()
- },
- _updateImpl: function(key, values) {
- var userFunc = this._updateFunc,
- userResult,
- d = $.Deferred();
- ensureRequiredFuncOption(UPDATE, userFunc);
- userResult = userFunc(key, values);
- if (!isPromise(userResult))
- userResult = trivialPromise();
- userResult.done(function() {
- d.resolve(key, values)
- }).fail(createUserFuncFailureHandler(d));
- return d.promise()
- },
- _removeImpl: function(key) {
- var userFunc = this._removeFunc,
- userResult,
- d = $.Deferred();
- ensureRequiredFuncOption(REMOVE, userFunc);
- userResult = userFunc(key);
- if (!isPromise(userResult))
- userResult = trivialPromise();
- userResult.done(function() {
- d.resolve(key)
- }).fail(createUserFuncFailureHandler(d));
- return d.promise()
- }
- });
- data.CustomStore_internals = {ERRORS: {
- QUERY_NOT_SUPPORTED: ERROR_QUERY_NOT_SUPPORTED,
- MISSING_USER_FUNC: ERROR_MISSING_USER_FUNC,
- INVALID_RETURN: ERROR_INVALID_RETURN
- }}
- })(jQuery, DevExpress);
- /*! Module core, file data.dataSource.js */
- (function($, DX, undefined) {
- var data = DX.data,
- CustomStore = data.CustomStore,
- Class = DX.Class;
- var storeTypeRegistry = {
- jaydata: "JayDataStore",
- breeze: "BreezeStore",
- odata: "ODataStore",
- local: "LocalStore",
- array: "ArrayStore"
- };
- function normalizeDataSourceOptions(options) {
- var store;
- function createCustomStoreFromLoadFunc() {
- var storeConfig = {};
- $.each(["key", "load", "byKey", "lookup", "totalCount", "insert", "update", "remove"], function() {
- storeConfig[this] = options[this];
- delete options[this]
- });
- return new CustomStore(storeConfig)
- }
- function createStoreFromConfig(storeConfig) {
- var storeCtor = data[storeTypeRegistry[storeConfig.type]];
- delete storeConfig.type;
- return new storeCtor(storeConfig)
- }
- function createCustomStoreFromUrl(url) {
- return new CustomStore({load: function() {
- return $.getJSON(url)
- }})
- }
- if (typeof options === "string")
- options = createCustomStoreFromUrl(options);
- if (options === undefined)
- options = [];
- if ($.isArray(options) || options instanceof data.Store)
- options = {store: options};
- else
- options = $.extend({}, options);
- if (options.store === undefined)
- options.store = [];
- store = options.store;
- if ("load" in options)
- store = createCustomStoreFromLoadFunc();
- else if ($.isArray(store))
- store = new data.ArrayStore(store);
- else if ($.isPlainObject(store))
- store = createStoreFromConfig($.extend({}, store));
- options.store = store;
- return options
- }
- function normalizeStoreLoadOptionAccessorArguments(originalArguments) {
- switch (originalArguments.length) {
- case 0:
- return undefined;
- case 1:
- return originalArguments[0]
- }
- return $.makeArray(originalArguments)
- }
- function generateStoreLoadOptionAccessor(optionName) {
- return function() {
- var args = normalizeStoreLoadOptionAccessorArguments(arguments);
- if (args !== undefined)
- this._storeLoadOptions[optionName] = args;
- return this._storeLoadOptions[optionName]
- }
- }
- function addOldUserDataSourceBackwardCompatibilityOptions(dataSource, storeLoadOptions) {
- storeLoadOptions.refresh = !dataSource._paginate || dataSource._pageIndex === 0;
- if (storeLoadOptions.searchValue !== null)
- storeLoadOptions.searchString = storeLoadOptions.searchValue
- }
- var DataSource = Class.inherit({
- ctor: function(options) {
- options = normalizeDataSourceOptions(options);
- this._store = options.store;
- this._storeLoadOptions = this._extractLoadOptions(options);
- this._mapFunc = options.map;
- this._postProcessFunc = options.postProcess;
- this._pageIndex = 0;
- this._pageSize = options.pageSize !== undefined ? options.pageSize : 20;
- this._items = [];
- this._totalCount = -1;
- this._isLoaded = false;
- this._loadingCount = 0;
- this._preferSync = options._preferSync;
- this._loadQueue = this._createLoadQueue();
- this._searchValue = "searchValue" in options ? options.searchValue : null;
- this._searchOperation = options.searchOperation || "contains";
- this._searchExpr = options.searchExpr;
- this._paginate = options.paginate;
- if (this._paginate === undefined)
- this._paginate = !this.group();
- this._isLastPage = !this._paginate;
- this._userData = {};
- this.changed = $.Callbacks();
- this.loadError = $.Callbacks();
- this.loadingChanged = $.Callbacks()
- },
- dispose: function() {
- this.changed.empty();
- this.loadError.empty();
- this.loadingChanged.empty();
- delete this._store;
- this._disposed = true
- },
- _extractLoadOptions: function(options) {
- var result = {},
- names = ["sort", "filter", "select", "group", "requireTotalCount"],
- customNames = this._store._customLoadOptions();
- if (customNames)
- names = names.concat(customNames);
- $.each(names, function() {
- result[this] = options[this]
- });
- return result
- },
- loadOptions: function() {
- return this._storeLoadOptions
- },
- items: function() {
- return this._items
- },
- pageIndex: function(newIndex) {
- if (newIndex !== undefined) {
- this._pageIndex = newIndex;
- this._isLastPage = !this._paginate
- }
- return this._pageIndex
- },
- paginate: function(value) {
- if (arguments.length < 1)
- return this._paginate;
- value = !!value;
- if (this._paginate !== value) {
- this._paginate = value;
- this.pageIndex(0)
- }
- },
- isLastPage: function() {
- return this._isLastPage
- },
- sort: generateStoreLoadOptionAccessor("sort"),
- filter: function() {
- var newFilter = normalizeStoreLoadOptionAccessorArguments(arguments);
- if (newFilter !== undefined) {
- this._storeLoadOptions.filter = newFilter;
- this.pageIndex(0)
- }
- return this._storeLoadOptions.filter
- },
- group: generateStoreLoadOptionAccessor("group"),
- select: generateStoreLoadOptionAccessor("select"),
- searchValue: function(value) {
- if (value !== undefined) {
- this.pageIndex(0);
- this._searchValue = value
- }
- return this._searchValue
- },
- searchOperation: function(op) {
- if (op !== undefined) {
- this.pageIndex(0);
- this._searchOperation = op
- }
- return this._searchOperation
- },
- searchExpr: function(expr) {
- var argc = arguments.length;
- if (argc) {
- if (argc > 1)
- expr = $.makeArray(arguments);
- this.pageIndex(0);
- this._searchExpr = expr
- }
- return this._searchExpr
- },
- store: function() {
- return this._store
- },
- key: function() {
- return this._store && this._store.key()
- },
- totalCount: function() {
- return this._totalCount
- },
- isLoaded: function() {
- return this._isLoaded
- },
- isLoading: function() {
- return this._loadingCount > 0
- },
- _createLoadQueue: function() {
- return DX.createQueue()
- },
- _changeLoadingCount: function(increment) {
- var oldLoading = this.isLoading(),
- newLoading;
- this._loadingCount += increment;
- newLoading = this.isLoading();
- if (oldLoading ^ newLoading)
- this.loadingChanged.fire(newLoading)
- },
- _scheduleLoadCallbacks: function(deferred) {
- var thisSource = this;
- thisSource._changeLoadingCount(1);
- deferred.always(function() {
- thisSource._changeLoadingCount(-1)
- })
- },
- _scheduleChangedCallbacks: function(deferred) {
- var that = this;
- deferred.done(function() {
- that.changed.fire()
- })
- },
- loadSingle: function(propName, propValue) {
- var that = this;
- var d = $.Deferred().fail(this.loadError.fire),
- key = this.key(),
- store = this._store,
- loadOptions = this._createStoreLoadOptions();
- function handleSuccess(data) {
- d.resolve(that._transformLoadedData(data)[0])
- }
- if (arguments.length < 2) {
- propValue = propName;
- propName = key
- }
- delete loadOptions.skip;
- delete loadOptions.group;
- delete loadOptions.refresh;
- delete loadOptions.pageIndex;
- delete loadOptions.searchString;
- if (propName === key || store instanceof data.CustomStore)
- store.byKey(propValue, loadOptions).done(handleSuccess).fail(d.reject);
- else {
- loadOptions.take = 1;
- loadOptions._preferSync = true;
- loadOptions.filter = loadOptions.filter ? [loadOptions.filter, [propName, propValue]] : [propName, propValue];
- store.load(loadOptions).done(handleSuccess).fail(d.reject)
- }
- return d.promise()
- },
- load: function() {
- var thisSource = this,
- d = $.Deferred(),
- errorCallback = this.loadError,
- storeLoadOptions;
- this._scheduleLoadCallbacks(d);
- this._scheduleChangedCallbacks(d);
- storeLoadOptions = this._createStoreLoadOptions();
- function loadTask() {
- if (thisSource._disposed)
- return undefined;
- return thisSource._loadFromStore(storeLoadOptions, d)
- }
- this._loadQueue.add(function() {
- loadTask();
- return d.promise()
- }, function() {
- thisSource._changeLoadingCount(-1)
- });
- return d.promise().fail($.proxy(errorCallback.fire, errorCallback))
- },
- _addSearchOptions: function(storeLoadOptions) {
- if (this._disposed)
- return;
- if (this.store()._useDefaultSearch)
- this._addSearchFilter(storeLoadOptions);
- else {
- storeLoadOptions.searchValue = this._searchValue;
- storeLoadOptions.searchExpr = this._searchExpr
- }
- },
- _createStoreLoadOptions: function() {
- var result = $.extend({}, this._storeLoadOptions);
- this._addSearchOptions(result);
- if (this._paginate) {
- result.pageIndex = this._pageIndex;
- if (this._pageSize) {
- result.skip = this._pageIndex * this._pageSize;
- result.take = this._pageSize
- }
- }
- result.userData = this._userData;
- addOldUserDataSourceBackwardCompatibilityOptions(this, result);
- return result
- },
- _addSearchFilter: function(storeLoadOptions) {
- var value = this._searchValue,
- op = this._searchOperation,
- selector = this._searchExpr,
- searchFilter = [];
- if (!value)
- return;
- if (!selector)
- selector = "this";
- if (!$.isArray(selector))
- selector = [selector];
- $.each(selector, function(i, item) {
- if (searchFilter.length)
- searchFilter.push("or");
- searchFilter.push([item, op, value])
- });
- if (storeLoadOptions.filter)
- storeLoadOptions.filter = [searchFilter, storeLoadOptions.filter];
- else
- storeLoadOptions.filter = searchFilter
- },
- _loadFromStore: function(storeLoadOptions, pendingDeferred) {
- var thisSource = this;
- function handleSuccess(data, extra) {
- function processResult() {
- thisSource._processStoreLoadResult(data, extra, storeLoadOptions, pendingDeferred)
- }
- if (thisSource._preferSync)
- processResult();
- else
- DX.utils.executeAsync(processResult)
- }
- return this.store().load(storeLoadOptions).done(handleSuccess).fail($.proxy(pendingDeferred.reject, pendingDeferred))
- },
- _processStoreLoadResult: function(data, extra, storeLoadOptions, pendingDeferred) {
- var thisSource = this;
- function resolvePendingDeferred() {
- thisSource._isLoaded = true;
- thisSource._totalCount = isFinite(extra.totalCount) ? extra.totalCount : -1;
- return pendingDeferred.resolve(data, extra)
- }
- function proceedLoadingTotalCount() {
- thisSource.store().totalCount(storeLoadOptions).done(function(count) {
- extra.totalCount = count;
- resolvePendingDeferred()
- }).fail(function(){})
- }
- if (thisSource._disposed)
- return;
- data = thisSource._transformLoadedData(data);
- if (!$.isPlainObject(extra))
- extra = {};
- thisSource._items = data;
- if (!data.length || !thisSource._paginate || thisSource._pageSize && data.length < thisSource._pageSize)
- thisSource._isLastPage = true;
- if (storeLoadOptions.requireTotalCount && !isFinite(extra.totalCount))
- proceedLoadingTotalCount();
- else
- resolvePendingDeferred()
- },
- _transformLoadedData: function(data) {
- var result = $.makeArray(data);
- if (this._mapFunc)
- result = $.map(result, this._mapFunc);
- if (this._postProcessFunc)
- result = this._postProcessFunc(result);
- return result
- }
- });
- data.Store.redefine({toDataSource: function(options) {
- DX.utils.logger.warn("toDataSource() method is deprecated, use 'new DevExpress.data.DataSource(...)' instead");
- return new DataSource($.extend({store: this}, options))
- }});
- $.extend(true, data, {
- DataSource: DataSource,
- createDataSource: function(options) {
- DX.utils.logger.warn("createDataSource() method is deprecated, use 'new DevExpress.data.DataSource(...)' instead");
- return new DataSource(options)
- },
- utils: {
- storeTypeRegistry: storeTypeRegistry,
- normalizeDataSourceOptions: normalizeDataSourceOptions
- }
- })
- })(jQuery, DevExpress);
- /*! Module core, file ko.js */
- (function($, DX, undefined) {
- if (!DX.support.hasKo)
- return;
- var ko = window.ko;
- (function checkKnockoutVersion(version) {
- version = version.split(".");
- if (version[0] < 2 || version[0] == 2 && version[1] < 3)
- throw Error("Your version of KnockoutJS is too old. Please upgrade KnockoutJS to 2.3.0 or later.");
- })(ko.version)
- })(jQuery, DevExpress);
- /*! Module core, file ng.js */
- (function($, DX, undefined) {
- if (!DX.support.hasNg)
- return;
- DX.ng = {module: window.angular.module("dx", ["ngSanitize"])}
- })(jQuery, DevExpress);
- /*! Module core, file component.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- utils = DX.utils,
- dataUtils = DX.data.utils;
- var Component = DX.Class.inherit({
- NAME: "Component",
- _deprecatedOptions: {},
- _optionAliases: {},
- _setDefaultOptions: function(){},
- _defaultOptionsRules: function() {
- return []
- },
- _setOptionsByDevice: function() {
- var rules = this._defaultOptionsRules(),
- currentDevice = DX.devices.current(),
- result = {};
- if (this._customRules)
- rules = rules.concat(this._customRules);
- var deviceMatch = function(device, filter) {
- filter = $.makeArray(filter);
- return filter.length === 1 && $.isEmptyObject(filter[0]) || utils.findBestMatches(device, filter).length > 0
- };
- $.each(rules, function(index, rule) {
- var deviceFilter = rule.device || {},
- match;
- if ($.isFunction(deviceFilter))
- match = deviceFilter(currentDevice);
- else
- match = deviceMatch(currentDevice, deviceFilter);
- if (match)
- $.extend(result, rule.options)
- });
- this.option(result)
- },
- _optionsByReference: function() {
- return {}
- },
- ctor: function(options) {
- if (!this.NAME)
- throw Error("NAME is not specified");
- this._options = {};
- this._updateLockCount = 0;
- this.optionChanged = $.Callbacks();
- this.beginUpdate();
- try {
- this._suppressDeprecatedWarnings();
- this._setDefaultOptions();
- this._setOptionsByDevice();
- this._resumeDeprecatedWarnings();
- this._initialOptions = $.extend({}, this.option());
- this._initOptions(options || {})
- }
- finally {
- this.endUpdate()
- }
- },
- _initOptions: function(options) {
- this.option(options)
- },
- _optionValuesEqual: function(name, oldValue, newValue) {
- oldValue = dataUtils.toComparable(oldValue, true);
- newValue = dataUtils.toComparable(newValue, true);
- if (oldValue && newValue && oldValue.jquery && newValue.jquery)
- return newValue.is(oldValue);
- if (oldValue === null || typeof oldValue !== "object")
- return oldValue === newValue;
- return false
- },
- _init: $.noop,
- _optionChanged: $.noop,
- instance: function() {
- return this
- },
- beginUpdate: function() {
- this._updateLockCount++
- },
- endUpdate: function() {
- this._updateLockCount--;
- if (!this._updateLockCount)
- if (!this._initializing && !this._initialized) {
- this._initializing = true;
- try {
- this._init()
- }
- finally {
- this._initializing = false;
- this._initialized = true
- }
- }
- },
- _logWarningIfDeprecated: function(option) {
- var info = this._deprecatedOptions[option];
- if (info && !this._deprecatedOptionsSuppressed)
- this._logDeprecatedWarning(option, info)
- },
- _logDeprecatedWarningCount: 0,
- _logDeprecatedWarning: function(option, info) {
- utils.logger.warn("'" + option + "' option is deprecated since " + info.since + ". " + info.message);
- ++this._logDeprecatedWarningCount
- },
- _suppressDeprecatedWarnings: function() {
- this._deprecatedOptionsSuppressed = true
- },
- _resumeDeprecatedWarnings: function() {
- this._deprecatedOptionsSuppressed = false
- },
- _getOptionAliases: function(option) {
- return $.map(this._optionAliases, function(aliasedOption, alias) {
- return option === aliasedOption ? alias : undefined
- })
- },
- _notifyOptionChanged: function(option, value, previousValue) {
- var that = this,
- optionWithAliases;
- if (this._initialized) {
- optionWithAliases = this._getOptionAliases(option);
- optionWithAliases.push(option);
- $.each(optionWithAliases, function(index, name) {
- var topLevelName = name.split(/[.\[]/)[0];
- that.optionChanged.fireWith(that, [topLevelName, value, previousValue]);
- that._optionChanged(topLevelName, value, previousValue)
- })
- }
- },
- initialOption: function(optionName) {
- var options = this._initialOptions;
- return options[optionName]
- },
- option: function(options) {
- var that = this,
- name = options,
- value = arguments[1];
- if (arguments.length < 2 && $.type(name) !== "object") {
- if (name) {
- this._logWarningIfDeprecated(name);
- if (this._optionAliases[name])
- name = this._optionAliases[name]
- }
- $.each(this._optionAliases, function(alias, option) {
- that._options[alias] = dataUtils.compileGetter(option)(that._options, {functionsAsIs: true})
- });
- return dataUtils.compileGetter(name)(that._options, {functionsAsIs: true})
- }
- if (typeof name === "string") {
- options = {};
- options[name] = value
- }
- that.beginUpdate();
- try {
- $.each(options, function(name, value) {
- that._logWarningIfDeprecated(name);
- if (that._optionAliases[name])
- name = that._optionAliases[name];
- var prevValue = dataUtils.compileGetter(name)(that._options, {functionsAsIs: true});
- if (that._optionValuesEqual(name, prevValue, value))
- return;
- dataUtils.compileSetter(name)(that._options, value, {
- functionsAsIs: true,
- merge: !that._optionsByReference()[name]
- });
- that._notifyOptionChanged(name, value, prevValue)
- })
- }
- finally {
- that.endUpdate()
- }
- }
- });
- $.extend(DX, {Component: Component})
- })(jQuery, DevExpress);
- /*! Module core, file DOMComponent.js */
- (function($, DX, undefined) {
- var windowResizeCallbacks = DX.utils.windowResizeCallbacks;
- var RTL_DIRECTION_CLASS = "dx-rtl",
- COMPONENT_NAMES_DATA_KEY = "dxComponents",
- VISIBILITY_CHANGE_CLASS = "dx-visibility-change-handler",
- VISIBILITY_CHANGE_EVENTNAMESPACE = "dxVisibilityChange";
- var DOMComponent = DX.Component.inherit({
- NAME: "DOMComponent",
- NAMESPACE: DX,
- _setDefaultOptions: function() {
- this.callBase();
- this.option({rtlEnabled: DX.rtlEnabled})
- },
- ctor: function(element, options) {
- this._$element = $(element);
- this._element().data(this.NAME, this);
- this._attachInstanceToElement(this._$element);
- this.disposing = $.Callbacks();
- this.callBase(options)
- },
- _attachInstanceToElement: $.noop,
- _visibilityChanged: DX.abstract,
- _dimensionChanged: DX.abstract,
- _init: function() {
- this.callBase();
- this._attachWindowResizeCallback()
- },
- _attachWindowResizeCallback: function() {
- if (this._isDimensionChangeSupported()) {
- var windowResizeCallBack = this._windowResizeCallBack = $.proxy(this._dimensionChanged, this);
- windowResizeCallbacks.add(windowResizeCallBack)
- }
- },
- _isDimensionChangeSupported: function() {
- return this._dimensionChanged !== DX.abstract
- },
- _render: function() {
- this._toggleRTLDirection(this.option("rtlEnabled"));
- this._renderVisiblityChange()
- },
- _renderVisiblityChange: function() {
- if (!this._isVisibilityChangeSupported())
- return;
- this._element().addClass(VISIBILITY_CHANGE_CLASS);
- this._attachVisiblityChangeHandlers()
- },
- _attachVisiblityChangeHandlers: function() {
- var that = this;
- that._element().off("." + VISIBILITY_CHANGE_EVENTNAMESPACE).on("dxhiding." + VISIBILITY_CHANGE_EVENTNAMESPACE, function() {
- that._visibilityChanged(false)
- }).on("dxshown." + VISIBILITY_CHANGE_EVENTNAMESPACE, function() {
- that._visibilityChanged(true)
- })
- },
- _isVisibilityChangeSupported: function() {
- return this._visibilityChanged !== DX.abstract
- },
- _clean: $.noop,
- _modelByElement: $.noop,
- _invalidate: function() {
- if (!this._updateLockCount)
- throw Error("Invalidate called outside update transaction");
- this._requireRefresh = true
- },
- _refresh: function() {
- this._clean();
- this._render()
- },
- _dispose: function() {
- this._clean();
- this._detachWindowResizeCallback();
- this.optionChanged.empty();
- this.disposing.fireWith(this).empty()
- },
- _detachWindowResizeCallback: function() {
- if (this._isDimensionChangeSupported())
- windowResizeCallbacks.remove(this._windowResizeCallBack)
- },
- _toggleRTLDirection: function(rtl) {
- this._element().toggleClass(RTL_DIRECTION_CLASS, rtl)
- },
- _createAction: function(actionSource, config) {
- var that = this;
- config = $.extend({}, config);
- var element = config.element || that._element(),
- model = that._modelByElement(element);
- config.context = model || that;
- config.component = that;
- var action = new DX.Action(actionSource, config);
- return function(e) {
- if (!arguments.length)
- e = {};
- if (e instanceof $.Event)
- throw Error("Action must be executed with jQuery.Event like action({ jQueryEvent: event })");
- if (!$.isPlainObject(e))
- e = {actionValue: e};
- return action.execute.call(action, $.extend(e, {
- component: that,
- element: element,
- model: model
- }))
- }
- },
- _createActionByOption: function(optionName, config) {
- if (typeof optionName !== "string")
- throw Error("Option name type is unexpected");
- this._suppressDeprecatedWarnings();
- var action = this._createAction(this.option(optionName), config);
- this._resumeDeprecatedWarnings();
- return action
- },
- _optionChanged: function(name, value, prevValue) {
- if (name === "rtlEnabled")
- this._invalidate()
- },
- _element: function() {
- return this._$element
- },
- endUpdate: function() {
- var requireRender = !this._initializing && !this._initialized;
- this.callBase.apply(this, arguments);
- if (!this._updateLockCount)
- if (requireRender)
- this._render();
- else if (this._requireRefresh) {
- this._requireRefresh = false;
- this._refresh()
- }
- }
- });
- var registerComponent = function(name, componentClass) {
- componentClass.redefine({_attachInstanceToElement: function($element) {
- $element.data(name, this);
- if (!$element.data(COMPONENT_NAMES_DATA_KEY))
- $element.data(COMPONENT_NAMES_DATA_KEY, []);
- $element.data(COMPONENT_NAMES_DATA_KEY).push(name)
- }});
- componentClass.prototype.NAMESPACE[name] = componentClass;
- componentClass.prototype.NAME = name;
- componentClass.defaultOptions = function(rule) {
- componentClass.prototype._customRules = componentClass.prototype._customRules || [];
- componentClass.prototype._customRules.push(rule)
- };
- $.fn[name] = function(options) {
- var isMemberInvoke = typeof options === "string",
- result;
- if (isMemberInvoke) {
- var memberName = options,
- memberArgs = $.makeArray(arguments).slice(1);
- this.each(function() {
- var instance = $(this).data(name);
- if (!instance)
- throw Error(DX.utils.stringFormat("Component {0} has not been initialized on this element", name));
- var member = instance[memberName],
- memberValue = member.apply(instance, memberArgs);
- if (result === undefined)
- result = memberValue
- })
- }
- else {
- this.each(function() {
- var instance = $(this).data(name);
- if (instance)
- instance.option(options);
- else
- new componentClass(this, options)
- });
- result = this
- }
- return result
- }
- };
- var getComponents = function(element) {
- element = $(element);
- var names = element.data(COMPONENT_NAMES_DATA_KEY);
- if (!names)
- return [];
- return $.map(names, function(name) {
- return element.data(name)
- })
- };
- var disposeComponents = function() {
- $.each(getComponents(this), function() {
- this._dispose()
- })
- };
- var originalCleanData = $.cleanData;
- $.cleanData = function(element) {
- $.each(element, disposeComponents);
- return originalCleanData.apply(this, arguments)
- };
- registerComponent("DOMComponent", DOMComponent);
- DX.registerComponent = registerComponent
- })(jQuery, DevExpress);
- /*! Module core, file social.js */
- DevExpress.social = {};
- /*! Module core, file facebook.js */
- (function($, DX, undefined) {
- function notifyDeprecated() {
- DX.utils.logger.warn("DevExpress.social API is deprecated. Use official Facebook library instead")
- }
- var social = DX.social;
- var location = window.location,
- navigator = window.navigator,
- encodeURIComponent = window.encodeURIComponent,
- decodeURIComponent = window.decodeURIComponent,
- iosStandaloneMode = navigator.standalone,
- cordovaMode = false;
- if (window.cordova)
- $(document).on("deviceready", function() {
- cordovaMode = true
- });
- var ACCESS_TOKEN_KEY = "dx-facebook-access-token",
- IOS_STANDALONE_STEP1_KEY = "dx-facebook-step1",
- IOS_STANDALONE_STEP2_KEY = "dx-facebook-step2";
- var accessToken = null,
- expires = null,
- connectionChanged = $.Callbacks();
- var pendingLoginRedirectUrl;
- var isConnected = function() {
- return !!accessToken
- };
- var getAccessTokenObject = function() {
- return {
- accessToken: accessToken,
- expiresIn: accessToken ? expires : 0
- }
- };
- var FB = social.Facebook = {
- loginRedirectUrl: "FacebookLoginCallback.html",
- connectionChanged: connectionChanged,
- isConnected: isConnected,
- getAccessTokenObject: getAccessTokenObject,
- jsonp: false
- };
- var login = function(appId, options) {
- notifyDeprecated();
- options = options || {};
- if (cordovaMode)
- pendingLoginRedirectUrl = "https://www.facebook.com/connect/login_success.html";
- else
- pendingLoginRedirectUrl = formatLoginRedirectUrl();
- var scope = (options.permissions || []).join(),
- url = "https://www.facebook.com/dialog/oauth?display=popup&client_id=" + appId + "&redirect_uri=" + encodeURIComponent(pendingLoginRedirectUrl) + "&scope=" + encodeURIComponent(scope) + "&response_type=token";
- if (iosStandaloneMode)
- putData(IOS_STANDALONE_STEP1_KEY, location.href);
- if (cordovaMode)
- startLogin_cordova(url);
- else
- startLogin_browser(url)
- };
- var formatLoginRedirectUrl = function() {
- var pathSegments = location.pathname.split(/\//g);
- pathSegments.pop();
- pathSegments.push(FB.loginRedirectUrl);
- return location.protocol + "//" + location.host + pathSegments.join("/")
- };
- var startLogin_browser = function(loginUrl) {
- var width = 512,
- height = 320,
- left = (screen.width - width) / 2,
- top = (screen.height - height) / 2;
- window.open(loginUrl, null, "width=" + width + ",height=" + height + ",toolbar=0,scrollbars=0,status=0,resizable=0,menuBar=0,left=" + left + ",top=" + top)
- };
- var startLogin_cordova = function(loginUrl) {
- var ref = window.open(loginUrl, "_blank");
- ref.addEventListener('exit', function(event) {
- pendingLoginRedirectUrl = null
- });
- ref.addEventListener('loadstop', function(event) {
- var url = unescape(event.url);
- if (url.indexOf(pendingLoginRedirectUrl) === 0) {
- ref.close();
- _processLoginRedirectUrl(url)
- }
- })
- };
- var handleLoginRedirect = function() {
- var opener = window.opener;
- if (iosStandaloneMode) {
- putData(IOS_STANDALONE_STEP2_KEY, location.href);
- location.href = getData(IOS_STANDALONE_STEP1_KEY)
- }
- else if (opener && opener.DevExpress) {
- opener.DevExpress.social.Facebook._processLoginRedirectUrl(location.href);
- window.close()
- }
- };
- var _processLoginRedirectUrl = function(url) {
- var params = parseUrlFragment(url);
- expires = params.expires_in;
- changeToken(params.access_token);
- pendingLoginRedirectUrl = null
- };
- var parseUrlFragment = function(url) {
- var hash = url.split("#")[1];
- if (!hash)
- return {};
- var pairs = hash.split(/&/g),
- result = {};
- $.each(pairs, function(i) {
- var splitPair = this.split("=");
- result[splitPair[0]] = decodeURIComponent(splitPair[1])
- });
- return result
- };
- var logout = function() {
- notifyDeprecated();
- changeToken(null)
- };
- var changeToken = function(value) {
- if (value === accessToken)
- return;
- accessToken = value;
- putData(ACCESS_TOKEN_KEY, value);
- connectionChanged.fire(!!value)
- };
- var api = function(resource, method, params) {
- notifyDeprecated();
- if (!isConnected())
- throw Error("Not connected");
- if (typeof method !== "string") {
- params = method;
- method = undefined
- }
- method = (method || "get").toLowerCase();
- var d = $.Deferred();
- var args = arguments;
- $.ajax({
- url: "https://graph.facebook.com/" + resource,
- type: method,
- data: $.extend({access_token: accessToken}, params),
- dataType: FB.jsonp && method === "get" ? "jsonp" : "json"
- }).done(function(response) {
- response = response || simulateErrorResponse();
- if (response.error)
- d.reject(response.error);
- else
- d.resolve(response)
- }).fail(function(xhr) {
- var response;
- try {
- response = $.parseJSON(xhr.responseText);
- var tries = args[3] || 0;
- if (tries++ < 3 && response.error.code == 190 && response.error.error_subcode == 466) {
- setTimeout(function() {
- api(resource, method, params, tries).done(function(result) {
- d.resolve(result)
- }).fail(function(error) {
- d.reject(error)
- })
- }, 500);
- return
- }
- }
- catch(x) {
- response = simulateErrorResponse()
- }
- d.reject(response.error)
- });
- return d.promise()
- };
- var simulateErrorResponse = function() {
- return {error: {message: "Unknown error"}}
- };
- var ensureStorageBackend = function() {
- if (!hasStorageBackend())
- throw Error("HTML5 sessionStorage or jQuery.cookie plugin is required");
- };
- var hasStorageBackend = function() {
- return !!($.cookie || window.sessionStorage)
- };
- var putData = function(key, data) {
- ensureStorageBackend();
- data = JSON.stringify(data);
- if (window.sessionStorage)
- if (data === null)
- sess.removeItem(key);
- else
- sessionStorage.setItem(key, data);
- else
- $.cookie(key, data)
- };
- var getData = function(key) {
- ensureStorageBackend();
- try {
- return JSON.parse(window.sessionStorage ? sessionStorage.getItem(key) : $.cookie(key))
- }
- catch(x) {
- return null
- }
- };
- if (hasStorageBackend())
- accessToken = getData(ACCESS_TOKEN_KEY);
- if (iosStandaloneMode) {
- var url = getData(IOS_STANDALONE_STEP2_KEY);
- if (url) {
- _processLoginRedirectUrl(url);
- putData(IOS_STANDALONE_STEP1_KEY, null);
- putData(IOS_STANDALONE_STEP2_KEY, null)
- }
- }
- $.extend(FB, {
- login: login,
- logout: logout,
- handleLoginRedirect: handleLoginRedirect,
- _processLoginRedirectUrl: _processLoginRedirectUrl,
- api: api
- })
- })(jQuery, DevExpress);
- /*! Module core, file ui.js */
- (function($, DX, undefined) {
- var ui = DX.ui = {};
- var TemplateProvider = DX.Class.inherit({
- getTemplateClass: function() {
- return Template
- },
- supportDefaultTemplate: function() {
- return false
- },
- getDefaultTemplate: function() {
- return null
- }
- });
- var Template = DX.Class.inherit({
- ctor: function(element, owner) {
- this._template = this._element = $(element).detach();
- this._owner = owner
- },
- render: function(container) {
- var renderedTemplate = this._template.clone();
- container.append(renderedTemplate);
- return renderedTemplate
- },
- dispose: function() {
- this._owner = null
- },
- owner: function() {
- return this._owner
- }
- });
- var GESTURE_LOCK_KEY = "dxGestureLock";
- DX.registerActionExecutor({
- designMode: {validate: function(e) {
- if (DX.designMode)
- e.cancel = true
- }},
- gesture: {validate: function(e) {
- if (!e.args.length)
- return;
- var args = e.args[0],
- element = args[e.validatingTargetName] || args.element;
- while (element && element.length) {
- if (element.data(GESTURE_LOCK_KEY)) {
- e.cancel = true;
- break
- }
- element = element.parent()
- }
- }},
- disabled: {validate: function(e) {
- if (!e.args.length)
- return;
- var args = e.args[0],
- element = args[e.validatingTargetName] || args.element;
- if (element && element.is(".dx-state-disabled, .dx-state-disabled *"))
- e.cancel = true
- }}
- });
- $.extend(ui, {
- TemplateProvider: TemplateProvider,
- Template: Template,
- initViewport: function() {
- DX.utils.logger.warn("DevExpress.ui.initViewport is deprecated. Use DX.utils.initMobileViewport instead");
- DX.utils.initMobileViewport()
- }
- });
- ui.__internals = ui.__internals || {};
- $.extend(ui.__internals, {Template: Template})
- })(jQuery, DevExpress);
- /*! Module core, file ko.components.js */
- (function($, DX, undefined) {
- if (!DX.support.hasKo)
- return;
- var ko = window.ko,
- ui = DX.ui,
- LOCKS_DATA_KEY = "dxKoLocks",
- CREATED_WITH_KO_DATA_KEY = "dxKoCreation";
- var Locks = function() {
- var info = {};
- var currentCount = function(lockName) {
- return info[lockName] || 0
- };
- return {
- obtain: function(lockName) {
- info[lockName] = currentCount(lockName) + 1
- },
- release: function(lockName) {
- var count = currentCount(lockName);
- if (count < 1)
- throw Error("Not locked");
- if (count === 1)
- delete info[lockName];
- else
- info[lockName] = count - 1
- },
- locked: function(lockName) {
- return currentCount(lockName) > 0
- }
- }
- };
- var registerComponentKoBinding = function(componentName) {
- ko.bindingHandlers[componentName] = {init: function(domNode, valueAccessor) {
- var element = $(domNode),
- ctorOptions = {},
- optionNameToModelMap = {};
- var applyModelValueToOption = function(optionName, modelValue) {
- var component = element.data(componentName),
- locks = element.data(LOCKS_DATA_KEY),
- optionValue = ko.utils.unwrapObservable(modelValue);
- if (ko.isWriteableObservable(modelValue))
- optionNameToModelMap[optionName] = modelValue;
- if (component) {
- if (locks.locked(optionName))
- return;
- locks.obtain(optionName);
- try {
- component.option(optionName, optionValue)
- }
- finally {
- locks.release(optionName)
- }
- }
- else
- ctorOptions[optionName] = optionValue
- };
- var handleOptionChanged = function(optionName, optionValue) {
- if (!(optionName in optionNameToModelMap))
- return;
- var element = this._$element,
- locks = element.data(LOCKS_DATA_KEY);
- if (locks.locked(optionName))
- return;
- locks.obtain(optionName);
- try {
- optionNameToModelMap[optionName](optionValue)
- }
- finally {
- locks.release(optionName)
- }
- };
- var createComponent = function() {
- element.data(CREATED_WITH_KO_DATA_KEY, true);
- element[componentName](ctorOptions);
- ctorOptions = null;
- element.data(LOCKS_DATA_KEY, new Locks);
- element.data(componentName).optionChanged.add(handleOptionChanged)
- };
- ko.computed(function() {
- var component = element.data(componentName);
- if (component)
- component.beginUpdate();
- $.each(ko.unwrap(valueAccessor()), function(modelName, modelValueExpr) {
- ko.computed(function() {
- applyModelValueToOption(modelName, modelValueExpr)
- }, null, {disposeWhenNodeIsRemoved: domNode})
- });
- if (component)
- component.endUpdate();
- else
- createComponent()
- }, null, {disposeWhenNodeIsRemoved: domNode});
- return {controlsDescendantBindings: ui[componentName] && ui[componentName].subclassOf(ui.Widget)}
- }}
- };
- var KoComponent = DX.DOMComponent.inherit({_modelByElement: function(element) {
- if (element.length)
- return ko.dataFor(element.get(0))
- }});
- var originalRegisterComponent = DX.registerComponent;
- var registerKoComponent = function(name, componentClass) {
- originalRegisterComponent(name, componentClass);
- registerComponentKoBinding(name)
- };
- ko.bindingHandlers.dxAction = {update: function(element, valueAccessor, allBindingsAccessor, viewModel) {
- var $element = $(element);
- var unwrappedValue = ko.utils.unwrapObservable(valueAccessor()),
- actionSource = unwrappedValue,
- actionOptions = {context: element};
- if (unwrappedValue.execute) {
- actionSource = unwrappedValue.execute;
- $.extend(actionOptions, unwrappedValue)
- }
- var action = new DX.Action(actionSource, actionOptions);
- $element.off(".dxActionBinding").on("dxclick.dxActionBinding", function(e) {
- action.execute({
- element: $element,
- model: viewModel,
- evaluate: function(expression) {
- var context = viewModel;
- if (expression.length > 0 && expression[0] === "$")
- context = ko.contextFor(element);
- var getter = DX.data.utils.compileGetter(expression);
- return getter(context)
- },
- jQueryEvent: e
- });
- if (!actionOptions.bubbling)
- e.stopPropagation()
- })
- }};
- var cleanKoData = function(element, andSelf) {
- var cleanNode = function() {
- ko.cleanNode(this)
- };
- if (andSelf)
- element.each(cleanNode);
- else
- element.find("*").each(cleanNode)
- };
- var originalEmpty = $.fn.empty;
- $.fn.empty = function() {
- cleanKoData(this, false);
- return originalEmpty.apply(this, arguments)
- };
- var originalRemove = $.fn.remove;
- $.fn.remove = function(selector, keepData) {
- if (!keepData) {
- var subject = this;
- if (selector)
- subject = subject.filter(selector);
- cleanKoData(subject, true)
- }
- return originalRemove.call(this, selector, keepData)
- };
- var originalHtml = $.fn.html;
- $.fn.html = function(value) {
- if (typeof value === "string")
- cleanKoData(this, false);
- return originalHtml.apply(this, arguments)
- };
- DX.registerComponent = registerKoComponent;
- registerKoComponent("DOMComponent", KoComponent)
- })(jQuery, DevExpress);
- /*! Module core, file ng.components.js */
- (function($, DX, undefined) {
- if (!DX.support.hasNg)
- return;
- var ui = DX.ui,
- compileSetter = DX.data.utils.compileSetter,
- compileGetter = DX.data.utils.compileGetter;
- var CREATED_WITH_NG_DATA_KEY = "dxNgCreation",
- TEMPLATES_DATA_KEY = "dxTemplates",
- COMPILER_DATA_KEY = "dxNgCompiler",
- DEFAULT_COMPILER_DATA_KEY = "dxDefaultCompilerGetter",
- ANONYMOUS_TEMPLATE_NAME = "template";
- var phoneJsModule = DX.ng.module;
- var ComponentBuilder = DX.Class.inherit({
- ctor: function(options) {
- this._componentName = options.componentName;
- this._$element = options.$element;
- this._$templates = options.$templates;
- this._scope = options.scope;
- this._compile = options.compile;
- this._ngOptions = options.ngOptions;
- this._componentDisposing = $.Callbacks();
- this._$element.data(CREATED_WITH_NG_DATA_KEY, true);
- if (options.ngOptions.data)
- this._initDataScope(options.ngOptions.data)
- },
- initDefaultCompilerGetter: function() {
- var that = this;
- that._$element.data(DEFAULT_COMPILER_DATA_KEY, function($template) {
- return that._compilerByTemplate($template)
- })
- },
- initTemplateCompilers: function() {
- var that = this;
- if (this._$templates)
- this._$templates.each(function(i, template) {
- $(template).data(COMPILER_DATA_KEY, that._compilerByTemplate(template))
- })
- },
- initComponentWithBindings: function() {
- this._initComponent(this._scope);
- this._initComponentBindings()
- },
- _initDataScope: function(data) {
- if (typeof data === "string") {
- var dataStr = data,
- rootScope = this._scope;
- data = rootScope.$eval(data);
- this._scope = rootScope.$new();
- this._synchronizeDataScopes(rootScope, this._scope, data, dataStr)
- }
- $.extend(this._scope, data)
- },
- _synchronizeDataScopes: function(parentScope, childScope, data, parentPrefix) {
- var that = this;
- $.each(data, function(fieldPath) {
- that._synchronizeScopeField({
- parentScope: parentScope,
- childScope: childScope,
- fieldPath: fieldPath,
- parentPrefix: parentPrefix
- })
- })
- },
- _initComponent: function(scope) {
- this._component = this._$element[this._componentName](this._evalOptions(scope)).data(this._componentName)
- },
- _initComponentBindings: function() {
- var that = this,
- optionDependencies = {};
- if (that._ngOptions.bindingOptions)
- $.each(that._ngOptions.bindingOptions, function(optionPath, valuePath) {
- var separatorIndex = optionPath.search(/\[|\./),
- optionForSubscribe = separatorIndex > -1 ? optionPath.substring(0, separatorIndex) : optionPath,
- prevWatchMethod,
- clearWatcher;
- if (!optionDependencies[optionForSubscribe])
- optionDependencies[optionForSubscribe] = {};
- optionDependencies[optionForSubscribe][optionPath] = valuePath;
- var watchCallback = function(newValue, oldValue) {
- if (newValue !== oldValue) {
- that._component.option(optionPath, newValue);
- updateWatcher()
- }
- };
- var updateWatcher = function() {
- var watchMethod = $.isArray(that._scope.$eval(valuePath)) ? "$watchCollection" : "$watch";
- if (prevWatchMethod !== watchMethod) {
- if (clearWatcher)
- clearWatcher();
- clearWatcher = that._scope[watchMethod](valuePath, watchCallback, true);
- prevWatchMethod = watchMethod
- }
- };
- updateWatcher();
- that._component.disposing.add(function() {
- clearWatcher();
- that._componentDisposing.fire()
- })
- });
- that._component.optionChanged.add(function(optionName, optionValue) {
- if (that._scope.$root.$$phase === "$digest" || !optionDependencies || !optionDependencies[optionName])
- return;
- safeApply(function(scope) {
- $.each(optionDependencies[optionName], function(optionPath, valuePath) {
- var setter = compileSetter(valuePath),
- getter = compileGetter(optionPath);
- var tmpData = {};
- tmpData[optionName] = optionValue;
- setter(scope, getter(tmpData))
- })
- }, that._scope)
- })
- },
- _compilerByTemplate: function(template) {
- var that = this,
- scopeItemsPath = this._getScopeItemsPath();
- return function(data, index) {
- var $resultMarkup = $(template).clone(),
- templateScope;
- if (data !== undefined) {
- var dataIsScope = data.$id,
- templateScope = dataIsScope ? data : that._createScopeWithData(data);
- $resultMarkup.on("$destroy", function() {
- var destroyAlreadyCalled = !templateScope.$parent;
- if (destroyAlreadyCalled)
- return;
- templateScope.$destroy()
- })
- }
- else
- templateScope = that._scope;
- if (scopeItemsPath)
- that._synchronizeScopes(templateScope, scopeItemsPath, index);
- safeApply(that._compile($resultMarkup), templateScope);
- return $resultMarkup
- }
- },
- _getScopeItemsPath: function() {
- if (ui[this._componentName].subclassOf(ui.CollectionContainerWidget) && this._ngOptions.bindingOptions)
- return this._ngOptions.bindingOptions.items
- },
- _createScopeWithData: function(data) {
- var newScope = this._scope.$new(true);
- if (typeof data === "object")
- $.extend(newScope, data);
- else
- newScope.scopeValue = data;
- return newScope
- },
- _synchronizeScopes: function(itemScope, parentPrefix, itemIndex) {
- var that = this,
- item = compileGetter(parentPrefix + "[" + itemIndex + "]")(this._scope);
- if (!$.isPlainObject(item))
- item = {scopeValue: item};
- $.each(item, function(itemPath) {
- that._synchronizeScopeField({
- parentScope: that._scope,
- childScope: itemScope,
- fieldPath: itemPath,
- parentPrefix: parentPrefix,
- itemIndex: itemIndex
- })
- })
- },
- _synchronizeScopeField: function(args) {
- var parentScope = args.parentScope,
- childScope = args.childScope,
- fieldPath = args.fieldPath,
- parentPrefix = args.parentPrefix,
- itemIndex = args.itemIndex;
- var innerPathSuffix = fieldPath === "scopeValue" ? "" : "." + fieldPath,
- collectionField = itemIndex !== undefined,
- optionOuterBag = [parentPrefix],
- optionOuterPath;
- if (collectionField)
- optionOuterBag.push("[", itemIndex, "]");
- optionOuterBag.push(innerPathSuffix);
- optionOuterPath = optionOuterBag.join("");
- var clearParentWatcher = parentScope.$watch(optionOuterPath, function(newValue, oldValue) {
- if (newValue !== oldValue)
- compileSetter(fieldPath)(childScope, newValue)
- });
- var clearItemWatcher = childScope.$watch(fieldPath, function(newValue, oldValue) {
- if (newValue !== oldValue) {
- if (collectionField && !compileGetter(parentPrefix)(parentScope)[itemIndex]) {
- clearItemWatcher();
- return
- }
- compileSetter(optionOuterPath)(parentScope, newValue)
- }
- });
- this._componentDisposing.add([clearParentWatcher, clearItemWatcher])
- },
- _evalOptions: function(scope) {
- var result = $.extend({}, this._ngOptions);
- delete result.data;
- delete result.bindingOptions;
- if (this._ngOptions.bindingOptions)
- $.each(this._ngOptions.bindingOptions, function(key, value) {
- result[key] = scope.$eval(value)
- });
- return result
- }
- });
- var safeApply = function(func, scope) {
- if (scope.$root.$$phase)
- func(scope);
- else
- scope.$apply(function() {
- func(scope)
- })
- };
- var extractTemplates = function($element, componentName) {
- if ($element.data(TEMPLATES_DATA_KEY))
- return $element.data(TEMPLATES_DATA_KEY);
- var $templates;
- if (ui[componentName] && ui[componentName].subclassOf(ui.Widget) && $.trim($element.html())) {
- var isAnonymousTemplate = !$element.children().first().attr("data-options");
- if (isAnonymousTemplate)
- $templates = $("<div/>").attr("data-options", "dxTemplate: { name: '" + ANONYMOUS_TEMPLATE_NAME + "' }").append($element.contents());
- else
- $templates = $element.children().detach();
- $element.data(TEMPLATES_DATA_KEY, $templates)
- }
- return $templates
- };
- var NgComponent = DX.DOMComponent.inherit({
- _modelByElement: function(element) {
- if (element.length)
- return element.scope()
- },
- _createAction: function() {
- var action = this.callBase.apply(this, arguments);
- var component = this,
- wrappedAction = function() {
- var that = this,
- scope = component._modelByElement(component._element()),
- args = arguments;
- if (!scope || scope.$root.$$phase)
- return action.apply(that, args);
- return scope.$apply(function() {
- return action.apply(that, args)
- })
- };
- return wrappedAction
- }
- });
- var originalRegisterComponent = DX.registerComponent;
- var registerNgComponent = function(componentName, componentClass) {
- originalRegisterComponent(componentName, componentClass);
- phoneJsModule.directive(componentName, ["$compile", function(compile) {
- return {
- restrict: "A",
- compile: function($element) {
- var $templates = extractTemplates($element, componentName);
- return function(scope, $element, attrs) {
- var componentBuilder = new ComponentBuilder({
- componentName: componentName,
- compile: compile,
- $element: $element,
- scope: scope,
- ngOptions: attrs[componentName] ? scope.$eval(attrs[componentName]) : {},
- $templates: $templates
- });
- componentBuilder.initTemplateCompilers();
- componentBuilder.initDefaultCompilerGetter();
- componentBuilder.initComponentWithBindings()
- }
- }
- }
- }])
- };
- DX.registerComponent = registerNgComponent;
- registerNgComponent("DOMComponent", NgComponent)
- })(jQuery, DevExpress);
- /*! Module core, file ko.templates.js */
- (function($, DX, undefined) {
- if (!DX.support.hasKo)
- return;
- var ko = window.ko,
- ui = DX.ui,
- CREATED_WITH_KO_DATA_KEY = "dxKoCreation";
- var KoTemplate = ui.Template.inherit({
- ctor: function(element) {
- this.callBase.apply(this, arguments);
- this._template = $("<div>").append(element);
- this._registerKoTemplate()
- },
- _cleanTemplateElement: function() {
- this._element.each(function() {
- ko.cleanNode(this)
- })
- },
- _registerKoTemplate: function() {
- var template = this._template.get(0);
- new ko.templateSources.anonymousTemplate(template)['nodes'](template)
- },
- render: function(container, data) {
- data = data !== undefined ? data : ko.dataFor(container.get(0)) || {};
- var containerBindingContext = ko.contextFor(container[0]);
- var bindingContext = containerBindingContext ? containerBindingContext.createChildContext(data) : data;
- var renderBag = $("<div />").appendTo(container);
- ko.renderTemplate(this._template.get(0), bindingContext, null, renderBag.get(0));
- var result = renderBag.contents();
- container.append(result);
- renderBag.remove();
- return result
- },
- dispose: function() {
- this.callBase();
- this._template.remove()
- }
- });
- var KoTemplateProvider = ui.TemplateProvider.inherit({
- getTemplateClass: function(widget) {
- return this._createdWithKo(widget) ? KoTemplate : this.callBase(widget)
- },
- supportDefaultTemplate: function(widget) {
- return this._createdWithKo(widget) ? true : this.callBase(widget)
- },
- getDefaultTemplate: function(widget) {
- if (this._createdWithKo(widget))
- return defaultKoTemplate(widget.NAME)
- },
- _createdWithKo: function(widget) {
- return !!widget._element().data(CREATED_WITH_KO_DATA_KEY)
- }
- });
- var defaultKoTemplate = function() {
- var cache = {};
- return function(widgetName) {
- if (!DEFAULT_ITEM_TEMPLATE_GENERATORS[widgetName])
- widgetName = "base";
- if (!cache[widgetName]) {
- var html = DEFAULT_ITEM_TEMPLATE_GENERATORS[widgetName](),
- markup = DX.utils.createMarkupFromString(html);
- cache[widgetName] = new KoTemplate(markup)
- }
- return cache[widgetName]
- }
- }();
- var createElementWithBindAttr = function(tagName, bindings, closeTag, additionalProperties) {
- closeTag = closeTag === undefined ? true : closeTag;
- var bindAttr = $.map(bindings, function(value, key) {
- return key + ":" + value
- }).join(",");
- additionalProperties = additionalProperties || "";
- return "<" + tagName + " data-bind=\"" + bindAttr + "\" " + additionalProperties + ">" + (closeTag ? "</" + tagName + ">" : "")
- };
- var defaultKoTemplateBasicBindings = {css: "{ 'dx-state-disabled': $data.disabled, 'dx-state-invisible': !($data.visible === undefined || ko.unwrap($data.visible)) }"};
- var DEFAULT_ITEM_TEMPLATE_GENERATORS = {base: function() {
- var template = [createElementWithBindAttr("div", defaultKoTemplateBasicBindings, false)],
- htmlBinding = createElementWithBindAttr("div", {html: "html"}),
- textBinding = createElementWithBindAttr("div", {text: "text"}),
- primitiveBinding = createElementWithBindAttr("div", {text: "String($data)"});
- template.push("<!-- ko if: $data.html && !$data.text -->", htmlBinding, "<!-- /ko -->", "<!-- ko if: !$data.html && $data.text -->", textBinding, "<!-- /ko -->", "<!-- ko ifnot: $.isPlainObject($data) -->", primitiveBinding, "<!-- /ko -->", "</div>");
- return template.join("")
- }};
- DEFAULT_ITEM_TEMPLATE_GENERATORS.dxPivotTabs = function() {
- var template = DEFAULT_ITEM_TEMPLATE_GENERATORS.base(),
- titleBinding = createElementWithBindAttr("span", {text: "title"});
- var divInnerStart = template.indexOf(">") + 1,
- divInnerFinish = template.length - 6;
- template = [template.substring(0, divInnerStart), titleBinding, template.substring(divInnerFinish, template.length)];
- return template.join("")
- };
- DEFAULT_ITEM_TEMPLATE_GENERATORS.dxPanorama = function() {
- var template = DEFAULT_ITEM_TEMPLATE_GENERATORS.base(),
- headerBinding = createElementWithBindAttr("div", {text: "header"}, true, 'class="dx-panorama-item-header"');
- var divInnerStart = template.indexOf(">") + 1;
- template = [template.substring(0, divInnerStart), "<!-- ko if: $data.header -->", headerBinding, "<!-- /ko -->", template.substring(divInnerStart, template.length)];
- return template.join("")
- };
- DEFAULT_ITEM_TEMPLATE_GENERATORS.dxList = function() {
- var template = DEFAULT_ITEM_TEMPLATE_GENERATORS.base(),
- keyBinding = createElementWithBindAttr("div", {text: "key"});
- template = [template.substring(0, template.length - 6), "<!-- ko if: $data.key -->" + keyBinding + "<!-- /ko -->", "</div>"];
- return template.join("")
- };
- DEFAULT_ITEM_TEMPLATE_GENERATORS.dxToolbar = function() {
- var template = DEFAULT_ITEM_TEMPLATE_GENERATORS.base();
- template = [template.substring(0, template.length - 6), "<!-- ko if: $data.widget -->"];
- $.each(["button", "tabs", "dropDownMenu"], function() {
- var bindingName = DX.inflector.camelize(["dx", "-", this].join("")),
- bindingObj = {};
- bindingObj[bindingName] = "$data.options";
- template.push("<!-- ko if: $data.widget === '", this, "' -->", createElementWithBindAttr("div", bindingObj), "<!-- /ko -->")
- });
- template.push("<!-- /ko -->");
- return template.join("")
- };
- DEFAULT_ITEM_TEMPLATE_GENERATORS.dxGallery = function() {
- var template = DEFAULT_ITEM_TEMPLATE_GENERATORS.base(),
- primitiveBinding = createElementWithBindAttr("div", {text: "String($data)"}),
- imgBinding = createElementWithBindAttr("img", {attr: "{ src: String($data) }"}, false);
- template = template.replace(primitiveBinding, imgBinding);
- return template
- };
- DEFAULT_ITEM_TEMPLATE_GENERATORS.dxTabs = function() {
- var template = DEFAULT_ITEM_TEMPLATE_GENERATORS.base(),
- baseTextBinding = createElementWithBindAttr("div", {text: "text"}),
- iconBinding = createElementWithBindAttr("span", {
- attr: "{ 'class': 'dx-icon-' + $data.icon }",
- css: "{ 'dx-icon': true }"
- }),
- iconSrcBinding = createElementWithBindAttr("img", {
- attr: "{ src: $data.iconSrc }",
- css: "{ 'dx-icon': true }"
- }, false),
- textBinding = "<!-- ko if: $data.icon -->" + iconBinding + "<!-- /ko -->" + "<!-- ko if: !$data.icon && $data.iconSrc -->" + iconSrcBinding + "<!-- /ko -->" + "<span class=\"dx-tab-text\" data-bind=\"text: $data.text\"></span>";
- template = template.replace("<!-- ko if: !$data.html && $data.text -->", "<!-- ko if: !$data.html && ($data.text || $data.icon || $data.iconSrc) -->").replace(baseTextBinding, textBinding);
- return template
- };
- DEFAULT_ITEM_TEMPLATE_GENERATORS.dxActionSheet = function() {
- return createElementWithBindAttr("div", {dxButton: "{ text: $data.text, clickAction: $data.clickAction, type: $data.type, disabled: !!ko.unwrap($data.disabled) }"})
- };
- DEFAULT_ITEM_TEMPLATE_GENERATORS.dxNavBar = DEFAULT_ITEM_TEMPLATE_GENERATORS.dxTabs;
- DEFAULT_ITEM_TEMPLATE_GENERATORS.dxMenu = function() {
- var template = [createElementWithBindAttr("div", defaultKoTemplateBasicBindings, false)],
- iconBinding = createElementWithBindAttr("span", {
- attr: "{ 'class': 'dx-icon-' + $data.icon }",
- css: "{ 'dx-icon': true }"
- }),
- iconSrcBinding = createElementWithBindAttr("img", {
- attr: "{ src: $data.iconSrc }",
- css: "{ 'dx-icon': true }"
- }),
- textBinding = createElementWithBindAttr("span", {
- text: "text",
- css: "{ 'dx-menu-item-text': true }"
- }),
- primitiveBinding = createElementWithBindAttr("span", {
- text: "String($data)",
- css: "{ 'dx-menu-item-text': true }"
- }),
- popout = '<span class="dx-menu-item-popout-container"><div class="dx-menu-item-popout"></div></span>';
- template.push('<div class="dx-menu-item-content">', '<!-- ko if: $data.icon -->', iconBinding, '<!-- /ko -->', '<!-- ko if: !$data.icon && $data.iconSrc -->', iconSrcBinding, '<!-- /ko -->', '<!-- ko if: $.isPlainObject($data) -->', textBinding, '<!-- /ko -->', '<!-- ko ifnot: $.isPlainObject($data) -->', primitiveBinding, '<!-- /ko -->', '<!-- ko if: $data.items -->', popout, '<!-- /ko -->', '</div>', '</div>');
- return template.join("")
- };
- DEFAULT_ITEM_TEMPLATE_GENERATORS.dxContextMenu = DEFAULT_ITEM_TEMPLATE_GENERATORS.dxMenu;
- $.extend(ui, {
- TemplateProvider: KoTemplateProvider,
- Template: KoTemplate,
- defaultTemplate: defaultKoTemplate
- });
- ui.__internals = ui.__internals || {};
- $.extend(ui.__internals, {KoTemplate: KoTemplate})
- })(jQuery, DevExpress);
- /*! Module core, file ng.templates.js */
- (function($, DX, undefined) {
- if (!DX.support.hasNg)
- return;
- var ui = DX.ui;
- var CREATED_WITH_NG_DATA_KEY = "dxNgCreation",
- COMPILER_DATA_KEY = "dxNgCompiler",
- DEFAULT_COMPILER_DATA_KEY = "dxDefaultCompilerGetter";
- var NgTemplate = ui.Template.inherit({
- ctor: function() {
- this.callBase.apply(this, arguments);
- this._compiler = this._template.data(COMPILER_DATA_KEY)
- },
- render: function(container, data, index) {
- var compiler = this._compiler,
- result = $.isFunction(compiler) ? compiler(data, index) : compiler;
- container.append(result);
- return result
- },
- setCompiler: function(compilerGetter) {
- this._compiler = compilerGetter(this._element)
- }
- });
- var NgTemplateProvider = ui.TemplateProvider.inherit({
- getTemplateClass: function(widget) {
- if (this._createdWithNg(widget))
- return NgTemplate;
- return this.callBase(widget)
- },
- supportDefaultTemplate: function(widget) {
- return this._createdWithNg(widget) ? true : this.callBase(widget)
- },
- getDefaultTemplate: function(widget) {
- if (this._createdWithNg(widget)) {
- var compilerGetter = widget._element().data(DEFAULT_COMPILER_DATA_KEY),
- template = defaultNgTemplate(widget.NAME);
- template.setCompiler(compilerGetter);
- return template
- }
- },
- _createdWithNg: function(widget) {
- return !!widget._element().data(CREATED_WITH_NG_DATA_KEY)
- }
- });
- var defaultNgTemplate = function() {
- var cache = {};
- return function(widgetName) {
- if (!DEFAULT_ITEM_TEMPLATE_GENERATORS[widgetName])
- widgetName = "base";
- if (!cache[widgetName])
- cache[widgetName] = DEFAULT_ITEM_TEMPLATE_GENERATORS[widgetName]();
- return new NgTemplate(cache[widgetName])
- }
- }();
- var baseElements = {
- container: function() {
- return $("<div>").attr("ng-class", "{ 'dx-state-invisible': !visible && visible != undefined, 'dx-state-disabled': !!disabled }")
- },
- html: function() {
- return $("<div>").attr("ng-if", "html").attr("ng-bind-html", "html")
- },
- text: function() {
- return $("<div>").attr("ng-if", "text").attr("ng-bind", "text")
- },
- primitive: function() {
- return $("<div>").attr("ng-if", "scopeValue").attr("ng-bind-html", "'' + scopeValue")
- }
- };
- var DEFAULT_ITEM_TEMPLATE_GENERATORS = {base: function() {
- return baseElements.container().append(baseElements.html()).append(baseElements.text()).append(baseElements.primitive())
- }};
- DEFAULT_ITEM_TEMPLATE_GENERATORS.dxList = function() {
- return DEFAULT_ITEM_TEMPLATE_GENERATORS.base().append($("<div>").attr("ng-if", "key").attr("ng-bind", "key"))
- };
- DEFAULT_ITEM_TEMPLATE_GENERATORS.dxToolbar = function() {
- var template = DEFAULT_ITEM_TEMPLATE_GENERATORS.base();
- $.each(["button", "tabs", "dropDownMenu"], function(i, widgetName) {
- var bindingName = "dx-" + DX.inflector.dasherize(this);
- $("<div>").attr("ng-if", "widget === '" + widgetName + "'").attr(bindingName, "options").appendTo(template)
- });
- return template
- };
- DEFAULT_ITEM_TEMPLATE_GENERATORS.dxGallery = function() {
- return baseElements.container().append(baseElements.html()).append(baseElements.text()).append($("<img>").attr("ng-if", "scopeValue").attr("ng-src", "{{'' + scopeValue}}"))
- };
- DEFAULT_ITEM_TEMPLATE_GENERATORS.dxTabs = function() {
- var container = baseElements.container();
- var text = $("<span>").addClass("dx-tab-text").attr("ng-bind", "text").attr("ng-if", "text"),
- icon = $("<span>").attr("ng-if", "icon").addClass("dx-icon").attr("ng-class", "'dx-icon-' + icon"),
- iconSrc = $("<img>").attr("ng-if", "iconSrc").addClass("dx-icon").attr("ng-src", "{{iconSrc}}");
- return container.append(baseElements.html()).append(icon).append(iconSrc).append(text).append(baseElements.primitive())
- };
- DEFAULT_ITEM_TEMPLATE_GENERATORS.dxMenu = function() {
- var container = baseElements.container();
- var content = $("<div>").addClass("dx-menu-item-content"),
- text = $("<span>").attr("ng-if", "text").addClass("dx-menu-item-text").attr("ng-bind", "text"),
- icon = $("<span>").attr("ng-if", "icon").addClass("dx-icon").attr("ng-class", "'dx-icon-' + icon"),
- iconSrc = $("<img>").attr("ng-if", "iconSrc").addClass("dx-icon").attr("ng-src", "{{iconSrc}}"),
- popout = $("<span>").addClass("dx-menu-item-popout-container").attr("ng-if", "items").append($("<div>").addClass("dx-menu-item-popout"));
- content.append(baseElements.html()).append(icon).append(iconSrc).append(text).append(popout).append(baseElements.primitive()).appendTo(container);
- return container
- },
- DEFAULT_ITEM_TEMPLATE_GENERATORS.dxActionSheet = function() {
- return $("<div>").attr("dx-button", "{ bindingOptions: { text: 'text', clickAction: 'clickAction', type: 'type', disabled: 'disabled' } }")
- };
- DEFAULT_ITEM_TEMPLATE_GENERATORS.dxNavBar = DEFAULT_ITEM_TEMPLATE_GENERATORS.dxTabs;
- $.extend(ui, {
- Template: NgTemplate,
- TemplateProvider: NgTemplateProvider
- })
- })(jQuery, DevExpress);
- /*! Module core, file ui.themes.js */
- (function($, DX, undefined) {
- var DX_LINK_SELECTOR = "link[rel=dx-theme]",
- THEME_ATTR = "data-theme",
- ACTIVE_ATTR = "data-active";
- var context,
- $activeThemeLink,
- knownThemes,
- currentThemeName,
- pendingThemeName;
- var THEME_MARKER_PREFIX = "dx.";
- function readThemeMarker() {
- var element = $("<div></div>", context).addClass("dx-theme-marker").appendTo(context.documentElement),
- result;
- try {
- result = element.css("font-family");
- if (!result)
- return null;
- result = result.replace(/["']/g, "");
- if (result.substr(0, THEME_MARKER_PREFIX.length) !== THEME_MARKER_PREFIX)
- return null;
- return result.substr(THEME_MARKER_PREFIX.length)
- }
- finally {
- element.remove()
- }
- }
- function waitForThemeLoad(themeName, callback) {
- var timerId,
- waitStartTime;
- pendingThemeName = themeName;
- function handleLoaded() {
- pendingThemeName = null;
- callback()
- }
- if (isPendingThemeLoaded())
- handleLoaded();
- else {
- waitStartTime = $.now();
- timerId = setInterval(function() {
- var isLoaded = isPendingThemeLoaded(),
- isTimeout = !isLoaded && $.now() - waitStartTime > 15 * 1000;
- if (isTimeout)
- DX.utils.logger.warn("Theme loading timed out: " + pendingThemeName);
- if (isLoaded || isTimeout) {
- clearInterval(timerId);
- handleLoaded()
- }
- }, 10)
- }
- }
- function isPendingThemeLoaded() {
- return !pendingThemeName || readThemeMarker() === pendingThemeName
- }
- function processMarkup() {
- var $allThemeLinks = $(DX_LINK_SELECTOR, context);
- if (!$allThemeLinks.length)
- return;
- knownThemes = {};
- $activeThemeLink = $(DX.utils.createMarkupFromString("<link rel=stylesheet>"), context);
- $allThemeLinks.each(function() {
- var link = $(this, context),
- fullThemeName = link.attr(THEME_ATTR),
- url = link.attr("href"),
- isActive = link.attr(ACTIVE_ATTR) === "true";
- knownThemes[fullThemeName] = {
- url: url,
- isActive: isActive
- }
- });
- $allThemeLinks.last().after($activeThemeLink);
- $allThemeLinks.remove()
- }
- function resolveFullThemeName(desiredThemeName) {
- var desiredThemeParts = desiredThemeName.split("."),
- result = null;
- if (knownThemes)
- $.each(knownThemes, function(knownThemeName, themeData) {
- var knownThemeParts = knownThemeName.split(".");
- if (knownThemeParts[0] !== desiredThemeParts[0])
- return;
- if (desiredThemeParts[1] && desiredThemeParts[1] !== knownThemeParts[1])
- return;
- if (!result || themeData.isActive)
- result = knownThemeName;
- if (themeData.isActive)
- return false
- });
- return result
- }
- function initContext(newContext) {
- try {
- if (newContext !== context)
- knownThemes = null
- }
- catch(x) {
- knownThemes = null
- }
- context = newContext
- }
- function init(options) {
- options = options || {};
- initContext(options.context || document);
- processMarkup();
- currentThemeName = undefined;
- current(options)
- }
- function current(options) {
- if (!arguments.length)
- return currentThemeName || readThemeMarker();
- options = options || {};
- if (typeof options === "string")
- options = {theme: options};
- var isAutoInit = options._autoInit,
- loadCallback = options.loadCallback,
- currentThemeData;
- currentThemeName = options.theme || currentThemeName;
- if (isAutoInit && !currentThemeName)
- currentThemeName = themeNameFromDevice(DX.devices.current());
- currentThemeName = resolveFullThemeName(currentThemeName);
- if (currentThemeName)
- currentThemeData = knownThemes[currentThemeName];
- if (currentThemeData) {
- $activeThemeLink.removeAttr("href");
- $activeThemeLink.attr("href", knownThemes[currentThemeName].url);
- if (loadCallback)
- waitForThemeLoad(currentThemeName, loadCallback);
- else if (pendingThemeName)
- pendingThemeName = currentThemeName
- }
- else if (isAutoInit) {
- if (loadCallback)
- loadCallback()
- }
- else
- throw Error("Unknown theme: " + currentThemeName);
- }
- function themeNameFromDevice(device) {
- var themeName = device.platform,
- majorVersion = device.version && device.version[0];
- if (themeName === "ios" && (!majorVersion || majorVersion > 6))
- themeName += "7";
- return themeName
- }
- function getCssClasses(themeName) {
- themeName = themeName || current();
- var result = [],
- themeNameParts = themeName && themeName.split(".");
- if (themeNameParts) {
- result.push("dx-theme-" + themeNameParts[0], "dx-theme-" + themeNameParts[0] + "-typography");
- if (themeNameParts.length > 1)
- result.push("dx-color-scheme-" + themeNameParts[1])
- }
- return result
- }
- function attachCssClasses(element, themeName) {
- $(element).addClass(getCssClasses(themeName).join(" "))
- }
- function detachCssClasses(element, themeName) {
- $(element).removeClass(getCssClasses(themeName).join(" "))
- }
- $.holdReady(true);
- init({
- _autoInit: true,
- loadCallback: function() {
- $.holdReady(false)
- }
- });
- $(function() {
- if ($(DX_LINK_SELECTOR, context).length)
- throw Error("LINK[rel=dx-theme] tags must go before DevExpress included scripts");
- });
- DX.ui.themes = {
- init: init,
- current: current,
- attachCssClasses: attachCssClasses,
- detachCssClasses: detachCssClasses
- };
- DX.ui.themes.__internals = {
- themeNameFromDevice: themeNameFromDevice,
- waitForThemeLoad: waitForThemeLoad,
- resetTheme: function() {
- $activeThemeLink.attr("href", "about:blank");
- currentThemeName = null;
- pendingThemeName = null
- }
- }
- })(jQuery, DevExpress);
- /*! Module core, file ui.events.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- eventNS = $.event,
- specialNS = eventNS.special,
- EVENT_SOURCES_REGEX = {
- mouse: /(mouse|wheel|click)/i,
- wheel: /wheel/i,
- touch: /^touch/i,
- keyboard: /^key/i,
- pointer: /pointer/i
- };
- var eventSource = function(e) {
- var result = "other";
- $.each(EVENT_SOURCES_REGEX, function(key) {
- if (this.test(e.type)) {
- result = key;
- return false
- }
- });
- return result
- };
- var isPointerEvent = function(e) {
- return eventSource(e) === "pointer"
- };
- var isMouseEvent = function(e) {
- return eventSource(e) === "mouse" || isPointerEvent(e) && e.pointerType === "mouse"
- };
- var isTouchEvent = function(e) {
- return eventSource(e) === "touch" || isPointerEvent(e) && e.pointerType === "touch"
- };
- var isKeyboardEvent = function(e) {
- return eventSource(e) === "keyboard"
- };
- var isMouseWheelEvent = function(e) {
- return EVENT_SOURCES_REGEX["wheel"].test(e.type)
- };
- var addNamespace = function(eventNames, namespace) {
- if (!namespace)
- throw Error("Namespace is not defined");
- if (typeof eventNames === "string")
- return addNamespace(eventNames.split(/\s+/g), namespace);
- $.each(eventNames, function(index, eventName) {
- eventNames[index] = eventName + "." + namespace
- });
- return eventNames.join(" ")
- };
- var eventData = function(e) {
- if (isPointerEvent(e) && isTouchEvent(e)) {
- var touch = (e.originalEvent.originalEvent || e.originalEvent).changedTouches[0];
- return {
- x: touch.pageX,
- y: touch.pageY,
- time: e.timeStamp
- }
- }
- if (isMouseEvent(e))
- return {
- x: e.pageX,
- y: e.pageY,
- time: e.timeStamp
- };
- if (isTouchEvent(e)) {
- var touch = (e.changedTouches || e.originalEvent.changedTouches)[0];
- return {
- x: touch.pageX,
- y: touch.pageY,
- time: e.timeStamp
- }
- }
- };
- var eventDelta = function(from, to) {
- return {
- x: to.x - from.x,
- y: to.y - from.y,
- time: to.time - from.time || 1
- }
- };
- var hasTouches = function(e) {
- if (isTouchEvent(e))
- return (e.originalEvent.touches || []).length;
- return 0
- };
- var needSkipEvent = function(e) {
- var $target = $(e.target),
- touchInInput = $target.is("input, textarea, select");
- if (isMouseWheelEvent(e) && touchInInput)
- return false;
- if (isMouseEvent(e))
- return touchInInput || e.which > 1;
- if (isTouchEvent(e))
- return touchInInput && $target.is(":focus") || (e.originalEvent.changedTouches || e.originalEvent.originalEvent.changedTouches).length !== 1
- };
- var createEvent = function(sourceEvent, props) {
- var event = $.Event(sourceEvent),
- originalEvent = event.originalEvent,
- propNames = $.event.props.slice();
- if (isMouseEvent(sourceEvent) || isTouchEvent(sourceEvent))
- $.merge(propNames, $.event.mouseHooks.props);
- if (isKeyboardEvent(sourceEvent))
- $.merge(propNames, $.event.keyHooks.props);
- if (originalEvent)
- $.each(propNames, function() {
- event[this] = originalEvent[this]
- });
- if (props)
- $.extend(event, props);
- return event
- };
- var fireEvent = function(props) {
- var event = createEvent(props.originalEvent, props);
- $.event.trigger(event, null, props.target || event.target);
- return event
- };
- var handleGestureEvent = function(e, type) {
- var gestureEvent = $(e.target).data("dxGestureEvent");
- if (!gestureEvent || gestureEvent === type) {
- $(e.target).data("dxGestureEvent", type);
- return true
- }
- return false
- };
- var registerEvent = function(eventName, eventObject) {
- var strategy = {};
- if ("noBubble" in eventObject)
- strategy.noBubble = eventObject.noBubble;
- if ("bindType" in eventObject)
- strategy.bindType = eventObject.bindType;
- if ("delegateType" in eventObject)
- strategy.delegateType = eventObject.delegateType;
- $.each(["setup", "teardown", "add", "remove", "trigger", "handle", "_default", "dispose"], function(_, methodName) {
- if (!eventObject[methodName])
- return;
- strategy[methodName] = function() {
- var args = $.makeArray(arguments);
- args.unshift(this);
- return eventObject[methodName].apply(eventObject, args)
- }
- });
- specialNS[eventName] = strategy
- };
- ui.events = {
- eventSource: eventSource,
- isPointerEvent: isPointerEvent,
- isMouseEvent: isMouseEvent,
- isTouchEvent: isTouchEvent,
- isKeyboardEvent: isKeyboardEvent,
- addNamespace: addNamespace,
- hasTouches: hasTouches,
- eventData: eventData,
- eventDelta: eventDelta,
- needSkipEvent: needSkipEvent,
- createEvent: createEvent,
- fireEvent: fireEvent,
- handleGestureEvent: handleGestureEvent,
- registerEvent: registerEvent
- }
- })(jQuery, DevExpress);
- /*! Module core, file ko.events.js */
- (function($, DX, undefined) {
- if (!DX.support.hasKo)
- return;
- var ko = window.ko,
- events = DX.ui.events;
- var originalRegisterEvent = events.registerEvent;
- var registerKoEvent = function(eventName, eventObject) {
- originalRegisterEvent(eventName, eventObject);
- var koBindingEventName = events.addNamespace(eventName, eventName + "Binding");
- ko.bindingHandlers[eventName] = {update: function(element, valueAccessor, allBindingsAccessor, viewModel) {
- var $element = $(element),
- unwrappedValue = ko.utils.unwrapObservable(valueAccessor()),
- eventSource = unwrappedValue.execute ? unwrappedValue.execute : unwrappedValue;
- $element.off(koBindingEventName).on(koBindingEventName, $.isPlainObject(unwrappedValue) ? unwrappedValue : {}, function(e) {
- eventSource(viewModel, e)
- })
- }}
- };
- $.extend(events, {registerEvent: registerKoEvent})
- })(jQuery, DevExpress);
- /*! Module core, file ng.events.js */
- (function($, DX, undefined) {
- if (!DX.support.hasNg)
- return;
- var events = DX.ui.events;
- var originalRegisterEvent = events.registerEvent;
- var registerNgEvent = function(eventName, eventObject) {
- originalRegisterEvent(eventName, eventObject);
- var ngEventName = eventName.slice(0, 2) + eventName.charAt(2).toUpperCase() + eventName.slice(3);
- DX.ng.module.directive(ngEventName, ['$parse', function($parse) {
- return function(scope, element, attr) {
- var attrValue = $.trim(attr[ngEventName]),
- handler,
- eventOptions = {};
- if (attrValue.charAt(0) === "{") {
- eventOptions = scope.$eval(attrValue);
- handler = $parse(eventOptions.execute)
- }
- else
- handler = $parse(attr[ngEventName]);
- element.on(eventName, eventOptions, function(e) {
- scope.$apply(function() {
- handler(scope, {$event: e})
- })
- })
- }
- }])
- };
- $.extend(events, {registerEvent: registerNgEvent})
- })(jQuery, DevExpress);
- /*! Module core, file ui.hierarchicalKeyDownProcessor.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- events = ui.events;
- ui.HierarchicalKeyDownProcessor = DX.Class.inherit({
- _keydown: events.addNamespace("keydown", "HierarchicalKeyDownProcessor"),
- codes: {
- "9": "tab",
- "13": "enter",
- "27": "escape",
- "33": "pageUp",
- "34": "pageDown",
- "37": "leftArrow",
- "38": "upArrow",
- "39": "rightArrow",
- "40": "downArrow",
- "32": "space",
- "70": "F",
- "65": "A"
- },
- ctor: function(options) {
- var _this = this;
- options = options || {};
- if (options.element)
- this._element = $(options.element);
- this._handler = options.handler;
- this._context = options.context;
- this._childProcessors = [];
- if (this._element)
- this._element.on(this._keydown, function(e) {
- _this.process(e)
- })
- },
- dispose: function() {
- if (this._element)
- this._element.off(this._keydown);
- this._element = undefined;
- this._handler = undefined;
- this._context = undefined;
- this._childProcessors = undefined
- },
- attachChildProcessor: function() {
- var childProcessor = new ui.HierarchicalKeyDownProcessor;
- this._childProcessors.push(childProcessor);
- return childProcessor
- },
- reinitialize: function(childHandler, childContext) {
- this._context = childContext;
- this._handler = childHandler;
- return this
- },
- process: function(e) {
- var args = {
- key: this.codes[e.which],
- ctrl: e.ctrlKey,
- shift: e.shiftKey,
- originalEvent: e
- };
- if (this.codes[e.which] && this._handler && this._handler.call(this._context, args))
- $.each(this._childProcessors, function(index, childProcessor) {
- childProcessor.process(e)
- })
- }
- })
- })(jQuery, DevExpress);
- /*! Module core, file ui.dialog.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- utils = DX.utils;
- var DEFAULT_BUTTON = {
- text: "OK",
- clickAction: function() {
- return true
- }
- };
- var DX_DIALOG_CLASSNAME = "dx-dialog",
- DX_DIALOG_WRAPPER_CLASSNAME = DX_DIALOG_CLASSNAME + "-wrapper",
- DX_DIALOG_ROOT_CLASSNAME = DX_DIALOG_CLASSNAME + "-root",
- DX_DIALOG_CONTENT_CLASSNAME = DX_DIALOG_CLASSNAME + "-content",
- DX_DIALOG_MESSAGE_CLASSNAME = DX_DIALOG_CLASSNAME + "-message",
- DX_DIALOG_BUTTONS_CLASSNAME = DX_DIALOG_CLASSNAME + "-buttons",
- DX_DIALOG_BUTTON_CLASSNAME = DX_DIALOG_CLASSNAME + "-button";
- var FakeDialogComponent = DX.Component.inherit({
- NAME: "dxDialog",
- ctor: function(element, options) {
- this.callBase(options)
- },
- _defaultOptionsRules: function() {
- return this.callBase().slice(0).concat([{
- device: [{platform: "ios"}, {platform: "ios7"}],
- options: {width: 276}
- }, {
- device: {platform: "android"},
- options: {
- lWidth: "60%",
- pWidth: "80%"
- }
- }, {
- device: {
- platform: "win8",
- phone: false
- },
- options: {width: function() {
- return $(window).width()
- }}
- }, {
- device: {
- platform: "win8",
- phone: true
- },
- options: {position: {
- my: "top center",
- at: "top center",
- of: window,
- offset: "0 0"
- }}
- }])
- }
- });
- var dialog = function(options) {
- var that = this,
- result;
- if (!ui.dxPopup)
- throw new Error("DevExpress.ui.dxPopup required");
- var deferred = $.Deferred();
- var defaultOptions = (new FakeDialogComponent).option();
- options = $.extend(defaultOptions, options);
- var $holder = $(DX.overlayTargetContainer());
- var $element = $("<div>").addClass(DX_DIALOG_CLASSNAME).appendTo($holder);
- var $message = $("<div>").addClass(DX_DIALOG_MESSAGE_CLASSNAME).html(String(options.message));
- var $buttons = $("<div>").addClass(DX_DIALOG_BUTTONS_CLASSNAME);
- var popupInstance = $element.dxPopup({
- title: options.title || that.title,
- height: "auto",
- width: function() {
- var isPortrait = $(window).height() > $(window).width(),
- key = (isPortrait ? "p" : "l") + "Width",
- widthOption = options.hasOwnProperty(key) ? options[key] : options["width"];
- return $.isFunction(widthOption) ? widthOption() : widthOption
- },
- contentReadyAction: function() {
- popupInstance.content().addClass(DX_DIALOG_CONTENT_CLASSNAME).append($message).append($buttons)
- },
- animation: {
- show: {
- type: "pop",
- duration: 400
- },
- hide: {
- type: "pop",
- duration: 400,
- to: {
- opacity: 0,
- scale: 0
- },
- from: {
- opacity: 1,
- scale: 1
- }
- }
- },
- rtlEnabled: DX.rtlEnabled
- }).data("dxPopup");
- popupInstance._wrapper().addClass(DX_DIALOG_WRAPPER_CLASSNAME);
- if (options.position)
- popupInstance.option("position", options.position);
- $.each(options.buttons || [DEFAULT_BUTTON], function() {
- var button = $("<div>").addClass(DX_DIALOG_BUTTON_CLASSNAME).appendTo($buttons);
- var action = new DX.Action(this.clickAction, {context: popupInstance});
- button.dxButton($.extend(this, {clickAction: function() {
- result = action.execute(arguments);
- hide()
- }}))
- });
- popupInstance._wrapper().addClass(DX_DIALOG_ROOT_CLASSNAME);
- function show() {
- popupInstance.show();
- utils.resetActiveElement();
- return deferred.promise()
- }
- function hide(value) {
- popupInstance.hide().done(function() {
- popupInstance._element().remove()
- });
- deferred.resolve(result || value)
- }
- return {
- show: show,
- hide: hide
- }
- };
- var alert = function(message, title) {
- var dialogInstance,
- options = $.isPlainObject(message) ? message : {
- title: title,
- message: message
- };
- dialogInstance = ui.dialog.custom(options);
- return dialogInstance.show()
- };
- var confirm = function(message, title) {
- var dialogInstance,
- options = $.isPlainObject(message) ? message : {
- title: title,
- message: message,
- buttons: [{
- text: Globalize.localize("Yes"),
- clickAction: function() {
- return true
- }
- }, {
- text: Globalize.localize("No"),
- clickAction: function() {
- return false
- }
- }]
- };
- dialogInstance = ui.dialog.custom(options);
- return dialogInstance.show()
- };
- var notify = function(message, type, displayTime) {
- var options = $.isPlainObject(message) ? message : {message: message};
- if (!ui.dxToast) {
- alert(options.message);
- return
- }
- var userHiddenAction = options.hiddenAction;
- $.extend(options, {
- type: type,
- displayTime: displayTime,
- hiddenAction: function(args) {
- args.element.remove();
- new DX.Action(userHiddenAction, {context: args.model}).execute(arguments)
- }
- });
- $("<div>").appendTo(DX.overlayTargetContainer()).dxToast(options).dxToast("instance").show()
- };
- $.extend(ui, {
- notify: notify,
- dialog: {
- custom: dialog,
- alert: alert,
- confirm: confirm,
- FakeDialogComponent: FakeDialogComponent
- }
- })
- })(jQuery, DevExpress);
- /*! Module core, file ui.dataHelper.js */
- (function($, DX, undefined) {
- var data = DX.data;
- var DATA_SOURCE_OPTIONS_METHOD = "_dataSourceOptions",
- DATA_SOURCE_CHANGED_METHOD = "_handleDataSourceChanged",
- DATA_SOURCE_LOAD_ERROR_METHOD = "_handleDataSourceLoadError",
- DATA_SOURCE_LOADING_CHANGED_METHOD = "_handleDataSourceLoadingChanged";
- DX.ui.DataHelperMixin = {
- ctor: function() {
- this.disposing.add(function() {
- this._disposeDataSource()
- })
- },
- _refreshDataSource: function() {
- this._initDataSource();
- this._loadDataSource()
- },
- _initDataSource: function() {
- var dataSourceOptions = this.option("dataSource"),
- widgetDataSourceOptions,
- dataSourceType;
- this._disposeDataSource();
- if (dataSourceOptions) {
- if (dataSourceOptions instanceof data.DataSource) {
- this._isSharedDataSource = true;
- this._dataSource = dataSourceOptions
- }
- else {
- widgetDataSourceOptions = DATA_SOURCE_OPTIONS_METHOD in this ? this[DATA_SOURCE_OPTIONS_METHOD]() : {};
- dataSourceType = this._dataSourceType ? this._dataSourceType() : data.DataSource;
- this._dataSource = new dataSourceType($.extend(true, {}, widgetDataSourceOptions, data.utils.normalizeDataSourceOptions(dataSourceOptions)))
- }
- this._addDataSourceHandlers()
- }
- },
- _addDataSourceHandlers: function() {
- if (DATA_SOURCE_CHANGED_METHOD in this)
- this._addDataSourceChangeHandler();
- if (DATA_SOURCE_LOAD_ERROR_METHOD in this)
- this._addDataSourceLoadErrorHandler();
- if (DATA_SOURCE_LOADING_CHANGED_METHOD in this)
- this._addDataSourceLoadingChangedHandler()
- },
- _addDataSourceChangeHandler: function() {
- var that = this,
- dataSource = this._dataSource;
- this._dataSourceChangedHandler = function() {
- that[DATA_SOURCE_CHANGED_METHOD](dataSource.items())
- };
- dataSource.changed.add(this._dataSourceChangedHandler)
- },
- _addDataSourceLoadErrorHandler: function() {
- this._dataSourceLoadErrorHandler = $.proxy(this[DATA_SOURCE_LOAD_ERROR_METHOD], this);
- this._dataSource.loadError.add(this._dataSourceLoadErrorHandler)
- },
- _addDataSourceLoadingChangedHandler: function() {
- this._dataSourceLoadingChangedHandler = $.proxy(this[DATA_SOURCE_LOADING_CHANGED_METHOD], this);
- this._dataSource.loadingChanged.add(this._dataSourceLoadingChangedHandler)
- },
- _loadDataSource: function() {
- if (this._dataSource) {
- var dataSource = this._dataSource;
- if (dataSource.isLoaded())
- this._dataSourceChangedHandler();
- else
- dataSource.load()
- }
- },
- _loadSingle: function(key, value) {
- key = key === "this" ? this._dataSource.key() || "this" : key;
- return this._dataSource.loadSingle(key, value)
- },
- _disposeDataSource: function() {
- if (this._dataSource) {
- if (this._isSharedDataSource) {
- delete this._isSharedDataSource;
- this._dataSource.changed.remove(this._dataSourceChangedHandler);
- this._dataSource.loadError.remove(this._dataSourceLoadErrorHandler);
- this._dataSource.loadingChanged.remove(this._dataSourceLoadingChangedHandler)
- }
- else
- this._dataSource.dispose();
- delete this._dataSource;
- delete this._dataSourceChangedHandler;
- delete this._dataSourceLoadErrorHandler;
- delete this._dataSourceLoadingChangedHandler
- }
- }
- }
- })(jQuery, DevExpress);
- /*! Module core, file ui.events.mspointer.js */
- (function($, DX, undefined) {
- var POINTER_TYPE_MAP = {
- 2: "touch",
- 3: "pen",
- 4: "mouse"
- };
- var pointerEventHook = {
- filter: function(event, originalEvent) {
- var pointerType = originalEvent.pointerType;
- if ($.isNumeric(pointerType))
- event.pointerType = POINTER_TYPE_MAP[pointerType];
- return event
- },
- props: $.event.mouseHooks.props.concat(["pointerId", "originalTarget", "namespace", "width", "height", "pressure", "result", "tiltX", "charCode", "tiltY", "detail", "isPrimary", "prevValue"])
- };
- $.each(["MSPointerDown", "MSPointerMove", "MSPointerUp", "MSPointerCancel", "MSPointerOver", "MSPointerOut", "MSPointerEnter", "MSPointerLeave", "pointerdown", "pointermove", "pointerup", "pointercancel", "pointerover", "pointerout", "pointerenter", "pointerleave"], function() {
- $.event.fixHooks[this] = pointerEventHook
- })
- })(jQuery, DevExpress);
- /*! Module core, file ui.events.touch.js */
- (function($, DX, undefined) {
- var touchEventHook = {
- filter: function(event, originalEvent) {
- if (originalEvent.changedTouches.length)
- $.each(["pageX", "pageY", "screenX", "screenY", "clientX", "clientY"], function() {
- event[this] = originalEvent.changedTouches[0][this]
- });
- return event
- },
- props: $.event.mouseHooks.props.concat(["touches", "changedTouches", "targetTouches", "detail", "result", "namespace", "originalTarget", "charCode", "prevValue"])
- };
- $.each(["touchstart", "touchmove", "touchend", "touchcancel"], function() {
- $.event.fixHooks[this] = touchEventHook
- })
- })(jQuery, DevExpress);
- /*! Module core, file ui.events.pointer.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- support = DX.support,
- device = $.proxy(DX.devices.real, DX.devices),
- events = ui.events;
- var POINTER_EVENTS_NAMESPACE = "dxPointerEvents",
- MouseStrategyEventMap = {
- dxpointerdown: "mousedown",
- dxpointermove: "mousemove",
- dxpointerup: "mouseup",
- dxpointercancel: ""
- },
- TouchStrategyEventMap = {
- dxpointerdown: "touchstart",
- dxpointermove: "touchmove",
- dxpointerup: "touchend",
- dxpointercancel: "touchcancel"
- },
- PointerStrategyEventMap = {
- dxpointerdown: "pointerdown",
- dxpointermove: "pointermove",
- dxpointerup: "pointerup",
- dxpointercancel: "pointercancel"
- },
- MouseAndTouchStrategyEventMap = {
- dxpointerdown: "touchstart mousedown",
- dxpointermove: "touchmove mousemove",
- dxpointerup: "touchend mouseup",
- dxpointercancel: "touchcancel"
- };
- var eventMap = function() {
- if (support.touch && !(device().tablet || device().phone))
- return MouseAndTouchStrategyEventMap;
- if (support.pointer)
- return MouseStrategyEventMap;
- if (support.touch)
- return TouchStrategyEventMap;
- return MouseStrategyEventMap
- }();
- var skipTouchWithSameIdentifier = function(pointerEvent) {
- return device().platform === "ios" && (pointerEvent === "dxpointerdown" || pointerEvent === "dxpointerup")
- };
- var SingleEventStrategy = DX.Class.inherit({
- ctor: function(eventName, originalEvents) {
- this._eventName = eventName;
- this._eventNamespace = [POINTER_EVENTS_NAMESPACE, ".", this._eventName].join("");
- this._originalEvents = originalEvents;
- this._pointerId = 0;
- this._handlerCount = 0
- },
- _handler: function(e) {
- if (this._eventName === "dxpointerdown")
- $(e.target).data("dxGestureEvent", null);
- if (events.isTouchEvent(e) && skipTouchWithSameIdentifier(this._eventName)) {
- var touch = e.changedTouches[0];
- if (this._pointerId === touch.identifier && this._pointerId !== 0)
- return;
- this._pointerId = touch.identifier
- }
- return events.fireEvent({
- type: this._eventName,
- pointerType: events.eventSource(e),
- originalEvent: e
- })
- },
- setup: function() {
- if (this._handlerCount > 0)
- return;
- $(document).on(events.addNamespace(this._originalEvents, this._eventNamespace), $.proxy(this._handler, this))
- },
- add: function() {
- this._handlerCount++
- },
- remove: function() {
- this._handlerCount--
- },
- teardown: function() {
- if (this._handlerCount)
- return;
- $(document).off("." + this._eventNamespace)
- },
- dispose: function() {
- $(document).off("." + this._eventNamespace)
- }
- });
- var MultiEventStrategy = SingleEventStrategy.inherit({
- EVENT_LOCK_TIMEOUT: 100,
- _handler: function(e) {
- if (events.isTouchEvent(e))
- this._skipNextEvents = true;
- if (events.isMouseEvent(e) && this._mouseLocked)
- return;
- if (events.isMouseEvent(e) && this._skipNextEvents) {
- this._skipNextEvents = false;
- this._mouseLocked = true;
- clearTimeout(this._unlockMouseTimer);
- this._unlockMouseTimer = setTimeout($.proxy(function() {
- this._mouseLocked = false
- }, this), this.EVENT_LOCK_TIMEOUT);
- return
- }
- return this.callBase(e)
- },
- dispose: function() {
- this.callBase();
- this._skipNextEvents = false;
- this._mouseLocked = false;
- clearTimeout(this._unlockMouseTimer)
- }
- });
- var getStrategy = function() {
- return eventMap === MouseAndTouchStrategyEventMap ? MultiEventStrategy : SingleEventStrategy
- };
- $.each(eventMap, function(pointerEvent, originalEvents) {
- var Strategy = getStrategy();
- events.registerEvent(pointerEvent, new Strategy(pointerEvent, originalEvents))
- });
- DX.ui.events.__internals = DX.ui.events.__internals || {};
- $.extend(DX.ui.events.__internals, {
- SingleEventStrategy: SingleEventStrategy,
- MultiEventStrategy: MultiEventStrategy,
- MouseStrategyEventMap: MouseStrategyEventMap,
- TouchStrategyEventMap: TouchStrategyEventMap,
- PointerStrategyEventMap: PointerStrategyEventMap,
- MouseAndTouchStrategyEventMap: MouseAndTouchStrategyEventMap,
- eventMap: eventMap
- })
- })(jQuery, DevExpress);
- /*! Module core, file ui.events.click.js */
- (function($, DX, wnd, undefined) {
- var ua = navigator.userAgent,
- screen = wnd.screen,
- ui = DX.ui,
- utils = DX.utils,
- events = ui.events,
- support = DX.support,
- device = $.proxy(DX.devices.real, DX.devices),
- EVENTS_NAME_SPACE = "dxSpecialEvents",
- CLICK_NAME_SPACE = "dxClick" + EVENTS_NAME_SPACE,
- CLICK_EVENT_NAME = "dxclick",
- SCROLLABLE_PARENT_DATA_KEY = "dxClickScrollableParent",
- SCROLLABLE_PARENT_SCROLL_OFFSET_DATA_KEY = "dxClickScrollableParentOffset",
- preferNativeClick = function() {
- var iPhone4SAndElder = device().deviceType === "phone" && screen.height <= 480,
- iPad2AndElder = device().deviceType === "tablet" && wnd.devicePixelRatio < 2,
- IOS7AndNewer = device().platform === "ios" && device().version[0] > 6;
- return IOS7AndNewer && (iPhone4SAndElder || iPad2AndElder)
- }(),
- useNativeClick = function() {
- if (!support.touch)
- return true;
- var chromeInfo = ua.match(/Chrome\/([0-9]+)/) || [],
- chrome = !!chromeInfo[0],
- chromeVersion = ~~chromeInfo[1],
- android = device().platform === "android";
- if (chrome)
- if (android) {
- if ($("meta[name=viewport][content*='width=device-width']").length)
- return false;
- if (chromeVersion > 31 && wnd.innerWidth <= screen.width)
- return true;
- if ($("meta[name=viewport][content*='user-scalable=no']").length)
- return true
- }
- else
- return true;
- return false
- }();
- var SimulatedStrategy = DX.Class.inherit({
- TOUCH_BOUNDARY: 10,
- ctor: function() {
- this._startX = 0;
- this._startY = 0;
- this._handlerCount = 0;
- this._target = null
- },
- _touchWasMoved: function(e) {
- var boundary = this.TOUCH_BOUNDARY;
- return Math.abs(e.pageX - this._startX) > boundary || Math.abs(e.pageY - this._startY) > boundary
- },
- _getClosestScrollable: function($element) {
- var $scrollParent = $();
- if ($element.data(SCROLLABLE_PARENT_DATA_KEY))
- $scrollParent = $element.data(SCROLLABLE_PARENT_DATA_KEY);
- else {
- var $current = $element;
- while ($current.length) {
- if ($current[0].scrollHeight - $current[0].offsetHeight > 1) {
- $scrollParent = $current;
- $element.data(SCROLLABLE_PARENT_DATA_KEY, $scrollParent);
- break
- }
- $current = $current.parent()
- }
- }
- return $scrollParent
- },
- _saveClosestScrollableOffset: function($element) {
- var $scrollable = this._getClosestScrollable($element);
- if ($scrollable.length)
- $element.data(SCROLLABLE_PARENT_SCROLL_OFFSET_DATA_KEY, $scrollable.scrollTop())
- },
- _closestScrollableWasMoved: function($element) {
- var $scrollable = $element.data(SCROLLABLE_PARENT_DATA_KEY);
- return $scrollable && $scrollable.scrollTop() !== $element.data(SCROLLABLE_PARENT_SCROLL_OFFSET_DATA_KEY)
- },
- _hasClosestScrollable: function($element) {
- var $scrollable = this._getClosestScrollable($element);
- if (!$scrollable.length)
- return false;
- if ($scrollable.is("body"))
- return false;
- if ($scrollable === window)
- return false;
- if ($scrollable.css("overflow") === "hidden")
- return false;
- return true
- },
- _handleStart: function(e) {
- this._reset();
- if (events.isMouseEvent(e) && e.which !== 1)
- return;
- this._saveClosestScrollableOffset($(e.target));
- this._target = e.target;
- this._startX = e.pageX;
- this._startY = e.pageY
- },
- _handleEnd: function(e) {
- var $target = $(e.target);
- if (!$target.is(this._target) || this._touchWasMoved(e))
- return;
- if (this._nativeClickShouldBeUsed($target) || this._closestScrollableWasMoved($target))
- return;
- var targetIsInput = $target.is("input, textarea");
- if (!targetIsInput && !e.dxPreventBlur)
- utils.resetActiveElement();
- this._fireClickEvent(e)
- },
- _handleCancel: function(e) {
- this._reset()
- },
- _reset: function() {
- this._target = null
- },
- _handleClick: function(e) {
- var $target = $(e.target);
- if ($target.is(this._target)) {
- if (this._nativeClickShouldBeUsed($target))
- this._fireClickEvent(e)
- }
- else if ($target.is("input, textarea"))
- utils.resetActiveElement()
- },
- _nativeClickShouldBeUsed: function($target) {
- return preferNativeClick && this._hasClosestScrollable($target)
- },
- _fireClickEvent: function(e) {
- if (events.handleGestureEvent(e, CLICK_EVENT_NAME))
- events.fireEvent({
- type: CLICK_EVENT_NAME,
- originalEvent: e
- })
- },
- _makeElementClickable: function($element) {
- if (!$element.attr("onclick"))
- $element.attr("onclick", "void(0)")
- },
- setup: function(element) {
- var $element = $(element);
- this._makeElementClickable($element);
- if (this._handlerCount > 0)
- return;
- var $doc = $(document).on(events.addNamespace("dxpointerdown", CLICK_NAME_SPACE), $.proxy(this._handleStart, this)).on(events.addNamespace("dxpointerup", CLICK_NAME_SPACE), $.proxy(this._handleEnd, this)).on(events.addNamespace("dxpointercancel", CLICK_NAME_SPACE), $.proxy(this._handleCancel, this)).on(events.addNamespace("click", CLICK_NAME_SPACE), $.proxy(this._handleClick, this))
- },
- add: function() {
- this._handlerCount++
- },
- remove: function() {
- this._handlerCount--
- },
- teardown: function(element) {
- if (this._handlerCount)
- return;
- $(element).off("." + CLICK_NAME_SPACE);
- this.dispose()
- },
- dispose: function() {
- $(document).off("." + CLICK_NAME_SPACE)
- }
- });
- var NativeStrategy = DX.Class.inherit({
- bindType: "click",
- delegateType: "click",
- handle: function(element, event) {
- event.type = "dxclick";
- if (events.handleGestureEvent(event, CLICK_EVENT_NAME))
- return event.handleObj.handler.call(element, event)
- }
- });
- events.registerEvent(CLICK_EVENT_NAME, new(useNativeClick ? NativeStrategy : SimulatedStrategy));
- DX.ui.events.__internals = DX.ui.events.__internals || {};
- $.extend(DX.ui.events.__internals, {
- NativeClickStrategy: NativeStrategy,
- SimulatedClickStrategy: SimulatedStrategy,
- preferNativeClickAccessor: function(value) {
- if (!arguments.length)
- return preferNativeClick;
- preferNativeClick = value
- }
- })
- })(jQuery, DevExpress, window);
- /*! Module core, file ui.events.hold.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- events = ui.events,
- jqSpecialEvent = $.event.special,
- EVENTS_NAME_SPACE = "dxSpecialEvents",
- HOLD_NAME_SPACE = "dxHold",
- HOLD_EVENT_NAME = "dxhold",
- HOLD_TIMER_DATA_KEY = EVENTS_NAME_SPACE + "HoldTimer";
- var Hold = DX.Class.inherit({
- HOLD_TIMEOUT: 750,
- TOUCH_BOUNDARY: 5,
- _startX: 0,
- _startY: 0,
- _touchWasMoved: function(e) {
- var boundary = this.TOUCH_BOUNDARY;
- return Math.abs(e.pageX - this._startX) > boundary || Math.abs(e.pageY - this._startY) > boundary
- },
- setup: function(element, data) {
- var $target,
- holdInited = false;
- var handleStart = function(e) {
- if (holdInited)
- return;
- $target = $(e.target);
- holdInited = true;
- if ($target.data(HOLD_TIMER_DATA_KEY))
- return;
- this._startX = e.pageX;
- this._startY = e.pageY;
- var holdTimeout = data && "timeout" in data ? data.timeout : this.HOLD_TIMEOUT;
- var holdTimer = setTimeout(function() {
- $target.removeData(HOLD_TIMER_DATA_KEY);
- if (events.handleGestureEvent(e, HOLD_EVENT_NAME))
- events.fireEvent({
- type: HOLD_EVENT_NAME,
- originalEvent: e
- })
- }, holdTimeout);
- $target.data(HOLD_TIMER_DATA_KEY, holdTimer)
- };
- var handleMove = function(e) {
- if (!this._touchWasMoved(e))
- return;
- handleEnd()
- };
- var handleEnd = function() {
- if ($target) {
- clearTimeout($target.data(HOLD_TIMER_DATA_KEY));
- $target.removeData(HOLD_TIMER_DATA_KEY);
- $target = null;
- holdInited = false
- }
- };
- $(element).on(events.addNamespace("dxpointerdown", HOLD_NAME_SPACE), $.proxy(handleStart, this)).on(events.addNamespace("dxpointermove", HOLD_NAME_SPACE), $.proxy(handleMove, this)).on(events.addNamespace("dxpointerup", HOLD_NAME_SPACE), $.proxy(handleEnd, this))
- },
- teardown: function(element) {
- element = $(element);
- clearTimeout(element.data(HOLD_TIMER_DATA_KEY));
- element.removeData(HOLD_TIMER_DATA_KEY).off("." + HOLD_NAME_SPACE)
- }
- });
- events.registerEvent(HOLD_EVENT_NAME, new Hold)
- })(jQuery, DevExpress);
- /*! Module core, file ui.events.hover.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- events = ui.events;
- var HOVER_EVENTS_NAMESPACE = "dxSpecialEvents",
- HOVER_START = "dxhoverstart",
- HOVER_END = "dxhoverend",
- MOUSE_ENTER = "mouseenter",
- MOUSE_LEAVE = "mouseleave",
- TOUCH_START = "dxpointerdown";
- var HoverStart = DX.Class.inherit({
- ctor: function() {
- this._wasTouch = false;
- this._selector = undefined
- },
- setup: function(element, data) {
- var $element = $(element);
- this._selector = data ? data.selector : undefined;
- if (!!$element.data("dxHoverStart"))
- return;
- $element.data("dxHoverStart", true).on(events.addNamespace(MOUSE_ENTER, HOVER_EVENTS_NAMESPACE), this._selector, $.proxy(this._handleEnter, this)).on(events.addNamespace(TOUCH_START, HOVER_EVENTS_NAMESPACE), $.proxy(this._handleTouchStart, this))
- },
- _handleEnter: function(e) {
- if (!this._wasTouch)
- events.fireEvent({
- type: HOVER_START,
- originalEvent: e
- })
- },
- _handleTouchStart: function(e) {
- this._wasTouch = events.isTouchEvent(e)
- },
- teardown: function(element) {
- $(element).data("dxHoverStart", false).off(events.addNamespace(MOUSE_ENTER, HOVER_EVENTS_NAMESPACE), this._selector).off(events.addNamespace(TOUCH_START, HOVER_EVENTS_NAMESPACE))
- }
- });
- var HoverEnd = DX.Class.inherit({
- ctor: function() {
- this._wasTouch = false;
- this._selector = undefined
- },
- setup: function(element, data) {
- var $element = $(element);
- this._selector = data ? data.selector : undefined;
- if (!!$element.data("dxHoverEnd"))
- return;
- $element.data("dxHoverEnd", true).on(events.addNamespace(MOUSE_LEAVE, HOVER_EVENTS_NAMESPACE), this._selector, $.proxy(this._handleLeave, this)).on(events.addNamespace(TOUCH_START, HOVER_EVENTS_NAMESPACE), $.proxy(this._handleTouchStart, this))
- },
- _handleLeave: function(e) {
- if (!this._wasTouch)
- events.fireEvent({
- type: HOVER_END,
- originalEvent: e
- })
- },
- _handleTouchStart: function(e) {
- this._wasTouch = events.isTouchEvent(e)
- },
- teardown: function(element) {
- $(element).data("dxHoverEnd", false).off(events.addNamespace(MOUSE_LEAVE, HOVER_EVENTS_NAMESPACE), this._selector).off(events.addNamespace(TOUCH_START, HOVER_EVENTS_NAMESPACE))
- }
- });
- events.registerEvent(HOVER_START, new HoverStart);
- events.registerEvent(HOVER_END, new HoverEnd)
- })(jQuery, DevExpress);
- /*! Module core, file ui.events.wheel.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- events = ui.events;
- var EVENT_NAME = "dxmousewheel",
- EVENT_NAMESPACE = "dxWheel";
- var WHEEL_DISTANCE = 10;
- $.event.fixHooks["wheel"] = $.event.mouseHooks;
- var wheelEvent = document.onmousewheel !== undefined ? "mousewheel" : "wheel";
- var wheel = {
- setup: function(element, data) {
- var $element = $(element);
- $element.on(events.addNamespace(wheelEvent, EVENT_NAMESPACE), $.proxy(wheel._handleWheel, wheel))
- },
- teardown: function(element) {
- var $element = $(element);
- $element.off("." + EVENT_NAMESPACE)
- },
- _handleWheel: function(e) {
- $(e.target).data("dxGestureEvent", null);
- var delta = this._getWheelDelta(e.originalEvent);
- events.fireEvent({
- type: EVENT_NAME,
- originalEvent: e,
- delta: delta
- });
- e.stopPropagation()
- },
- _getWheelDelta: function(event) {
- return event.wheelDelta / 60 || -event.deltaY
- }
- };
- events.registerEvent(EVENT_NAME, wheel)
- })(jQuery, DevExpress);
- /*! Module core, file ui.gestureEmitter.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- events = ui.events;
- var GestureEmitter = DX.Class.inherit({
- ctor: function(element) {
- this._$element = $(element);
- this._cancelCallback = $.Callbacks()
- },
- getElement: function() {
- return this._$element
- },
- getDirection: function() {
- return this.direction
- },
- validate: function(e) {
- return e.type !== "dxmousewheel"
- },
- configurate: function(data) {
- $.extend(this, data)
- },
- addCancelCallback: function(callback) {
- this._cancelCallback.add(callback)
- },
- removeCancelCallback: function() {
- this._cancelCallback.empty()
- },
- init: $.noop,
- start: $.noop,
- move: $.noop,
- end: $.noop,
- cancel: $.noop,
- wheel: $.noop,
- _fireEvent: function(eventName, event, params) {
- var eventData = {
- type: eventName,
- originalEvent: event,
- target: this.getElement().get(0)
- };
- event = events.fireEvent($.extend(eventData, params));
- if (event.cancel)
- this._cancel(event);
- return event
- },
- _cancel: function(e) {
- this._cancelCallback.fire()
- }
- });
- var gestureEmitters = [];
- $.extend(ui, {
- GestureEmitter: GestureEmitter,
- gestureEmitters: gestureEmitters
- })
- })(jQuery, DevExpress);
- /*! Module core, file ui.scrollEmitter.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- events = ui.events;
- var SCROLL_INIT_EVENT = "dxscrollinit",
- SCROLL_START_EVENT = "dxscrollstart",
- SCROLL_MOVE_EVENT = "dxscroll",
- SCROLL_END_EVENT = "dxscrollend",
- SCROLL_STOP_EVENT = "dxscrollstop",
- SCROLL_CANCEL_EVENT = "dxscrollcancel",
- SCROLL_WHEEL_EVENT = "dxscrollwheel",
- INERTIA_TIMEOUT = 100,
- VELOCITY_CALC_TIMEOUT = 200,
- FRAME_DURATION = Math.round(1000 / 60);
- var ScrollEmitter = ui.GestureEmitter.inherit({
- ctor: function(element) {
- this.callBase(element);
- this.direction = "vertical"
- },
- init: function(e) {
- this._savedEventData = this._prevEventData = events.eventData(e);
- this._fireEvent(SCROLL_INIT_EVENT, e)
- },
- start: function(e) {
- this._fireEvent(SCROLL_START_EVENT, e, {delta: events.eventDelta(this._prevEventData, events.eventData(e))})
- },
- move: function(e) {
- var currentEventData = events.eventData(e);
- this._fireEvent(SCROLL_MOVE_EVENT, e, {delta: events.eventDelta(this._prevEventData, currentEventData)});
- var eventDelta = events.eventDelta(this._savedEventData, currentEventData);
- if (eventDelta.time > VELOCITY_CALC_TIMEOUT)
- this._savedEventData = this._prevEventData;
- this._prevEventData = currentEventData
- },
- end: function(e) {
- var endEventDelta = events.eventDelta(this._prevEventData, events.eventData(e));
- var velocity = {
- x: 0,
- y: 0
- };
- if (endEventDelta.time < INERTIA_TIMEOUT) {
- var deltaEventData = events.eventDelta(this._savedEventData, this._prevEventData);
- velocity = {
- x: deltaEventData.x * FRAME_DURATION / deltaEventData.time,
- y: deltaEventData.y * FRAME_DURATION / deltaEventData.time
- }
- }
- this._fireEvent(SCROLL_END_EVENT, e, {velocity: velocity})
- },
- stop: function(e) {
- this._fireEvent(SCROLL_STOP_EVENT, e)
- },
- cancel: function(e) {
- this._fireEvent(SCROLL_CANCEL_EVENT, e)
- },
- wheel: function(e) {
- this._fireEvent(SCROLL_WHEEL_EVENT, e, {delta: e.delta})
- }
- });
- ui.gestureEmitters.push({
- emitter: ScrollEmitter,
- events: [SCROLL_INIT_EVENT, SCROLL_START_EVENT, SCROLL_MOVE_EVENT, SCROLL_END_EVENT, SCROLL_STOP_EVENT, SCROLL_CANCEL_EVENT, SCROLL_WHEEL_EVENT]
- })
- })(jQuery, DevExpress);
- /*! Module core, file ui.swipeEmitter.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- utils = DX.utils,
- events = ui.events,
- SWIPE_START_EVENT = "dxswipestart",
- SWIPE_EVENT = "dxswipe",
- SWIPE_END_EVENT = "dxswipeend";
- var HorizontalStrategy = {
- defaultItemSizeFunc: function() {
- return this.getElement().width()
- },
- getBounds: function() {
- return [this._maxLeftOffset, this._maxRightOffset]
- },
- calcOffsetRatio: function(e) {
- var endEventData = events.eventData(e);
- return (endEventData.x - (this._startEventData && this._startEventData.x || 0)) / this._itemSizeFunc().call(this, e)
- },
- isFastSwipe: function(e) {
- var endEventData = events.eventData(e);
- return this.FAST_SWIPE_SPEED_LIMIT * Math.abs(endEventData.x - this._tickData.x) >= endEventData.time - this._tickData.time
- }
- };
- var VerticalStrategy = {
- defaultItemSizeFunc: function() {
- return this.getElement().height()
- },
- getBounds: function() {
- return [this._maxTopOffset, this._maxBottomOffset]
- },
- calcOffsetRatio: function(e) {
- var endEventData = events.eventData(e);
- return (endEventData.y - (this._startEventData && this._startEventData.y || 0)) / this._itemSizeFunc().call(this, e)
- },
- isFastSwipe: function(e) {
- var endEventData = events.eventData(e);
- return this.FAST_SWIPE_SPEED_LIMIT * Math.abs(endEventData.y - this._tickData.y) >= endEventData.time - this._tickData.time
- }
- };
- var STRATEGIES = {
- horizontal: HorizontalStrategy,
- vertical: VerticalStrategy
- };
- var SwipeEmitter = ui.GestureEmitter.inherit({
- TICK_INTERVAL: 300,
- FAST_SWIPE_SPEED_LIMIT: 5,
- ctor: function(element) {
- this.callBase(element);
- this.direction = "horizontal";
- this.elastic = true
- },
- _getStrategy: function() {
- return STRATEGIES[this.direction]
- },
- _defaultItemSizeFunc: function() {
- return this._getStrategy().defaultItemSizeFunc.call(this)
- },
- _itemSizeFunc: function() {
- return this.itemSizeFunc || this._defaultItemSizeFunc
- },
- init: function(e) {
- this._startEventData = events.eventData(e);
- this._tickData = {time: 0}
- },
- start: function(e) {
- e = this._fireEvent(SWIPE_START_EVENT, e);
- if (!e.cancel) {
- this._maxLeftOffset = e.maxLeftOffset;
- this._maxRightOffset = e.maxRightOffset;
- this._maxTopOffset = e.maxTopOffset;
- this._maxBottomOffset = e.maxBottomOffset
- }
- },
- move: function(e) {
- var strategy = this._getStrategy(),
- moveEventData = events.eventData(e),
- offset = strategy.calcOffsetRatio.call(this, e);
- offset = this._fitOffset(offset, this.elastic);
- if (moveEventData.time - this._tickData.time > this.TICK_INTERVAL)
- this._tickData = moveEventData;
- this._fireEvent(SWIPE_EVENT, e, {offset: offset});
- e.preventDefault()
- },
- end: function(e) {
- var strategy = this._getStrategy(),
- offsetRatio = strategy.calcOffsetRatio.call(this, e),
- isFast = strategy.isFastSwipe.call(this, e),
- startOffset = offsetRatio,
- targetOffset = this._calcTargetOffset(offsetRatio, isFast);
- startOffset = this._fitOffset(startOffset, this.elastic);
- targetOffset = this._fitOffset(targetOffset, false);
- this._fireEvent(SWIPE_END_EVENT, e, {
- offset: startOffset,
- targetOffset: targetOffset
- })
- },
- _fitOffset: function(offset, elastic) {
- var strategy = this._getStrategy(),
- bounds = strategy.getBounds.call(this);
- if (offset < -bounds[0])
- return elastic ? (-2 * bounds[0] + offset) / 3 : -bounds[0];
- if (offset > bounds[1])
- return elastic ? (2 * bounds[1] + offset) / 3 : bounds[1];
- return offset
- },
- _calcTargetOffset: function(offsetRatio, isFast) {
- var result;
- if (isFast) {
- result = Math.ceil(Math.abs(offsetRatio));
- if (offsetRatio < 0)
- result = -result
- }
- else
- result = Math.round(offsetRatio);
- return result
- }
- });
- ui.gestureEmitters.push({
- emitter: SwipeEmitter,
- events: [SWIPE_START_EVENT, SWIPE_EVENT, SWIPE_END_EVENT]
- })
- })(jQuery, DevExpress);
- /*! Module core, file ui.dragEmitter.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- utils = DX.utils,
- events = ui.events,
- wrapToArray = utils.wrapToArray;
- var DRAG_START_EVENT = "dxdragstart",
- DRAG_EVENT = "dxdrag",
- DRAG_END_EVENT = "dxdragend",
- DRAG_ENTER_EVENT = "dxdragenter",
- DRAG_LEAVE_EVENT = "dxdragleave",
- DROP_EVENT = "dxdrop";
- var knownDropTargets = [],
- knownDropTargetConfigs = [];
- var dropTargetRegistration = {
- setup: function(element, data) {
- var knownDropTarget = $.inArray(element, knownDropTargets) !== -1;
- if (!knownDropTarget) {
- knownDropTargets.push(element);
- knownDropTargetConfigs.push(data || {})
- }
- },
- teardown: function(element, data) {
- var elementEvents = $._data(element, "events"),
- handlersCount = 0;
- $.each([DRAG_ENTER_EVENT, DRAG_LEAVE_EVENT, DROP_EVENT], function(_, eventName) {
- var eventHandlers = elementEvents[eventName];
- if (eventHandlers)
- handlersCount += eventHandlers.length
- });
- if (!handlersCount) {
- var index = $.inArray(element, knownDropTargets);
- knownDropTargets.splice(index, 1);
- knownDropTargetConfigs.splice(index, 1)
- }
- }
- };
- events.registerEvent(DRAG_ENTER_EVENT, dropTargetRegistration);
- events.registerEvent(DRAG_LEAVE_EVENT, dropTargetRegistration);
- events.registerEvent(DROP_EVENT, dropTargetRegistration);
- var getItemConfig = function($element) {
- var dropTargetIndex = $.inArray($element.get(0), knownDropTargets);
- return knownDropTargetConfigs[dropTargetIndex]
- };
- var getItemPosition = function($element) {
- var dropTargetConfig = getItemConfig($element);
- if (dropTargetConfig.itemPositionFunc)
- return dropTargetConfig.itemPositionFunc();
- else
- return $element.offset()
- };
- var getItemSize = function($element) {
- var dropTargetConfig = getItemConfig($element);
- if (dropTargetConfig.itemSizeFunc)
- return dropTargetConfig.itemSizeFunc();
- else
- return {
- width: $element.width(),
- height: $element.height()
- }
- };
- var DragEmitter = ui.GestureEmitter.inherit({
- ctor: function(element) {
- this.callBase(element);
- this.direction = "both"
- },
- init: function(e) {
- var eventData = events.eventData(e);
- this._startEventData = eventData
- },
- start: function(e) {
- e = this._fireEvent(DRAG_START_EVENT, e);
- this._maxLeftOffset = e.maxLeftOffset;
- this._maxRightOffset = e.maxRightOffset;
- this._maxTopOffset = e.maxTopOffset;
- this._maxBottomOffset = e.maxBottomOffset;
- var dropTargets = wrapToArray(e.targetElements || knownDropTargets);
- this._$dropTargetElements = $.map(dropTargets, function(element) {
- return $(element)
- })
- },
- move: function(e) {
- var eventData = events.eventData(e),
- dragOffset = this._calculateOffset(eventData);
- this._fireEvent(DRAG_EVENT, e, {offset: dragOffset});
- this._processDropTargets(e, dragOffset);
- e.preventDefault()
- },
- _calculateOffset: function(eventData) {
- return {
- x: this._calculateXOffset(eventData),
- y: this._calculateYOffset(eventData)
- }
- },
- _calculateXOffset: function(eventData) {
- if (this.direction !== "vertical") {
- var offset = eventData.x - this._startEventData.x;
- return this._fitOffset(offset, this._maxLeftOffset, this._maxRightOffset)
- }
- return 0
- },
- _calculateYOffset: function(eventData) {
- if (this.direction !== "horizontal") {
- var offset = eventData.y - this._startEventData.y;
- return this._fitOffset(offset, this._maxTopOffset, this._maxBottomOffset)
- }
- return 0
- },
- _fitOffset: function(offset, minOffset, maxOffset) {
- if (minOffset != null)
- offset = Math.max(offset, -minOffset);
- if (maxOffset != null)
- offset = Math.min(offset, maxOffset);
- return offset
- },
- _processDropTargets: function(e, dragOffset) {
- var target = this._findDropTarget(e),
- sameTarget = target === this._$currentDropTarget;
- if (!sameTarget) {
- this._fireDropTargetEvent(e, DRAG_LEAVE_EVENT);
- this._$currentDropTarget = target;
- this._fireDropTargetEvent(e, DRAG_ENTER_EVENT)
- }
- },
- _fireDropTargetEvent: function(event, eventName) {
- if (!this._$currentDropTarget)
- return;
- var eventData = {
- type: eventName,
- originalEvent: event,
- draggingElement: this._$element.get(0),
- target: this._$currentDropTarget.get(0)
- };
- events.fireEvent(eventData)
- },
- _findDropTarget: function(e) {
- var that = this,
- $result;
- $.each(this._$dropTargetElements, function(_, $target) {
- if (that._checkDropTarget($target, e)) {
- $result = $target;
- return false
- }
- });
- return $result
- },
- _checkDropTarget: function($target, e) {
- var isDraggingElement = $target.get(0) === this._$element.get(0);
- if (isDraggingElement)
- return false;
- var targetPosition = getItemPosition($target);
- if (e.pageX < targetPosition.left)
- return false;
- if (e.pageY < targetPosition.top)
- return false;
- var targetSize = getItemSize($target);
- if (e.pageX > targetPosition.left + targetSize.width)
- return false;
- if (e.pageY > targetPosition.top + targetSize.height)
- return false;
- return $target
- },
- end: function(e) {
- var eventData = events.eventData(e);
- this._fireEvent(DRAG_END_EVENT, e, {offset: this._calculateOffset(eventData)});
- this._fireDropTargetEvent(e, DROP_EVENT);
- delete this._$currentDropTarget
- }
- });
- ui.gestureEmitters.push({
- emitter: DragEmitter,
- events: [DRAG_START_EVENT, DRAG_EVENT, DRAG_END_EVENT]
- });
- DX.ui.events.__internals = DX.ui.events.__internals || {};
- $.extend(DX.ui.events.__internals, {dropTargets: knownDropTargets})
- })(jQuery, DevExpress);
- /*! Module core, file ui.events.gesture.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- events = ui.events,
- utils = DX.utils;
- var abs = Math.abs;
- var GESTURE_EVENT = "dxGesture",
- GESTURE_EVENT_DATA = "dxGestureEmitter",
- GESTURE_LOCK_KEY = "dxGestureLock",
- GESTURE_UNLOCK_TIMEOUT = 400,
- TOUCH_BOUNDARY = 10,
- HORIZONTAL = "horizontal",
- VERTICAL = "vertical",
- BOTH = "both";
- var GestureEventManager = DX.Class.inherit({
- SLEEP: 0,
- INITED: 1,
- STARTED: 2,
- ctor: function() {
- this._attachHandlers();
- this.reset()
- },
- _attachHandlers: function() {
- $(document).on(events.addNamespace("dxpointerdown", GESTURE_EVENT), $.proxy(this._handlePointerDown, this)).on(events.addNamespace("dxpointermove", GESTURE_EVENT), $.proxy(this._handlePointerMove, this)).on(events.addNamespace("dxpointerup dxpointercancel", GESTURE_EVENT), $.proxy(this._handlePointerUp, this)).on(events.addNamespace("dxmousewheel", GESTURE_EVENT), $.proxy(this._handleMouseWheel, this))
- },
- _eachEmitter: function(callback) {
- $.each(this._activeEmitters || {}, function(direction, emitter) {
- return callback(emitter, direction)
- })
- },
- _noEmitters: function() {
- return $.isEmptyObject(this._activeEmitters)
- },
- reset: function() {
- this._eachEmitter(function(emitter) {
- emitter.removeCancelCallback()
- });
- this._forgetGesture();
- this._stage = this.SLEEP;
- this._activeEmitters = {}
- },
- _handlePointerDown: function(e) {
- if (events.needSkipEvent(e) || events.hasTouches(e) > 1)
- return;
- this.reset();
- this._activeEmitters = this._closestEmitter(e);
- if (this._noEmitters())
- return;
- this._startEvent = e;
- this._startEventData = events.eventData(e);
- this._stage = this.INITED;
- this._applyToActive("init", e)
- },
- _applyToActive: function(method) {
- var args = $.makeArray(arguments).slice(1);
- this._eachEmitter(function(emitter) {
- if (method in emitter)
- emitter[method].apply(emitter, args)
- })
- },
- _closestEmitter: function(e) {
- var result = {},
- foundForAllDirections = false,
- $element = $(e.target);
- while ($element.length && !foundForAllDirections) {
- var emitter = $element.data(GESTURE_EVENT_DATA);
- if (emitter && emitter.validate(e)) {
- var direction = emitter.getDirection(e);
- if (direction) {
- emitter.addCancelCallback($.proxy(this._handleCancel, this, emitter, e));
- result[direction] = result[direction] || emitter
- }
- }
- foundForAllDirections = result[HORIZONTAL] && result[VERTICAL] || result[BOTH];
- $element = $element.parent()
- }
- return result
- },
- _handleCancel: function(canceledEmitter, e) {
- var canceledDirection;
- this._eachEmitter(function(emitter, direction) {
- if (emitter === canceledEmitter) {
- canceledDirection = direction;
- emitter.removeCancelCallback()
- }
- });
- this._forgetGesture([canceledEmitter]);
- this._cancelEmitter(canceledEmitter, e);
- if (this._noEmitters())
- this.reset()
- },
- _handlePointerMove: function(e) {
- if (this._stage === this.INITED && this._directionDetected(e))
- this._handleStart(e);
- if (this._stage === this.STARTED)
- this._handleMove(e)
- },
- _directionDetected: function(e) {
- var delta = events.eventDelta(this._startEventData, events.eventData(e));
- return delta.x || delta.y
- },
- _handleStart: function(e) {
- this._filterEmitters(e);
- if (this._noEmitters())
- return;
- this._resetActiveElement();
- this._applyToActive("start", this._startEvent);
- this._stage = this.STARTED
- },
- _resetActiveElement: function() {
- if (DX.devices.real().platform !== "ios")
- return;
- this._eachEmitter(function(emitter) {
- if ($(":focus", emitter.getElement()).length)
- utils.resetActiveElement()
- })
- },
- _filterEmitters: function(e) {
- this._filterByDirection(e);
- if (this._emitersAmount() > 1)
- this._takeFirstEmitter()
- },
- _emitersAmount: function() {
- var result = 0;
- this._eachEmitter(function() {
- result++
- });
- return result
- },
- _filterByDirection: function(e) {
- var delta = events.eventDelta(this._startEventData, events.eventData(e)),
- horizontalMove = abs(delta.y) < abs(delta.x),
- verticalMove = abs(delta.y) > abs(delta.x),
- horizontalEmmiter = this._activeEmitters[HORIZONTAL],
- verticalEmmiter = this._activeEmitters[VERTICAL],
- bothEmitter = this._activeEmitters[BOTH],
- existsHorizontalEmitter = horizontalEmmiter || bothEmitter,
- existsVerticalEmitter = verticalEmmiter || bothEmitter;
- if (horizontalMove && existsHorizontalEmitter)
- this._cancelEmitter(verticalEmmiter, e);
- else if (verticalMove && existsVerticalEmitter)
- this._cancelEmitter(horizontalEmmiter, e)
- },
- _cancelEmitter: function(canceledEmmiter, e) {
- if (!canceledEmmiter)
- return;
- canceledEmmiter.cancel(e);
- delete this._activeEmitters[canceledEmmiter.getDirection(e)]
- },
- _takeFirstEmitter: function() {
- var activeEmitters = {};
- this._eachEmitter(function(emitter, direction) {
- activeEmitters[direction] = emitter;
- return false
- });
- this._activeEmitters = activeEmitters
- },
- _prepareGesture: function() {
- this._gestureLocked = true;
- clearTimeout(this._gestureEndTimer);
- this._eachEmitter(function(emitter) {
- emitter.getElement().data(GESTURE_LOCK_KEY, true)
- });
- ui.feedback.reset()
- },
- _handleMove: function(e) {
- if (!this._gestureLocked) {
- var delta = events.eventDelta(this._startEventData, events.eventData(e));
- if (abs(delta.x) > TOUCH_BOUNDARY || abs(delta.y) > TOUCH_BOUNDARY) {
- events.handleGestureEvent(e, GESTURE_EVENT);
- this._prepareGesture()
- }
- }
- this._applyToActive("move", e)
- },
- _forgetGesture: function(activeEmitters) {
- activeEmitters = activeEmitters || this._activeEmitters;
- if (this._noEmitters())
- return;
- this._gestureLocked = false;
- this._gestureEndTimer = setTimeout(function() {
- $.each(activeEmitters, function(_, emitter) {
- emitter.getElement().data(GESTURE_LOCK_KEY, false)
- })
- }, GESTURE_UNLOCK_TIMEOUT)
- },
- _handlePointerUp: function(e) {
- if (!DX.devices.isRippleEmulator() && events.hasTouches(e))
- return;
- if (this._stage === this.STARTED)
- this._applyToActive("end", e);
- else if (this._stage === this.INITED)
- this._applyToActive("stop", e);
- this.reset()
- },
- _handleMouseWheel: function(e) {
- this._handlePointerDown(e);
- if (this._stage !== this.INITED)
- return;
- this._takeFirstEmitter();
- this._eachEmitter(function(emitter, direction) {
- var prop = direction !== "horizontal" ? "pageY" : "pageX";
- e[prop] += e.delta
- });
- this._handlePointerMove(e);
- this._handlePointerUp(e)
- },
- isActive: function(element) {
- var result = false;
- this._eachEmitter(function(emitter) {
- result = result || emitter.getElement().is(element)
- });
- return result
- }
- });
- var gestureEventManager = new GestureEventManager;
- var registerEmitter = function(emitterConfig) {
- var emitterClass = emitterConfig.emitter;
- $.each(emitterConfig.events, function(_, eventName) {
- events.registerEvent(eventName, {
- noBubble: true,
- setup: function(element, data) {
- var emitter = $(element).data(GESTURE_EVENT_DATA) || new emitterClass(element);
- emitter.configurate(data);
- $(element).data(GESTURE_EVENT_DATA, emitter)
- },
- teardown: function(element) {
- if (gestureEventManager.isActive(element))
- gestureEventManager.reset();
- $(element).removeData(GESTURE_EVENT_DATA)
- }
- })
- })
- };
- $.each(ui.gestureEmitters, function(_, emitterConfig) {
- registerEmitter(emitterConfig)
- });
- events.__internals = events.__internals || {};
- $.extend(events.__internals, {registerEmitter: registerEmitter})
- })(jQuery, DevExpress);
- /*! Module core, file ui.widget.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- UI_FEEDBACK = "UIFeedback",
- UI_FEEDBACK_CLASS = "dx-feedback",
- ACTIVE_STATE_CLASS = "dx-state-active",
- DISABLED_STATE_CLASS = "dx-state-disabled",
- INVISIBLE_STATE_CLASS = "dx-state-invisible",
- HOVER_STATE_CLASS = "dx-state-hover",
- FEEDBACK_SHOW_TIMEOUT = 30,
- FEEDBACK_HIDE_TIMEOUT = 400,
- HOVER_START = "dxhoverstart",
- HOVER_END = "dxhoverend",
- ANONYMOUS_TEMPLATE_NAME = "template",
- TEMPLATE_SELECTOR = "[data-options*='dxTemplate']",
- TEMPLATES_DATA_KEY = "dxTemplates";
- var getTemplateOptions = function(element) {
- var options = $(element).data("options");
- if ($.trim(options).charAt(0) !== "{")
- options = "{" + options + "}";
- return new Function("return " + options)().dxTemplate
- };
- var activeElement,
- events = ui.events;
- ui.feedback = {reset: function() {
- handleEnd(true)
- }};
- ui.Widget = DX.DOMComponent.inherit({
- NAME: "Widget",
- NAMESPACE: ui,
- _setDefaultOptions: function() {
- this.callBase();
- this.option({
- disabled: false,
- visible: true,
- activeStateEnabled: true,
- width: undefined,
- height: undefined,
- contentReadyAction: null,
- hoverStateEnabled: false
- })
- },
- _init: function() {
- this.callBase();
- this._feedbackShowTimeout = FEEDBACK_SHOW_TIMEOUT;
- this._feedbackHideTimeout = FEEDBACK_HIDE_TIMEOUT;
- if (this._templatesSupported()) {
- this._initTemplates();
- this._initContentReadyAction()
- }
- },
- _templatesSupported: function() {
- return this._renderContentImpl !== DX.abstract
- },
- _initTemplates: function() {
- var that = this,
- templates = {},
- dataTemplateElements = this._element().data(TEMPLATES_DATA_KEY),
- templateElements = dataTemplateElements ? dataTemplateElements : this._element().contents().filter(TEMPLATE_SELECTOR);
- this._templateProvider = new ui.TemplateProvider;
- this._templateClass = this._templateProvider.getTemplateClass(this);
- if (templateElements.length) {
- var templatesMap = {};
- templateElements.each(function() {
- var templateOptions = getTemplateOptions(this);
- if (!templateOptions)
- return;
- if (!templateOptions.name)
- throw Error("Template name was not specified");
- templatesMap[templateOptions.name] = templatesMap[templateOptions.name] || [];
- templatesMap[templateOptions.name].push(this)
- });
- $.each(templatesMap, function(templateName, value) {
- var deviceTemplate = that._findTemplateByDevice(value);
- if (deviceTemplate)
- templates[templateName] = that._createTemplate(deviceTemplate)
- })
- }
- else
- templates[ANONYMOUS_TEMPLATE_NAME] = that._createTemplate(that._element().contents());
- this.option("_templates", templates)
- },
- _getTemplateByOption: function(optionName) {
- return this._getTemplate(this.option(optionName))
- },
- _getTemplate: function(templateName) {
- var result = this._acquireTemplate.apply(this, arguments);
- if (!result && this._templateProvider.supportDefaultTemplate(this)) {
- result = this._templateProvider.getDefaultTemplate(this);
- if (!result)
- throw Error(DX.utils.stringFormat("Template \"{0}\" was not found and no default template specified!", templateName));
- }
- return result
- },
- _acquireTemplate: function(templateSource) {
- if (templateSource == null)
- return templateSource;
- if (templateSource instanceof this._templateClass)
- return templateSource;
- if (templateSource.nodeType || templateSource.jquery) {
- templateSource = $(templateSource);
- if (templateSource.is("script"))
- templateSource = templateSource.html();
- return this._createTemplate(templateSource)
- }
- if (typeof templateSource === "string")
- return this.option("_templates")[templateSource];
- if ($.isFunction(templateSource)) {
- var args = $.makeArray(arguments).slice(1);
- return this._acquireTemplate(templateSource.apply(this, args))
- }
- return this._acquireTemplate(templateSource.toString())
- },
- _createTemplate: function(element) {
- return new this._templateClass(element, this)
- },
- _findTemplateByDevice: function(templates) {
- var suitableTemplate = DX.utils.findBestMatches(DX.devices.current(), templates, function(template) {
- return getTemplateOptions(template)
- })[0];
- $.each(templates, function(index, template) {
- if (template !== suitableTemplate)
- $(template).remove()
- });
- return suitableTemplate
- },
- _cleanTemplates: function() {
- var that = this;
- $.each(this.option("_templates"), function(templateName, template) {
- if (that === template.owner())
- template.dispose()
- })
- },
- _initContentReadyAction: function() {
- this._contentReadyAction = this._createActionByOption("contentReadyAction", {excludeValidators: ["gesture", "designMode", "disabled"]})
- },
- _render: function() {
- this.callBase();
- this._element().addClass("dx-widget");
- this._toggleDisabledState(this.option("disabled"));
- this._toggleVisibility(this.option("visible"));
- this._refreshFeedback();
- this._renderDimensions();
- if (this._templatesSupported())
- this._renderContent();
- this._attachHoverEvents()
- },
- _renderContent: function() {
- this._renderContentImpl();
- this._fireContentReadyAction()
- },
- _renderContentImpl: DX.abstract,
- _fireContentReadyAction: function() {
- this._contentReadyAction({excludeValidators: ["disabled", "gesture"]})
- },
- _dispose: function() {
- if (this._templatesSupported())
- this._cleanTemplates();
- this._contentReadyAction = null;
- this._clearTimers();
- if (activeElement && activeElement.closest(this._element()).length)
- activeElement = null;
- this.callBase()
- },
- _clean: function() {
- this.callBase();
- this._element().empty()
- },
- _clearTimers: function() {
- clearTimeout(this._feedbackHideTimer);
- clearTimeout(this._feedbackShowTimer)
- },
- _toggleVisibility: function(visible) {
- this._element().toggleClass(INVISIBLE_STATE_CLASS, !visible)
- },
- _attachHoverEvents: function() {
- var that = this,
- hoverableSelector = that._activeStateUnit,
- nameStart = events.addNamespace(HOVER_START, UI_FEEDBACK),
- nameEnd = events.addNamespace(HOVER_END, UI_FEEDBACK);
- that._element().off(nameStart, hoverableSelector).off(nameEnd, hoverableSelector);
- if (this.option("hoverStateEnabled")) {
- var startAction = new DX.Action(function(args) {
- var $target = args.element;
- that._refreshHoveredElement($target)
- });
- that._element().on(nameStart, hoverableSelector, {selector: hoverableSelector}, function(e) {
- startAction.execute({element: $(e.target)})
- }).on(nameEnd, hoverableSelector, {selector: hoverableSelector}, function(e) {
- e.stopImmediatePropagation();
- that._forgetHoveredElement()
- })
- }
- else
- this._toggleHoverClass(false)
- },
- _refreshHoveredElement: function(hoveredElement) {
- var selector = this._activeStateUnit || this._element();
- this._forgetHoveredElement();
- this._hoveredElement = hoveredElement.closest(selector);
- this._toggleHoverClass(true)
- },
- _forgetHoveredElement: function() {
- this._toggleHoverClass(false);
- delete this._hoveredElement
- },
- _toggleHoverClass: function(value) {
- if (this._hoveredElement)
- this._hoveredElement.toggleClass(HOVER_STATE_CLASS, value && this.option("hoverStateEnabled"))
- },
- _renderDimensions: function() {
- var width = this.option("width"),
- height = this.option("height");
- this._setDimension(width, "width");
- this._setDimension(height, "height")
- },
- _setDimension: function(dimensionSize, dimension) {
- var $element = this._element();
- dimensionSize = $.isFunction(dimensionSize) ? dimensionSize() : dimensionSize;
- if ($.isNumeric(dimensionSize))
- dimensionSize = dimensionSize + "px";
- if (!dimensionSize && dimension === "width")
- dimensionSize = this._calculateWidth();
- $element.css(dimension, dimensionSize)
- },
- _calculateWidth: function() {
- var $element = this._element(),
- explicitWidth = $element[0].style.width,
- calculatedWidth;
- if (explicitWidth[explicitWidth.length - 1] === "%" && !this.option("width"))
- return explicitWidth;
- else
- calculatedWidth = explicitWidth && explicitWidth !== "auto" && explicitWidth !== "inherit" ? $element.outerWidth() : this.option("width");
- return calculatedWidth
- },
- _refreshFeedback: function() {
- if (this._feedbackDisabled()) {
- this._feedbackOff(true);
- this._element().removeClass(UI_FEEDBACK_CLASS)
- }
- else
- this._element().addClass(UI_FEEDBACK_CLASS)
- },
- _feedbackDisabled: function() {
- return !this.option("activeStateEnabled") || this.option("disabled")
- },
- _feedbackOn: function(element, immediate) {
- if (this._feedbackDisabled())
- return;
- this._clearTimers();
- if (immediate)
- this._feedbackShow(element);
- else
- this._feedbackShowTimer = window.setTimeout($.proxy(this._feedbackShow, this, element), this._feedbackShowTimeout);
- this._saveActiveElement()
- },
- _feedbackShow: function(element) {
- var activeStateElement = this._element();
- if (this._activeStateUnit)
- activeStateElement = $(element).closest(this._activeStateUnit);
- if (!activeStateElement.hasClass(DISABLED_STATE_CLASS)) {
- activeStateElement.addClass(ACTIVE_STATE_CLASS);
- this._toggleHoverClass(false)
- }
- },
- _saveActiveElement: function() {
- activeElement = this._element()
- },
- _feedbackOff: function(immediate) {
- this._clearTimers();
- if (immediate)
- this._feedbackHide();
- else
- this._feedbackHideTimer = window.setTimeout($.proxy(this._feedbackHide, this), this._feedbackHideTimeout)
- },
- _feedbackHide: function() {
- var activeStateElement = this._element();
- if (this._activeStateUnit)
- activeStateElement = activeStateElement.find(this._activeStateUnit);
- activeStateElement.removeClass(ACTIVE_STATE_CLASS);
- this._toggleHoverClass(!this.option("disabled"));
- this._clearActiveElement()
- },
- _clearActiveElement: function() {
- var rootDomElement = this._element().get(0),
- activeDomElement = activeElement && activeElement.get(0);
- if (activeDomElement && (activeDomElement === rootDomElement || $.contains(rootDomElement, activeDomElement)))
- activeElement = null
- },
- _toggleDisabledState: function(value) {
- this._element().toggleClass(DISABLED_STATE_CLASS, Boolean(value));
- this._toggleHoverClass(!value)
- },
- _optionChanged: function(name, value) {
- switch (name) {
- case"disabled":
- this._toggleDisabledState(value);
- this._refreshFeedback();
- break;
- case"activeStateEnabled":
- this._refreshFeedback();
- break;
- case"hoverStateEnabled":
- this._attachHoverEvents();
- break;
- case"visible":
- this._toggleVisibility(value);
- break;
- case"width":
- case"height":
- this._renderDimensions();
- break;
- case"contentReadyAction":
- this._initContentReadyAction();
- break;
- case"_templates":
- this._refresh();
- break;
- default:
- this.callBase.apply(this, arguments)
- }
- },
- repaint: function() {
- this._refresh()
- }
- });
- var handleStart = function(args, immediate) {
- var e = args.jQueryEvent,
- $target = args.element,
- widget;
- if (events.needSkipEvent(e))
- return;
- if (activeElement) {
- widget = getWidget(activeElement);
- if (widget)
- widget._feedbackOff(true)
- }
- var closestFeedbackElement = $target.closest("." + UI_FEEDBACK_CLASS);
- if (closestFeedbackElement.length) {
- widget = getWidget(closestFeedbackElement);
- if (!widget)
- return;
- widget._feedbackOn($target, immediate);
- if (immediate)
- widget._feedbackOff()
- }
- };
- var handleEnd = function(immediate) {
- if (!activeElement)
- return;
- var widget = getWidget(activeElement);
- if (widget)
- widget._feedbackOff(immediate)
- };
- var getWidget = function(widgetElement) {
- var result;
- $.each(widgetElement.data("dxComponents") || [], function(index, componentName) {
- if (ui[componentName] && ui[componentName].subclassOf(ui.Widget)) {
- result = widgetElement.data(componentName);
- return false
- }
- });
- return result
- };
- $(function() {
- var startAction = new DX.Action(handleStart);
- $(document).on(events.addNamespace("dxpointerdown", UI_FEEDBACK), function(e) {
- startAction.execute({
- jQueryEvent: e,
- element: $(e.target)
- })
- }).on(events.addNamespace("dxpointerup dxpointercancel", UI_FEEDBACK), function(e) {
- var activeElementClicked = activeElement && $(e.target).closest("." + UI_FEEDBACK_CLASS).get(0) === activeElement.get(0);
- if (activeElementClicked)
- startAction.execute({
- jQueryEvent: e,
- element: $(e.target)
- }, true);
- handleEnd()
- })
- })
- })(jQuery, DevExpress);
- /*! Module core, file ui.editor.js */
- (function($, DX, undefined) {
- var ui = DX.ui;
- DX.registerComponent("dxEditor", ui.Widget.inherit({
- _setDefaultOptions: function() {
- this.callBase();
- this.option({
- value: undefined,
- valueChangeAction: undefined
- })
- },
- _recreateValueChangeAction: function() {
- this._valueChangeAction = this._createActionByOption("valueChangeAction")
- },
- _suppressValueChangeAction: function() {
- this._valueChangeActionSuppressed = true
- },
- _resumeValueChangeAction: function() {
- this._valueChangeActionSuppressed = false
- },
- _render: function() {
- this._recreateValueChangeAction();
- this.callBase()
- },
- _raiseValueChangeAction: function(value, previousValue, extraArguments) {
- var args = {
- value: value,
- previousValue: previousValue,
- jQueryEvent: this._valueChangeEventInstance
- };
- if (extraArguments)
- args = $.extend(args, extraArguments);
- this._valueChangeAction(args)
- },
- _optionChanged: function(name, value, previousValue) {
- switch (name) {
- case"valueChangeAction":
- this._recreateValueChangeAction();
- break;
- case"value":
- if (!this._valueChangeActionSuppressed)
- this._raiseValueChangeAction(value, previousValue);
- this._valueChangeEventInstance = undefined;
- break;
- default:
- this.callBase.apply(this, arguments)
- }
- }
- }))
- })(jQuery, DevExpress);
- /*! Module core, file ui.template.js */
- (function($, DX, undefined) {
- var isString = DX.utils.isString;
- var currentTemplateEngine;
- var templateEngines = [];
- var BaseTemplate = DevExpress.Class.inherit({
- _compile: function(html, element) {
- return element
- },
- _render: function(template, data) {
- return template
- },
- ctor: function(element) {
- this._element = $(element);
- if (this._element.length === 1) {
- if (this._element[0].nodeName.toLowerCase() !== "script")
- this._element = $("<div />").append(this._element);
- this._template = this._compile(this._element.html() || "", this._element)
- }
- },
- render: function(container, data) {
- var result;
- if (this._template) {
- result = this._render(this._template, data);
- if (isString(result))
- result = $.parseHTML(result);
- result = $(result);
- if (container)
- container.append(result);
- return result
- }
- },
- owner: $.noop,
- dispose: $.noop
- });
- var createTemplateEngine = function(options) {
- if (options && options.compile && options.render)
- return BaseTemplate.inherit({
- allowRenderToDetachedContainer: options.allowRenderToDetachedContainer !== false,
- _compile: options.compile,
- _render: options.render
- });
- else
- throw Error("Template Engine must contains compile and render methods");
- };
- if (window.ko) {
- var koCustomTemplateEngine = function(){};
- koCustomTemplateEngine.prototype = ko.utils.extend(new ko.templateEngine, {
- renderTemplateSource: function(templateSource, bindingContext, options) {
- var precompiledTemplate = templateSource["data"]("precompiledTemplate");
- if (!precompiledTemplate) {
- precompiledTemplate = new currentTemplateEngine(templateSource.domElement);
- templateSource["data"]("precompiledTemplate", precompiledTemplate)
- }
- return precompiledTemplate.render(null, bindingContext.$data)
- },
- allowTemplateRewriting: false
- })
- }
- DevExpress.ui.setTemplateEngine = function(templateEngine) {
- if (isString(templateEngine)) {
- currentTemplateEngine = templateEngines && templateEngines[templateEngine];
- if (!currentTemplateEngine && templateEngine !== "default")
- throw Error(DX.utils.stringFormat("Template Engine \"{0}\" is not supported", templateEngine));
- }
- else
- currentTemplateEngine = createTemplateEngine(templateEngine) || currentTemplateEngine;
- if (window.ko)
- ko.setTemplateEngine(currentTemplateEngine ? new koCustomTemplateEngine : new ko.nativeTemplateEngine)
- };
- DevExpress.ui.TemplateProvider = DevExpress.ui.TemplateProvider.inherit({getTemplateClass: function() {
- if (currentTemplateEngine)
- return currentTemplateEngine;
- return this.callBase.apply(this, arguments)
- }});
- var registerTemplateEngine = function(name, templateOptions) {
- templateEngines[name] = createTemplateEngine(templateOptions)
- };
- registerTemplateEngine("jquery-tmpl", {
- compile: function(html, element) {
- return element
- },
- render: function(template, data) {
- return template.tmpl(data)
- }
- });
- registerTemplateEngine("jsrender", {
- compile: function(html) {
- return $.templates(html)
- },
- render: function(template, data) {
- return template.render(data)
- }
- });
- registerTemplateEngine("mustache", {
- compile: function(html) {
- return Mustache.compile(html)
- },
- render: function(template, data) {
- return template(data)
- }
- });
- registerTemplateEngine("hogan", {
- compile: function(html) {
- return Hogan.compile(html)
- },
- render: function(template, data) {
- return template.render(data)
- }
- });
- registerTemplateEngine("underscore", {
- compile: function(html) {
- return _.template(html)
- },
- render: function(template, data) {
- return template(data)
- }
- });
- registerTemplateEngine("handlebars", {
- compile: function(html) {
- return Handlebars.compile(html)
- },
- render: function(template, data) {
- return template(data)
- }
- });
- registerTemplateEngine("doT", {
- compile: function(html) {
- return doT.template(html)
- },
- render: function(template, data) {
- return template(data)
- }
- })
- })(jQuery, DevExpress);
- /*! Module core, file ui.collectionContainerWidget.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- events = ui.events;
- var CollectionContainerWidget = ui.Widget.inherit({
- _setDefaultOptions: function() {
- this.callBase();
- this.option({
- items: [],
- itemTemplate: "item",
- itemRender: null,
- itemRenderedAction: null,
- itemClickAction: null,
- itemHoldAction: null,
- itemHoldTimeout: 750,
- noDataText: Globalize.localize("dxCollectionContainerWidget-noDataText"),
- dataSource: null,
- selectedIndex: -1,
- itemSelectAction: null,
- itemTemplateProperty: "template"
- })
- },
- _init: function() {
- this.callBase();
- this._cleanRenderedItems();
- this._refreshDataSource()
- },
- _dataSourceOptions: function() {
- var options = {
- paginate: false,
- _preferSync: false
- };
- if ($.isArray(this.option("dataSource")))
- options._preferSync = true;
- return options
- },
- _cleanRenderedItems: function() {
- this._renderedItemsCount = 0
- },
- _fireSelectItemEvent: function(index, prevIndex) {
- if (this._selectionEnabled()) {
- this._updateSelectedIndex(index, prevIndex);
- this._handleItemEvent(this._selectedItemElement(index), "itemSelectAction", {
- selectedIndex: index,
- previousIndex: prevIndex
- }, {excludeValidators: ["gesture", "disabled"]})
- }
- },
- _optionChanged: function(name, value, prevValue) {
- switch (name) {
- case"items":
- case"itemTemplateProperty":
- if (this._selectionEnabled()) {
- var itemsCount = value && value.length || 0,
- maxIndex = Math.max(itemsCount - 1, 0);
- if (maxIndex < this.option("selectedIndex"))
- this.option("selectedIndex", 0)
- }
- this._cleanRenderedItems();
- this._invalidate();
- break;
- case"dataSource":
- this._refreshDataSource();
- if (!this._dataSource)
- this.option("items", []);
- this._renderEmptyMessage();
- break;
- case"noDataText":
- this._renderEmptyMessage();
- break;
- case"itemTemplate":
- this._invalidate();
- break;
- case"itemRender":
- this._itemRender = null;
- this._invalidate();
- break;
- case"itemRenderedAction":
- this._createItemRenderAction();
- break;
- case"itemClickAction":
- break;
- case"itemHoldAction":
- case"itemHoldTimeout":
- this._attachHoldEvent();
- break;
- case"selectedIndex":
- this._fireSelectItemEvent(value, prevValue);
- break;
- case"itemSelectAction":
- break;
- default:
- this.callBase(name, value, prevValue)
- }
- },
- _expectNextPageLoading: function() {
- this._startIndexForAppendedItems = 0
- },
- _expectLastItemLoading: function() {
- this._startIndexForAppendedItems = -1
- },
- _forgetNextPageLoading: function() {
- this._startIndexForAppendedItems = null
- },
- _handleDataSourceChanged: function(newItems) {
- var items = this.option("items");
- if (this._initialized && items && this._shouldAppendItems()) {
- this._renderedItemsCount = items.length;
- if (!this._dataSource.isLastPage() || this._startIndexForAppendedItems !== -1)
- this.option().items = items.concat(newItems.slice(this._startIndexForAppendedItems));
- this._renderContent();
- this._forgetNextPageLoading()
- }
- else
- this.option("items", newItems)
- },
- _handleDataSourceLoadError: function() {
- this._forgetNextPageLoading()
- },
- _shouldAppendItems: function() {
- return this._startIndexForAppendedItems != null && this._allowDinamicItemsAppend()
- },
- _allowDinamicItemsAppend: function() {
- return false
- },
- _clean: function() {
- this._itemContainer().empty()
- },
- _refresh: function() {
- this._cleanRenderedItems();
- this.callBase.apply(this, arguments)
- },
- _itemContainer: function() {
- return this._element()
- },
- _itemClass: DX.abstract,
- _itemSelector: function() {
- return "." + this._itemClass()
- },
- _itemDataKey: DX.abstract,
- _itemElements: function() {
- return this._itemContainer().find(this._itemSelector())
- },
- _render: function() {
- this.callBase();
- this._attachClickEvent();
- this._attachHoldEvent();
- if (this._selectionEnabled()) {
- this._renderSelectedIndex(this.option("selectedIndex"));
- this._attachSelectedEvent()
- }
- },
- _selectionEnabled: function() {
- return this._renderSelectedIndex !== DX.abstract
- },
- _selectionByClickEnabled: function() {
- return true
- },
- _renderSelectedIndex: DX.abstract,
- _attachSelectedEvent: function() {
- if (!this._selectionByClickEnabled())
- return;
- var itemSelector = this._itemSelector(),
- itemSelectHandler = this._createAction($.proxy(function(e) {
- this._handleItemSelect(e.jQueryEvent)
- }, this), {validatingTargetName: "itemElement"}),
- eventName = events.addNamespace("dxclick", this.NAME);
- this._element().off(eventName, itemSelector).on(eventName, itemSelector, $.proxy(function(e) {
- var $itemElement = $(e.target).closest(itemSelector);
- itemSelectHandler({
- itemElement: $itemElement,
- jQueryEvent: e
- });
- this._handleItemClick(e)
- }, this))
- },
- _handleItemSelect: function(e) {
- if (events.needSkipEvent(e))
- return;
- var items = this.option("items"),
- selectedItem = $(e.currentTarget).data(this._itemDataKey()),
- selectedItemIndex = $.inArray(selectedItem, items);
- this.option("selectedIndex", selectedItemIndex)
- },
- _updateSelectedIndex: function() {
- this._renderSelectedIndex.apply(this, arguments)
- },
- _selectedItemElement: function(index) {
- return this._itemElements().eq(index)
- },
- _attachClickEvent: function() {
- if (this._selectionEnabled() && this._selectionByClickEnabled())
- return;
- var itemSelector = this._itemSelector(),
- eventName = events.addNamespace("dxclick", this.NAME);
- this._itemContainer().off(eventName, itemSelector).on(eventName, itemSelector, $.proxy(this._handleItemClick, this))
- },
- _handleItemClick: function(e) {
- this._handleItemJQueryEvent(e, "itemClickAction")
- },
- _attachHoldEvent: function() {
- var $itemContainer = this._itemContainer(),
- itemSelector = this._itemSelector(),
- eventName = events.addNamespace("dxhold", this.NAME);
- $itemContainer.off(eventName, itemSelector);
- if (this._shouldAttachHoldEvent())
- $itemContainer.on(eventName, itemSelector, {timeout: this.option("itemHoldTimeout")}, $.proxy(this._handleItemHold, this))
- },
- _shouldAttachHoldEvent: function() {
- return this.option("itemHoldAction")
- },
- _handleItemHold: function(e) {
- this._handleItemJQueryEvent(e, "itemHoldAction")
- },
- _renderContentImpl: function() {
- var items = this.option("items") || [];
- if (this._renderedItemsCount)
- this._renderItems(items.slice(this._renderedItemsCount));
- else
- this._renderItems(items)
- },
- _renderItems: function(items) {
- if (items.length)
- $.each(items, $.proxy(this._renderItem, this));
- this._renderEmptyMessage()
- },
- _renderItem: function(index, itemData, container) {
- container = container || this._itemContainer();
- var itemRenderer = this._getItemRenderer(),
- itemTemplateName = this._getItemTemplateName(itemData),
- itemTemplate = this._getTemplate(itemTemplateName, index, itemData),
- itemElement,
- renderArgs = {
- index: index,
- item: itemData,
- container: container
- };
- if (itemRenderer)
- itemElement = this._createItemByRenderer(itemRenderer, renderArgs);
- else if (itemTemplate)
- itemElement = this._createItemByTemplate(itemTemplate, renderArgs);
- else
- itemElement = this._createItemByRenderer(this._itemRenderDefault, renderArgs);
- itemElement.addClass(this._itemClass()).data(this._itemDataKey(), itemData);
- var postprocessRenderArgs = {
- itemElement: itemElement,
- itemData: itemData,
- itemIndex: index
- };
- this._postprocessRenderItem(postprocessRenderArgs);
- this._getItemRenderAction()({
- itemElement: itemElement,
- itemData: itemData
- });
- return itemElement
- },
- _createItemRenderAction: function() {
- return this._itemRenderAction = this._createActionByOption("itemRenderedAction", {
- element: this._element(),
- excludeValidators: ["gesture", "designMode", "disabled"]
- })
- },
- _getItemRenderAction: function() {
- return this._itemRenderAction || this._createItemRenderAction()
- },
- _getItemRenderer: function() {
- this._itemRender = this._itemRender || this.option("itemRender");
- return this._itemRender
- },
- _createItemByRenderer: function(itemRenderer, renderArgs) {
- var itemElement = $("<div />").appendTo(renderArgs.container);
- var rendererResult = itemRenderer.call(this, renderArgs.item, renderArgs.index, itemElement);
- if (rendererResult != null && itemElement[0] !== rendererResult[0])
- itemElement.append(rendererResult);
- return itemElement
- },
- _getItemTemplateName: function(itemData) {
- var templateProperty = this.option("itemTemplateProperty");
- return itemData && itemData[templateProperty] || this.option("itemTemplate")
- },
- _createItemByTemplate: function(itemTemplate, renderArgs) {
- return itemTemplate.render(renderArgs.container, renderArgs.item, renderArgs.index, "ignoreTarget")
- },
- _itemRenderDefault: function(item, index, itemElement) {
- if ($.isPlainObject(item)) {
- if (item.visible !== undefined && !item.visible)
- itemElement.hide();
- if (item.disabled)
- itemElement.addClass("dx-state-disabled");
- if (item.text)
- itemElement.text(item.text);
- if (item.html)
- itemElement.html(item.html)
- }
- else
- itemElement.html(String(item))
- },
- _postprocessRenderItem: $.noop,
- _renderEmptyMessage: function() {
- if (!this._selectionEnabled()) {
- var noDataText = this.option("noDataText"),
- items = this.option("items"),
- dataSourceLoading = this._dataSource && this._dataSource.isLoading(),
- hideNoData = !noDataText || items && items.length || dataSourceLoading;
- if (hideNoData && this._$nodata) {
- this._$nodata.remove();
- this._$nodata = null
- }
- if (!hideNoData) {
- this._$nodata = this._$nodata || $("<div />").addClass("dx-empty-message");
- this._$nodata.appendTo(this._itemContainer()).text(noDataText)
- }
- }
- },
- _handleItemJQueryEvent: function(jQueryEvent, handlerOptionName, actionArgs, actionConfig) {
- this._handleItemEvent(jQueryEvent.target, handlerOptionName, $.extend(actionArgs, {jQueryEvent: jQueryEvent}), actionConfig)
- },
- _handleItemEvent: function(initiator, handlerOptionName, actionArgs, actionConfig) {
- var action = this._createActionByOption(handlerOptionName, $.extend({validatingTargetName: "itemElement"}, actionConfig));
- return this._handleItemEventImpl(initiator, action, actionArgs)
- },
- _handleItemEventByHandler: function(initiator, handler, actionArgs, actionConfig) {
- var action = this._createAction(handler, $.extend({validatingTargetName: "itemElement"}, actionConfig));
- return this._handleItemEventImpl(initiator, action, actionArgs)
- },
- _handleItemEventImpl: function(initiator, action, actionArgs) {
- var $itemElement = this._closestItemElement($(initiator));
- actionArgs = $.extend({
- itemElement: $itemElement,
- itemData: this._getItemData($itemElement)
- }, actionArgs);
- return action(actionArgs)
- },
- _closestItemElement: function($element) {
- return $($element).closest(this._itemSelector())
- },
- _getItemData: function($itemElement) {
- return $itemElement.data(this._itemDataKey())
- },
- itemElements: function() {
- return this._itemElements()
- },
- itemsContainer: function() {
- return this._itemContainer()
- }
- }).include(ui.DataHelperMixin);
- ui.CollectionContainerWidget = CollectionContainerWidget
- })(jQuery, DevExpress);
- /*! Module core, file ui.tooltip.js */
- (function($, DX, undefined) {
- var $tooltip = null;
- var createTooltip = function(options) {
- options = $.extend({position: "top"}, options);
- var content = options.content;
- delete options.content;
- return $("<div />").html(content).appendTo(DX.overlayTargetContainer()).dxTooltip(options)
- };
- var removeTooltip = function() {
- if (!$tooltip)
- return;
- $tooltip.remove();
- $tooltip = null
- };
- var tooltip = {
- show: function(options) {
- removeTooltip();
- $tooltip = createTooltip(options);
- return $tooltip.dxTooltip("show")
- },
- hide: function() {
- if (!$tooltip)
- return $.when();
- return $tooltip.dxTooltip("hide").done(removeTooltip).promise()
- }
- };
- DX.ui.tooltip = tooltip
- })(jQuery, DevExpress)
- }
- if (!DevExpress.MOD_WIDGETS_BASE) {
- if (!window.DevExpress)
- throw Error('Required module is not referenced: core');
- /*! Module widgets-base, file ui.scrollable.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- events = ui.events;
- var SCROLLABLE = "dxScrollable",
- SCROLLABLE_STRATEGY = "dxScrollableStrategy",
- SCROLLABLE_CLASS = "dx-scrollable",
- SCROLLABLE_DISABLED_CLASS = "dx-scrollable-disabled",
- SCROLLABLE_CONTAINER_CLASS = "dx-scrollable-container",
- SCROLLABLE_CONTENT_CLASS = "dx-scrollable-content",
- VERTICAL = "vertical",
- HORIZONTAL = "horizontal",
- BOTH = "both";
- DX.registerComponent(SCROLLABLE, DX.DOMComponent.inherit({
- NAMESPACE: ui,
- _setDefaultOptions: function() {
- this.callBase();
- this.option({
- disabled: false,
- scrollAction: null,
- direction: VERTICAL,
- showScrollbar: true,
- useNative: true,
- updateAction: null,
- useSimulatedScrollbar: false,
- useKeyboard: true,
- inertiaEnabled: true,
- bounceEnabled: true,
- scrollByContent: true,
- scrollByThumb: false,
- startAction: null,
- endAction: null,
- bounceAction: null,
- stopAction: null
- })
- },
- _defaultOptionsRules: function() {
- return this.callBase().slice(0).concat([{
- device: function(device) {
- return !DX.support.nativeScrolling
- },
- options: {
- useNative: false,
- useSimulatedScrollbar: true
- }
- }, {
- device: function(device) {
- return !DX.support.nativeScrolling && !DX.devices.isSimulator() && DX.devices.real().platform === "generic" && device.platform === "generic"
- },
- options: {
- scrollByThumb: true,
- scrollByContent: DX.support.touch,
- showScrollbar: "onHover",
- bounceEnabled: false
- }
- }, {
- device: function(device) {
- return DX.support.nativeScrolling && DX.devices.real().platform === "android"
- },
- options: {useSimulatedScrollbar: true}
- }])
- },
- _init: function() {
- this.callBase();
- this._initMarkup();
- this._attachNativeScrollbarsCustomizationCss();
- this._locked = false
- },
- _visibilityChanged: function(visible) {
- if (visible) {
- this.update();
- this._savedScrollOffset && this.scrollTo(this._savedScrollOffset)
- }
- else
- this._savedScrollOffset = this.scrollOffset()
- },
- _initMarkup: function() {
- var $element = this._element().addClass(SCROLLABLE_CLASS),
- $container = this._$container = $("<div>").addClass(SCROLLABLE_CONTAINER_CLASS),
- $content = this._$content = $("<div>").addClass(SCROLLABLE_CONTENT_CLASS);
- $content.append($element.contents()).appendTo($container);
- $container.appendTo($element)
- },
- _dimensionChanged: function() {
- this.update()
- },
- _attachNativeScrollbarsCustomizationCss: function() {
- if (!(navigator.platform.indexOf('Mac') > -1 && DevExpress.browser['webkit']))
- this._element().addClass("dx-scrollable-customizable-scrollbars")
- },
- _render: function() {
- this._renderDirection();
- this._renderStrategy();
- this._attachEventHandlers();
- this._renderDisabledState();
- this._createActions();
- this.update();
- this.callBase()
- },
- _toggleRTLDirection: function(rtl) {
- this.callBase(rtl);
- if (rtl)
- this.scrollTo({left: this.scrollWidth() - this.clientWidth()})
- },
- _attachEventHandlers: function() {
- var strategy = this._strategy;
- var initEventData = {
- getDirection: $.proxy(strategy.getDirection, strategy),
- validate: $.proxy(this._validate, this)
- };
- this._$container.off("." + SCROLLABLE).on(events.addNamespace("scroll", SCROLLABLE), $.proxy(strategy.handleScroll, strategy)).on(events.addNamespace("dxscrollinit", SCROLLABLE), initEventData, $.proxy(strategy.handleInit, strategy)).on(events.addNamespace("dxscrollstart", SCROLLABLE), $.proxy(strategy.handleStart, strategy)).on(events.addNamespace("dxscroll", SCROLLABLE), $.proxy(strategy.handleMove, strategy)).on(events.addNamespace("dxscrollend", SCROLLABLE), $.proxy(strategy.handleEnd, strategy)).on(events.addNamespace("dxscrollcancel", SCROLLABLE), $.proxy(strategy.handleCancel, strategy)).on(events.addNamespace("dxscrollstop", SCROLLABLE), $.proxy(strategy.handleStop, strategy))
- },
- _validate: function(e) {
- this.update();
- return this._strategy.validate(e)
- },
- _renderDisabledState: function() {
- this._element().toggleClass(SCROLLABLE_DISABLED_CLASS, this.option("disabled"));
- if (this.option("disabled"))
- this._lock();
- else
- this._unlock()
- },
- _renderDirection: function() {
- this._element().removeClass("dx-scrollable-" + HORIZONTAL).removeClass("dx-scrollable-" + VERTICAL).removeClass("dx-scrollable-" + BOTH).addClass("dx-scrollable-" + this.option("direction"))
- },
- _renderStrategy: function() {
- this._createStrategy();
- this._strategy.render();
- this._element().data(SCROLLABLE_STRATEGY, this._strategy)
- },
- _createStrategy: function() {
- this._strategy = this.option("useNative") ? new ui.NativeScrollableStrategy(this) : new ui.SimulatedScrollableStrategy(this)
- },
- _createActions: function() {
- this._strategy.createActions()
- },
- _clean: function() {
- this._strategy.dispose()
- },
- _optionChanged: function(optionName, optionValue) {
- switch (optionName) {
- case"startAction":
- case"endAction":
- case"stopAction":
- case"updateAction":
- case"scrollAction":
- case"bounceAction":
- this._createActions();
- break;
- case"direction":
- this._resetInactiveDirection();
- this._invalidate();
- break;
- case"inertiaEnabled":
- case"bounceEnabled":
- case"scrollByContent":
- case"scrollByThumb":
- case"bounceEnabled":
- case"useNative":
- case"useKeyboard":
- case"showScrollbar":
- case"useSimulatedScrollbar":
- this._invalidate();
- break;
- case"disabled":
- this._renderDisabledState();
- break;
- default:
- this.callBase.apply(this, arguments)
- }
- },
- _resetInactiveDirection: function() {
- var inactiveProp = this._getInactiveProp();
- if (!inactiveProp)
- return;
- var scrollOffset = this.scrollOffset();
- scrollOffset[inactiveProp] = 0;
- this.scrollTo(scrollOffset)
- },
- _getInactiveProp: function() {
- var direction = this.option("direction");
- if (direction === VERTICAL)
- return "left";
- if (direction === HORIZONTAL)
- return "top"
- },
- _location: function() {
- return this._strategy.location()
- },
- _normalizeLocation: function(location) {
- var direction = this.option("direction");
- return {
- left: $.isPlainObject(location) ? -(location.left || location.x || 0) : direction !== VERTICAL ? -location : 0,
- top: $.isPlainObject(location) ? -(location.top || location.y || 0) : direction !== HORIZONTAL ? -location : 0
- }
- },
- _isLocked: function() {
- return this._locked
- },
- _lock: function() {
- this._locked = true
- },
- _unlock: function() {
- this._locked = false
- },
- _isDirection: function(direction) {
- var current = this.option("direction");
- if (direction === VERTICAL)
- return current !== HORIZONTAL;
- if (direction === HORIZONTAL)
- return current !== VERTICAL;
- return current === direction
- },
- _updateAllowedDirection: function() {
- var allowedDirections = this._strategy._allowedDirections();
- if (this._isDirection(BOTH) && allowedDirections.vertical && allowedDirections.horizontal)
- this._allowedDirectionValue = BOTH;
- else if (this._isDirection(HORIZONTAL) && allowedDirections.horizontal)
- this._allowedDirectionValue = HORIZONTAL;
- else if (this._isDirection(VERTICAL) && allowedDirections.vertical)
- this._allowedDirectionValue = VERTICAL;
- else
- this._allowedDirectionValue = null
- },
- _allowedDirection: function() {
- return this._allowedDirectionValue
- },
- content: function() {
- return this._$content
- },
- scrollOffset: function() {
- var location = this._location();
- return {
- top: -location.top,
- left: -location.left
- }
- },
- scrollTop: function() {
- return this.scrollOffset().top
- },
- scrollLeft: function() {
- return this.scrollOffset().left
- },
- clientHeight: function() {
- return this._$container.height()
- },
- scrollHeight: function() {
- return this.content().height()
- },
- clientWidth: function() {
- return this._$container.width()
- },
- scrollWidth: function() {
- return this.content().width()
- },
- update: function() {
- this._strategy.update();
- this._updateAllowedDirection();
- return $.Deferred().resolve().promise()
- },
- scrollBy: function(distance) {
- distance = this._normalizeLocation(distance);
- if (!distance.top && !distance.left)
- return;
- this._strategy.scrollBy(distance)
- },
- scrollTo: function(targetLocation) {
- targetLocation = this._normalizeLocation(targetLocation);
- var location = this._location();
- this.scrollBy({
- left: location.left - targetLocation.left,
- top: location.top - targetLocation.top
- })
- },
- scrollToElement: function(element) {
- var $element = $(element);
- if (!$element.length || !this._element().find($element).length)
- return;
- var position = {
- top: 0,
- left: 0
- };
- var direction = this.option("direction");
- if (direction !== VERTICAL)
- position.left = this._elementPosition($element, HORIZONTAL);
- if (direction !== HORIZONTAL)
- position.top = this._elementPosition($element, VERTICAL);
- this.scrollTo(position)
- },
- _elementPosition: function($element, direction) {
- var elementPosition = $element.position()[direction === VERTICAL ? 'top' : 'left'];
- var elementSize = $element[direction === VERTICAL ? 'outerHeight' : 'outerWidth']();
- var elementBottom = elementPosition + elementSize;
- var scrollLocation = direction === VERTICAL ? this.scrollTop() : this.scrollLeft();
- var clientSize = direction === VERTICAL ? this.clientHeight() : this.clientWidth();
- var isAlreadyVisible = scrollLocation <= elementPosition && elementBottom <= scrollLocation + clientSize;
- var isElementBelowScrollLocation = scrollLocation > elementPosition;
- return isAlreadyVisible ? scrollLocation : elementPosition + (isElementBelowScrollLocation ? 0 : elementSize - clientSize)
- }
- }))
- })(jQuery, DevExpress);
- /*! Module widgets-base, file ui.scrollbar.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- events = ui.events;
- var SCROLLBAR = "dxScrollbar",
- SCROLLABLE_SCROLLBAR_CLASS = "dx-scrollable-scrollbar",
- SCROLLABLE_SCROLLBAR_ACTIVE_CLASS = SCROLLABLE_SCROLLBAR_CLASS + "-active",
- SCROLLABLE_SCROLL_CLASS = "dx-scrollable-scroll",
- SCROLLABLE_SCROLLBARS_HIDDEN = "dx-scrollable-scrollbars-hidden",
- HOVER_ENABLED_STATE = "dx-scrollbar-hoverable",
- VERTICAL = "vertical",
- HORIZONTAL = "horizontal",
- THUMB_MIN_SIZE = 15;
- var SCROLLBAR_VISIBLE = {
- onScroll: "onScroll",
- onHover: "onHover",
- always: "always",
- never: "never"
- };
- DX.registerComponent(SCROLLBAR, ui.Widget.inherit({
- _setDefaultOptions: function() {
- this.callBase();
- this.option({
- direction: null,
- visible: false,
- activeStateEnabled: false,
- visibilityMode: SCROLLBAR_VISIBLE.onScroll,
- containerSize: 0,
- contentSize: 0
- })
- },
- _init: function() {
- this.callBase();
- this._isHovered = false
- },
- _render: function() {
- this._renderThumb();
- this.callBase();
- this._renderDirection();
- this._update();
- this._attachPointerDownHandler();
- this.option("hoverStateEnabled", this._isHoverMode());
- this._element().toggleClass(HOVER_ENABLED_STATE, this.option("hoverStateEnabled"))
- },
- _renderThumb: function() {
- this._$thumb = $("<div>").addClass(SCROLLABLE_SCROLL_CLASS);
- this._element().addClass(SCROLLABLE_SCROLLBAR_CLASS).append(this._$thumb)
- },
- isThumb: function($element) {
- return !!this._element().find($element).length
- },
- _isHoverMode: function() {
- return this.option("visibilityMode") === SCROLLBAR_VISIBLE.onHover
- },
- _renderDirection: function() {
- var direction = this.option("direction");
- this._element().addClass("dx-scrollbar-" + direction);
- this._dimension = direction === HORIZONTAL ? "width" : "height";
- this._prop = direction === HORIZONTAL ? "left" : "top"
- },
- _attachPointerDownHandler: function() {
- this._$thumb.on(events.addNamespace("dxpointerdown", SCROLLBAR), $.proxy(this.feedbackOn, this))
- },
- feedbackOn: function() {
- this._element().addClass(SCROLLABLE_SCROLLBAR_ACTIVE_CLASS);
- activeScrollbar = this
- },
- feedbackOff: function() {
- this._element().removeClass(SCROLLABLE_SCROLLBAR_ACTIVE_CLASS);
- activeScrollbar = null
- },
- cursorEnter: function() {
- this._isHovered = true;
- this.option("visible", true)
- },
- cursorLeave: function() {
- this._isHovered = false;
- this.option("visible", false)
- },
- _renderDimensions: function() {
- this._$thumb.height(this.option("height"));
- this._$thumb.width(this.option("width"))
- },
- _toggleVisibility: function(visible) {
- visible = this._adjustVisibility(visible);
- this.option().visible = visible;
- this._$thumb.toggleClass("dx-state-invisible", !visible)
- },
- _adjustVisibility: function(visible) {
- if (this.containerToContentRatio() && !this._needScrollbar())
- return false;
- switch (this.option("visibilityMode")) {
- case SCROLLBAR_VISIBLE.onScroll:
- break;
- case SCROLLBAR_VISIBLE.onHover:
- visible = visible || !!this._isHovered;
- break;
- case SCROLLBAR_VISIBLE.never:
- visible = false;
- break;
- case SCROLLBAR_VISIBLE.always:
- visible = true;
- break
- }
- return visible
- },
- moveTo: function(location) {
- if (this._isHidden())
- return;
- if ($.isPlainObject(location))
- location = location[this._prop] || 0;
- var scrollBarLocation = {};
- scrollBarLocation[this._prop] = this._calculateScrollBarPosition(location);
- DX.translator.move(this._$thumb, scrollBarLocation)
- },
- _calculateScrollBarPosition: function(location) {
- return -location * this._thumbRatio
- },
- _update: function() {
- var containerSize = this.option("containerSize"),
- contentSize = this.option("contentSize");
- this._containerToContentRatio = containerSize / contentSize;
- var thumbSize = Math.round(Math.max(Math.round(containerSize * this._containerToContentRatio), THUMB_MIN_SIZE));
- this._thumbRatio = (containerSize - thumbSize) / (contentSize - containerSize);
- this.option(this._dimension, thumbSize);
- this._element().toggle(this._needScrollbar())
- },
- _isHidden: function() {
- return this.option("visibilityMode") === SCROLLBAR_VISIBLE.never
- },
- _needScrollbar: function() {
- return !this._isHidden() && this._containerToContentRatio < 1
- },
- containerToContentRatio: function() {
- return this._containerToContentRatio
- },
- _normalizeSize: function(size) {
- return $.isPlainObject(size) ? size[this._dimension] || 0 : size
- },
- _clean: function() {
- this.callBase();
- if (this === activeScrollbar)
- activeScrollbar = null;
- this._$thumb.off("." + SCROLLBAR)
- },
- _optionChanged: function(name, value) {
- if (this._isHidden())
- return;
- switch (name) {
- case"containerSize":
- case"contentSize":
- this.option()[name] = this._normalizeSize(value);
- this._update();
- break;
- case"visibilityMode":
- case"direction":
- this._invalidate();
- break;
- default:
- this.callBase.apply(this, arguments)
- }
- }
- }));
- var activeScrollbar = null;
- $(document).on(events.addNamespace("dxpointerup", SCROLLBAR), function() {
- if (activeScrollbar)
- activeScrollbar.feedbackOff()
- })
- })(jQuery, DevExpress);
- /*! Module widgets-base, file ui.scrollable.native.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- events = ui.events,
- utils = DX.utils,
- devices = DX.devices,
- abs = Math.abs;
- var SCROLLABLE_NATIVE = "dxNativeScrollable",
- SCROLLABLE_NATIVE_CLASS = "dx-scrollable-native",
- SCROLLABLE_SCROLLBAR_SIMULATED = "dx-scrollable-scrollbar-simulated",
- SCROLLABLE_SCROLLBARS_HIDDEN = "dx-scrollable-scrollbars-hidden",
- VERTICAL = "vertical",
- HORIZONTAL = "horizontal",
- GESTURE_LOCK_KEY = "dxGestureLock",
- GESTURE_LOCK_TIMEOUT = 400,
- HIDE_SCROLLBAR_TIMOUT = 500;
- ui.NativeScrollableStrategy = DX.Class.inherit({
- ctor: function(scrollable) {
- this._init(scrollable)
- },
- _init: function(scrollable) {
- this._component = scrollable;
- this._$element = scrollable._element();
- this._$container = scrollable._$container;
- this._$content = scrollable._$content;
- this._direction = scrollable.option("direction");
- this._useSimulatedScrollbar = scrollable.option("useSimulatedScrollbar");
- this._showScrollbar = scrollable.option("showScrollbar");
- this.option = $.proxy(scrollable.option, scrollable);
- this._createActionByOption = $.proxy(scrollable._createActionByOption, scrollable);
- this._isLocked = $.proxy(scrollable._isLocked, scrollable);
- this._isDirection = $.proxy(scrollable._isDirection, scrollable);
- this._allowedDirection = $.proxy(scrollable._allowedDirection, scrollable)
- },
- render: function() {
- this._$element.addClass(SCROLLABLE_NATIVE_CLASS).addClass(SCROLLABLE_NATIVE_CLASS + "-" + devices.real().platform).toggleClass(SCROLLABLE_SCROLLBARS_HIDDEN, !this._showScrollbar);
- if (this._showScrollbar && this._useSimulatedScrollbar)
- this._renderScrollbars()
- },
- _renderScrollbars: function() {
- this._scrollbars = {};
- this._hideScrollbarTimeout = 0;
- this._$element.addClass(SCROLLABLE_SCROLLBAR_SIMULATED);
- this._renderScrollbar(VERTICAL);
- this._renderScrollbar(HORIZONTAL)
- },
- _renderScrollbar: function(direction) {
- if (!this._isDirection(direction))
- return;
- var $scrollbar = $("<div>").dxScrollbar({direction: direction}).appendTo(this._$element);
- this._scrollbars[direction] = $scrollbar.dxScrollbar("instance")
- },
- handleInit: $.noop,
- handleStart: $.noop,
- handleMove: function(e) {
- if (this._isLocked()) {
- e.cancel = true;
- return
- }
- if (this._allowedDirection())
- e.originalEvent.originalEvent.isScrollingEvent = true
- },
- handleEnd: $.noop,
- handleStop: $.noop,
- _eachScrollbar: function(callback) {
- callback = $.proxy(callback, this);
- $.each(this._scrollbars || {}, function(direction, scrollbar) {
- callback(scrollbar, direction)
- })
- },
- createActions: function() {
- var actionConfig = {excludeValidators: ["gesture"]};
- this._scrollAction = this._createActionByOption("scrollAction", actionConfig);
- this._updateAction = this._createActionByOption("updateAction", actionConfig)
- },
- _createActionArgs: function() {
- var location = this.location();
- return {
- jQueryEvent: this._eventForUserAction,
- scrollOffset: {
- top: -location.top,
- left: -location.left
- },
- reachedLeft: this._isDirection(HORIZONTAL) ? location.left >= 0 : undefined,
- reachedRight: this._isDirection(HORIZONTAL) ? location.left <= this._containerSize.width - this._componentContentSize.width : undefined,
- reachedTop: this._isDirection(VERTICAL) ? location.top >= 0 : undefined,
- reachedBottom: this._isDirection(VERTICAL) ? location.top <= this._containerSize.height - this._componentContentSize.height : undefined
- }
- },
- handleScroll: function(e) {
- if (!this._isScrollLocationChanged()) {
- e.stopImmediatePropagation();
- return
- }
- this._eventForUserAction = e;
- this._moveScrollbars();
- this._scrollAction(this._createActionArgs());
- this._treatNativeGesture();
- this._lastLocation = this.location()
- },
- _isScrollLocationChanged: function() {
- var currentLocation = this.location(),
- lastLocation = this._lastLocation || {},
- isTopChanged = lastLocation.top !== currentLocation.top,
- isLeftChanged = lastLocation.left !== currentLocation.left;
- return isTopChanged || isLeftChanged
- },
- _moveScrollbars: function() {
- this._eachScrollbar(function(scrollbar) {
- scrollbar.moveTo(this.location());
- scrollbar.option("visible", true)
- });
- this._hideScrollbars()
- },
- _hideScrollbars: function() {
- clearTimeout(this._hideScrollbarTimeout);
- this._hideScrollbarTimeout = setTimeout($.proxy(function() {
- this._eachScrollbar(function(scrollbar) {
- scrollbar.option("visible", false)
- })
- }, this), HIDE_SCROLLBAR_TIMOUT)
- },
- _treatNativeGesture: function() {
- this._prepareGesture();
- this._forgetGesture()
- },
- _prepareGesture: function() {
- if (this._gestureEndTimer) {
- clearTimeout(this._gestureEndTimer);
- this._gestureEndTimer = null
- }
- else
- this._$element.data(GESTURE_LOCK_KEY, true)
- },
- _forgetGesture: function() {
- this._gestureEndTimer = setTimeout($.proxy(function() {
- this._$element.data(GESTURE_LOCK_KEY, false);
- this._gestureEndTimer = null
- }, this), GESTURE_LOCK_TIMEOUT)
- },
- location: function() {
- return {
- left: -this._$container.scrollLeft(),
- top: -this._$container.scrollTop()
- }
- },
- disabledChanged: $.noop,
- update: function() {
- this._update();
- this._updateAction(this._createActionArgs())
- },
- _update: function() {
- this._updateDimensions();
- this._updateScrollbars()
- },
- _updateDimensions: function() {
- this._containerSize = {
- height: this._$container.height(),
- width: this._$container.width()
- };
- this._componentContentSize = {
- height: this._component.content().height(),
- width: this._component.content().width()
- };
- this._contentSize = {
- height: this._$content.height(),
- width: this._$content.width()
- }
- },
- _updateScrollbars: function() {
- this._eachScrollbar(function(scrollbar, direction) {
- var dimension = direction === VERTICAL ? "height" : "width";
- scrollbar.option({
- containerSize: this._containerSize[dimension],
- contentSize: this._componentContentSize[dimension]
- })
- })
- },
- _allowedDirections: function() {
- return {
- vertical: this._isDirection(VERTICAL) && this._contentSize.height > this._containerSize.height,
- horizontal: this._isDirection(HORIZONTAL) && this._contentSize.width > this._containerSize.width
- }
- },
- dispose: function() {
- this._$element.removeClass(function(index, className) {
- var scrollableNativeRegexp = new RegExp(SCROLLABLE_NATIVE_CLASS + "\\S*", "g");
- if (scrollableNativeRegexp.test(className))
- return className.match(scrollableNativeRegexp).join(" ")
- });
- this._$element.off("." + SCROLLABLE_NATIVE);
- this._$container.off("." + SCROLLABLE_NATIVE);
- this._removeScrollbars();
- clearTimeout(this._gestureEndTimer)
- },
- _removeScrollbars: function() {
- this._eachScrollbar(function(scrollbar) {
- scrollbar._element().remove()
- })
- },
- scrollBy: function(distance) {
- var location = this.location();
- this._$container.scrollTop(-location.top - distance.top);
- this._$container.scrollLeft(-location.left - distance.left)
- },
- validate: function() {
- return !this.option("disabled") && this._allowedDirection()
- },
- getDirection: function() {
- return this._allowedDirection()
- }
- })
- })(jQuery, DevExpress);
- /*! Module widgets-base, file ui.scrollable.simulated.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- events = ui.events,
- math = Math;
- var realDevice = DX.devices.real;
- var isSluggishPlatform = realDevice.platform === "win8" || realDevice.platform === "android";
- var SCROLLABLE_SIMULATED = "dxSimulatedScrollable",
- SCROLLABLE_STRATEGY = "dxScrollableStrategy",
- SCROLLABLE_SIMULATED_CURSOR = SCROLLABLE_SIMULATED + "Cursor",
- SCROLLABLE_SIMULATED_KEYBOARD = SCROLLABLE_SIMULATED + "Keyboard",
- SCROLLABLE_SIMULATED_CLASS = "dx-scrollable-simulated",
- SCROLLABLE_SCROLLBARS_HIDDEN = "dx-scrollable-scrollbars-hidden",
- VERTICAL = "vertical",
- HORIZONTAL = "horizontal",
- ACCELERATION = isSluggishPlatform ? 0.95 : 0.92,
- OUT_BOUNDS_ACCELERATION = 0.5,
- MIN_VELOCITY_LIMIT = 1,
- FRAME_DURATION = math.round(1000 / 60),
- SCROLL_LINE_HEIGHT = 20,
- BOUNCE_MIN_VELOCITY_LIMIT = MIN_VELOCITY_LIMIT / 5,
- BOUNCE_DURATION = isSluggishPlatform ? 300 : 400,
- BOUNCE_FRAMES = BOUNCE_DURATION / FRAME_DURATION,
- BOUNCE_ACCELERATION_SUM = (1 - math.pow(ACCELERATION, BOUNCE_FRAMES)) / (1 - ACCELERATION);
- var KEY_CODES = {
- PAGE_UP: 33,
- PAGE_DOWN: 34,
- END: 35,
- HOME: 36,
- LEFT: 37,
- UP: 38,
- RIGHT: 39,
- DOWN: 40
- };
- var InertiaAnimator = DX.Animator.inherit({
- ctor: function(scroller) {
- this.callBase();
- this.scroller = scroller
- },
- VELOCITY_LIMIT: MIN_VELOCITY_LIMIT,
- _isFinished: function() {
- return math.abs(this.scroller._velocity) <= this.VELOCITY_LIMIT
- },
- _step: function() {
- this.scroller._scrollStep(this.scroller._velocity);
- this.scroller._velocity *= this._acceleration()
- },
- _acceleration: function() {
- return this.scroller._inBounds() ? ACCELERATION : OUT_BOUNDS_ACCELERATION
- },
- _complete: function() {
- this.scroller._scrollComplete()
- },
- _stop: function() {
- this.scroller._stopComplete()
- }
- });
- var BounceAnimator = InertiaAnimator.inherit({
- VELOCITY_LIMIT: BOUNCE_MIN_VELOCITY_LIMIT,
- _isFinished: function() {
- return this.scroller._crossBoundOnNextStep() || this.callBase()
- },
- _acceleration: function() {
- return ACCELERATION
- },
- _complete: function() {
- this.scroller._move(this.scroller._bounceLocation);
- this.callBase()
- }
- });
- var isWheelEvent = function(e) {
- return e.type === "dxmousewheel"
- };
- var Scroller = ui.Scroller = DX.Class.inherit({
- ctor: function(options) {
- this._initOptions(options);
- this._initAnimators();
- this._initScrollbar()
- },
- _initOptions: function(options) {
- this._location = 0;
- this._topReached = false;
- this._bottomReached = false;
- this._axis = options.direction === HORIZONTAL ? "x" : "y";
- this._prop = options.direction === HORIZONTAL ? "left" : "top";
- this._dimension = options.direction === HORIZONTAL ? "width" : "height";
- this._scrollProp = options.direction === HORIZONTAL ? "scrollLeft" : "scrollTop";
- $.each(options, $.proxy(function(optionName, optionValue) {
- this["_" + optionName] = optionValue
- }, this))
- },
- _initAnimators: function() {
- this._inertiaAnimator = new InertiaAnimator(this);
- this._bounceAnimator = new BounceAnimator(this)
- },
- _initScrollbar: function() {
- this._$scrollbar = $("<div>").dxScrollbar({
- direction: this._direction,
- visible: this._scrollByThumb,
- visibilityMode: this._visibilityModeNormalize(this._scrollbarVisible),
- containerSize: this._containerSize(),
- contentSize: this._contentSize()
- }).appendTo(this._$container);
- this._scrollbar = this._$scrollbar.dxScrollbar("instance")
- },
- _visibilityModeNormalize: function(mode) {
- return mode === true ? "onScroll" : mode === false ? "never" : mode
- },
- _scrollStep: function(delta) {
- var prevLocation = this._location;
- this._location += delta;
- this._suppressBounce();
- this._move();
- if (prevLocation !== this._location) {
- this._scrollAction();
- this._$element.triggerHandler("scroll")
- }
- },
- _suppressBounce: function() {
- if (this._bounceEnabled || this._inBounds(this._location))
- return;
- this._velocity = 0;
- this._location = this._boundLocation()
- },
- _boundLocation: function() {
- var location = math.min(this._location, this._maxOffset);
- return math.max(location, this._minOffset)
- },
- _move: function(location) {
- this._location = location !== undefined ? location : this._location;
- this._moveContent();
- this._moveScrollbar()
- },
- _moveContent: function() {
- var targetLocation = {};
- targetLocation[this._prop] = this._location;
- DX.translator.move(this._$content, targetLocation)
- },
- _moveScrollbar: function() {
- this._scrollbar.moveTo(this._location)
- },
- _scrollComplete: function() {
- if (this._inBounds()) {
- this._hideScrollbar();
- this._correctLocation();
- if (this._completeDeferred)
- this._completeDeferred.resolve()
- }
- this._scrollToBounds()
- },
- _correctLocation: function() {
- this._location = math.round(this._location);
- this._move()
- },
- _scrollToBounds: function() {
- if (this._inBounds())
- return;
- this._bounceAction();
- this._setupBounce();
- this._bounceAnimator.start()
- },
- _setupBounce: function() {
- var boundLocation = this._bounceLocation = this._boundLocation(),
- bounceDistance = boundLocation - this._location;
- this._velocity = bounceDistance / BOUNCE_ACCELERATION_SUM
- },
- _inBounds: function(location) {
- location = location !== undefined ? location : this._location;
- return location >= this._minOffset && location <= this._maxOffset
- },
- _crossBoundOnNextStep: function() {
- var location = this._location,
- nextLocation = location + this._velocity;
- return location < this._minOffset && nextLocation >= this._minOffset || location > this._maxOffset && nextLocation <= this._maxOffset
- },
- _handleInit: function(e) {
- this._stopDeferred = $.Deferred();
- this._stopScrolling();
- this._prepareThumbScrolling(e);
- return this._stopDeferred.promise()
- },
- _stopScrolling: function() {
- this._hideScrollbar();
- this._inertiaAnimator.stop();
- this._bounceAnimator.stop()
- },
- _prepareThumbScrolling: function(e) {
- if (isWheelEvent(e.originalEvent))
- return;
- var $target = $(e.originalEvent.target);
- var scrollbarClicked = this._isScrollbar($target);
- if (scrollbarClicked)
- this._moveToMouseLocation(e);
- this._thumbScrolling = scrollbarClicked || this._isThumb($target);
- if (this._thumbScrolling)
- this._scrollbar.feedbackOn()
- },
- _moveToMouseLocation: function(e) {
- var mouseLocation = e["page" + this._axis.toUpperCase()] - this._$element.offset()[this._prop];
- var location = this._location + mouseLocation / this._containerToContentRatio() - this._$container.height() / 2;
- this._scrollStep(-location)
- },
- _stopComplete: function() {
- if (this._stopDeferred)
- this._stopDeferred.resolve()
- },
- _handleStart: function() {
- this._showScrollbar()
- },
- _handleMove: function(delta) {
- delta = delta[this._axis];
- if (this._thumbScrolling)
- delta = -delta / this._containerToContentRatio();
- if (!this._inBounds())
- delta *= OUT_BOUNDS_ACCELERATION;
- this._scrollStep(delta)
- },
- _containerToContentRatio: function() {
- return this._scrollbar.containerToContentRatio()
- },
- _handleEnd: function(velocity) {
- this._completeDeferred = $.Deferred();
- this._velocity = velocity[this._axis];
- this._handleInertia();
- this._resetThumbScrolling();
- return this._completeDeferred.promise()
- },
- _handleInertia: function() {
- this._suppressIntertia();
- this._inertiaAnimator.start()
- },
- _suppressIntertia: function() {
- if (!this._inertiaEnabled || this._thumbScrolling)
- this._velocity = 0
- },
- _resetThumbScrolling: function() {
- this._thumbScrolling = false
- },
- _handleStop: function() {
- this._resetThumbScrolling();
- this._scrollToBounds()
- },
- _handleDispose: function() {
- this._stopScrolling();
- this._$scrollbar.remove()
- },
- _handleUpdate: function() {
- this._update();
- this._moveToBounds()
- },
- _update: function() {
- this._stopScrolling();
- this._updateLocation();
- this._updateBounds();
- this._updateScrollbar();
- this._moveScrollbar();
- this._updateScrollbarVisibility()
- },
- _updateLocation: function() {
- this._location = DX.translator.locate(this._$content)[this._prop]
- },
- _updateBounds: function() {
- this._maxOffset = 0;
- this._minOffset = math.min(this._containerSize() - this._contentSize(), 0)
- },
- _updateScrollbar: function() {
- this._scrollbar.option({
- containerSize: this._containerSize(),
- contentSize: this._contentSize()
- })
- },
- _updateScrollbarVisibility: function() {
- this._showScrollbar();
- this._hideScrollbar()
- },
- _moveToBounds: function() {
- this._location = this._boundLocation();
- this._move()
- },
- _handleCreateActions: function(actions) {
- this._scrollAction = actions.scrollAction;
- this._bounceAction = actions.bounceAction
- },
- _showScrollbar: function() {
- this._scrollbar.option("visible", true)
- },
- _hideScrollbar: function() {
- this._scrollbar.option("visible", false)
- },
- _containerSize: function() {
- return this._$container[this._dimension]()
- },
- _contentSize: function() {
- return this._$content[this._dimension]()
- },
- _validateEvent: function(e) {
- var $target = $(e.originalEvent.target);
- if (this._isThumb($target) || this._isScrollbar($target)) {
- e.preventDefault();
- return true
- }
- return this._isContent($target)
- },
- _isThumb: function($element) {
- return this._scrollByThumb && this._scrollbar.isThumb($element)
- },
- _isScrollbar: function($element) {
- return this._scrollByThumb && $element && $element.is(this._$scrollbar)
- },
- _isContent: function($element) {
- return this._scrollByContent && !!$element.closest(this._$element).length
- },
- _reachedMin: function() {
- return this._location <= this._minOffset
- },
- _reachedMax: function() {
- return this._location >= this._maxOffset
- },
- _handleCursorEnter: function() {
- this._scrollbar.cursorEnter()
- },
- _handleCursorLeave: function() {
- this._scrollbar.cursorLeave()
- }
- });
- var hoveredScrollable,
- activeScrollable;
- ui.SimulatedScrollableStrategy = DX.Class.inherit({
- ctor: function(scrollable) {
- this._init(scrollable)
- },
- _init: function(scrollable) {
- this._component = scrollable;
- this._$element = scrollable._element();
- this._$container = scrollable._$container.prop("tabindex", 0);
- this._$content = scrollable._$content;
- this.option = $.proxy(scrollable.option, scrollable);
- this._createActionByOption = $.proxy(scrollable._createActionByOption, scrollable);
- this._isLocked = $.proxy(scrollable._isLocked, scrollable);
- this._isDirection = $.proxy(scrollable._isDirection, scrollable);
- this._allowedDirection = $.proxy(scrollable._allowedDirection, scrollable)
- },
- render: function() {
- this._$element.addClass(SCROLLABLE_SIMULATED_CLASS);
- this._createScrollers();
- this._attachKeyboardHandler();
- this._attachCursorHandlers()
- },
- _createScrollers: function() {
- this._scrollers = {};
- if (this._isDirection(HORIZONTAL))
- this._createScroller(HORIZONTAL);
- if (this._isDirection(VERTICAL))
- this._createScroller(VERTICAL);
- this._$element.toggleClass(SCROLLABLE_SCROLLBARS_HIDDEN, !this.option("showScrollbar"))
- },
- _createScroller: function(direction) {
- this._scrollers[direction] = new Scroller(this._scrollerOptions(direction))
- },
- _scrollerOptions: function(direction) {
- return {
- direction: direction,
- $content: this._$content,
- $container: this._$container,
- $element: this._$element,
- scrollByContent: this.option("scrollByContent"),
- scrollByThumb: this.option("scrollByThumb"),
- scrollbarVisible: this.option("showScrollbar"),
- bounceEnabled: this.option("bounceEnabled"),
- inertiaEnabled: this.option("inertiaEnabled")
- }
- },
- handleInit: function(e) {
- this._supressDirections(e);
- this._eventForUserAction = e;
- this._handleEvent("Init", e).done(this._stopAction)
- },
- _supressDirections: function(e) {
- if (isWheelEvent(e.originalEvent)) {
- this._prepareDirections(true);
- return
- }
- this._prepareDirections();
- this._eachScroller(function(scroller, direction) {
- var isValid = scroller._validateEvent(e);
- this._validDirections[direction] = isValid
- })
- },
- _prepareDirections: function(value) {
- value = value || false;
- this._validDirections = {};
- this._validDirections[HORIZONTAL] = value;
- this._validDirections[VERTICAL] = value
- },
- _eachScroller: function(callback) {
- callback = $.proxy(callback, this);
- $.each(this._scrollers, function(direction, scroller) {
- callback(scroller, direction)
- })
- },
- handleStart: function(e) {
- this._saveActive();
- this._handleEvent("Start").done(this._startAction)
- },
- _saveActive: function() {
- activeScrollable = this
- },
- _resetActive: function() {
- activeScrollable = null
- },
- _validateDirection: function(delta) {
- var result = false;
- this._eachScroller(function(scroller) {
- result = result || scroller._validateDirection(delta)
- });
- return result
- },
- handleMove: function(e) {
- if (this._isLocked()) {
- e.cancel = true;
- this._resetActive();
- return
- }
- e.preventDefault && e.preventDefault();
- this._adjustDistance(e.delta);
- this._eventForUserAction = e;
- this._handleEvent("Move", e.delta)
- },
- _adjustDistance: function(distance) {
- distance.x *= this._validDirections[HORIZONTAL];
- distance.y *= this._validDirections[VERTICAL]
- },
- handleEnd: function(e) {
- this._resetActive();
- this._refreshCursorState(e.originalEvent && e.originalEvent.target);
- this._adjustDistance(e.velocity);
- this._eventForUserAction = e;
- return this._handleEvent("End", e.velocity).done(this._endAction)
- },
- handleCancel: function(e) {
- this._resetActive();
- this._eventForUserAction = e;
- return this._handleEvent("End", {
- x: 0,
- y: 0
- })
- },
- handleStop: function() {
- this._resetActive();
- this._handleEvent("Stop")
- },
- handleScroll: function() {
- var distance = {
- left: this._$container.scrollLeft(),
- top: this._$container.scrollTop()
- };
- this._$container.scrollLeft(-distance.left);
- this._$container.scrollTop(-distance.top);
- this.scrollBy(distance)
- },
- _attachKeyboardHandler: function() {
- this._$element.off("." + SCROLLABLE_SIMULATED_KEYBOARD);
- if (!this.option("disabled") && this.option("useKeyboard"))
- this._$element.on(events.addNamespace("keydown", SCROLLABLE_SIMULATED_KEYBOARD), $.proxy(this._handleKeyDown, this))
- },
- _handleKeyDown: function(e) {
- if (!this._$container.is(document.activeElement))
- return;
- var handled = true;
- switch (e.keyCode) {
- case KEY_CODES.DOWN:
- this._scrollByLine({y: 1});
- break;
- case KEY_CODES.UP:
- this._scrollByLine({y: -1});
- break;
- case KEY_CODES.RIGHT:
- this._scrollByLine({x: 1});
- break;
- case KEY_CODES.LEFT:
- this._scrollByLine({x: -1});
- break;
- case KEY_CODES.PAGE_DOWN:
- this._scrollByPage(1);
- break;
- case KEY_CODES.PAGE_UP:
- this._scrollByPage(-1);
- break;
- case KEY_CODES.HOME:
- this._scrollToHome();
- break;
- case KEY_CODES.END:
- this._scrollToEnd();
- break;
- default:
- handled = false;
- break
- }
- if (handled) {
- e.stopPropagation();
- e.preventDefault()
- }
- },
- _scrollByLine: function(lines) {
- this.scrollBy({
- top: (lines.y || 0) * -SCROLL_LINE_HEIGHT,
- left: (lines.x || 0) * -SCROLL_LINE_HEIGHT
- })
- },
- _scrollByPage: function(page) {
- var prop = this._wheelProp(),
- dimension = this._dimensionByProp(prop);
- var distance = {};
- distance[prop] = page * -this._$container[dimension]();
- this.scrollBy(distance)
- },
- _dimensionByProp: function(prop) {
- return prop === "left" ? "width" : "height"
- },
- _scrollToHome: function() {
- var prop = this._wheelProp();
- var distance = {};
- distance[prop] = 0;
- this._component.scrollTo(distance)
- },
- _scrollToEnd: function() {
- var prop = this._wheelProp(),
- dimension = this._dimensionByProp(prop);
- var distance = {};
- distance[prop] = this._$content[dimension]() - this._$container[dimension]();
- this._component.scrollTo(distance)
- },
- createActions: function() {
- this._startAction = this._createActionHandler("startAction");
- this._stopAction = this._createActionHandler("stopAction");
- this._endAction = this._createActionHandler("endAction");
- this._updateAction = this._createActionHandler("updateAction");
- this._createScrollerActions()
- },
- _createScrollerActions: function() {
- this._handleEvent("CreateActions", {
- scrollAction: this._createActionHandler("scrollAction"),
- bounceAction: this._createActionHandler("bounceAction")
- })
- },
- _createActionHandler: function(optionName) {
- var that = this,
- actionHandler = that._createActionByOption(optionName, {excludeValidators: ["gesture"]});
- return function() {
- actionHandler($.extend(that._createActionArgs(), arguments))
- }
- },
- _createActionArgs: function() {
- var scrollerX = this._scrollers[HORIZONTAL],
- scrollerY = this._scrollers[VERTICAL];
- return {
- jQueryEvent: this._eventForUserAction,
- scrollOffset: {
- top: scrollerY && -scrollerY._location,
- left: scrollerX && -scrollerX._location
- },
- reachedLeft: scrollerX && scrollerX._reachedMax(),
- reachedRight: scrollerX && scrollerX._reachedMin(),
- reachedTop: scrollerY && scrollerY._reachedMax(),
- reachedBottom: scrollerY && scrollerY._reachedMin()
- }
- },
- _handleEvent: function(eventName) {
- var args = $.makeArray(arguments).slice(1),
- deferreds = $.map(this._scrollers, function(scroller) {
- return scroller["_handle" + eventName].apply(scroller, args)
- });
- return $.when.apply($, deferreds).promise()
- },
- location: function() {
- return DX.translator.locate(this._$content)
- },
- disabledChanged: function() {
- this._attachCursorHandlers()
- },
- _attachCursorHandlers: function() {
- this._$element.off("." + SCROLLABLE_SIMULATED_CURSOR);
- if (!this.option("disabled") && this._isHoverMode())
- this._$element.on(events.addNamespace("mouseenter", SCROLLABLE_SIMULATED_CURSOR), $.proxy(this._handleCursorEnter, this)).on(events.addNamespace("mouseleave", SCROLLABLE_SIMULATED_CURSOR), $.proxy(this._handleCursorLeave, this))
- },
- _isHoverMode: function() {
- return this.option("showScrollbar") === "onHover"
- },
- _handleCursorEnter: function(e) {
- e = e || {};
- e.originalEvent = e.originalEvent || {};
- if (activeScrollable || e.originalEvent._hoverHandled)
- return;
- if (hoveredScrollable)
- hoveredScrollable._handleCursorLeave();
- hoveredScrollable = this;
- this._handleEvent("CursorEnter");
- e.originalEvent._hoverHandled = true
- },
- _handleCursorLeave: function(e) {
- if (hoveredScrollable !== this || activeScrollable === hoveredScrollable)
- return;
- this._handleEvent("CursorLeave");
- hoveredScrollable = null;
- this._refreshCursorState(e && e.relatedTarget)
- },
- _refreshCursorState: function(target) {
- if (!this._isHoverMode() && (!target || activeScrollable))
- return;
- var $target = $(target);
- var $scrollable = $target.closest("." + SCROLLABLE_SIMULATED_CLASS + ":not(.dx-state-disabled)");
- var targetScrollable = $scrollable.length && $scrollable.data(SCROLLABLE_STRATEGY);
- if (hoveredScrollable && hoveredScrollable !== targetScrollable)
- hoveredScrollable._handleCursorLeave();
- if (targetScrollable)
- targetScrollable._handleCursorEnter()
- },
- update: function() {
- return this._handleEvent("Update").done(this._updateAction)
- },
- _allowedDirections: function() {
- var bounceEnabled = this.option("bounceEnabled");
- return {
- vertical: this._isDirection(VERTICAL) && (this._scrollers[VERTICAL]._minOffset < 0 || bounceEnabled),
- horizontal: this._isDirection(HORIZONTAL) && (this._scrollers[HORIZONTAL]._minOffset < 0 || bounceEnabled)
- }
- },
- scrollBy: function(distance) {
- this._prepareDirections(true);
- this._handleEvent("Start").done(this._startAction);
- this._handleEvent("Move", {
- x: distance.left,
- y: distance.top
- });
- this._handleEvent("End", {
- x: 0,
- y: 0
- }).done(this._endAction)
- },
- validate: function(e) {
- if (this.option("disabled"))
- return false;
- if (this.option("bounceEnabled"))
- return true;
- return isWheelEvent(e) ? this._validateWheel(e) : this._validateMove()
- },
- _validateWheel: function(e) {
- var scroller = this._scrollers[this._wheelDirection()];
- var reachedMin = scroller._reachedMin();
- var reachedMax = scroller._reachedMax();
- var contentGreaterThanContainer = !reachedMin || !reachedMax;
- var locatedNotAtBound = !reachedMin && !reachedMax;
- var scrollFromMin = reachedMin && e.delta > 0;
- var scrollFromMax = reachedMax && e.delta < 0;
- return contentGreaterThanContainer && (locatedNotAtBound || scrollFromMin || scrollFromMax)
- },
- _validateMove: function() {
- return this._allowedDirection()
- },
- getDirection: function(e) {
- return isWheelEvent(e) ? this._wheelDirection() : this._allowedDirection()
- },
- _wheelProp: function() {
- return this._wheelDirection() === HORIZONTAL ? "left" : "top"
- },
- _wheelDirection: function() {
- switch (this.option("direction")) {
- case HORIZONTAL:
- return HORIZONTAL;
- case VERTICAL:
- return VERTICAL;
- default:
- return this._scrollers[VERTICAL]._containerToContentRatio() >= 1 ? HORIZONTAL : VERTICAL
- }
- },
- dispose: function() {
- if (activeScrollable === this)
- activeScrollable = null;
- if (hoveredScrollable === this)
- hoveredScrollable = null;
- this._handleEvent("Dispose");
- this._detachEventHandlers();
- this._$element.removeClass(SCROLLABLE_SIMULATED_CLASS);
- this._eventForUserAction = null;
- clearTimeout(this._gestureEndTimer)
- },
- _detachEventHandlers: function() {
- this._$element.off("." + SCROLLABLE_SIMULATED_CURSOR);
- this._$container.off("." + SCROLLABLE_SIMULATED_KEYBOARD)
- }
- });
- ui.dxScrollable.__internals = $.extend(ui.dxScrollable.__internals || {}, {
- ACCELERATION: ACCELERATION,
- MIN_VELOCITY_LIMIT: MIN_VELOCITY_LIMIT,
- FRAME_DURATION: FRAME_DURATION,
- SCROLL_LINE_HEIGHT: SCROLL_LINE_HEIGHT
- })
- })(jQuery, DevExpress);
- /*! Module widgets-base, file ui.scrollView.js */
- (function($, DX, undefined) {
- var ui = DX.ui;
- var SCROLLVIEW_CLASS = "dx-scrollview",
- SCROLLVIEW_CONTENT_CLASS = SCROLLVIEW_CLASS + "-content",
- SCROLLVIEW_TOP_POCKET_CLASS = SCROLLVIEW_CLASS + "-top-pocket",
- SCROLLVIEW_BOTTOM_POCKET_CLASS = SCROLLVIEW_CLASS + "-bottom-pocket",
- SCROLLVIEW_PULLDOWN_CLASS = SCROLLVIEW_CLASS + "-pull-down",
- SCROLLVIEW_PULLDOWN_IMAGE_CLASS = SCROLLVIEW_PULLDOWN_CLASS + "-image",
- SCROLLVIEW_PULLDOWN_INDICATOR_CLASS = SCROLLVIEW_PULLDOWN_CLASS + "-indicator",
- SCROLLVIEW_PULLDOWN_TEXT_CLASS = SCROLLVIEW_PULLDOWN_CLASS + "-text",
- SCROLLVIEW_REACHBOTTOM_CLASS = SCROLLVIEW_CLASS + "-scrollbottom",
- SCROLLVIEW_REACHBOTTOM_INDICATOR_CLASS = SCROLLVIEW_REACHBOTTOM_CLASS + "-indicator",
- SCROLLVIEW_REACHBOTTOM_TEXT_CLASS = SCROLLVIEW_REACHBOTTOM_CLASS + "-text",
- SCROLLVIEW_LOADPANEL = SCROLLVIEW_CLASS + "-loadpanel";
- DX.registerComponent("dxScrollView", ui.dxScrollable.inherit({
- _setDefaultOptions: function() {
- this.callBase();
- this.option({
- pullingDownText: Globalize.localize("dxScrollView-pullingDownText"),
- pulledDownText: Globalize.localize("dxScrollView-pulledDownText"),
- refreshingText: Globalize.localize("dxScrollView-refreshingText"),
- reachBottomText: Globalize.localize("dxScrollView-reachBottomText"),
- pullDownAction: null,
- reachBottomAction: null,
- refreshStrategy: "pullDown"
- })
- },
- _defaultOptionsRules: function() {
- return this.callBase().slice(0).concat([{
- device: function(device) {
- return DevExpress.devices.real().platform === "android"
- },
- options: {refreshStrategy: "swipeDown"}
- }, {
- device: function(device) {
- return DevExpress.devices.real().platform === "win8"
- },
- options: {refreshStrategy: "slideDown"}
- }])
- },
- _init: function() {
- this.callBase();
- this._loadingIndicatorEnabled = true
- },
- _initMarkup: function() {
- this.callBase();
- this._element().addClass(SCROLLVIEW_CLASS);
- this._initContent();
- this._initTopPocket();
- this._initBottomPocket();
- this._initLoadPanel()
- },
- _initContent: function() {
- var $content = $("<div>").addClass(SCROLLVIEW_CONTENT_CLASS);
- this._$content.wrapInner($content)
- },
- _initTopPocket: function() {
- var $topPocket = this._$topPocket = $("<div>").addClass(SCROLLVIEW_TOP_POCKET_CLASS),
- $pullDown = this._$pullDown = $("<div>").addClass(SCROLLVIEW_PULLDOWN_CLASS);
- $topPocket.append($pullDown);
- this._$content.prepend($topPocket)
- },
- _initBottomPocket: function() {
- var $bottomPocket = this._$bottomPocket = $("<div>").addClass(SCROLLVIEW_BOTTOM_POCKET_CLASS),
- $reachBottom = this._$reachBottom = $("<div>").addClass(SCROLLVIEW_REACHBOTTOM_CLASS),
- $loadContainer = $("<div>").addClass(SCROLLVIEW_REACHBOTTOM_INDICATOR_CLASS),
- $loadIndicator = $("<div>").dxLoadIndicator(),
- $text = this._$reachBottomText = $("<div>").addClass(SCROLLVIEW_REACHBOTTOM_TEXT_CLASS);
- this._updateReachBottomText();
- $reachBottom.append($loadContainer.append($loadIndicator)).append($text);
- $bottomPocket.append($reachBottom);
- this._$content.append($bottomPocket)
- },
- _initLoadPanel: function() {
- this._loadPanel = $("<div>").addClass(SCROLLVIEW_LOADPANEL).appendTo(this._element()).dxLoadPanel({
- shading: false,
- delay: 400,
- position: {of: this._element()}
- }).dxLoadPanel("instance")
- },
- _updateReachBottomText: function() {
- this._$reachBottomText.text(this.option("reachBottomText"))
- },
- _createStrategy: function() {
- var strategyName = this.option("useNative") ? this.option("refreshStrategy") : "simulated";
- var strategyClass = ui.scrollViewRefreshStrategies[strategyName];
- if (!strategyClass)
- throw Error("Unknown dxScrollView refresh strategy " + this.option("refreshStrategy"));
- this._strategy = new strategyClass(this);
- this._strategy.pullDownCallbacks.add($.proxy(this._handlePullDown, this));
- this._strategy.releaseCallbacks.add($.proxy(this._handleRelease, this));
- this._strategy.reachBottomCallbacks.add($.proxy(this._handleReachBottom, this))
- },
- _createActions: function() {
- this.callBase();
- this._pullDownAction = this._createActionByOption("pullDownAction", {excludeValidators: ["gesture"]});
- this._reachBottomAction = this._createActionByOption("reachBottomAction", {excludeValidators: ["gesture"]});
- this._pullDownEnable(!!this.option("pullDownAction") && !DX.designMode);
- this._reachBottomEnable(!!this.option("reachBottomAction") && !DX.designMode)
- },
- _pullDownEnable: function(enabled) {
- this._$pullDown.toggle(enabled);
- this._strategy.pullDownEnable(enabled)
- },
- _reachBottomEnable: function(enabled) {
- this._$reachBottom.toggle(enabled);
- this._strategy.reachBottomEnable(enabled)
- },
- _handlePullDown: function() {
- this._loadingIndicator(false);
- this._pullDownLoading()
- },
- _loadingIndicator: function(value) {
- if (arguments.length < 1)
- return this._loadingIndicatorEnabled;
- this._loadingIndicatorEnabled = value
- },
- _pullDownLoading: function() {
- this.startLoading();
- this._pullDownAction()
- },
- _handleReachBottom: function() {
- this._loadingIndicator(false);
- this._reachBottomLoading()
- },
- _reachBottomLoading: function() {
- this.startLoading();
- this._reachBottomAction()
- },
- _handleRelease: function() {
- this.finishLoading();
- this._loadingIndicator(true)
- },
- _optionChanged: function(optionName, optionValue) {
- switch (optionName) {
- case"pullDownAction":
- case"reachBottomAction":
- this._createActions();
- break;
- case"pullingDownText":
- case"pulledDownText":
- case"refreshingText":
- case"refreshStrategy":
- this._invalidate();
- break;
- case"reachBottomText":
- this._updateReachBottomText();
- break;
- default:
- this.callBase.apply(this, arguments)
- }
- },
- content: function() {
- return this._$content.children().eq(1)
- },
- release: function(preventReachBottom) {
- if (preventReachBottom !== undefined)
- this.toggleLoading(!preventReachBottom);
- return this._strategy.release()
- },
- toggleLoading: function(showOrHide) {
- this._reachBottomEnable(showOrHide)
- },
- isFull: function() {
- return this.content().height() >= this._$container.height()
- },
- refresh: function() {
- if (!this.option("pullDownAction"))
- return;
- this._strategy.pendingRelease();
- this._pullDownLoading()
- },
- startLoading: function() {
- if (this._loadingIndicator() && this._element().is(":visible"))
- this._loadPanel.show();
- this._lock()
- },
- finishLoading: function() {
- if (this._loadingIndicator())
- this._loadPanel.hide();
- this._unlock()
- },
- _dispose: function() {
- this.callBase();
- if (this._loadPanel)
- this._loadPanel._element().remove()
- }
- }));
- ui.scrollViewRefreshStrategies = {}
- })(jQuery, DevExpress);
- /*! Module widgets-base, file ui.scrollView.native.pullDown.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- math = Math;
- var SCROLLVIEW_PULLDOWN_REFRESHING_CLASS = "dx-scrollview-pull-down-loading",
- SCROLLVIEW_PULLDOWN_READY_CLASS = "dx-scrollview-pull-down-ready",
- SCROLLVIEW_PULLDOWN_IMAGE_CLASS = "dx-scrollview-pull-down-image",
- SCROLLVIEW_PULLDOWN_INDICATOR_CLASS = "dx-scrollview-pull-down-indicator",
- SCROLLVIEW_PULLDOWN_TEXT_CLASS = "dx-scrollview-pull-down-text",
- STATE_RELEASED = 0,
- STATE_READY = 1,
- STATE_REFRESHING = 2,
- STATE_LOADING = 3;
- var SCROLLVIEW_CONTENT_PADDING = 2;
- var PullDownNativeScrollViewStrategy = ui.NativeScrollableStrategy.inherit({
- _init: function(scrollView) {
- this.callBase(scrollView);
- this._$topPocket = scrollView._$topPocket;
- this._$pullDown = scrollView._$pullDown;
- this._$bottomPocket = scrollView._$bottomPocket;
- this._$refreshingText = scrollView._$refreshingText;
- this._$scrollViewContent = scrollView.content();
- this._initCallbacks()
- },
- _initCallbacks: function() {
- this.pullDownCallbacks = $.Callbacks();
- this.releaseCallbacks = $.Callbacks();
- this.reachBottomCallbacks = $.Callbacks()
- },
- render: function() {
- this.callBase();
- this._renderPullDown();
- this._releaseState()
- },
- _renderPullDown: function() {
- var $image = $("<div>").addClass(SCROLLVIEW_PULLDOWN_IMAGE_CLASS),
- $loadContainer = $("<div>").addClass(SCROLLVIEW_PULLDOWN_INDICATOR_CLASS),
- $loadIndicator = $("<div>").dxLoadIndicator(),
- $text = this._$pullDownText = $("<div>").addClass(SCROLLVIEW_PULLDOWN_TEXT_CLASS);
- this._$pullingDownText = $("<div>").text(this.option("pullingDownText")).appendTo($text);
- this._$pulledDownText = $("<div>").text(this.option("pulledDownText")).appendTo($text);
- this._$refreshingText = $("<div>").text(this.option("refreshingText")).appendTo($text);
- this._$pullDown.empty().append($image).append($loadContainer.append($loadIndicator)).append($text)
- },
- _releaseState: function() {
- this._state = STATE_RELEASED;
- this._refreshPullDownText()
- },
- _refreshPullDownText: function() {
- this._$pullingDownText.css("opacity", this._state === STATE_RELEASED ? 1 : 0);
- this._$pulledDownText.css("opacity", this._state === STATE_READY ? 1 : 0);
- this._$refreshingText.css("opacity", this._state === STATE_REFRESHING ? 1 : 0)
- },
- update: function() {
- this.callBase();
- this._setTopPocketOffset()
- },
- _updateDimensions: function() {
- this.callBase();
- this._topPocketSize = this._$topPocket.height();
- this._bottomPocketSize = this._$bottomPocket.height();
- this._scrollOffset = this._$container.height() - this._$content.height();
- this._pushBackFromBoundary()
- },
- _allowedDirections: function() {
- var allowedDirections = this.callBase();
- allowedDirections.vertical = allowedDirections.vertical || this._pullDownEnabled;
- return allowedDirections
- },
- _setTopPocketOffset: function() {
- this._$topPocket.css({top: -this._topPocketSize})
- },
- handleEnd: function() {
- this._complete()
- },
- handleStop: function() {
- this._complete()
- },
- _complete: function() {
- if (this._state === STATE_READY) {
- this._setPullDownOffset(this._topPocketSize);
- clearTimeout(this._pullDownRefreshTimeout);
- this._pullDownRefreshTimeout = setTimeout($.proxy(function() {
- this._pullDownRefreshing()
- }, this), 400)
- }
- },
- _setPullDownOffset: function(offset) {
- DX.translator.move(this._$topPocket, {top: offset});
- DX.translator.move(this._$scrollViewContent, {top: offset})
- },
- handleScroll: function(e) {
- this.callBase(e);
- this._pushBackFromBoundary();
- if (this._state === STATE_REFRESHING)
- return;
- this._location = this.location().top;
- if (this._isPullDown())
- this._pullDownReady();
- else if (this._isReachBottom())
- this._reachBottom();
- else
- this._stateReleased()
- },
- _pushBackFromBoundary: function() {
- var scrollTopPos = this._$container.scrollTop(),
- scrollBottomPos = this._scrollOffset + scrollTopPos - SCROLLVIEW_CONTENT_PADDING;
- if (!scrollTopPos)
- this._$container.scrollTop(1);
- else if (!scrollBottomPos)
- this._$container.scrollTop(1 - this._scrollOffset)
- },
- _isPullDown: function() {
- return this._pullDownEnabled && this._location >= this._topPocketSize
- },
- _isReachBottom: function() {
- return this._reachBottomEnabled && this._location <= this._scrollOffset + this._bottomPocketSize
- },
- _reachBottom: function() {
- if (this._state === STATE_LOADING)
- return;
- this._state = STATE_LOADING;
- this.reachBottomCallbacks.fire()
- },
- _pullDownReady: function() {
- if (this._state === STATE_READY)
- return;
- this._state = STATE_READY;
- this._$pullDown.addClass(SCROLLVIEW_PULLDOWN_READY_CLASS);
- this._refreshPullDownText()
- },
- _stateReleased: function() {
- if (this._state === STATE_RELEASED)
- return;
- this._$pullDown.removeClass(SCROLLVIEW_PULLDOWN_REFRESHING_CLASS).removeClass(SCROLLVIEW_PULLDOWN_READY_CLASS);
- this._releaseState()
- },
- _pullDownRefreshing: function() {
- if (this._state === STATE_REFRESHING)
- return;
- this._state = STATE_REFRESHING;
- this._$pullDown.addClass(SCROLLVIEW_PULLDOWN_REFRESHING_CLASS).removeClass(SCROLLVIEW_PULLDOWN_READY_CLASS);
- this._refreshPullDownText();
- this.pullDownCallbacks.fire()
- },
- pullDownEnable: function(enabled) {
- this._pullDownEnabled = enabled
- },
- reachBottomEnable: function(enabled) {
- this._reachBottomEnabled = enabled
- },
- pendingRelease: function() {
- this._state = STATE_READY
- },
- release: function() {
- var deferred = $.Deferred();
- this._updateDimensions();
- clearTimeout(this._releaseTimeout);
- this._releaseTimeout = setTimeout($.proxy(function() {
- this._setPullDownOffset(0);
- this._stateReleased();
- this.releaseCallbacks.fire();
- this._updateAction();
- deferred.resolve()
- }, this), 400);
- return deferred.promise()
- },
- location: function() {
- return {
- left: -this._$container.scrollLeft(),
- top: 1 - this._$container.scrollTop()
- }
- },
- scrollBy: function(distance) {
- var location = this.location();
- this._$container.scrollTop(-location.top - distance.top + 1);
- this._$container.scrollLeft(-location.left - distance.left)
- },
- dispose: function() {
- clearTimeout(this._pullDownRefreshTimeout);
- clearTimeout(this._releaseTimeout);
- this.callBase()
- }
- });
- ui.scrollViewRefreshStrategies.pullDown = PullDownNativeScrollViewStrategy
- })(jQuery, DevExpress);
- /*! Module widgets-base, file ui.scrollView.native.swipeDown.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- events = ui.events,
- math = Math;
- var SCROLLVIEW_PULLDOWN_REFRESHING_CLASS = "dx-scrollview-pull-down-loading",
- SCROLLVIEW_OBSOLETE_ANDROID_CLASS = "dx-scrollview-obsolete-android-browser",
- PULLDOWN_HEIGHT = 160,
- STATE_RELEASED = 0,
- STATE_READY = 1,
- STATE_REFRESHING = 2,
- STATE_LOADING = 3,
- STATE_TOUCHED = 4,
- STATE_PULLED = 5;
- var SwipeDownNativeScrollViewStrategy = ui.NativeScrollableStrategy.inherit({
- _init: function(scrollView) {
- this.callBase(scrollView);
- this._$topPocket = scrollView._$topPocket;
- this._$bottomPocket = scrollView._$bottomPocket;
- this._$pullDown = scrollView._$pullDown;
- this._$scrollViewContent = scrollView.content();
- this._initCallbacks();
- this._releaseState();
- this._location = 0
- },
- _initCallbacks: function() {
- this.pullDownCallbacks = $.Callbacks();
- this.releaseCallbacks = $.Callbacks();
- this.reachBottomCallbacks = $.Callbacks()
- },
- render: function() {
- this.callBase();
- this._renderPullDown()
- },
- _renderPullDown: function() {
- this._$pullDown.empty().append($("<div class='dx-scrollview-pulldown-pointer1'>")).append($("<div class='dx-scrollview-pulldown-pointer2'>")).append($("<div class='dx-scrollview-pulldown-pointer3'>")).append($("<div class='dx-scrollview-pulldown-pointer4'>"))
- },
- _releaseState: function() {
- this._state = STATE_RELEASED;
- this._$pullDown.css({
- width: "0%",
- opacity: 0
- });
- this._updateDimensions()
- },
- _updateDimensions: function() {
- this.callBase();
- this._topPocketSize = this._$topPocket.height();
- this._bottomPocketSize = this._$bottomPocket.height();
- this._scrollOffset = this._$container.height() - this._$content.height()
- },
- _allowedDirections: function() {
- var allowedDirections = this.callBase();
- allowedDirections.vertical = allowedDirections.vertical || this._pullDownEnabled;
- return allowedDirections
- },
- handleInit: function(e) {
- this.callBase(e);
- if (this._state === STATE_RELEASED && this._location === 0) {
- this._startClientY = events.eventData(e.originalEvent).y;
- this._state = STATE_TOUCHED
- }
- },
- handleMove: function(e) {
- this.callBase(e);
- this._deltaY = events.eventData(e.originalEvent).y - this._startClientY;
- if (this._state === STATE_TOUCHED)
- if (this._pullDownEnabled && this._deltaY > 0) {
- e.preventDefault();
- this._state = STATE_PULLED
- }
- else
- this._complete();
- if (this._state === STATE_PULLED) {
- if (this._deltaY < 0) {
- this._complete();
- return
- }
- this._$pullDown.css({
- opacity: 1,
- width: math.min(math.abs(this._deltaY * 100 / PULLDOWN_HEIGHT), 100) + "%"
- });
- if (this._isPullDown())
- this._pullDownRefreshing()
- }
- },
- _isPullDown: function() {
- return this._pullDownEnabled && this._deltaY >= PULLDOWN_HEIGHT
- },
- handleEnd: function() {
- this._complete()
- },
- handleStop: function() {
- this._complete()
- },
- _complete: function() {
- if (this._state === STATE_TOUCHED || this._state === STATE_PULLED)
- this._releaseState()
- },
- handleScroll: function(e) {
- this.callBase(e);
- if (this._state === STATE_REFRESHING)
- return;
- var currentLocation = this.location().top,
- scrollDelta = this._location - currentLocation;
- this._location = currentLocation;
- if (scrollDelta > 0 && this._isReachBottom())
- this._reachBottom();
- else
- this._stateReleased()
- },
- _isReachBottom: function() {
- return this._reachBottomEnabled && this._location <= this._scrollOffset + this._bottomPocketSize
- },
- _reachBottom: function() {
- this.reachBottomCallbacks.fire()
- },
- _stateReleased: function() {
- if (this._state === STATE_RELEASED)
- return;
- this._$pullDown.removeClass(SCROLLVIEW_PULLDOWN_REFRESHING_CLASS);
- this._releaseState()
- },
- _pullDownRefreshing: function() {
- if (this._state === STATE_REFRESHING)
- return;
- this._state = STATE_REFRESHING;
- clearTimeout(this._pullDownRefreshTimeout);
- this._pullDownRefreshTimeout = setTimeout($.proxy(function() {
- this._$pullDown.addClass(SCROLLVIEW_PULLDOWN_REFRESHING_CLASS);
- this.pullDownCallbacks.fire()
- }, this), 400)
- },
- pullDownEnable: function(enabled) {
- this._$topPocket.toggle(enabled);
- this._pullDownEnabled = enabled
- },
- reachBottomEnable: function(enabled) {
- this._reachBottomEnabled = enabled
- },
- pendingRelease: function() {
- this._state = STATE_READY
- },
- release: function() {
- var deferred = $.Deferred();
- this._updateDimensions();
- clearTimeout(this._releaseTimeout);
- this._releaseTimeout = setTimeout($.proxy(function() {
- this._stateReleased();
- this.releaseCallbacks.fire();
- this._updateAction();
- deferred.resolve()
- }, this), 800);
- return deferred.promise()
- },
- dispose: function() {
- clearTimeout(this._pullDownRefreshTimeout);
- clearTimeout(this._releaseTimeout);
- this.callBase()
- }
- });
- ui.scrollViewRefreshStrategies.swipeDown = SwipeDownNativeScrollViewStrategy
- })(jQuery, DevExpress);
- /*! Module widgets-base, file ui.scrollView.native.slideDown.js */
- (function($, DX, undefined) {
- var ui = DX.ui;
- var DX_SLIDE_DOWN_NATIVE_SCROLLVIEW_STRATEGY = "dxSlideDownNativeScrollViewStrategy",
- STATE_RELEASED = 0,
- STATE_READY = 1,
- STATE_LOADING = 2,
- LOADING_HEIGHT = 80;
- var SlideDownNativeScrollViewStrategy = ui.NativeScrollableStrategy.inherit({
- _init: function(scrollView) {
- this.callBase(scrollView);
- this._$topPocket = scrollView._$topPocket;
- this._$bottomPocket = scrollView._$bottomPocket;
- this._initCallbacks()
- },
- _initCallbacks: function() {
- this.pullDownCallbacks = $.Callbacks();
- this.releaseCallbacks = $.Callbacks();
- this.reachBottomCallbacks = $.Callbacks()
- },
- render: function() {
- this.callBase();
- this._renderPullDown();
- this._renderBottom();
- this._releaseState();
- this._updateDimensions()
- },
- _renderPullDown: function() {
- this._$topPocket.empty()
- },
- _renderBottom: function() {
- this._$bottomPocket.empty().append("<progress>")
- },
- _releaseState: function() {
- if (this._state === STATE_RELEASED)
- return;
- this._state = STATE_RELEASED
- },
- _updateDimensions: function() {
- this._scrollOffset = this._$container.prop("scrollHeight") - this._$container.prop("clientHeight");
- this._containerSize = {
- height: this._$container.prop("clientHeight"),
- width: this._$container.prop("clientWidth")
- };
- this._contentSize = this._componentContentSize = {
- height: this._$container.prop("scrollHeight"),
- width: this._$container.prop("scrollWidth")
- }
- },
- handleScroll: function(e) {
- this.callBase(e);
- if (this._isReachBottom(this._lastLocation.top))
- this._reachBottom()
- },
- _isReachBottom: function(location) {
- this._scrollContent = this._$container.prop("scrollHeight") - this._$container.prop("clientHeight");
- return this._reachBottomEnabled && location < -this._scrollContent + LOADING_HEIGHT
- },
- _reachBottom: function() {
- if (this._state === STATE_LOADING)
- return;
- this._state = STATE_LOADING;
- this.reachBottomCallbacks.fire()
- },
- pullDownEnable: function(enabled) {
- this._pullDownEnabled = enabled
- },
- reachBottomEnable: function(enabled) {
- this._reachBottomEnabled = enabled;
- this._$bottomPocket.toggle(enabled)
- },
- pendingRelease: function() {
- this._state = STATE_READY
- },
- release: function() {
- var deferred = $.Deferred();
- this._state = STATE_RELEASED;
- this.releaseCallbacks.fire();
- this.update();
- return deferred.resolve().promise()
- }
- });
- ui.scrollViewRefreshStrategies.slideDown = SlideDownNativeScrollViewStrategy
- })(jQuery, DevExpress);
- /*! Module widgets-base, file ui.scrollView.simulated.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- math = Math;
- var SCROLLVIEW_PULLDOWN_REFRESHING_CLASS = "dx-scrollview-pull-down-loading",
- SCROLLVIEW_PULLDOWN_READY_CLASS = "dx-scrollview-pull-down-ready",
- SCROLLVIEW_PULLDOWN_IMAGE_CLASS = "dx-scrollview-pull-down-image",
- SCROLLVIEW_PULLDOWN_INDICATOR_CLASS = "dx-scrollview-pull-down-indicator",
- SCROLLVIEW_PULLDOWN_TEXT_CLASS = "dx-scrollview-pull-down-text",
- STATE_RELEASED = 0,
- STATE_READY = 1,
- STATE_REFRESHING = 2,
- STATE_LOADING = 3;
- var ScrollViewScroller = ui.ScrollViewScroller = ui.Scroller.inherit({
- ctor: function() {
- this.callBase.apply(this, arguments);
- this._initCallbacks();
- this._releaseState()
- },
- _releaseState: function() {
- this._state = STATE_RELEASED;
- this._refreshPullDownText()
- },
- _refreshPullDownText: function() {
- this._$pullingDownText.css("opacity", this._state === STATE_RELEASED ? 1 : 0);
- this._$pulledDownText.css("opacity", this._state === STATE_READY ? 1 : 0);
- this._$refreshingText.css("opacity", this._state === STATE_REFRESHING ? 1 : 0)
- },
- _initCallbacks: function() {
- this.pullDownCallbacks = $.Callbacks();
- this.releaseCallbacks = $.Callbacks();
- this.reachBottomCallbacks = $.Callbacks()
- },
- _updateBounds: function() {
- var considerPockets = this._direction !== "horizontal";
- this._topPocketSize = considerPockets ? this._$topPocket[this._dimension]() : 0;
- this._bottomPocketSize = considerPockets ? this._$bottomPocket[this._dimension]() : 0;
- this._updateOffsets()
- },
- _updateOffsets: function() {
- this._minOffset = math.min(this._containerSize() - this._contentSize() + this._bottomPocketSize, -this._topPocketSize);
- this._maxOffset = -this._topPocketSize;
- this._bottomBound = this._minOffset - this._bottomPocketSize
- },
- _updateScrollbar: function() {
- this._scrollbar.option({
- containerSize: this._containerSize(),
- contentSize: this._contentSize() - this._topPocketSize - this._bottomPocketSize
- })
- },
- _moveContent: function() {
- this.callBase();
- if (this._isPullDown())
- this._pullDownReady();
- else if (this._isReachBottom())
- this._reachBottomReady();
- else if (this._state !== STATE_RELEASED)
- this._stateReleased()
- },
- _moveScrollbar: function() {
- this._scrollbar.moveTo(this._topPocketSize + this._location)
- },
- _isPullDown: function() {
- return this._pullDownEnabled && this._location >= 0
- },
- _isReachBottom: function() {
- return this._reachBottomEnabled && this._location <= this._bottomBound
- },
- _scrollComplete: function() {
- if (this._inBounds() && this._state === STATE_READY)
- this._pullDownRefreshing();
- else if (this._inBounds() && this._state === STATE_LOADING)
- this._reachBottomLoading();
- else
- this.callBase()
- },
- _reachBottomReady: function() {
- if (this._state === STATE_LOADING)
- return;
- this._state = STATE_LOADING;
- this._minOffset = math.min(this._containerSize() - this._contentSize(), 0)
- },
- _reachBottomLoading: function() {
- this.reachBottomCallbacks.fire()
- },
- _pullDownReady: function() {
- if (this._state === STATE_READY)
- return;
- this._state = STATE_READY;
- this._maxOffset = 0;
- this._$pullDown.addClass(SCROLLVIEW_PULLDOWN_READY_CLASS);
- this._refreshPullDownText()
- },
- _stateReleased: function() {
- if (this._state === STATE_RELEASED)
- return;
- this._releaseState();
- this._updateOffsets();
- this._$pullDown.removeClass(SCROLLVIEW_PULLDOWN_REFRESHING_CLASS).removeClass(SCROLLVIEW_PULLDOWN_READY_CLASS);
- this.releaseCallbacks.fire()
- },
- _pullDownRefreshing: function() {
- if (this._state === STATE_REFRESHING)
- return;
- this._state = STATE_REFRESHING;
- this._$pullDown.addClass(SCROLLVIEW_PULLDOWN_REFRESHING_CLASS).removeClass(SCROLLVIEW_PULLDOWN_READY_CLASS);
- this._refreshPullDownText();
- this.pullDownCallbacks.fire()
- },
- _handleRelease: function() {
- if (this._state === STATE_RELEASED)
- this._moveToBounds();
- this._update();
- return DX.utils.executeAsync($.proxy(this._release, this))
- },
- _release: function() {
- this._stateReleased();
- this._scrollComplete()
- },
- _handleReachBottomEnabling: function(enabled) {
- if (this._reachBottomEnabled === enabled)
- return;
- this._reachBottomEnabled = enabled;
- this._updateBounds()
- },
- _handlePullDownEnabling: function(enabled) {
- if (this._pullDownEnabled === enabled)
- return;
- this._pullDownEnabled = enabled;
- this._considerTopPocketChange();
- this._handleUpdate()
- },
- _considerTopPocketChange: function() {
- this._location -= this._$topPocket.height() || -this._topPocketSize;
- this._move()
- },
- _handlePendingRelease: function() {
- this._state = STATE_READY
- }
- });
- var SimulatedScrollViewStrategy = ui.SimulatedScrollableStrategy.inherit({
- _init: function(scrollView) {
- this.callBase(scrollView);
- this._$pullDown = scrollView._$pullDown;
- this._$topPocket = scrollView._$topPocket;
- this._$bottomPocket = scrollView._$bottomPocket;
- this._initCallbacks()
- },
- _initCallbacks: function() {
- this.pullDownCallbacks = $.Callbacks();
- this.releaseCallbacks = $.Callbacks();
- this.reachBottomCallbacks = $.Callbacks()
- },
- render: function() {
- this._renderPullDown();
- this.callBase()
- },
- _renderPullDown: function() {
- var $image = $("<div>").addClass(SCROLLVIEW_PULLDOWN_IMAGE_CLASS),
- $loadContainer = $("<div>").addClass(SCROLLVIEW_PULLDOWN_INDICATOR_CLASS),
- $loadIndicator = $("<div>").dxLoadIndicator(),
- $text = this._$pullDownText = $("<div>").addClass(SCROLLVIEW_PULLDOWN_TEXT_CLASS);
- this._$pullingDownText = $("<div>").text(this.option("pullingDownText")).appendTo($text);
- this._$pulledDownText = $("<div>").text(this.option("pulledDownText")).appendTo($text);
- this._$refreshingText = $("<div>").text(this.option("refreshingText")).appendTo($text);
- this._$pullDown.empty().append($image).append($loadContainer.append($loadIndicator)).append($text)
- },
- pullDownEnable: function(enabled) {
- this._handleEvent("PullDownEnabling", enabled)
- },
- reachBottomEnable: function(enabled) {
- this._handleEvent("ReachBottomEnabling", enabled)
- },
- _createScroller: function(direction) {
- var that = this;
- var scroller = that._scrollers[direction] = new ScrollViewScroller(that._scrollerOptions(direction));
- scroller.pullDownCallbacks.add(function() {
- that.pullDownCallbacks.fire()
- });
- scroller.releaseCallbacks.add(function() {
- that.releaseCallbacks.fire()
- });
- scroller.reachBottomCallbacks.add(function() {
- that.reachBottomCallbacks.fire()
- })
- },
- _scrollerOptions: function(direction) {
- return $.extend(this.callBase(direction), {
- $topPocket: this._$topPocket,
- $bottomPocket: this._$bottomPocket,
- $pullDown: this._$pullDown,
- $pullDownText: this._$pullDownText,
- $pullingDownText: this._$pullingDownText,
- $pulledDownText: this._$pulledDownText,
- $refreshingText: this._$refreshingText
- })
- },
- pendingRelease: function() {
- this._handleEvent("PendingRelease")
- },
- release: function() {
- return this._handleEvent("Release").done(this._updateAction)
- }
- });
- ui.scrollViewRefreshStrategies.simulated = SimulatedScrollViewStrategy
- })(jQuery, DevExpress);
- /*! Module widgets-base, file ui.map.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- events = ui.events,
- utils = DX.utils,
- winJS = DX.support.winJS,
- wrapToArray = utils.wrapToArray,
- removeDublicates = utils.removeDublicates,
- titleize = DX.inflector.titleize;
- ui.MapProvider = DX.Class.inherit({
- _defaultRouteWeight: function() {
- return 5
- },
- _defaultRouteOpacity: function() {
- return .5
- },
- _defaultRouteColor: function() {
- return "#0000FF"
- },
- ctor: function(map, $container) {
- this._mapWidget = map;
- this._$container = $container
- },
- load: $.noop,
- render: function() {
- var deferred = $.Deferred(),
- that = this;
- this._renderImpl().done(function() {
- var markersPromise = that.addMarkers(that._option("markers"));
- var routesPromise = that.addRoutes(that._option("routes"));
- $.when(markersPromise, routesPromise).done(function() {
- deferred.resolve(true)
- })
- });
- return deferred.promise()
- },
- _renderImpl: DX.abstract,
- updateDimensions: DX.abstract,
- updateMapType: DX.abstract,
- updateCenter: DX.abstract,
- updateZoom: DX.abstract,
- updateControls: DX.abstract,
- updateMarkers: function(markerOptionsToRemove, markerOptionsToAdd) {
- var deferred = $.Deferred(),
- that = this;
- this.removeMarkers(markerOptionsToRemove).done(function() {
- that.addMarkers(markerOptionsToAdd).done(function() {
- deferred.resolve.apply(deferred, arguments)
- })
- });
- return deferred.promise()
- },
- addMarkers: DX.abstract,
- removeMarkers: DX.abstract,
- adjustViewport: DX.abstract,
- updateRoutes: function(routeOptionsToRemove, routeOptionsToAdd) {
- var deferred = $.Deferred(),
- that = this;
- this.removeRoutes(routeOptionsToRemove).done(function() {
- that.addRoutes(routeOptionsToAdd).done(function() {
- deferred.resolve.apply(deferred, arguments)
- })
- });
- return deferred.promise()
- },
- addRoutes: DX.abstract,
- removeRoutes: DX.abstract,
- clean: DX.abstract,
- cancelEvents: false,
- map: function() {
- return this._map
- },
- mapRendered: function() {
- return !!this._map
- },
- _option: function(name, value) {
- if (value === undefined)
- return this._mapWidget.option(name);
- this._mapWidget.setOptionSilent(name, value)
- },
- _keyOption: function(providerName) {
- var key = this._option("key");
- return key[providerName] === undefined ? key : key[providerName]
- },
- _parseTooltipOptions: function(option) {
- return {
- text: option.text || option,
- visible: option.isShown || false
- }
- },
- _addEventNamespace: function(name) {
- return events.addNamespace(name, this._mapWidget.NAME)
- },
- _createAction: function() {
- var mapWidget = this._mapWidget;
- return mapWidget._createAction.apply(mapWidget, arguments)
- },
- _fireAction: function(name, actionArguments) {
- var option = this._option(name);
- if (option)
- this._createAction(option)(actionArguments)
- },
- _fireClickAction: function(actionArguments) {
- this._fireAction("clickAction", actionArguments)
- },
- _fireMarkerAddedAction: function(actionArguments) {
- this._fireAction("markerAddedAction", actionArguments)
- },
- _fireMarkerRemovedAction: function(actionArguments) {
- this._fireAction("markerRemovedAction", actionArguments)
- },
- _fireRouteAddedAction: function(actionArguments) {
- this._fireAction("routeAddedAction", actionArguments)
- },
- _fireRouteRemovedAction: function(actionArguments) {
- this._fireAction("routeRemovedAction", actionArguments)
- }
- });
- var providers = {};
- ui.registerMapProvider = function(name, provider) {
- providers[name] = provider
- };
- var MAP_CLASS = "dx-map",
- MAP_CONTAINER_CLASS = "dx-map-container",
- MAP_SHIELD_CLASS = "dx-map-shield";
- DX.registerComponent("dxMap", ui.Widget.inherit({
- ctor: function() {
- this.callBase.apply(this, arguments);
- this.addMarker = $.proxy(this._addFunction, this, "markers");
- this.removeMarker = $.proxy(this._removeFunction, this, "markers");
- this.addRoute = $.proxy(this._addFunction, this, "routes");
- this.removeRoute = $.proxy(this._removeFunction, this, "routes")
- },
- _addFunction: function(optionName, addingValue) {
- var deferred = $.Deferred(),
- that = this,
- providerDeffered = $.Deferred(),
- optionValue = this.option(optionName),
- addingValues = wrapToArray(addingValue);
- optionValue.push.apply(optionValue, addingValues);
- this._notificationDeffered = providerDeffered;
- this.option(optionName, optionValue);
- providerDeffered.done(function(instance) {
- deferred.resolveWith(that, instance && instance.length > 1 ? [instance] : instance)
- });
- return deferred.promise()
- },
- _removeFunction: function(optionName, removingValue) {
- var deferred = $.Deferred(),
- that = this,
- providerDeffered = $.Deferred(),
- optionValue = this.option(optionName),
- removingValues = wrapToArray(removingValue);
- $.each(removingValues, function(_, removingValue) {
- var index = $.isNumeric(removingValue) ? removingValue : $.inArray(removingValue, optionValue);
- if (index !== -1)
- optionValue.splice(index, 1);
- else
- throw new Error(titleize(optionName.substring(0, optionName.length - 1)) + " '" + removingValue + "' you are trying to remove does not exist");
- });
- this._notificationDeffered = providerDeffered;
- this.option(optionName, optionValue);
- providerDeffered.done(function() {
- deferred.resolveWith(that)
- });
- return deferred.promise()
- },
- _deprecatedOptions: {location: {
- since: "14.1",
- message: "Use the 'center' option instead."
- }},
- _optionAliases: {center: "location"},
- _setDefaultOptions: function() {
- this.callBase();
- this.option({
- center: {
- lat: 0,
- lng: 0
- },
- location: {
- lat: 0,
- lng: 0
- },
- width: 300,
- height: 300,
- zoom: 1,
- type: "roadmap",
- provider: "google",
- autoAdjust: true,
- markers: [],
- markerIconSrc: null,
- markerAddedAction: null,
- markerRemovedAction: null,
- routes: [],
- routeAddedAction: null,
- routeRemovedAction: null,
- key: {
- bing: "",
- google: "",
- googleStatic: ""
- },
- controls: false,
- readyAction: null,
- updateAction: null,
- clickAction: null
- })
- },
- _init: function() {
- this._checkMarkersOption(this.option("markers"));
- this._checkRoutesOption(this.option("routes"));
- this.callBase();
- this._initContainer();
- this._grabEvents();
- this._initProvider();
- this._cleanRenderedMarkers();
- this._cleanRenderedRoutes()
- },
- _cleanRenderedMarkers: function() {
- this._renderedMarkers = []
- },
- _cleanRenderedRoutes: function(routes) {
- this._renderedRoutes = []
- },
- _checkMarkersOption: function(markers) {
- if (!$.isArray(markers))
- throw new Error("Markers option should be an array");
- },
- _checkRoutesOption: function(routes) {
- if (!$.isArray(routes))
- throw new Error("Routes option should be an array");
- },
- _visibilityChanged: function(visible) {
- if (visible)
- this._dimensionChanged()
- },
- _dimensionChanged: function() {
- this._execAsyncProviderAction("updateDimensions")
- },
- _initContainer: function() {
- this._$container = $("<div />").addClass(MAP_CONTAINER_CLASS);
- this._element().append(this._$container)
- },
- _grabEvents: function() {
- var eventName = events.addNamespace("dxpointerdown", this.NAME);
- this._element().on(eventName, $.proxy(this._cancelEvent, this))
- },
- _cancelEvent: function(e) {
- var cancelByProvider = this._provider.cancelEvents && !this.option("disabled");
- if (!DX.designMode && cancelByProvider)
- e.stopPropagation()
- },
- _initProvider: function() {
- var provider = this.option("provider");
- if (winJS && this.option("provider") === "google")
- throw new Error("Google provider cannot be used in winJS application");
- this._cleanProvider();
- this._provider = new providers[provider](this, this._$container);
- this._mapLoader = this._provider.load()
- },
- _render: function() {
- this.callBase();
- this._element().addClass(MAP_CLASS);
- this._renderShield();
- this._execAsyncProviderAction("render").done($.proxy(function() {
- this._saveRenderedMarkers();
- this._saveRenderedRoutes()
- }, this))
- },
- _saveRenderedMarkers: function(markers) {
- markers = markers || this.option("markers");
- this._renderedMarkers = markers.slice()
- },
- _saveRenderedRoutes: function(routes) {
- routes = routes || this.option("routes");
- this._renderedRoutes = routes.slice()
- },
- _renderShield: function() {
- if (DX.designMode || this.option("disabled")) {
- var $shield = $("<div/>").addClass(MAP_SHIELD_CLASS);
- this._element().append($shield)
- }
- else {
- var $shield = this._element().find("." + MAP_SHIELD_CLASS);
- $shield.remove()
- }
- },
- _clean: function() {
- this._cleanProvider();
- this._cleanRenderedMarkers();
- this._cleanRenderedRoutes()
- },
- _cleanProvider: function() {
- if (this._provider)
- this._provider.clean()
- },
- _optionChanged: function(name, value, prevValue) {
- if (this._cancelOptionChange)
- return;
- var notificationDeffered = this._notificationDeffered;
- delete this._notificationDeffered;
- switch (name) {
- case"disabled":
- this._renderShield();
- this.callBase.apply(this, arguments);
- break;
- case"width":
- case"height":
- this.callBase.apply(this, arguments);
- this._dimensionChanged();
- break;
- case"type":
- this._execAsyncProviderAction("updateMapType");
- break;
- case"center":
- this._execAsyncProviderAction("updateCenter");
- break;
- case"zoom":
- this._execAsyncProviderAction("updateZoom");
- break;
- case"controls":
- this._execAsyncProviderAction("updateControls");
- break;
- case"markers":
- this._checkMarkersOption(value);
- this._execAsyncProviderAction("updateMarkers", $.proxy(function() {
- return notificationDeffered ? removeDublicates(this._renderedMarkers, value) : this._renderedMarkers
- }, this), $.proxy(function() {
- return notificationDeffered ? removeDublicates(value, this._renderedMarkers) : value
- }, this)).done($.proxy(function() {
- this._saveRenderedMarkers(value);
- if (notificationDeffered)
- notificationDeffered.resolve.apply(notificationDeffered, arguments)
- }, this));
- break;
- case"markerIconSrc":
- this._execAsyncProviderAction("updateMarkers", prevValue, value);
- break;
- case"autoAdjust":
- this._execAsyncProviderAction("adjustViewport");
- break;
- case"routes":
- this._checkRoutesOption(value);
- this._execAsyncProviderAction("updateRoutes", $.proxy(function() {
- return notificationDeffered ? removeDublicates(this._renderedRoutes, value) : this._renderedRoutes
- }, this), $.proxy(function() {
- return notificationDeffered ? removeDublicates(value, this._renderedRoutes) : value
- }, this)).done($.proxy(function() {
- this._saveRenderedRoutes(value);
- if (notificationDeffered)
- notificationDeffered.resolve.apply(notificationDeffered, arguments)
- }, this));
- break;
- case"key":
- utils.logger.warn("Key option can not be modified after initialization");
- case"provider":
- this._initProvider();
- this._invalidate();
- break;
- case"readyAction":
- case"updateAction":
- case"markerAddedAction":
- case"markerRemovedAction":
- case"routeAddedAction":
- case"routeRemovedAction":
- case"clickAction":
- break;
- default:
- this.callBase.apply(this, arguments)
- }
- },
- _execAsyncProviderAction: function(name) {
- if (!this._provider.mapRendered() && !(name === "render"))
- return $.when(undefined).promise();
- var deferred = $.Deferred(),
- that = this,
- options = $.makeArray(arguments).slice(1);
- $.when(this._mapLoader).done(function() {
- var provider = that._provider;
- $.each(options, function(index, option) {
- if ($.isFunction(option))
- options[index] = option()
- });
- provider[name].apply(provider, options).done(function(mapRefreshed) {
- deferred.resolve.apply(deferred, $.makeArray(arguments).slice(1));
- if (mapRefreshed)
- that._triggerReadyAction();
- else
- that._triggerUpdateAction()
- })
- });
- return deferred.promise()
- },
- _triggerReadyAction: function() {
- this._createActionByOption("readyAction")({originalMap: this._provider.map()})
- },
- _triggerUpdateAction: function() {
- this._createActionByOption("updateAction")()
- },
- setOptionSilent: function(name, value) {
- this._cancelOptionChange = true;
- this.option(name, value);
- this._cancelOptionChange = false
- }
- }))
- })(jQuery, DevExpress);
- /*! Module widgets-base, file ui.map.bing.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- winJS = DX.support.winJS;
- var BING_MAP_READY = "_bingScriptReady",
- BING_URL = "https://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0&s=1&onScriptLoad=" + BING_MAP_READY,
- BING_LOCAL_FILES1 = "ms-appx:///Bing.Maps.JavaScript/js/veapicore.js",
- BING_LOCAL_FILES2 = "ms-appx:///Bing.Maps.JavaScript/js/veapiModules.js",
- BING_CREDENTIALS = "AhuxC0dQ1DBTNo8L-H9ToVMQStmizZzBJdraTSgCzDSWPsA1Qd8uIvFSflzxdaLH",
- MIN_LOCATION_RECT_LENGTH = 0.0000000000000001;
- var msMapsLoader;
- ui.registerMapProvider("bing", ui.MapProvider.inherit({
- _mapType: function(type) {
- var mapTypes = {
- roadmap: Microsoft.Maps.MapTypeId.road,
- hybrid: Microsoft.Maps.MapTypeId.aerial
- };
- return mapTypes[type] || mapTypes.roadmap
- },
- _movementMode: function(type) {
- var movementTypes = {
- driving: Microsoft.Maps.Directions.RouteMode.driving,
- walking: Microsoft.Maps.Directions.RouteMode.walking
- };
- return movementTypes[type] || movementTypes.driving
- },
- _resolveLocation: function(location) {
- var d = $.Deferred();
- if (typeof location === "string") {
- var searchManager = new Microsoft.Maps.Search.SearchManager(this._map);
- var searchRequest = {
- where: location,
- count: 1,
- callback: function(searchResponse) {
- var boundsBox = searchResponse.results[0].location;
- d.resolve(new Microsoft.Maps.Location(boundsBox.latitude, boundsBox.longitude))
- }
- };
- searchManager.geocode(searchRequest)
- }
- else if ($.isPlainObject(location) && $.isNumeric(location.lat) && $.isNumeric(location.lng))
- d.resolve(new Microsoft.Maps.Location(location.lat, location.lng));
- else if ($.isArray(location))
- d.resolve(new Microsoft.Maps.Location(location[0], location[1]));
- return d.promise()
- },
- _normalizeLocation: function(location) {
- return {
- lat: location.latitude,
- lng: location.longitude
- }
- },
- load: function() {
- if (!msMapsLoader) {
- msMapsLoader = $.Deferred();
- window[BING_MAP_READY] = $.proxy(this._mapReady, this);
- if (winJS)
- $.when($.getScript(BING_LOCAL_FILES1), $.getScript(BING_LOCAL_FILES2)).done(function() {
- Microsoft.Maps.loadModule("Microsoft.Maps.Map", {callback: window[BING_MAP_READY]})
- });
- else
- $.getScript(BING_URL)
- }
- this._markers = [];
- this._routes = [];
- return msMapsLoader
- },
- _mapReady: function() {
- try {
- delete window[BING_MAP_READY]
- }
- catch(e) {
- window[BING_MAP_READY] = undefined
- }
- var searchModulePromise = $.Deferred();
- var directionsModulePromise = $.Deferred();
- Microsoft.Maps.loadModule('Microsoft.Maps.Search', {callback: $.proxy(searchModulePromise.resolve, searchModulePromise)});
- Microsoft.Maps.loadModule('Microsoft.Maps.Directions', {callback: $.proxy(directionsModulePromise.resolve, directionsModulePromise)});
- $.when(searchModulePromise, directionsModulePromise).done(function() {
- msMapsLoader.resolve()
- })
- },
- _renderImpl: function() {
- var deferred = $.Deferred(),
- initPromise = $.Deferred(),
- controls = this._option("controls");
- var options = {
- credentials: this._keyOption("bing") || BING_CREDENTIALS,
- mapTypeId: this._mapType(this._option("type")),
- zoom: this._option("zoom"),
- showDashboard: controls,
- showMapTypeSelector: controls,
- showScalebar: controls
- };
- this._map = new Microsoft.Maps.Map(this._$container[0], options);
- var handler = Microsoft.Maps.Events.addHandler(this._map, 'tiledownloadcomplete', $.proxy(initPromise.resolve, initPromise));
- this._viewChangeHandler = Microsoft.Maps.Events.addHandler(this._map, 'viewchange', $.proxy(this._handleViewChange, this));
- this._clickHandler = Microsoft.Maps.Events.addHandler(this._map, 'click', $.proxy(this._handleClickAction, this));
- var locationPromise = this._renderCenter();
- $.when(initPromise, locationPromise).done(function() {
- Microsoft.Maps.Events.removeHandler(handler);
- deferred.resolve()
- });
- return deferred.promise()
- },
- _handleViewChange: function() {
- var center = this._map.getCenter();
- this._option("center", this._normalizeLocation(center));
- if (!this._preventZoomChangeEvent)
- this._option("zoom", this._map.getZoom())
- },
- updateDimensions: function() {
- this._map.setOptions({
- width: this._$container.width(),
- height: this._$container.height()
- });
- return $.Deferred().resolve().promise()
- },
- updateMapType: function() {
- this._map.setView({mapTypeId: this._mapType(this._option("type"))});
- return $.Deferred().resolve().promise()
- },
- updateCenter: function() {
- return this._renderCenter()
- },
- _renderCenter: function() {
- var deferred = $.Deferred(),
- that = this;
- this._resolveLocation(this._option("center")).done(function(location) {
- that._map.setView({
- animate: false,
- center: location
- });
- deferred.resolve()
- });
- return deferred.promise()
- },
- updateZoom: function() {
- this._map.setView({
- animate: false,
- zoom: this._option("zoom")
- });
- return $.Deferred().resolve().promise()
- },
- updateControls: function() {
- this.clean();
- return this.render()
- },
- addMarkers: function(options) {
- var deferred = $.Deferred(),
- that = this;
- var markerPromises = $.map(options, function(options) {
- return that._addMarker(options)
- });
- $.when.apply($, markerPromises).done(function() {
- var instances = $.map($.makeArray(arguments), function(markerObject) {
- return markerObject.pushpin
- });
- deferred.resolve(false, instances)
- });
- return deferred.promise()
- },
- _addMarker: function(options) {
- var that = this;
- return this._renderMarker(options).done(function(markerObject) {
- that._markers.push($.extend({options: options}, markerObject));
- that._updateMarkersBounds();
- that._fitBounds();
- that._fireMarkerAddedAction({
- options: options,
- originalMarker: markerObject.pushpin
- })
- })
- },
- _renderMarker: function(options) {
- var d = $.Deferred(),
- that = this;
- this._resolveLocation(options.location).done(function(location) {
- var pushpin = new Microsoft.Maps.Pushpin(location, {icon: options.iconSrc || that._option("markerIconSrc")});
- that._map.entities.push(pushpin);
- var infobox = that._renderTooltip(location, options.tooltip);
- var handler;
- if (options.clickAction || options.tooltip) {
- var markerClickAction = that._createAction(options.clickAction || $.noop),
- markerNormalizedLocation = that._normalizeLocation(location);
- handler = Microsoft.Maps.Events.addHandler(pushpin, "click", function() {
- markerClickAction({location: markerNormalizedLocation});
- if (infobox)
- infobox.setOptions({visible: true})
- })
- }
- d.resolve({
- location: location,
- pushpin: pushpin,
- infobox: infobox,
- handler: handler
- })
- });
- return d.promise()
- },
- _renderTooltip: function(location, options) {
- if (!options)
- return;
- options = this._parseTooltipOptions(options);
- var infobox = new Microsoft.Maps.Infobox(location, {
- description: options.text,
- offset: new Microsoft.Maps.Point(0, 33),
- visible: options.visible
- });
- this._map.entities.push(infobox, null);
- return infobox
- },
- removeMarkers: function(options) {
- var that = this;
- $.each(options, function(_, options) {
- that._removeMarker(options)
- });
- return $.Deferred().resolve().promise()
- },
- _removeMarker: function(options) {
- var that = this;
- $.each(this._markers, function(markerIndex, markerObject) {
- if (markerObject.options !== options)
- return true;
- var marker = that._markers[markerIndex];
- that._map.entities.remove(marker.pushpin);
- if (marker.infobox)
- that._map.entities.remove(marker.infobox);
- if (marker.handler)
- Microsoft.Maps.Events.removeHandler(marker.handler);
- that._markers.splice(markerIndex, 1);
- that._updateMarkersBounds();
- that._fitBounds();
- that._fireMarkerRemovedAction({options: options});
- return false
- })
- },
- _updateMarkersBounds: function() {
- var that = this;
- this._clearBounds();
- $.each(this._markers, function(_, markerObject) {
- that._extendBounds(markerObject.location)
- })
- },
- _clearMarkers: function() {
- for (var i = 0; this._markers.length > 0; )
- this._removeMarker(this._markers[0].options)
- },
- adjustViewport: function() {
- return this._fitBounds()
- },
- _clearBounds: function() {
- this._bounds = null
- },
- _extendBounds: function(location) {
- if (this._bounds)
- this._bounds = new Microsoft.Maps.LocationRect.fromLocations(this._bounds.getNorthwest(), this._bounds.getSoutheast(), location);
- else
- this._bounds = new Microsoft.Maps.LocationRect(location, MIN_LOCATION_RECT_LENGTH, MIN_LOCATION_RECT_LENGTH)
- },
- _fitBounds: function() {
- var autoAdjust = this._option("autoAdjust");
- if (this._bounds && autoAdjust) {
- var zoomBeforeFitting = this._map.getZoom();
- this._preventZoomChangeEvent = true;
- var bounds = this._bounds.clone();
- bounds.height = bounds.height * 1.1;
- bounds.width = bounds.width * 1.1;
- this._map.setView({
- animate: false,
- bounds: bounds
- });
- var zoomAfterFitting = this._map.getZoom();
- if (zoomBeforeFitting < zoomAfterFitting)
- this._map.setView({
- animate: false,
- zoom: zoomBeforeFitting
- });
- else
- this._option("zoom", zoomAfterFitting);
- delete this._preventZoomChangeEvent
- }
- return $.Deferred().resolve().promise()
- },
- addRoutes: function(options) {
- var deferred = $.Deferred(),
- that = this;
- var routePromises = $.map(options, function(options) {
- return that._addRoute(options)
- });
- $.when.apply($, routePromises).done(function() {
- deferred.resolve(false, $.makeArray(arguments))
- });
- return deferred.promise()
- },
- _addRoute: function(options) {
- var that = this;
- return this._renderRoute(options).done(function(instance) {
- that._routes.push({
- options: options,
- instance: instance
- });
- that._fireRouteAddedAction({
- options: options,
- originalRoute: instance
- })
- })
- },
- _renderRoute: function(options) {
- var d = $.Deferred(),
- that = this;
- var points = $.map(options.locations, function(point) {
- return that._resolveLocation(point)
- });
- $.when.apply($, points).done(function() {
- var locations = $.makeArray(arguments),
- direction = new Microsoft.Maps.Directions.DirectionsManager(that._map),
- color = new DX.Color(options.color || that._defaultRouteColor()).toHex(),
- routeColor = new Microsoft.Maps.Color.fromHex(color);
- routeColor.a = (options.opacity || that._defaultRouteOpacity()) * 255;
- direction.setRenderOptions({
- autoUpdateMapView: false,
- displayRouteSelector: false,
- waypointPushpinOptions: {visible: false},
- drivingPolylineOptions: {
- strokeColor: routeColor,
- strokeThickness: options.weight || that._defaultRouteWeight()
- },
- walkingPolylineOptions: {
- strokeColor: routeColor,
- strokeThickness: options.weight || that._defaultRouteWeight()
- }
- });
- direction.setRequestOptions({
- routeMode: that._movementMode(options.mode),
- routeDraggable: false
- });
- $.each(locations, function(_, location) {
- var waypoint = new Microsoft.Maps.Directions.Waypoint({location: location});
- direction.addWaypoint(waypoint)
- });
- var handler = Microsoft.Maps.Events.addHandler(direction, 'directionsUpdated', function() {
- Microsoft.Maps.Events.removeHandler(handler);
- d.resolve(direction)
- });
- direction.calculateDirections()
- });
- return d.promise()
- },
- removeRoutes: function(options) {
- var that = this;
- $.each(options, function(routeIndex, options) {
- that._removeRoute(options)
- });
- return $.Deferred().resolve().promise()
- },
- _removeRoute: function(options) {
- var that = this;
- $.each(this._routes, function(routeIndex, routeObject) {
- if (routeObject.options !== options)
- return true;
- that._routes[routeIndex].instance.dispose();
- that._routes.splice(routeIndex, 1);
- that._fireRouteRemovedAction({options: options});
- return false
- })
- },
- _clearRoutes: function() {
- for (var i = 0; this._routes.length > 0; )
- this._removeRoute(this._routes[0].options)
- },
- _handleClickAction: function(e) {
- if (e.targetType == "map") {
- var point = new Microsoft.Maps.Point(e.getX(), e.getY()),
- location = e.target.tryPixelToLocation(point);
- this._fireClickAction({location: this._normalizeLocation(location)})
- }
- },
- clean: function() {
- if (this._map) {
- Microsoft.Maps.Events.removeHandler(this._viewChangeHandler);
- Microsoft.Maps.Events.removeHandler(this._clickHandler);
- this._clearMarkers();
- this._clearRoutes();
- this._map.dispose()
- }
- },
- cancelEvents: true
- }));
- if (!ui.dxMap.__internals)
- ui.dxMap.__internals = {};
- $.extend(ui.dxMap.__internals, {remapBingConstant: function(newValue) {
- BING_URL = newValue
- }})
- })(jQuery, DevExpress);
- /*! Module widgets-base, file ui.map.google.js */
- (function($, DX, undefined) {
- var ui = DX.ui;
- var GOOGLE_MAP_READY = "_googleScriptReady",
- GOOGLE_URL = "https://maps.google.com/maps/api/js?v=3.9&sensor=false&callback=" + GOOGLE_MAP_READY;
- var googleMapsLoader;
- ui.registerMapProvider("google", ui.MapProvider.inherit({
- _mapType: function(type) {
- var mapTypes = {
- hybrid: google.maps.MapTypeId.HYBRID,
- roadmap: google.maps.MapTypeId.ROADMAP
- };
- return mapTypes[type] || mapTypes.hybrid
- },
- _movementMode: function(type) {
- var movementTypes = {
- driving: google.maps.TravelMode.DRIVING,
- walking: google.maps.TravelMode.WALKING
- };
- return movementTypes[type] || movementTypes.driving
- },
- _resolveLocation: function(location) {
- var d = $.Deferred();
- if (typeof location === "string") {
- var geocoder = new google.maps.Geocoder;
- geocoder.geocode({address: location}, function(results, status) {
- if (status === google.maps.GeocoderStatus.OK)
- d.resolve(results[0].geometry.location)
- })
- }
- else if ($.isArray(location))
- d.resolve(new google.maps.LatLng(location[0], location[1]));
- else if ($.isPlainObject(location) && $.isNumeric(location.lat) && $.isNumeric(location.lng))
- d.resolve(new google.maps.LatLng(location.lat, location.lng));
- return d.promise()
- },
- _normalizeLocation: function(location) {
- return {
- lat: location.lat(),
- lng: location.lng()
- }
- },
- load: function() {
- if (!googleMapsLoader) {
- googleMapsLoader = $.Deferred();
- var key = this._keyOption("google");
- window[GOOGLE_MAP_READY] = $.proxy(this._mapReady, this);
- $.getScript(GOOGLE_URL + (key ? "&key=" + key : ""))
- }
- this._markers = [];
- this._routes = [];
- return googleMapsLoader.promise()
- },
- _mapReady: function() {
- try {
- delete window[GOOGLE_MAP_READY]
- }
- catch(e) {
- window[GOOGLE_MAP_READY] = undefined
- }
- googleMapsLoader.resolve()
- },
- _renderImpl: function() {
- var deferred = $.Deferred(),
- initPromise = $.Deferred(),
- controls = this._option("controls");
- var options = {
- zoom: this._option("zoom"),
- center: new google.maps.LatLng(0, 0),
- mapTypeId: this._mapType(this._option("type")),
- panControl: controls,
- zoomControl: controls,
- mapTypeControl: controls,
- streetViewControl: controls
- };
- this._map = new google.maps.Map(this._$container[0], options);
- var listner = google.maps.event.addListener(this._map, 'idle', $.proxy(initPromise.resolve, initPromise));
- this._zoomChangeListener = google.maps.event.addListener(this._map, 'zoom_changed', $.proxy(this._handleZoomChange, this));
- this._centerChangeListener = google.maps.event.addListener(this._map, 'center_changed', $.proxy(this._handleCenterChange, this));
- this._clickListener = google.maps.event.addListener(this._map, 'click', $.proxy(this._handleClickAction, this));
- var locationPromise = this._renderCenter();
- $.when(initPromise, locationPromise).done(function() {
- google.maps.event.removeListener(listner);
- deferred.resolve()
- });
- return deferred.promise()
- },
- updateDimensions: function() {
- google.maps.event.trigger(this._map, 'resize');
- return $.Deferred().resolve().promise()
- },
- updateMapType: function() {
- this._map.setMapTypeId(this._mapType(this._option("type")));
- return $.Deferred().resolve().promise()
- },
- updateCenter: function() {
- return this._renderCenter()
- },
- _handleCenterChange: function() {
- var center = this._map.getCenter();
- this._option("center", this._normalizeLocation(center))
- },
- _renderCenter: function() {
- var deferred = $.Deferred(),
- that = this;
- this._resolveLocation(this._option("center")).done(function(location) {
- that._map.setCenter(location);
- deferred.resolve()
- });
- return deferred.promise()
- },
- _handleZoomChange: function() {
- if (!this._preventZoomChangeEvent)
- this._option("zoom", this._map.getZoom())
- },
- updateZoom: function() {
- this._map.setZoom(this._option("zoom"));
- return $.Deferred().resolve().promise()
- },
- updateControls: function() {
- var controls = this._option("controls");
- this._map.setOptions({
- panControl: controls,
- zoomControl: controls,
- mapTypeControl: controls,
- streetViewControl: controls
- });
- return $.Deferred().resolve().promise()
- },
- addMarkers: function(options) {
- var deferred = $.Deferred(),
- that = this;
- var markerPromises = $.map(options, function(options) {
- return that._addMarker(options)
- });
- $.when.apply($, markerPromises).done(function() {
- var instances = $.map($.makeArray(arguments), function(markerObject) {
- return markerObject.marker
- });
- deferred.resolve(false, instances)
- });
- return deferred.promise()
- },
- _addMarker: function(options) {
- var that = this;
- return this._renderMarker(options).done(function(markerObject) {
- that._markers.push($.extend({options: options}, markerObject));
- that._updateMarkersBounds();
- that._fitBounds();
- that._fireMarkerAddedAction({
- options: options,
- originalMarker: markerObject.marker
- })
- })
- },
- _renderMarker: function(options) {
- var d = $.Deferred(),
- that = this;
- this._resolveLocation(options.location).done(function(location) {
- var marker = new google.maps.Marker({
- position: location,
- map: that._map,
- icon: options.iconSrc || that._option("markerIconSrc")
- }),
- listner;
- var infoWindow = that._renderTooltip(marker, options.tooltip);
- if (options.clickAction || options.tooltip) {
- var markerClickAction = that._createAction(options.clickAction || $.noop),
- markerNormalizedLocation = that._normalizeLocation(location);
- listner = google.maps.event.addListener(marker, "click", function() {
- markerClickAction({location: markerNormalizedLocation});
- if (infoWindow)
- infoWindow.open(that._map, marker)
- })
- }
- d.resolve({
- location: location,
- marker: marker,
- listner: listner
- })
- });
- return d.promise()
- },
- _renderTooltip: function(marker, options) {
- if (!options)
- return;
- options = this._parseTooltipOptions(options);
- var infoWindow = new google.maps.InfoWindow({content: options.text});
- if (options.visible)
- infoWindow.open(this._map, marker);
- return infoWindow
- },
- removeMarkers: function(markersOptionsToRemove) {
- var that = this;
- $.each(markersOptionsToRemove, function(_, markerOptionToRemove) {
- that._removeMarker(markerOptionToRemove)
- });
- return $.Deferred().resolve().promise()
- },
- _removeMarker: function(markersOptionToRemove) {
- var that = this;
- $.each(this._markers, function(markerIndex, markerObject) {
- if (markerObject.options !== markersOptionToRemove)
- return true;
- var marker = that._markers[markerIndex];
- marker.marker.setMap(null);
- if (marker.listner)
- google.maps.event.removeListener(marker.listner);
- that._markers.splice(markerIndex, 1);
- that._updateMarkersBounds();
- that._fitBounds();
- that._fireMarkerRemovedAction({options: markerObject.options});
- return false
- })
- },
- _updateMarkersBounds: function() {
- var that = this;
- this._clearBounds();
- $.each(this._markers, function(_, markerObject) {
- that._extendBounds(markerObject.location)
- })
- },
- _clearMarkers: function() {
- for (var i = 0; this._markers.length > 0; )
- this._removeMarker(this._markers[0].options)
- },
- adjustViewport: function() {
- return this._fitBounds()
- },
- _extendBounds: function(location) {
- if (this._bounds)
- this._bounds.extend(location);
- else {
- this._bounds = new google.maps.LatLngBounds;
- this._bounds.extend(location)
- }
- },
- _fitBounds: function() {
- var autoAdjust = this._option("autoAdjust");
- if (this._bounds && autoAdjust) {
- var zoomBeforeFitting = this._map.getZoom();
- this._preventZoomChangeEvent = true;
- this._map.fitBounds(this._bounds);
- var zoomAfterFitting = this._map.getZoom();
- if (zoomBeforeFitting < zoomAfterFitting)
- this._map.setZoom(zoomBeforeFitting);
- else
- this._option("zoom", zoomAfterFitting);
- delete this._preventZoomChangeEvent
- }
- return $.Deferred().resolve().promise()
- },
- _clearBounds: function() {
- this._bounds = null
- },
- addRoutes: function(options) {
- var deferred = $.Deferred(),
- that = this;
- var routePromises = $.map(options, function(options) {
- return that._addRoute(options)
- });
- $.when.apply($, routePromises).done(function() {
- deferred.resolve(false, $.makeArray(arguments))
- });
- return deferred.promise()
- },
- _addRoute: function(options) {
- var that = this;
- return this._renderRoute(options).done(function(instance) {
- that._routes.push({
- options: options,
- instance: instance
- });
- that._fireRouteAddedAction({
- options: options,
- originalRoute: instance
- })
- })
- },
- _renderRoute: function(options) {
- var d = $.Deferred(),
- that = this,
- directionsService = new google.maps.DirectionsService;
- var points = $.map(options.locations, function(point) {
- return that._resolveLocation(point)
- });
- $.when.apply($, points).done(function() {
- var locations = $.makeArray(arguments),
- origin = locations.shift(),
- destination = locations.pop(),
- waypoints = $.map(locations, function(location) {
- return {
- location: location,
- stopover: true
- }
- });
- var request = {
- origin: origin,
- destination: destination,
- waypoints: waypoints,
- optimizeWaypoints: true,
- travelMode: that._movementMode(options.mode)
- };
- directionsService.route(request, function(response, status) {
- if (status === google.maps.DirectionsStatus.OK) {
- var color = new DX.Color(options.color || that._defaultRouteColor()).toHex(),
- directionOptions = {
- directions: response,
- map: that._map,
- suppressMarkers: true,
- preserveViewport: true,
- polylineOptions: {
- strokeWeight: options.weight || that._defaultRouteWeight(),
- strokeOpacity: options.opacity || that._defaultRouteOpacity(),
- strokeColor: color
- }
- };
- var route = new google.maps.DirectionsRenderer(directionOptions);
- d.resolve(route)
- }
- })
- });
- return d.promise()
- },
- removeRoutes: function(options) {
- var that = this;
- $.each(options, function(routeIndex, options) {
- that._removeRoute(options)
- });
- return $.Deferred().resolve().promise()
- },
- _removeRoute: function(options) {
- var that = this;
- $.each(this._routes, function(routeIndex, routeObject) {
- if (routeObject.options !== options)
- return true;
- that._routes[routeIndex].instance.setMap(null);
- that._routes.splice(routeIndex, 1);
- that._fireRouteRemovedAction({options: options});
- return false
- })
- },
- _clearRoutes: function() {
- for (var i = 0; this._routes.length > 0; )
- this._removeRoute(this._routes[0].options)
- },
- _handleClickAction: function(e) {
- this._fireClickAction({location: this._normalizeLocation(e.latLng)})
- },
- clean: function() {
- if (this._map) {
- google.maps.event.removeListener(this._zoomChangeListener);
- google.maps.event.removeListener(this._centerChangeListener);
- google.maps.event.removeListener(this._clickListener);
- this._clearMarkers();
- this._clearRoutes();
- delete this._map;
- this._$container.empty()
- }
- },
- cancelEvents: true
- }));
- if (!ui.dxMap.__internals)
- ui.dxMap.__internals = {};
- $.extend(ui.dxMap.__internals, {remapGoogleConstant: function(newValue) {
- GOOGLE_URL = newValue
- }})
- })(jQuery, DevExpress);
- /*! Module widgets-base, file ui.map.googleStatic.js */
- (function($, DX, undefined) {
- var ui = DX.ui;
- var GOOGLE_STATIC_URL = "https://maps.google.com/maps/api/staticmap?";
- ui.registerMapProvider("googleStatic", ui.MapProvider.inherit({
- _locationToString: function(location) {
- return !$.isPlainObject(location) ? location.toString().replace(/ /g, "+") : location.lat + "," + location.lng
- },
- _renderImpl: function() {
- return this._updateMap()
- },
- updateDimensions: function() {
- return this._updateMap()
- },
- updateMapType: function() {
- return this._updateMap()
- },
- updateCenter: function() {
- return this._updateMap()
- },
- updateZoom: function() {
- return this._updateMap()
- },
- updateControls: function() {
- return $.Deferred().resolve().promise()
- },
- addMarkers: function(options) {
- var that = this;
- return this._updateMap().done(function() {
- $.each(options, function(_, options) {
- that._fireMarkerAddedAction({options: options})
- })
- })
- },
- removeMarkers: function(options) {
- var that = this;
- return this._updateMap().done(function() {
- $.each(options, function(_, options) {
- that._fireMarkerRemovedAction({options: options})
- })
- })
- },
- adjustViewport: function() {
- return $.Deferred().resolve().promise()
- },
- addRoutes: function(options) {
- var that = this;
- return this._updateMap().done(function() {
- $.each(options, function(_, options) {
- that._fireRouteAddedAction({options: options})
- })
- })
- },
- removeRoutes: function(options) {
- var that = this;
- return this._updateMap().done(function() {
- $.each(options, function(_, options) {
- that._fireRouteRemovedAction({options: options})
- })
- })
- },
- clean: function() {
- this._$container.css("background-image", "none");
- this._$container.off(this._addEventNamespace("dxclick"))
- },
- mapRendered: function() {
- return true
- },
- _updateMap: function() {
- var key = this._keyOption("googleStatic");
- var requestOptions = ["sensor=false", "size=" + this._option("width") + "x" + this._option("height"), "maptype=" + this._option("type"), "center=" + this._locationToString(this._option("center")), "zoom=" + this._option("zoom"), this._markersSubstring()];
- requestOptions.push.apply(requestOptions, this._routeSubstrings());
- if (key)
- requestOptions.push("key=" + key);
- var request = GOOGLE_STATIC_URL + requestOptions.join("&");
- this._$container.css("background", "url(\"" + request + "\") no-repeat 0 0");
- this._attachClickEvent();
- return $.Deferred().resolve(true).promise()
- },
- _markersSubstring: function() {
- var that = this,
- markers = [],
- markerIcon = this._option("markerIconSrc");
- if (markerIcon)
- markers.push("icon:" + markerIcon);
- $.each(this._option("markers"), function(_, marker) {
- markers.push(that._locationToString(marker.location))
- });
- return "markers=" + markers.join("|")
- },
- _routeSubstrings: function() {
- var that = this,
- routes = [];
- $.each(this._option("routes"), function(_, route) {
- var color = new DX.Color(route.color || that._defaultRouteColor()).toHex().replace('#', '0x'),
- opacity = Math.round((route.opacity || that._defaultRouteOpacity()) * 255).toString(16),
- width = route.weight || that._defaultRouteWeight(),
- locations = [];
- $.each(route.locations, function(_, routePoint) {
- locations.push(that._locationToString(routePoint))
- });
- routes.push("path=color:" + color + opacity + "|weight:" + width + "|" + locations.join("|"))
- });
- return routes
- },
- _attachClickEvent: function() {
- var that = this,
- eventName = this._addEventNamespace("dxclick");
- this._$container.off(eventName).on(eventName, function(e) {
- that._fireClickAction({jQueryEvent: e})
- })
- }
- }));
- if (!ui.dxMap.__internals)
- ui.dxMap.__internals = {};
- $.extend(ui.dxMap.__internals, {remapGoogleStaticConstant: function(newValue) {
- GOOGLE_STATIC_URL = newValue
- }})
- })(jQuery, DevExpress);
- /*! Module widgets-base, file ui.swipeable.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- events = ui.events,
- DX_SWIPEABLE = "dxSwipeable",
- SWIPEABLE_CLASS = "dx-swipeable",
- ACTION_TO_EVENT_MAP = {
- startAction: "dxswipestart",
- updateAction: "dxswipe",
- endAction: "dxswipeend",
- cancelAction: "dxswipecancel"
- };
- DX.registerComponent(DX_SWIPEABLE, DX.DOMComponent.inherit({
- NAMESPACE: ui,
- _setDefaultOptions: function() {
- this.callBase();
- this.option({
- elastic: true,
- direction: "horizontal",
- itemSizeFunc: null,
- startAction: null,
- updateAction: null,
- endAction: null,
- cancelAction: null
- })
- },
- _render: function() {
- this.callBase();
- this._element().addClass(SWIPEABLE_CLASS);
- this._attachEventHandlers()
- },
- _attachEventHandlers: function() {
- this._detachEventHanlers();
- if (this.option("disabled"))
- return;
- var NAME = this.NAME;
- this._createEventData();
- $.each(ACTION_TO_EVENT_MAP, $.proxy(function(actionName, eventName) {
- var action = this._createActionByOption(actionName, {
- context: this,
- excludeValidators: ["gesture"]
- });
- eventName = events.addNamespace(eventName, NAME);
- this._element().on(eventName, this._eventData, function(e) {
- return action({jQueryEvent: e})
- })
- }, this))
- },
- _createEventData: function() {
- this._eventData = {
- elastic: this.option("elastic"),
- itemSizeFunc: this.option("itemSizeFunc"),
- direction: this.option("direction")
- }
- },
- _detachEventHanlers: function() {
- this._element().off("." + DX_SWIPEABLE)
- },
- _optionChanged: function(name) {
- switch (name) {
- case"disabled":
- case"startAction":
- case"updateAction":
- case"endAction":
- case"cancelAction":
- case"elastic":
- case"itemSizeFunc":
- case"direction":
- this._detachEventHanlers();
- this._attachEventHandlers();
- break;
- case"rtlEnabled":
- break;
- default:
- this.callBase.apply(this, arguments)
- }
- }
- }))
- })(jQuery, DevExpress);
- /*! Module widgets-base, file ui.button.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- events = ui.events;
- var BUTTON_CLASS = "dx-button",
- BUTTON_CONTENT_CLASS = "dx-button-content",
- BUTTON_CONTENT_SELECTOR = ".dx-button-content",
- BUTTON_TEXT_CLASS = "dx-button-text",
- BUTTON_HAS_TEXT_CLASS = "dx-button-has-text",
- BUTTON_HAS_ICON_CLASS = "dx-button-has-icon",
- BUTTON_TEXT_SELECTOR = ".dx-button-text",
- BUTTON_BACK_ARROW_CLASS = "dx-button-back-arrow",
- ICON_CLASS = "dx-icon",
- ICON_SELECTOR = ".dx-icon",
- BUTTON_FEEDBACK_HIDE_TIMEOUT = 100;
- DX.registerComponent("dxButton", ui.Widget.inherit({
- _setDefaultOptions: function() {
- this.callBase();
- this.option({
- clickAction: null,
- type: "normal",
- text: "",
- icon: "",
- iconSrc: "",
- hoverStateEnabled: true
- })
- },
- _init: function() {
- this.callBase();
- this._feedbackHideTimeout = BUTTON_FEEDBACK_HIDE_TIMEOUT
- },
- _render: function() {
- this.callBase();
- this._element().addClass(BUTTON_CLASS).append($("<div />").addClass(BUTTON_CONTENT_CLASS));
- this._renderClick();
- this._renderIcon();
- this._renderType();
- this._renderText()
- },
- _renderClick: function() {
- var that = this,
- eventName = events.addNamespace("dxclick", this.NAME);
- this._clickAction = this._createActionByOption("clickAction");
- this._element().off(eventName).on(eventName, function(e) {
- that._clickAction({jQueryEvent: e})
- })
- },
- _removeTypesCss: function() {
- var css = this._element().attr("class");
- css = css.replace(/\bdx-button-[-a-z0-9]+\b/gi, "");
- this._element().attr("class", css)
- },
- _renderIcon: function() {
- var contentElement = this._element().find(BUTTON_CONTENT_SELECTOR),
- iconElement = contentElement.find(ICON_SELECTOR),
- icon = this.option("icon"),
- iconSrc = this.option("iconSrc");
- iconElement.remove();
- if (this.option("type") === "back" && !icon)
- icon = "back";
- if (!icon && !iconSrc)
- return;
- if (icon)
- iconElement = $("<span />").addClass("dx-icon-" + icon);
- else if (iconSrc)
- iconElement = $("<img />").attr("src", iconSrc);
- contentElement.prepend(iconElement.addClass(ICON_CLASS));
- this._element().addClass(BUTTON_HAS_ICON_CLASS)
- },
- _renderType: function() {
- var type = this.option("type");
- if (type)
- this._element().addClass("dx-button-" + type);
- if (type === "back")
- this._element().prepend($("<span />").addClass(BUTTON_BACK_ARROW_CLASS))
- },
- _renderText: function() {
- var text = this.option("text"),
- contentElement = this._element().find(BUTTON_CONTENT_SELECTOR),
- back = this.option("type") === "back";
- var textElement = contentElement.find(BUTTON_TEXT_SELECTOR);
- if (!text && !back) {
- textElement.remove();
- return
- }
- if (!textElement.length)
- textElement = $('<span />').addClass(BUTTON_TEXT_CLASS).appendTo(contentElement);
- textElement.text(text || DX.localization.localizeString("@Back"));
- this._element().addClass(BUTTON_HAS_TEXT_CLASS)
- },
- _clean: function() {
- this.callBase();
- this._removeTypesCss()
- },
- _optionChanged: function(name) {
- switch (name) {
- case"clickAction":
- this._renderClick();
- break;
- case"icon":
- case"iconSrc":
- this._renderIcon();
- break;
- case"text":
- this._renderText();
- break;
- case"type":
- this._invalidate();
- break;
- default:
- this.callBase.apply(this, arguments)
- }
- }
- }))
- })(jQuery, DevExpress);
- /*! Module widgets-base, file ui.checkBox.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- events = ui.events;
- var CHECKBOX_CLASS = "dx-checkbox",
- CHECKBOX_ICON_CLASS = "dx-checkbox-icon",
- CHECKBOX_CHECKED_CLASS = "dx-checkbox-checked",
- CHECKBOX_INDETERMINATE_CLASS = "dx-checkbox-indeterminate",
- CHECKBOX_FEEDBACK_HIDE_TIMEOUT = 100,
- CHECKBOX_DXCLICK_EVENT_NAME = events.addNamespace("dxclick", "dxCheckBox");
- DX.registerComponent("dxCheckBox", ui.dxEditor.inherit({
- _deprecatedOptions: {checked: {
- since: "14.1",
- message: "Use the 'value' option instead."
- }},
- _optionAliases: {checked: "value"},
- _setDefaultOptions: function() {
- this.callBase();
- this.option({
- value: undefined,
- valueChangeAction: null,
- hoverStateEnabled: true
- })
- },
- _init: function() {
- this.callBase();
- this._feedbackHideTimeout = CHECKBOX_FEEDBACK_HIDE_TIMEOUT
- },
- _render: function() {
- this.callBase();
- this._element().addClass(CHECKBOX_CLASS);
- this._$iconContainer = $("<span />");
- this._$iconContainer.addClass(CHECKBOX_ICON_CLASS).appendTo(this._element());
- this._renderValue();
- this._renderClick();
- this._updateContentSize()
- },
- _renderDimensions: function() {
- this.callBase();
- this._updateContentSize()
- },
- _updateContentSize: function() {
- var $element = this._element(),
- width = this.option("width"),
- height = this.option("height");
- if (this._$iconContainer && (width || height)) {
- width = this._element().width();
- height = this._element().height();
- var minDimention = Math.min(height, width);
- this._$iconContainer.css({
- height: minDimention,
- width: minDimention,
- "margin-top": (height - minDimention) / 2,
- "margin-left": (width - minDimention) / 2
- })
- }
- },
- _renderClick: function() {
- var clickAction = this._createAction(this._handleClick);
- this._element().off(CHECKBOX_DXCLICK_EVENT_NAME).on(CHECKBOX_DXCLICK_EVENT_NAME, function(e) {
- clickAction({jQueryEvent: e})
- })
- },
- _handleClick: function(args) {
- var that = args.component;
- that._valueChangeEventInstance = args.jQueryEvent;
- that.option("value", !that.option("value"))
- },
- _renderValue: function() {
- var $element = this._element(),
- checked = this.option("value"),
- indeterminate = checked === undefined;
- $element.toggleClass(CHECKBOX_CHECKED_CLASS, Boolean(checked));
- $element.toggleClass(CHECKBOX_INDETERMINATE_CLASS, indeterminate)
- },
- _optionChanged: function(name) {
- switch (name) {
- case"value":
- this._renderValue();
- default:
- this.callBase.apply(this, arguments)
- }
- }
- }))
- })(jQuery, DevExpress);
- /*! Module widgets-base, file ui.textEditor.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- events = ui.events;
- var TEXTEDITOR_CLASS = "dx-texteditor",
- TEXTEDITOR_INPUT_CLASS = "dx-texteditor-input",
- TEXTEDITOR_INPUT_SELECTOR = "." + TEXTEDITOR_INPUT_CLASS,
- TEXTEDITOR_BORDER_CLASS = "dx-texteditor-border",
- TEXTEDITOR_PLACEHOLDER_CLASS = "dx-placeholder",
- TEXTEDITOR_SHOW_CLEAR_BUTTON_CLASS = "dx-show-clear-button",
- TEXTEDITOR_CLEAR_ICON_CLASS = "dx-icon-clear",
- TEXTEDITOR_CLEAR_BUTTON_CLASS = "dx-clear-button-area",
- TEXTEDITOR_EMPTY_INPUT_CLASS = "dx-texteditor-empty",
- TEXTEDITOR_STATE_FOCUSED_CLASS = "dx-state-focused",
- EVENTS_LIST = ["focusIn", "focusOut", "keyDown", "keyPress", "keyUp", "change", "cut", "copy", "paste", "input"];
- var nativeClearButtonCancelSupport = function() {
- return DX.browser["msie"] && DX.browser.version > 9 || !DX.browser["msie"]
- }();
- DX.registerComponent("dxTextEditor", ui.dxEditor.inherit({
- _deprecatedOptions: {
- valueUpdateEvent: {
- since: "14.1",
- message: "Use the 'valueChangeEvent' option instead."
- },
- valueUpdateAction: {
- since: "14.1",
- message: "Use the 'valueChangeAction' option instead."
- }
- },
- _optionAliases: {valueUpdateEvent: "valueChangeEvent"},
- _setDefaultOptions: function() {
- this.callBase();
- this.option({
- value: "",
- showClearButton: false,
- valueChangeEvent: "change",
- valueUpdateAction: null,
- placeholder: "",
- readOnly: false,
- focusInAction: null,
- focusOutAction: null,
- keyDownAction: null,
- keyPressAction: null,
- keyUpAction: null,
- changeAction: null,
- inputAction: null,
- cutAction: null,
- copyAction: null,
- pasteAction: null,
- enterKeyAction: null,
- mode: "text",
- activeStateEnabled: false,
- hoverStateEnabled: true
- })
- },
- _input: function() {
- return this._element().find(TEXTEDITOR_INPUT_SELECTOR)
- },
- _render: function() {
- this._element().addClass(TEXTEDITOR_CLASS);
- this._renderInput();
- this._renderInputType();
- this._renderValue();
- this._renderProps();
- this._renderPlaceholder();
- this._renderEvents();
- this._toggleClearButton();
- this._renderEnterKeyAction();
- this._renderEmptinessEvent();
- this._renderFocusEvent();
- this.callBase()
- },
- _renderInput: function(inputContainer) {
- (inputContainer || this._element()).append($("<div>").addClass(TEXTEDITOR_BORDER_CLASS).append($("<input>").addClass(TEXTEDITOR_INPUT_CLASS)))
- },
- _renderValue: function(formattedValue) {
- var text = formattedValue || this.option("value");
- if (this._input().val() !== text) {
- this._input().val(text);
- this._toggleEmptinessEventHandler()
- }
- },
- _isValueValid: function() {
- var validity = this._input().get(0).validity;
- if (validity)
- return validity.valid;
- return true
- },
- _toggleEmptiness: function(visibility) {
- this._element().toggleClass(TEXTEDITOR_EMPTY_INPUT_CLASS, visibility)
- },
- _togglePlaceholderVisibility: function(visibility) {
- if (!this._$placeholder)
- return;
- if (DX.browser["msie"])
- this._$placeholder.toggle(!this._input().is(":focus") && visibility);
- else
- this._$placeholder.toggle(visibility)
- },
- _renderProps: function() {
- this._input().prop({
- readOnly: this._readOnlyPropValue(),
- disabled: this.option("disabled")
- })
- },
- _readOnlyPropValue: function() {
- return this.option("readOnly")
- },
- _renderPlaceholder: function() {
- var that = this,
- $input = that._input(),
- placeholderText = that.option("placeholder"),
- $placeholder = this._$placeholder = $('<div>').attr("data-dx_placeholder", placeholderText),
- startEvent = events.addNamespace("dxclick", this.NAME);
- $placeholder.on(startEvent, function() {
- $input.focus()
- });
- $placeholder.appendTo($input.parent());
- $placeholder.addClass(TEXTEDITOR_PLACEHOLDER_CLASS)
- },
- _toggleClearButton: function() {
- if (!nativeClearButtonCancelSupport)
- return;
- var $element = this._element(),
- showing = this.option("showClearButton") && !this.option("readOnly");
- $element.toggleClass(TEXTEDITOR_SHOW_CLEAR_BUTTON_CLASS, showing);
- if (showing)
- this._renderClearButton();
- else
- this._$clearButton && this._$clearButton.remove()
- },
- _renderClearButton: function() {
- var $clearButton = $("<span>").addClass(TEXTEDITOR_CLEAR_BUTTON_CLASS).append($("<span>").addClass(TEXTEDITOR_CLEAR_ICON_CLASS)).on(events.addNamespace("dxpointerdown", this.NAME), function() {
- return false
- }).on(events.addNamespace("dxpointerup", this.NAME), $.proxy(this._handleClearValue, this));
- this._element().append($clearButton);
- this._$clearButton = $clearButton
- },
- _handleClearValue: function() {
- var $input = this._input();
- this.option("value", "");
- if ($input.is(":focus")) {
- $input.val("");
- this._toggleEmptinessEventHandler()
- }
- else
- $input.trigger("focus")
- },
- _renderEvents: function() {
- var that = this,
- $input = that._input();
- that._renderValueUpdateEvent();
- $.each(EVENTS_LIST, function(_, event) {
- var eventName = events.addNamespace(event.toLowerCase(), that.NAME),
- action = that._createActionByOption(event + "Action");
- $input.off(eventName).on(eventName, function(e) {
- action({jQueryEvent: e})
- })
- })
- },
- _renderValueUpdateEvent: function() {
- var eventNamespace = this.NAME + "ValueUpdate";
- var valueChangeEvent = events.addNamespace(this.option("valueChangeEvent"), eventNamespace);
- this._input().off("." + eventNamespace).on(valueChangeEvent, $.proxy(this._handleValueChangeEvent, this));
- this._valueUpdateAction = this._createActionByOption("valueUpdateAction")
- },
- _renderFocusEvent: function() {
- var $element = this._element();
- $element.find("." + TEXTEDITOR_INPUT_CLASS).focusin(function() {
- $element.addClass(TEXTEDITOR_STATE_FOCUSED_CLASS)
- }).focusout(function() {
- $element.removeClass(TEXTEDITOR_STATE_FOCUSED_CLASS)
- }).filter(":focus").addClass(TEXTEDITOR_STATE_FOCUSED_CLASS);
- if (DX.browser["msie"])
- this._input().on('focus', $.proxy(function() {
- this._togglePlaceholderVisibility(false)
- }, this))
- },
- _renderEmptinessEvent: function() {
- var $input = this._input();
- $input.on("input blur", $.proxy(this._toggleEmptinessEventHandler, this));
- this._toggleEmptinessEventHandler()
- },
- _toggleEmptinessEventHandler: function(value) {
- var value = this._input().val(),
- visibility = (value === "" || value === null) && this._isValueValid();
- this._toggleEmptiness(visibility);
- this._togglePlaceholderVisibility(visibility)
- },
- _handleValueChangeEvent: function(e, formattedValue) {
- this._valueChangeEventInstance = e;
- this._suppressValueUpdateAction = true;
- this.option("value", arguments.length > 1 ? formattedValue : this._input().val());
- this._suppressValueUpdateAction = false;
- this._valueUpdateAction({
- value: this.option("value"),
- jQueryEvent: e
- })
- },
- _renderEnterKeyAction: function() {
- if (this.option("enterKeyAction")) {
- this._enterKeyAction = this._createActionByOption("enterKeyAction");
- this._input().on("keyup.enterKey.dxTextEditor", $.proxy(this._handleEnterKeyUp, this))
- }
- else {
- this._input().off("keyup.enterKey.dxTextEditor");
- this._enterKeyAction = undefined
- }
- },
- _handleEnterKeyUp: function(e) {
- if (e.which === 13)
- this._enterKeyAction({jQueryEvent: e})
- },
- _toggleDisabledState: function() {
- this.callBase.apply(this, arguments);
- this._renderProps()
- },
- _updateValue: function() {
- this._renderValue();
- if (!this._suppressValueUpdateAction)
- this._valueUpdateAction({value: this.option("value")})
- },
- _suppressUpdateValue: function() {
- this._valueUpdateSuppressed = true
- },
- _resumeUpdateValue: function() {
- this._valueUpdateSuppressed = false
- },
- _optionChanged: function(optionName) {
- if ($.inArray(optionName.replace("Action", ""), EVENTS_LIST) > -1) {
- this._renderEvents();
- return
- }
- switch (optionName) {
- case"valueChangeEvent":
- case"valueUpdateAction":
- this._renderValueUpdateEvent();
- break;
- case"readOnly":
- this._renderProps();
- this._toggleClearButton();
- break;
- case"mode":
- this._renderInputType();
- break;
- case"enterKeyAction":
- this._renderEnterKeyAction();
- break;
- case"placeholder":
- this._invalidate();
- break;
- case"showClearButton":
- this._toggleClearButton();
- break;
- case"value":
- if (!this._valueUpdateSuppressed)
- this._updateValue();
- default:
- this.callBase.apply(this, arguments)
- }
- },
- _renderInputType: function() {
- this._setInputType(this.option("mode"))
- },
- _setInputType: function(type) {
- var input = this._input();
- if (type === "search")
- type = "text";
- try {
- input.prop("type", type)
- }
- catch(e) {
- input.prop("type", "text")
- }
- },
- focus: function() {
- this._input().focus()
- },
- blur: function() {
- if (this._input().is(document.activeElement))
- DX.utils.resetActiveElement()
- }
- }))
- })(jQuery, DevExpress);
- /*! Module widgets-base, file ui.textBox.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- events = ui.events,
- devices = DX.devices,
- ua = window.navigator.userAgent,
- ignoreCode = [8, 9, 13, 33, 34, 35, 36, 37, 38, 39, 40, 46],
- TEXTBOX_CLASS = "dx-textbox",
- SEARCHBOX_CLASS = "dx-searchbox",
- SEARCH_ICON_CLASS = "dx-icon-search";
- DX.registerComponent("dxTextBox", ui.dxTextEditor.inherit({
- _setDefaultOptions: function() {
- this.callBase();
- this.option({
- mode: "text",
- maxLength: null
- })
- },
- _render: function() {
- this.callBase();
- this._element().addClass(TEXTBOX_CLASS);
- this._renderMaxLengthHandlers();
- this._renderSearchMode()
- },
- _renderMaxLengthHandlers: function() {
- if (this._isAndroid())
- this._input().on(events.addNamespace("keydown", this.NAME), $.proxy(this._onKeyDownAndroidHandler, this)).on(events.addNamespace("change", this.NAME), $.proxy(this._onChangeAndroidHandler, this))
- },
- _renderProps: function() {
- this.callBase();
- if (this._isAndroid())
- return;
- var maxLength = this.option("maxLength");
- if (maxLength > 0)
- this._input().prop("maxLength", maxLength)
- },
- _renderSearchMode: function() {
- var $element = this._$element;
- if (this.option("mode") === "search") {
- this._renderSearchIcon();
- $element.addClass(SEARCHBOX_CLASS);
- this._showClearButton = this.option("showClearButton");
- this.option("showClearButton", true)
- }
- if (this.option("mode") !== "search") {
- $element.removeClass(SEARCHBOX_CLASS);
- this._$searchIcon && this._$searchIcon.remove();
- this.option("showClearButton", this._showClearButton === undefined ? this.option("showClearButton") : this._showClearButton)
- }
- },
- _renderSearchIcon: function() {
- var $searchIcon = $("<div>").addClass(SEARCH_ICON_CLASS);
- $searchIcon.prependTo(this._input().parent());
- this._$searchIcon = $searchIcon
- },
- _optionChanged: function(name) {
- switch (name) {
- case"maxLength":
- this._renderProps();
- this._renderMaxLengthHandlers();
- break;
- case"mode":
- this._renderSearchMode();
- default:
- this.callBase.apply(this, arguments)
- }
- },
- _onKeyDownAndroidHandler: function(e) {
- var maxLength = this.option("maxLength");
- if (maxLength) {
- var $input = $(e.target),
- code = e.keyCode;
- this._cutOffExtraChar($input);
- return $input.val().length < maxLength || $.inArray(code, ignoreCode) !== -1 || window.getSelection().toString() !== ""
- }
- else
- return true
- },
- _onChangeAndroidHandler: function(e) {
- var $input = $(e.target);
- if (this.option("maxLength"))
- this._cutOffExtraChar($input)
- },
- _cutOffExtraChar: function($input) {
- var maxLength = this.option("maxLength"),
- textInput = $input.val();
- if (textInput.length > maxLength)
- $input.val(textInput.substr(0, maxLength))
- },
- _isAndroid: function() {
- var realDevice = devices.real();
- var version = realDevice.version.join(".");
- return realDevice.platform === "android" && version && /^(2\.|4\.1)/.test(version) && !/chrome/i.test(ua)
- }
- }));
- ui.dxTextBox.__internals = {
- uaAccessor: function(value) {
- if (!arguments.length)
- return ui;
- ua = value
- },
- SEARCHBOX_CLASS: SEARCHBOX_CLASS,
- SEARCH_ICON_CLASS: SEARCH_ICON_CLASS
- }
- })(jQuery, DevExpress);
- /*! Module widgets-base, file ui.dropDownEditor.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- events = ui.events,
- DROP_DOWN_EDITOR_CLASS = "dx-dropdowneditor",
- DROP_DOWN_EDITOR_READONLY_CLASS = "dx-dropdowneditor-readonly",
- DROP_DOWN_EDITOR_INPUT_WRAPPER_CLASS = "dx-dropdowneditor-input-wrapper",
- DROP_DOWN_EDITOR_BUTTON_CLASS = "dx-dropdowneditor-button",
- DROP_DOWN_EDITOR_BUTTON_ICON = "dx-dropdowneditor-icon",
- DROP_DOWN_EDITOR_OVERLAY = "dx-dropdowneditor-overlay",
- DROP_DOWN_EDITOR_ACTIVE = "dx-dropdowneditor-active",
- DROP_DOWN_EDITOR_BUTTON_VISIBLE = "dx-dropdowneditor-button-visible",
- DROP_DOWN_EDITOR_DXCLICK_EVENT_NAME = events.addNamespace("dxclick", "dxDropDownEditor"),
- DROP_DOWN_EDITOR_MOUSE_DOWN_EVENT_NAME = events.addNamespace("mousedown", "dxDropDownEditor"),
- keyboardKeys = {
- upArrow: 38,
- downArrow: 40
- };
- DX.registerComponent("dxDropDownEditor", ui.dxTextBox.inherit({
- _setDefaultOptions: function() {
- this.callBase();
- this.option({
- openAction: null,
- closeAction: null
- })
- },
- open: function() {
- this._showDropDown()
- },
- close: function() {
- this._hideDropDown()
- },
- _clean: function() {
- this.callBase();
- if (this._dropDownContainer) {
- this._dropDownContainer.remove();
- this._dropDown = undefined
- }
- },
- _render: function() {
- this._dropDownContainerRendered = false;
- this._element().addClass(DROP_DOWN_EDITOR_CLASS);
- this._renderButton();
- this.callBase();
- this._renderKeyboardEvents();
- var that = this;
- this._input().on("blur", function(e) {
- if (that._hideOnBlur() && !that._needToPreventBlur)
- that._hideDropDown();
- that._needToPreventBlur = false
- })
- },
- _renderInput: function(inputContainer) {
- this._inputWrapper = inputContainer || $("<div>");
- this._inputWrapper.addClass(DROP_DOWN_EDITOR_INPUT_WRAPPER_CLASS);
- this._element().prepend(this._inputWrapper);
- this.callBase(this._inputWrapper)
- },
- _renderButton: function(hideButton) {
- this._button = $("<div>").addClass(DROP_DOWN_EDITOR_BUTTON_CLASS);
- this._attachButtonEvents();
- this._updateButtonReadonlyState();
- this._buttonIcon = $("<div>").addClass(DROP_DOWN_EDITOR_BUTTON_ICON).appendTo(this._button);
- this._button.appendTo(this._element());
- if (hideButton) {
- this._element().removeClass(DROP_DOWN_EDITOR_BUTTON_VISIBLE);
- this._button.hide()
- }
- else
- this._element().addClass(DROP_DOWN_EDITOR_BUTTON_VISIBLE)
- },
- _attachButtonEvents: function() {
- var that = this,
- dxClickAction,
- mouseDownAction;
- this._button.off(DROP_DOWN_EDITOR_DXCLICK_EVENT_NAME).off(DROP_DOWN_EDITOR_MOUSE_DOWN_EVENT_NAME);
- if (!this.option("readOnly")) {
- dxClickAction = this._createAction(function() {
- that._toggleDropDown();
- that._dropDownClickHandler()
- });
- mouseDownAction = this._createAction(function(args) {
- that._mouseDownFocusKeeper(args.jQueryEvent)
- });
- this._button.on(DROP_DOWN_EDITOR_DXCLICK_EVENT_NAME, function(e) {
- dxClickAction({jQueryEvent: e})
- }).on(DROP_DOWN_EDITOR_MOUSE_DOWN_EVENT_NAME, function(e) {
- mouseDownAction({jQueryEvent: e})
- })
- }
- },
- _updateButtonReadonlyState: function() {
- this._button.removeClass(DROP_DOWN_EDITOR_READONLY_CLASS);
- if (this.option("readOnly"))
- this._button.addClass(DROP_DOWN_EDITOR_READONLY_CLASS)
- },
- _renderKeyboardEvents: function() {
- this._input().off(events.addNamespace("keydown", "dxDropDownEditor")).on(events.addNamespace("keydown", "dxDropDownEditor"), $.proxy(this._onKeyDownHandler, this))
- },
- _dropDownClickHandler: function() {
- if (!this._deviceHasTouchScreen() && !this._input().is(":focus"))
- this.focus();
- this._needToPreventBlur = false
- },
- _mouseDownFocusKeeper: function(e) {
- this._needToPreventBlur = true;
- if (e && e.preventDefault)
- e.preventDefault()
- },
- _deviceHasTouchScreen: function() {
- var device = DevExpress.devices.real();
- return device.phone || device.tablet
- },
- _hideOnBlur: function() {
- return true
- },
- _renderDropDownContent: function() {
- return []
- },
- _dropDownVisible: function() {
- return this._dropDown && this._dropDown.option("visible")
- },
- _toggleDropDown: function() {
- this._dropDownVisible() ? this._hideDropDown() : this._showDropDown()
- },
- _showDropDown: function() {
- if (!this._dropDownVisible()) {
- this._renderDropDownContainer();
- this._dropDown.show();
- this._element().addClass(DROP_DOWN_EDITOR_ACTIVE)
- }
- },
- _hideDropDown: function() {
- if (this._dropDownVisible()) {
- this._element().removeClass(DROP_DOWN_EDITOR_ACTIVE);
- this._dropDown.hide()
- }
- },
- _renderDropDownContainer: function() {
- var that = this,
- dropDownContent;
- if (!this._dropDownContainerRendered) {
- this._dropDownContainer = $("<div>").addClass(DROP_DOWN_EDITOR_OVERLAY).addClass(that.option("customOverlayCssClass"));
- this._element().append(this._dropDownContainer);
- this._createDropDown();
- dropDownContent = this._renderDropDownContent();
- if (!$.isArray(dropDownContent))
- dropDownContent = [dropDownContent];
- $.each(dropDownContent, function(index, contentElement) {
- contentElement.off(DROP_DOWN_EDITOR_MOUSE_DOWN_EVENT_NAME).on(DROP_DOWN_EDITOR_MOUSE_DOWN_EVENT_NAME, function(e) {
- that._mouseDownFocusKeeper(e)
- }).off(DROP_DOWN_EDITOR_DXCLICK_EVENT_NAME).on(DROP_DOWN_EDITOR_DXCLICK_EVENT_NAME, function() {
- that._dropDownClickHandler()
- });
- that._dropDownContainer.append(contentElement)
- });
- this._dropDownContainerRendered = true
- }
- },
- _createDropDown: function(options) {
- this._dropDown = this._dropDownContainer.dxOverlay($.extend(true, {
- position: {
- offset: "0 -1",
- my: "left top",
- at: "left bottom",
- of: this._element(),
- collision: "flip flip"
- },
- showTitle: false,
- width: "auto",
- height: "auto",
- shading: false,
- rtlEnabled: this.option("rtlEnabled"),
- closeOnTargetScroll: $.proxy(this._closeOnScrollHandler, this),
- closeOnOutsideClick: $.proxy(this._closeOutsideDropDownHandler, this),
- animation: {
- show: false,
- hide: false
- },
- shownAction: this.option("openAction"),
- hiddenAction: this.option("closeAction")
- }, options)).dxOverlay("instance")
- },
- _closeOnScrollHandler: function(e) {
- this._hideDropDown();
- return true
- },
- _closeOutsideDropDownHandler: function(e, ignoreContainerClicks) {
- if (e.target !== this._input()[0] && e.target !== this._button[0] && !this._button.find($(e.target)).length && (!ignoreContainerClicks || !this._dropDown._container().find($(e.target)).length))
- this._hideDropDown();
- return false
- },
- _onKeyDownHandler: function(e) {
- if (e.altKey) {
- if (e.which === keyboardKeys.downArrow)
- this._showDropDown();
- if (e.which === keyboardKeys.upArrow)
- this._hideDropDown()
- }
- },
- _optionChanged: function(name, value) {
- switch (name) {
- case"rtlEnabled":
- this.callBase.apply(this, arguments);
- if (this._dropDownContainerRendered)
- this._dropDown.option(name, value);
- break;
- case"openAction":
- if (this._dropDownContainerRendered)
- this._dropDown.option("shownAction", value);
- break;
- case"closeAction":
- if (this._dropDownContainerRendered)
- this._dropDown.option("hiddenAction", value);
- break;
- case"readOnly":
- this._attachButtonEvents();
- this._updateButtonReadonlyState();
- default:
- this.callBase.apply(this, arguments)
- }
- }
- }));
- ui.dxDropDownEditor.__internals = {
- DROP_DOWN_EDITOR_CLASS: DROP_DOWN_EDITOR_CLASS,
- DROP_DOWN_EDITOR_READONLY_CLASS: DROP_DOWN_EDITOR_READONLY_CLASS,
- DROP_DOWN_EDITOR_BUTTON_ICON: DROP_DOWN_EDITOR_BUTTON_ICON,
- DROP_DOWN_EDITOR_INPUT_WRAPPER_CLASS: DROP_DOWN_EDITOR_INPUT_WRAPPER_CLASS,
- DROP_DOWN_EDITOR_BUTTON_CLASS: DROP_DOWN_EDITOR_BUTTON_CLASS,
- DROP_DOWN_EDITOR_OVERLAY: DROP_DOWN_EDITOR_OVERLAY,
- DROP_DOWN_EDITOR_ACTIVE: DROP_DOWN_EDITOR_ACTIVE,
- DROP_DOWN_EDITOR_BUTTON_VISIBLE: DROP_DOWN_EDITOR_BUTTON_VISIBLE
- }
- })(jQuery, DevExpress);
- /*! Module widgets-base, file ui.textArea.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- events = ui.events;
- var TEXTAREA_CLASS = "dx-textarea",
- TEXTEDITOR_INPUT_CLASS = "dx-texteditor-input",
- TEXTEDITOR_BORDER_CLASS = "dx-texteditor-border";
- DX.registerComponent("dxTextArea", ui.dxTextBox.inherit({
- _setDefaultOptions: function() {
- this.callBase();
- this.option({})
- },
- _render: function() {
- this.callBase();
- this._element().addClass(TEXTAREA_CLASS)
- },
- _renderInput: function() {
- this._element().append($("<div />").addClass(TEXTEDITOR_BORDER_CLASS).append($("<textarea />").addClass(TEXTEDITOR_INPUT_CLASS)));
- this._renderScrollHandler()
- },
- _renderScrollHandler: function() {
- var $input = this._input(),
- eventY = 0;
- $input.on(events.addNamespace("dxpointerdown", this.NAME), function(e) {
- eventY = events.eventData(e).y
- });
- $input.on(events.addNamespace("dxpointermove", this.NAME), function(e) {
- var scrollTopPos = $input.scrollTop(),
- scrollBottomPos = $input.prop("scrollHeight") - $input.prop("clientHeight") - scrollTopPos;
- if (scrollTopPos === 0 && scrollBottomPos === 0)
- return;
- var currentEventY = events.eventData(e).y;
- var isScrollFromTop = scrollTopPos === 0 && eventY >= currentEventY,
- isScrollFromBottom = scrollBottomPos === 0 && eventY <= currentEventY,
- isScrollFromMiddle = scrollTopPos > 0 && scrollBottomPos > 0;
- if (isScrollFromTop || isScrollFromBottom || isScrollFromMiddle)
- e.originalEvent.isScrollingEvent = true;
- eventY = currentEventY
- })
- },
- _renderInputType: $.noop
- }))
- })(jQuery, DevExpress);
- /*! Module widgets-base, file ui.numberBox.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- math = Math,
- events = ui.events,
- WIDGET_CLASS = "dx-numberbox",
- SPIN_CLASS = WIDGET_CLASS + "-spin",
- SPIN_CONTAINER_CLASS = SPIN_CLASS + "-container",
- SPIN_UP_CLASS = SPIN_CLASS + "-up",
- SPIN_DOWN_CLASS = SPIN_CLASS + "-down",
- SPIN_BUTTON_CLASS = SPIN_CLASS + "-button",
- SPIN_UP_SELECTOR = "." + SPIN_UP_CLASS,
- SPIN_DOWN_SELECTOR = "." + SPIN_DOWN_CLASS,
- SPIN_HOLD_DELAY = 150,
- CONTROL_KEYS = ["Del", "Backspace", "Left", "Right", "Home", "End"];
- DX.registerComponent("dxSpinButton", ui.Widget.inherit({
- _setDefaultOptions: function() {
- this.callBase();
- this.option({
- direction: "up",
- changeAction: null
- })
- },
- _render: function() {
- this.callBase();
- var that = this,
- $element = this._element(),
- pointerDownEvent = events.addNamespace("dxpointerdown", this.NAME),
- direction = SPIN_CLASS + "-" + this.option("direction");
- $element.addClass(SPIN_BUTTON_CLASS).addClass(direction).off(pointerDownEvent).on(pointerDownEvent, $.proxy(this._handleSpinHold, this));
- this._spinIcon = $("<div>").addClass(direction + "-icon").appendTo(this._element());
- this._handleSpinChange = this._createActionByOption("changeAction")
- },
- _handleSpinHold: function(e) {
- e.preventDefault();
- var pointerUpEvent = events.addNamespace("dxpointerup", this.NAME),
- pointerCancelEvent = events.addNamespace("dxpointercancel", this.NAME);
- this._clearTimer();
- $(document).off(pointerUpEvent).off(pointerCancelEvent).on(pointerUpEvent, $.proxy(this._clearTimer, this)).on(pointerCancelEvent, $.proxy(this._clearTimer, this));
- this._handleSpinChange({jQueryEvent: e});
- this._holdTimer = setInterval(this._handleSpinChange, SPIN_HOLD_DELAY, {jQueryEvent: e})
- },
- _dispose: function() {
- this._clearTimer();
- this.callBase()
- },
- _clearTimer: function(e) {
- if (this._holdTimer)
- clearInterval(this._holdTimer)
- },
- _optionChanged: function(name, value, prevValue) {
- switch (name) {
- case"changeAction":
- case"direction":
- this._invalidate();
- break;
- default:
- this.callBase(name, value, prevValue)
- }
- }
- }));
- DX.registerComponent("dxNumberBox", ui.dxTextEditor.inherit({
- _setDefaultOptions: function() {
- this.callBase();
- this.option({
- value: 0,
- min: undefined,
- max: undefined,
- mode: "number",
- showSpinButtons: false,
- alignment: undefined, // yo2dh 2015-02-10
- step: 1
- })
- },
- _init: function() {
- this.callBase();
- this._initSpinButtons()
- },
- _initSpinButtons: function() {
- var eventName = events.addNamespace("dxpointerdown", this.NAME);
- this._$spinContainer = $("<div>").addClass(SPIN_CONTAINER_CLASS).off(eventName).on(eventName, $.proxy(this._handleSpinButtonsClick, this));
- this._$spinUp = $("<div>").dxSpinButton({
- direction: "up",
- changeAction: $.proxy(this._handleSpinUpChange, this)
- }).appendTo(this._$spinContainer);
- this._$spinDown = $("<div>").dxSpinButton({
- direction: "down",
- changeAction: $.proxy(this._handleSpinDownChange, this)
- }).appendTo(this._$spinContainer)
- },
- _handleSpinButtonsClick: function() {
- var $input = this._input();
- if (document.activeElement !== $input[0])
- $input.trigger("focus")
- },
- _render: function() {
- this.callBase();
- this._element().addClass(WIDGET_CLASS);
- this._renderSpinButtons();
- this._handleKeyPressEvent()
- },
- _handleKeyPressEvent: function() {
- var that = this;
- this._input().keypress(function(e) {
- var ch = String.fromCharCode(e.which),
- validCharRegExp = /[\d.,eE\-+]/,
- isInputCharValid = validCharRegExp.test(ch);
- if (!isInputCharValid)
- if (!(e.key && $.inArray(e.key, CONTROL_KEYS) >= 0)) {
- e.preventDefault();
- return false
- }
- that._isIncompleteValue = false;
- if (that._isValueIncomplete(that._input().val() + ch))
- that._isIncompleteValue = true
- })
- },
- _isValueIncomplete: function(value) {
- var expRegex = /\d+e$/,
- negRegex = /^-/;
- return expRegex.test(value) || negRegex.test(value)
- },
- _renderSpinButtons: function() {
- this._element().toggleClass(SPIN_CLASS, this.option("showSpinButtons"));
- if (this.option("showSpinButtons"))
- this._$spinContainer.appendTo(this._element());
- else
- this._$spinContainer.detach()
- },
- _handleSpinUpChange: function() {
- this._handleSpinChangeValue(1)
- },
- _handleSpinDownChange: function() {
- this._handleSpinChangeValue(-1)
- },
- _handleSpinChangeValue: function(sgn) {
- this._input().trigger(this.option("valueChangeEvent"));
- var value = parseFloat(this.option().value || 0),
- step = parseFloat(this.option().step);
- value = this._correctRounding(value, step * sgn);
- this.option("value", value)
- },
- _correctRounding: function(value, step) {
- var regex = /[,|.](.*)/;
- var isFloatValue = regex.test(value),
- isFloatStep = regex.test(step);
- if (isFloatValue || isFloatStep) {
- var valueAccuracy = isFloatValue ? regex.exec(value)[0].length : 0,
- stepAccuracy = isFloatStep ? regex.exec(step)[0].length : 0,
- accuracy = Math.max(valueAccuracy, stepAccuracy);
- value = this._round(value + step, accuracy);
- return value
- }
- return value + step
- },
- _round: function(value, precision) {
- precision = precision || 0;
- var multiplier = Math.pow(10, precision);
- value *= multiplier;
- value = Math.round(value) / multiplier;
- return value
- },
- _renderValue: function() {
- var value = this.option("value") ? this.option("value").toString() : this.option("value");
- if (this._input().val() !== value) {
- var inputType = this._input().attr("type");
- this._setInputType("text");
- this._input().val(this.option("value"));
- // yo2dh: 2015-02-10 - dxNumberBox는 무조건 왼쪽 정렬.
- // 이를 alignment option값에 따라 변경되도록 수정함.
- var alignment = this.option('alignment');
- if (alignment) {
- this._input().css('text-align', alignment);
- }
- this._setInputType(inputType);
- this._toggleEmptinessEventHandler()
- }
- },
- _renderProps: function() {
- this.callBase();
- this._input().prop({
- min: this.option("min"),
- max: this.option("max"),
- step: this.option("step")
- })
- },
- _trimInputValue: function() {
- var $input = this._input(),
- value = $.trim($input.val());
- if (value[value.length - 1] === ".")
- value = value.slice(0, -1);
- this._forceRefreshInputValue(value)
- },
- _inputInvalidHandler: function() {
- var $input = this._input(),
- value = $input.val();
- if (this._oldValue) {
- this.option("value", this._oldValue);
- $input.val(this._oldValue);
- this._oldValue = null
- }
- else {
- this.option("value", "");
- $input.val("")
- }
- },
- _forceRefreshInputValue: function(value) {
- var $input = this._input();
- $input.val("").val(value)
- },
- _renderValueUpdateEvent: function() {
- this.callBase();
- this._input().focusout($.proxy(this._trimInputValue, this))
- },
- _handleValueChangeEvent: function(e) {
- var $input = this._input(),
- value = $.trim($input.val()),
- input = $input.get(0);
- value = value.replace(",", ".");
- this._valueChangeEventInstance = e;
- if (!this._isIncompleteValue)
- if (!this._validateValue(value)) {
- this._inputInvalidHandler();
- return
- }
- if (value !== "") {
- if (this._isIncompleteValue)
- return;
- value = this._parseValue(value);
- if (!value && value !== 0)
- return;
- this.callBase(e, value);
- if ($input.val() != value)
- $input.val(value)
- }
- else
- this.option("value", "")
- },
- _validateValue: function(value) {
- var isValueValid = this._isValueValid();
- if (!value && isValueValid) {
- this.option("value", "");
- return true
- }
- var isNumber = /^-?\d*\.?\d*$/.test(value),
- isExponent = /^-?\d+e[-+]?\d+$/.test(value);
- this._oldValue = this.option("value");
- if (!isNumber && !isExponent && !isValueValid)
- return false;
- return true
- },
- _parseValue: function(value) {
- var number = parseFloat(value);
- if (this.option("min") !== undefined)
- number = math.max(number, this.option("min"));
- if (this.option("max") !== undefined)
- number = math.min(number, this.option("max"));
- return number
- },
- _setValue: function(value, prevValue) {
- if (!value && value !== 0) {
- this.option("value", "");
- return
- }
- if ($.type(value) === "string")
- value = value.replace(",", ".");
- value = this._parseValue(value);
- if (!value && value !== 0) {
- this.option("value", prevValue);
- return
- }
- this.option("value", value)
- },
- _invalidate: function() {
- this._$spinContainer.detach();
- this.callBase()
- },
- _dispose: function() {
- this._$spinContainer.remove();
- this.callBase()
- },
- _optionChanged: function(name, value, prevValue) {
- switch (name) {
- case"value":
- this._setValue(value, prevValue);
- this.callBase.apply(this, arguments);
- break;
- case"step":
- case"min":
- case"max":
- this._renderProps();
- break;
- case"showSpinButtons":
- this._renderSpinButtons();
- break;
- default:
- this.callBase.apply(this, arguments)
- }
- }
- }));
- ui.dxNumberBox.__internals = {
- WIDGET_CLASS: WIDGET_CLASS,
- SPIN_CLASS: SPIN_CLASS,
- SPIN_CONTAINER_CLASS: SPIN_CONTAINER_CLASS,
- SPIN_UP_CLASS: SPIN_UP_CLASS,
- SPIN_DOWN_CLASS: SPIN_DOWN_CLASS
- }
- })(jQuery, DevExpress);
- /*! Module widgets-base, file ui.radioButton.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- events = ui.events;
- var RADIO_BUTTON = "dxRadioButton",
- RADIO_BUTTON_CLASS = "dx-radio-button",
- RADIO_BUTTON_ICON_CLASS = "dx-radio-button-icon",
- RADIO_BUTTON_CHECKED_CLASS = "dx-radio-button-checked",
- RADIO_BUTTON_DXCLICK_EVENT_NAME = events.addNamespace("dxclick", RADIO_BUTTON);
- DX.registerComponent(RADIO_BUTTON, ui.dxEditor.inherit({
- _setDefaultOptions: function() {
- this.callBase();
- this.option({
- value: false,
- hoverStateEnabled: true
- })
- },
- _init: function() {
- this.callBase();
- this._element().addClass(RADIO_BUTTON_CLASS)
- },
- _render: function() {
- this.callBase();
- this._renderIcon();
- this._renderCheckedState(this.option("value"));
- this._renderClick()
- },
- _renderIcon: function() {
- var $icon = $("<div />").addClass(RADIO_BUTTON_ICON_CLASS);
- this._element().append($icon)
- },
- _renderCheckedState: function(checked) {
- this._element().toggleClass(RADIO_BUTTON_CHECKED_CLASS, checked)
- },
- _renderClick: function() {
- var clickAction = this._createAction($.proxy(function(args) {
- this._handleClick(args.jQueryEvent)
- }, this));
- this._element().off(RADIO_BUTTON_DXCLICK_EVENT_NAME).on(RADIO_BUTTON_DXCLICK_EVENT_NAME, function(e) {
- clickAction({jQueryEvent: e})
- })
- },
- _handleClick: function(e) {
- this._valueChangeEventInstance = e;
- this.option("value", true)
- },
- _optionChanged: function(name, value) {
- switch (name) {
- case"value":
- this._renderCheckedState(value);
- this.callBase.apply(this, arguments);
- break;
- default:
- this.callBase.apply(this, arguments)
- }
- }
- }))
- })(jQuery, DevExpress);
- /*! Module widgets-base, file ui.radioGroup.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- events = ui.events;
- var RADIO_GROUP_CLASS = "dx-radio-group",
- RADIO_GROUP_VERTICAL_CLASS = "dx-radio-group-vertical",
- RADIO_GROUP_HORIZONTAL_CLASS = "dx-radio-group-horizontal",
- RADIO_BUTTON_CLASS = "dx-radio-button",
- RADIO_BUTTON_ICON_CLASS = "dx-radio-button-icon",
- RADIO_VALUE_CONTAINER_CLASS = "dx-radio-value-container",
- RADIO_BUTTON_CHECKED_CLASS = "dx-radio-button-checked",
- RADIO_BUTTON_DATA_KEY = "dxRadioButtonData",
- RADIO_FEEDBACK_HIDE_TIMEOUT = 100;
- DX.registerComponent("dxRadioGroup", ui.CollectionContainerWidget.inherit({
- _activeStateUnit: "." + RADIO_BUTTON_CLASS,
- _setDefaultOptions: function() {
- this.callBase();
- this.option({
- layout: "vertical",
- value: undefined,
- valueExpr: null,
- hoverStateEnabled: true
- })
- },
- _defaultOptionsRules: function() {
- return this.callBase().slice(0).concat([{
- device: {tablet: true},
- options: {layout: "horizontal"}
- }])
- },
- _optionsByReference: function() {
- return $.extend(this.callBase(), {value: true})
- },
- _itemClass: function() {
- return RADIO_BUTTON_CLASS
- },
- _itemDataKey: function() {
- return RADIO_BUTTON_DATA_KEY
- },
- _itemContainer: function() {
- return this._element()
- },
- _init: function() {
- this.callBase();
- if (!this._dataSource)
- this._itemsToDataSource();
- this._feedbackHideTimeout = RADIO_FEEDBACK_HIDE_TIMEOUT
- },
- _itemsToDataSource: function() {
- this._dataSource = new DevExpress.data.DataSource(this.option("items"))
- },
- _render: function() {
- this._element().addClass(RADIO_GROUP_CLASS);
- this._compileValueGetter();
- this.callBase();
- this._renderLayout();
- this._renderValue();
- this._updateContentSize()
- },
- _renderDimensions: function() {
- this.callBase();
- this._updateContentSize()
- },
- _updateContentSize: function() {
- if (this.option("layout") === "horizontal")
- this._itemElements().css("height", "auto");
- else {
- var itemsCount = this.option("items").length;
- this._itemElements().css("height", 100 / itemsCount + "%")
- }
- },
- _compileValueGetter: function() {
- this._valueGetter = DX.data.utils.compileGetter(this._valueGetterExpr())
- },
- _valueGetterExpr: function() {
- return this.option("valueExpr") || this._dataSource && this._dataSource._store._key || "this"
- },
- _renderLayout: function() {
- var layout = this.option("layout");
- this._element().toggleClass(RADIO_GROUP_VERTICAL_CLASS, layout === "vertical");
- this._element().toggleClass(RADIO_GROUP_HORIZONTAL_CLASS, layout === "horizontal")
- },
- _renderValue: function() {
- var value = this.option("value");
- value != null && value !== undefined ? this._setIndexByValue() : this._setValueByIndex()
- },
- _setIndexByValue: function(value) {
- var that = this;
- value = value === undefined ? that.option("value") : value;
- that._searchValue(value).done(function(item) {
- if (that._dataSource.isLoaded())
- that._setIndexByItem(item);
- else
- that._dataSource.load().done(function() {
- that._setIndexByItem(item)
- })
- })
- },
- _setIndexByItem: function(item) {
- var selectedIndex = -1;
- $.each(this.option("items"), $.proxy(function(index, dataSourceItem) {
- if (this._valuesEqual(item, dataSourceItem)) {
- selectedIndex = index;
- return false
- }
- }, this));
- this.option("selectedIndex", selectedIndex)
- },
- _valuesEqual: function(item1, item2) {
- var dataSourceKey = this._dataSource && this._dataSource.key();
- var result = item1 === item2;
- if (dataSourceKey && !result) {
- var item1Key = DX.utils.unwrapObservable(item1[dataSourceKey]);
- var item2Key = DX.utils.unwrapObservable(item2[dataSourceKey]);
- result = item1Key === item2Key
- }
- return result
- },
- _searchValue: function(value) {
- var that = this,
- store = that._dataSource.store(),
- valueExpr = that._valueGetterExpr();
- var deffered = $.Deferred();
- if (valueExpr === store.key() || store instanceof DX.data.CustomStore)
- store.byKey(value).done(function(result) {
- deffered.resolveWith(that, [result])
- });
- else
- store.load({filter: [valueExpr, value]}).done(function(result) {
- deffered.resolveWith(that, result)
- });
- return deffered.promise()
- },
- _setValueByIndex: function() {
- var index = this.option("selectedIndex"),
- $items = this._itemElements();
- if (index < 0 || index >= $items.length) {
- this.option("value", null);
- return
- }
- var itemElement = this._selectedItemElement(index),
- itemData = this._getItemData(itemElement);
- this.option("value", this._getItemValue(itemData))
- },
- _getItemValue: function(item) {
- return !!this._valueGetter ? this._valueGetter(item) : item.text
- },
- _renderSelectedIndex: function(index) {
- var $radioButtons = this._itemElements();
- $radioButtons.removeClass(RADIO_BUTTON_CHECKED_CLASS);
- if (index >= 0 && index < $radioButtons.length)
- $radioButtons.eq(index).addClass(RADIO_BUTTON_CHECKED_CLASS)
- },
- _createItemByRenderer: function(itemRenderer, renderArgs) {
- var $itemElement = this.callBase.apply(this, arguments);
- this._renderInput($itemElement, renderArgs.item);
- return $itemElement
- },
- _createItemByTemplate: function(itemTemplate, renderArgs) {
- var $itemElement = this.callBase.apply(this, arguments);
- this._renderInput($itemElement, renderArgs.item);
- return $itemElement
- },
- _renderInput: function($element, item) {
- if (item.html)
- return;
- var $radio = $("<div>").addClass(RADIO_BUTTON_ICON_CLASS),
- $radioContainer = $("<div>").append($radio).addClass(RADIO_VALUE_CONTAINER_CLASS);
- $element.prepend($radioContainer)
- },
- _optionChanged: function(name, value) {
- switch (name) {
- case"value":
- this._setIndexByValue(value);
- break;
- case"selectedIndex":
- this.callBase.apply(this, arguments);
- this._setValueByIndex();
- break;
- case"layout":
- this._renderLayout();
- this._updateContentSize();
- break;
- case"valueExpr":
- this._compileValueGetter();
- this._setValueByIndex();
- break;
- default:
- this.callBase.apply(this, arguments)
- }
- }
- }))
- })(jQuery, DevExpress);
- /*! Module widgets-base, file ui.tabs.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- events = ui.events,
- TABS_CLASS = "dx-tabs",
- TABS_WRAPPER_CLASS = "dx-indent-wrapper",
- TABS_ITEM_CLASS = "dx-tab",
- TABS_ITEM_SELECTOR = ".dx-tab",
- TABS_ITEM_SELECTED_CLASS = "dx-tab-selected",
- TABS_ITEM_TEXT_CLASS = "dx-tab-text",
- ICON_CLASS = "dx-icon",
- TABS_ITEM_DATA_KEY = "dxTabData",
- FEEDBACK_HIDE_TIMEOUT = 100,
- ACTIVE_STATE_CLASS = "dx-state-active";
- DX.registerComponent("dxTabs", ui.CollectionContainerWidget.inherit({
- _activeStateUnit: TABS_ITEM_SELECTOR,
- _setDefaultOptions: function() {
- this.callBase();
- this.option({hoverStateEnabled: true})
- },
- _init: function() {
- this.callBase();
- this._feedbackHideTimeout = FEEDBACK_HIDE_TIMEOUT
- },
- _itemClass: function() {
- return TABS_ITEM_CLASS
- },
- _itemDataKey: function() {
- return TABS_ITEM_DATA_KEY
- },
- _itemRenderDefault: function(item, index, itemElement) {
- this.callBase(item, index, itemElement);
- if (item.html)
- return;
- var text = item.text,
- icon = item.icon,
- iconSrc = item.iconSrc,
- iconElement;
- if (text)
- itemElement.wrapInner($("<span />").addClass(TABS_ITEM_TEXT_CLASS));
- if (icon)
- iconElement = $("<span />").addClass(ICON_CLASS + "-" + icon);
- else if (iconSrc)
- iconElement = $("<img />").attr("src", iconSrc);
- if (iconElement)
- iconElement.addClass(ICON_CLASS).prependTo(itemElement)
- },
- _render: function() {
- this.callBase();
- var $element = this._element();
- $element.addClass(TABS_CLASS);
- this._renderWrapper();
- $element.addClass(ACTIVE_STATE_CLASS).removeClass(ACTIVE_STATE_CLASS)
- },
- _renderWrapper: function() {
- this._element().wrapInner($("<div />").addClass(TABS_WRAPPER_CLASS))
- },
- _renderSelectedIndex: function(current, previous) {
- var $tabs = this._itemElements();
- if (previous >= 0)
- $tabs.eq(previous).removeClass(TABS_ITEM_SELECTED_CLASS);
- if (current >= 0)
- $tabs.eq(current).addClass(TABS_ITEM_SELECTED_CLASS)
- }
- }))
- })(jQuery, DevExpress);
- /*! Module widgets-base, file ui.navBar.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- NAVBAR_CLASS = "dx-navbar",
- NABAR_ITEM_CLASS = "dx-nav-item",
- NAVBAR_ITEM_CONTENT_CLASS = "dx-nav-item-content",
- NAVBAR_ITEM_BADGE_CLASS = "dx-navbar-item-badge";
- DX.registerComponent("dxNavBar", ui.dxTabs.inherit({
- _render: function() {
- this.callBase();
- this._element().addClass(NAVBAR_CLASS)
- },
- _postprocessRenderItem: function(args) {
- var $itemElement = args.itemElement,
- itemData = args.itemData,
- badge = itemData.badge;
- if (badge)
- $("<div>").addClass(NAVBAR_ITEM_BADGE_CLASS).text(badge).appendTo($itemElement);
- $itemElement.addClass(NABAR_ITEM_CLASS);
- $itemElement.wrapInner($("<div>").addClass(NAVBAR_ITEM_CONTENT_CLASS));
- if (!itemData.icon && !itemData.iconSrc)
- $itemElement.addClass("dx-navbar-text-item")
- }
- }))
- })(jQuery, DevExpress);
- /*! Module widgets-base, file ui.toolbar.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- fx = DX.fx,
- utils = DX.utils,
- translator = DX.translator;
- var TOOLBAR_CLASS = "dx-toolbar",
- TOOLBAR_BOTTOM_CLASS = "dx-toolbar-bottom",
- TOOLBAR_MINI_CLASS = "dx-toolbar-mini",
- TOOLBAR_ITEM_CLASS = "dx-toolbar-item",
- TOOLBAR_LABEL_CLASS = "dx-toolbar-label",
- TOOLBAR_BUTTON_CLASS = "dx-toolbar-button",
- TOOLBAR_MENU_CONTAINER_CLASS = "dx-toolbar-menu-container",
- TOOLBAR_MENU_BUTTON_CLASS = "dx-toolbar-menu-button",
- TOOLBAR_ITEMS_CONTAINER_CLASS = "dx-toolbar-items-container",
- TOOLBAR_LABEL_SELECTOR = "." + TOOLBAR_LABEL_CLASS,
- TOOLBAR_ITEM_DATA_KEY = "dxToolbarItemDataKey",
- SUBMENU_SWIPE_EASING = "easeOutCubic",
- SUBMENU_HIDE_DURATION = 200,
- SUBMENU_SHOW_DURATION = 400;
- var slideSubmenu = function($element, position, isShowAnimation) {
- var duration = isShowAnimation ? SUBMENU_SHOW_DURATION : SUBMENU_HIDE_DURATION;
- fx.animate($element, {
- type: "slide",
- to: {top: position},
- easing: SUBMENU_SWIPE_EASING,
- duration: duration
- })
- };
- DX.registerComponent("dxToolbar", ui.CollectionContainerWidget.inherit({
- _setDefaultOptions: function() {
- this.callBase();
- this.option({
- menuItemRender: null,
- menuItemTemplate: "item",
- submenuType: "dxDropDownMenu",
- renderAs: "topToolbar"
- })
- },
- _defaultOptionsRules: function() {
- return this.callBase().slice(0).concat([{
- device: [{platform: "ios"}, {platform: "ios7"}],
- options: {submenuType: "dxActionSheet"}
- }, {
- device: {platform: "android"},
- options: {submenuType: "dxDropDownMenu"}
- }, {
- device: {platform: "win8"},
- options: {submenuType: "dxList"}
- }])
- },
- _itemContainer: function() {
- return this._$toolbarItemsContainer.find([".dx-toolbar-before", ".dx-toolbar-center", ".dx-toolbar-after"].join(","))
- },
- _itemClass: function() {
- return TOOLBAR_ITEM_CLASS
- },
- _itemDataKey: function() {
- return TOOLBAR_ITEM_DATA_KEY
- },
- _itemRenderDefault: function(item, index, itemElement) {
- this.callBase(item, index, itemElement);
- var widget = item.widget;
- if (widget) {
- var widgetElement = $("<div>").appendTo(itemElement),
- widgetName = DX.inflector.camelize("dx-" + widget),
- options = item.options || {};
- widgetElement[widgetName](options)
- }
- else if (item.text)
- itemElement.wrapInner("<div>")
- },
- _dimensionChanged: function() {
- if (this._menu)
- this._toggleMenuVisibility(false, true);
- this._arrangeTitle()
- },
- _render: function() {
- this._renderToolbar();
- this._renderSections();
- this.callBase();
- this._renderMenu();
- this._arrangeTitle()
- },
- _renderToolbar: function() {
- this._element().addClass(TOOLBAR_CLASS).toggleClass(TOOLBAR_BOTTOM_CLASS, this.option("renderAs") === "bottomToolbar");
- this._$toolbarItemsContainer = $("<div>").appendTo(this._element());
- this._$toolbarItemsContainer.addClass(TOOLBAR_ITEMS_CONTAINER_CLASS)
- },
- _renderSections: function() {
- var $container = this._$toolbarItemsContainer,
- that = this;
- $.each(["before", "center", "after"], function() {
- var sectionClass = "dx-toolbar-" + this,
- $section = $container.find("." + sectionClass);
- if (!$section.length)
- that["_$" + this + "Section"] = $section = $("<div>").addClass(sectionClass).appendTo($container)
- })
- },
- _arrangeTitle: function() {
- if (this._$element.is(":hidden")) {
- this._titleUpdateIsNeeded = true;
- return
- }
- this._titleUpdateIsNeeded = false;
- var $container = this._$toolbarItemsContainer,
- $centerSection = this._$centerSection,
- $label = $centerSection.children(TOOLBAR_LABEL_SELECTOR).eq(0);
- if ($label.length === 0)
- return;
- var containerWidth = $container.width(),
- beforeWidth = this._$beforeSection.outerWidth(),
- afterWidth = this._$afterSection.outerWidth();
- var elemsAtCenterWidth = 10;
- $centerSection.children().not(TOOLBAR_LABEL_SELECTOR).each(function() {
- elemsAtCenterWidth += $(this).outerWidth()
- });
- var maxLabelWidth = containerWidth - beforeWidth - afterWidth - elemsAtCenterWidth;
- var labelLongerThanMax = $label.width() > maxLabelWidth;
- $centerSection.css({
- marginLeft: labelLongerThanMax ? beforeWidth : "",
- marginRight: labelLongerThanMax ? afterWidth : ""
- });
- $label.css("max-width", maxLabelWidth)
- },
- _renderItem: function(index, item) {
- if (item.align)
- utils.logger.warn("dxToolbar.items.align is deprecated. Please use dxToolbar.items.location instead.");
- var align = item.location || item.align || "center";
- if (align === "left") {
- align = "before";
- utils.logger.warn("dxToolbar.items.location: value 'left' is deprecated. Please use 'before' instead.")
- }
- else if (align === "right") {
- align = "after";
- utils.logger.warn("dxToolbar.items.location: value 'right' is deprecated. Please use 'after' instead.")
- }
- var container = this._$toolbarItemsContainer.find(".dx-toolbar-" + align);
- var itemElement = this.callBase(index, item, container);
- itemElement.addClass(TOOLBAR_BUTTON_CLASS);
- if (item.text)
- itemElement.addClass(TOOLBAR_LABEL_CLASS).removeClass(TOOLBAR_BUTTON_CLASS);
- return itemElement
- },
- _hasVisibleMenuItems: function() {
- var menuItems = this._getMenuItems(),
- result = false;
- var optionGetter = DevExpress.data.utils.compileGetter("visible");
- $.each(menuItems, function(index, item) {
- var itemVisible = optionGetter(item, {functionsAsIs: true});
- if (itemVisible !== false)
- result = true
- });
- return result
- },
- _getToolbarItems: function() {
- return $.grep(this.option("items") || [], function(item) {
- return item.location !== "menu"
- })
- },
- _getMenuItems: function() {
- return $.grep(this.option("items") || [], function(item) {
- return item.location === "menu"
- })
- },
- _renderContentImpl: function() {
- var items = this._getToolbarItems();
- this._element().toggleClass(TOOLBAR_MINI_CLASS, items.length === 0);
- if (this._renderedItemsCount)
- this._renderItems(items.slice(this._renderedItemsCount));
- else
- this._renderItems(items)
- },
- _renderMenu: function() {
- var that = this,
- itemClickAction = this._createActionByOption("itemClickAction");
- var options = {
- itemRender: this.option("menuItemRender"),
- itemTemplate: this.option("menuItemTemplate"),
- itemClickAction: function(e) {
- that._toggleMenuVisibility(false, true);
- itemClickAction(e)
- },
- rtlEnabled: this.option("rtlEnabled")
- };
- this._menuType = this.option("submenuType");
- if (this._menuType === "dxList" && this.option("renderAs") === "topToolbar")
- this._menuType = "dxDropDownMenu";
- switch (this._menuType) {
- case"dxActionSheet":
- this._renderActionSheet(options);
- break;
- case"dxDropDownMenu":
- this._renderDropDown(options);
- break;
- case"dxList":
- this._renderList(options);
- break
- }
- },
- _renderMenuButton: function(options) {
- var buttonOptions = $.extend({clickAction: $.proxy(this._handleMenuButtonClick, this)}, options);
- this._renderMenuButtonContainer();
- this._$button = $("<div>").appendTo(this._$menuButtonContainer).addClass(TOOLBAR_MENU_BUTTON_CLASS).dxButton(buttonOptions)
- },
- _renderMenuButtonContainer: function() {
- var $afterSection = this._$afterSection;
- this._$menuButtonContainer = $("<div>").appendTo($afterSection).addClass(TOOLBAR_BUTTON_CLASS).addClass(TOOLBAR_MENU_CONTAINER_CLASS)
- },
- _renderDropDown: function(options) {
- if (!this._hasVisibleMenuItems())
- return;
- this._renderMenuButtonContainer();
- this._menu = $("<div>").appendTo(this._$menuButtonContainer).dxDropDownMenu(options).dxDropDownMenu("instance");
- this._renderMenuItems()
- },
- _renderActionSheet: function(options) {
- if (!this._hasVisibleMenuItems())
- return;
- this._renderMenuButton({icon: "overflow"});
- var actionSheetOptions = $.extend({
- target: this._$button,
- showTitle: false
- }, options);
- this._menu = $("<div>").appendTo(this._element()).dxActionSheet(actionSheetOptions).dxActionSheet("instance");
- this._renderMenuItems()
- },
- _renderList: function(options) {
- this._renderMenuButton({
- activeStateEnabled: false,
- text: "..."
- });
- var listOptions = $.extend({
- width: "100%",
- indicateLoading: false
- }, options);
- this._renderListOverlay();
- this._renderContainerSwipe();
- if (this._hasVisibleMenuItems()) {
- this._menu = $("<div>").appendTo(this._listOverlay.content()).dxList(listOptions).dxList("instance");
- this._renderMenuItems()
- }
- this._changeListVisible(this.option("visible"))
- },
- _renderMenuItems: function() {
- this._menu.option("items", this._getMenuItems())
- },
- _getListHeight: function() {
- var listHeight = this._listOverlay.content().find(".dx-list").height(),
- semiHiddenHeight = this._$toolbarItemsContainer.height() - this._element().height();
- return listHeight + semiHiddenHeight
- },
- _renderListOverlay: function() {
- var element = this._element();
- this._listOverlay = $("<div>").appendTo(element).dxOverlay({
- targetContainer: false,
- deferRendering: false,
- shading: false,
- height: "auto",
- width: "100%",
- showTitle: false,
- closeOnOutsideClick: $.proxy(this._handleListOutsideClick, this),
- position: null,
- animation: null,
- hideTopOverlayHandler: null
- }).dxOverlay("instance")
- },
- _hideTopOverlayHandler: function() {
- this._toggleMenuVisibility(false, true)
- },
- _toggleHideTopOverlayCallback: function() {
- if (this._closeCallback)
- DX.hideTopOverlayCallback.remove(this._closeCallback);
- if (this._menuShown) {
- this._closeCallback = $.proxy(this._hideTopOverlayHandler, this);
- DX.hideTopOverlayCallback.add(this._closeCallback)
- }
- },
- _renderContainerSwipe: function() {
- this._$toolbarItemsContainer.appendTo(this._listOverlay.content()).dxSwipeable({
- elastic: false,
- startAction: $.proxy(this._handleSwipeStart, this),
- updateAction: $.proxy(this._handleSwipeUpdate, this),
- endAction: $.proxy(this._handleSwipeEnd, this),
- itemSizeFunc: $.proxy(this._getListHeight, this),
- direction: "vertical"
- })
- },
- _handleListOutsideClick: function(e) {
- if (!$(e.target).closest(this._listOverlay.content()).length)
- this._toggleMenuVisibility(false, true)
- },
- _calculatePixelOffset: function(offset) {
- offset = (offset || 0) - 1;
- var maxOffset = this._getListHeight();
- return offset * maxOffset
- },
- _handleSwipeStart: function(e) {
- e.jQueryEvent.maxTopOffset = this._menuShown ? 0 : 1;
- e.jQueryEvent.maxBottomOffset = this._menuShown ? 1 : 0
- },
- _handleSwipeUpdate: function(e) {
- var offset = this._menuShown ? e.jQueryEvent.offset : 1 + e.jQueryEvent.offset;
- this._renderMenuPosition(offset, false)
- },
- _handleSwipeEnd: function(e) {
- var targetOffset = e.jQueryEvent.targetOffset;
- targetOffset -= this._menuShown - 1;
- this._toggleMenuVisibility(targetOffset === 0, true)
- },
- _renderMenuPosition: function(offset, animate) {
- var pos = this._calculatePixelOffset(offset),
- element = this._listOverlay.content();
- if (animate)
- slideSubmenu(element, pos, this._menuShown);
- else
- translator.move(element, {top: pos})
- },
- _handleMenuButtonClick: function() {
- this._toggleMenuVisibility(!this._menuShown, true)
- },
- _toggleMenuVisibility: function(visible, animate) {
- this._menuShown = visible;
- switch (this._menuType) {
- case"dxList":
- this._toggleHideTopOverlayCallback();
- this._renderMenuPosition(this._menuShown ? 0 : 1, animate);
- break;
- case"dxActionSheet":
- this._menu.toggle(this._menuShown);
- this._menuShown = false;
- break
- }
- },
- _renderEmptyMessage: $.noop,
- _clean: function() {
- this._$toolbarItemsContainer.children().empty();
- this._element().empty()
- },
- _changeMenuOption: function(name, value) {
- if (this._menu)
- this._menu.option(name, value)
- },
- _changeListVisible: function(value) {
- if (this._listOverlay) {
- this._listOverlay.option("visible", value);
- this._toggleMenuVisibility(false, false)
- }
- },
- _visibilityChanged: function(visible) {
- if (visible && this._titleUpdateIsNeeded)
- this._arrangeTitle()
- },
- _optionChanged: function(name, value) {
- switch (name) {
- case"renderAs":
- case"submenuType":
- this._invalidate();
- break;
- case"visible":
- this._changeListVisible(value);
- this.callBase.apply(this, arguments);
- break;
- case"menuItemRender":
- this._changeMenuOption("itemRender", value);
- break;
- case"menuItemTemplate":
- this._changeMenuOption("itemTemplate", value);
- break;
- case"itemClickAction":
- this._changeMenuOption(name, value);
- this.callBase.apply(this, arguments);
- break;
- default:
- this.callBase.apply(this, arguments)
- }
- }
- }))
- })(jQuery, DevExpress);
- /*! Module widgets-base, file ui.list.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- events = ui.events,
- utils = DX.utils;
- var LIST_CLASS = "dx-list",
- LIST_ITEM_CLASS = "dx-list-item",
- LIST_ITEM_SELECTOR = "." + LIST_ITEM_CLASS,
- LIST_GROUP_CLASS = "dx-list-group",
- LIST_GROUP_HEADER_CLASS = "dx-list-group-header",
- LIST_HAS_NEXT_CLASS = "dx-has-next",
- LIST_NEXT_BUTTON_CLASS = "dx-list-next-button",
- LIST_ITEM_DATA_KEY = "dxListItemData",
- LIST_FEEDBACK_SHOW_TIMEOUT = 70;
- DX.registerComponent("dxList", ui.CollectionContainerWidget.inherit({
- _activeStateUnit: LIST_ITEM_SELECTOR,
- _setDefaultOptions: function() {
- this.callBase();
- this.option({
- pullRefreshEnabled: false,
- autoPagingEnabled: true,
- scrollingEnabled: true,
- showScrollbar: true,
- useNativeScrolling: true,
- pullingDownText: Globalize.localize("dxList-pullingDownText"),
- pulledDownText: Globalize.localize("dxList-pulledDownText"),
- refreshingText: Globalize.localize("dxList-refreshingText"),
- pageLoadingText: Globalize.localize("dxList-pageLoadingText"),
- scrollAction: null,
- pullRefreshAction: null,
- pageLoadingAction: null,
- showNextButton: false,
- nextButtonText: Globalize.localize("dxList-nextButtonText"),
- itemSwipeAction: null,
- grouped: false,
- groupTemplate: "group",
- groupRender: null,
- indicateLoading: true,
- hoverStateEnabled: true
- })
- },
- _defaultOptionsRules: function() {
- return this.callBase().slice(0).concat([{
- device: function(device) {
- return !DX.support.nativeScrolling
- },
- options: {useNativeScrolling: false}
- }, {
- device: function(device) {
- return !DX.support.nativeScrolling && !DX.devices.isSimulator() && DX.devices.real().platform === "generic" && device.platform === "generic"
- },
- options: {
- showScrollbar: "onHover",
- showNextButton: true,
- autoPagingEnabled: false
- }
- }])
- },
- _itemClass: function() {
- return LIST_ITEM_CLASS
- },
- _itemDataKey: function() {
- return LIST_ITEM_DATA_KEY
- },
- _itemContainer: function() {
- return this._$container
- },
- _allowDinamicItemsAppend: function() {
- return true
- },
- _init: function() {
- this.callBase();
- this._$container = this._element();
- this._initScrollView();
- this._feedbackShowTimeout = LIST_FEEDBACK_SHOW_TIMEOUT
- },
- _dataSourceOptions: function() {
- return $.extend(this.callBase(), {paginate: true})
- },
- _initScrollView: function() {
- var scrollingEnabled = this.option("scrollingEnabled"),
- pullRefreshEnabled = scrollingEnabled && this.option("pullRefreshEnabled"),
- autoPagingEnabled = scrollingEnabled && this.option("autoPagingEnabled") && !!this._dataSource;
- var $scrollView = this._element().dxScrollView({
- rtlEnabled: this.option("rtlEnabled"),
- disabled: this.option("disabled") || !scrollingEnabled,
- scrollAction: $.proxy(this._handleScroll, this),
- pullDownAction: pullRefreshEnabled ? $.proxy(this._handlePullDown, this) : null,
- reachBottomAction: autoPagingEnabled ? $.proxy(this._handleScrollBottom, this) : null,
- showScrollbar: this.option("showScrollbar"),
- useNative: this.option("useNativeScrolling"),
- pullingDownText: this.option("pullingDownText"),
- pulledDownText: this.option("pulledDownText"),
- refreshingText: this.option("refreshingText"),
- reachBottomText: this.option("pageLoadingText")
- });
- this._scrollView = $scrollView.dxScrollView("instance");
- this._scrollView.toggleLoading(autoPagingEnabled);
- this._$container = this._scrollView.content();
- this._createScrollViewActions();
- this._afterItemsRendered()
- },
- _createScrollViewActions: function() {
- this._scrollAction = this._createActionByOption("scrollAction", {excludeValidators: ["gesture"]});
- this._pullRefreshAction = this._createActionByOption("pullRefreshAction", {excludeValidators: ["gesture"]});
- this._pageLoadingAction = this._createActionByOption("pageLoadingAction", {excludeValidators: ["gesture"]})
- },
- _handleScroll: function(e) {
- this._scrollAction(e)
- },
- _afterItemsRendered: function(tryLoadMore) {
- var isLastPage = this._isLastPage(),
- allDataLoaded = !tryLoadMore || isLastPage,
- autoPagingEnabled = this.option("autoPagingEnabled"),
- stopLoading = !autoPagingEnabled || allDataLoaded,
- scrollViewIsFull = this._scrollViewIsFull();
- if (stopLoading || scrollViewIsFull) {
- this._scrollView.release(stopLoading);
- this._loadIndicationSuppressed = false;
- if (this._shouldRenderNextButton() && this._dataSource.isLoaded())
- this._toggleNextButton(!allDataLoaded)
- }
- else
- this._infiniteDataLoading()
- },
- _shouldRenderNextButton: function() {
- return this.option("showNextButton") && this._dataSource
- },
- _handleDataSourceLoadingChanged: function(isLoading) {
- if (this._loadIndicationSuppressed)
- return;
- if (isLoading && this.option("indicateLoading"))
- this._showLoadingIndicatorTimer = setTimeout($.proxy(function() {
- this._scrollView && this._scrollView.startLoading()
- }, this));
- else {
- clearTimeout(this._showLoadingIndicatorTimer);
- this._scrollView && this._scrollView.finishLoading()
- }
- },
- _hideLoadingIfLoadIndicationOff: function() {
- if (!this.option("indicateLoading"))
- this._handleDataSourceLoadingChanged(false)
- },
- _suppressLoadingIndication: function() {
- this._loadIndicationSuppressed = true
- },
- _isLastPage: function() {
- return !this._dataSource || this._dataSource.isLastPage()
- },
- _scrollViewIsFull: function() {
- return !this._scrollView || this._scrollView.isFull()
- },
- _handlePullDown: function(e) {
- this._pullRefreshAction(e);
- if (this._dataSource && !this._dataSource.isLoading()) {
- this._dataSource.pageIndex(0);
- this._dataSource.load()
- }
- else
- this._afterItemsRendered()
- },
- _infiniteDataLoading: function() {
- var dataSource = this._dataSource;
- if (!this._scrollViewIsFull() && dataSource && !dataSource.isLoading() && !this._isLastPage())
- this._loadNextPageTimer = setTimeout($.proxy(this._loadNextPage, this))
- },
- _handleScrollBottom: function(e) {
- this._pageLoadingAction(e);
- var dataSource = this._dataSource;
- if (dataSource && !dataSource.isLoading())
- this._loadNextPage();
- else
- this._afterItemsRendered()
- },
- _loadNextPage: function() {
- var dataSource = this._dataSource;
- this._expectNextPageLoading();
- dataSource.pageIndex(1 + dataSource.pageIndex());
- return dataSource.load()
- },
- _renderItems: function(items) {
- if (this.option("grouped")) {
- $.each(items, $.proxy(this._renderGroup, this));
- this._renderEmptyMessage()
- }
- else
- this.callBase.apply(this, arguments);
- this._afterItemsRendered(true)
- },
- _handleDataSourceLoadError: function() {
- this.callBase.apply(this, arguments);
- if (this._initialized)
- this._afterItemsRendered()
- },
- _render: function() {
- this._element().addClass(LIST_CLASS);
- this.callBase()
- },
- _postprocessRenderItem: function(args) {
- if (this.option("itemSwipeAction"))
- this._attachSwipeEvent($(args.itemElement))
- },
- _attachSwipeEvent: function($itemElement) {
- var endEventName = events.addNamespace("dxswipeend", this.NAME);
- $itemElement.on(endEventName, $.proxy(this._handleItemSwipeEnd, this))
- },
- _handleItemSwipeEnd: function(e) {
- this._handleItemJQueryEvent(e, "itemSwipeAction", {direction: e.offset < 0 ? "left" : "right"}, {excludeValidators: ["gesture"]})
- },
- _handleNextButton: function() {
- var source = this._dataSource;
- if (source && !source.isLoading()) {
- this._scrollView.toggleLoading(true);
- this._$nextButton.detach();
- this._suppressLoadingIndication();
- this._loadNextPage()
- }
- },
- _groupRenderDefault: function(group) {
- return String(group.key || group)
- },
- _renderGroup: function(index, group) {
- var that = this;
- var groupElement = $("<div>").addClass(LIST_GROUP_CLASS).appendTo(that._itemContainer());
- var groupRenderer = that.option("groupRender"),
- groupTemplateName = that.option("groupTemplate"),
- groupTemplate = that._getTemplate(group.template || groupTemplateName, index, group),
- groupHeaderElement,
- renderArgs = {
- index: index,
- group: group,
- container: groupElement
- };
- if (groupRenderer)
- groupHeaderElement = that._createGroupByRenderer(groupRenderer, renderArgs);
- else if (groupTemplate)
- groupHeaderElement = that._createGroupByTemplate(groupTemplate, renderArgs);
- else
- groupHeaderElement = that._createGroupByRenderer(that._groupRenderDefault, renderArgs);
- groupHeaderElement.addClass(LIST_GROUP_HEADER_CLASS);
- this._renderingGroupIndex = index;
- $.each(group.items || [], function(index, item) {
- that._renderItem(index, item, groupElement)
- })
- },
- _createGroupByRenderer: function(groupRenderer, renderArgs) {
- var groupElement = $("<div>").appendTo(renderArgs.container);
- var rendererResult = groupRenderer(renderArgs.group, renderArgs.index, groupElement);
- if (rendererResult && groupElement[0] !== rendererResult[0])
- groupElement.append(rendererResult);
- return groupElement
- },
- _createGroupByTemplate: function(groupTemplate, renderArgs) {
- return groupTemplate.render(renderArgs.container, renderArgs.group)
- },
- _clean: function() {
- if (this._$nextButton) {
- this._$nextButton.remove();
- this._$nextButton = null
- }
- this.callBase.apply(this, arguments)
- },
- _dispose: function() {
- clearTimeout(this._holdTimer);
- clearTimeout(this._loadNextPageTimer);
- clearTimeout(this._showLoadingIndicatorTimer);
- this.callBase()
- },
- _toggleDisabledState: function(value) {
- this.callBase(value);
- this._scrollView.option("disabled", value || !this.option("scrollingEnabled"))
- },
- _toggleNextButton: function(value) {
- var dataSource = this._dataSource,
- $nextButton = this._getNextButton();
- this._element().toggleClass(LIST_HAS_NEXT_CLASS, value);
- if (value && dataSource && dataSource.isLoaded())
- $nextButton.appendTo(this._itemContainer());
- if (!value)
- $nextButton.detach()
- },
- _getNextButton: function() {
- if (!this._$nextButton)
- this._$nextButton = this._createNextButton();
- return this._$nextButton
- },
- _createNextButton: function() {
- var $result = $("<div>").addClass(LIST_NEXT_BUTTON_CLASS);
- $result.append($("<div>").dxButton({
- text: this.option("nextButtonText"),
- clickAction: $.proxy(this._handleNextButton, this)
- }));
- return $result
- },
- _optionChanged: function(name, value, prevValue) {
- switch (name) {
- case"showNextButton":
- this._toggleNextButton(value);
- break;
- case"dataSource":
- this.callBase.apply(this, arguments);
- this._initScrollView();
- break;
- case"pullingDownText":
- case"pulledDownText":
- case"refreshingText":
- case"pageLoadingText":
- case"useNativeScrolling":
- case"showScrollbar":
- case"scrollingEnabled":
- case"pullRefreshEnabled":
- case"autoPagingEnabled":
- this._initScrollView();
- break;
- case"nextButtonText":
- case"itemSwipeAction":
- this._invalidate();
- break;
- case"scrollAction":
- case"pullRefreshAction":
- case"pageLoadingAction":
- this._createScrollViewActions();
- this._invalidate();
- break;
- case"grouped":
- case"groupTemplate":
- case"groupRender":
- this._invalidate();
- break;
- case"items":
- this._invalidate();
- break;
- case"width":
- case"height":
- this.callBase.apply(this, arguments);
- this._scrollView.update();
- break;
- case"indicateLoading":
- this._hideLoadingIfLoadIndicationOff();
- break;
- case"visible":
- this.callBase.apply(this, arguments);
- this._scrollView.update();
- break;
- case"rtlEnabled":
- this._initScrollView();
- this.callBase.apply(this, arguments);
- break;
- default:
- this.callBase.apply(this, arguments)
- }
- },
- update: function() {
- utils.logger.warn("'update' method is deprecated since 14.1. Use the 'updateDimensions' method instead.");
- return this.updateDimensions.apply(this, arguments)
- },
- updateDimensions: function() {
- var that = this,
- deferred = $.Deferred();
- if (that._scrollView)
- that._scrollView.update().done(function() {
- deferred.resolveWith(that)
- });
- else
- deferred.resolveWith(that);
- return deferred.promise()
- },
- refresh: function() {
- utils.logger.warn("'refresh' method is deprecated since 14.1. Use the 'reload' method instead.");
- return this.reload.apply(this, arguments)
- },
- reload: function() {
- this.scrollTo(0);
- this._handlePullDown()
- },
- scrollTop: function() {
- return this._scrollView.scrollOffset().top
- },
- clientHeight: function() {
- return this._scrollView.clientHeight()
- },
- scrollHeight: function() {
- return this._scrollView.scrollHeight()
- },
- scrollBy: function(distance) {
- this._scrollView.scrollBy(distance)
- },
- scrollTo: function(location) {
- this._scrollView.scrollTo(location)
- },
- scrollToItem: function(itemElement) {
- this._scrollView.scrollToElement(itemElement)
- }
- }))
- })(jQuery, DevExpress);
- /*! Module widgets-base, file ui.list.edit.strategies.js */
- (function($, DX, undefined) {
- var ui = DX.ui;
- var ListEditStrategy = DX.Class.inherit({
- ctor: function(list) {
- this._list = list
- },
- getNormalizedIndex: function(value) {
- if (this._isNormalisedItemIndex(value))
- return value;
- if (this._isItemIndex(value))
- return this._normalizeItemIndex(value);
- return this._getNormalizedItemIndex(value)
- },
- getIndex: function(value) {
- if (this._isNormalisedItemIndex(value))
- return this._denormalizeItemIndex(value);
- if (this._isItemIndex(value))
- return value;
- return this._denormalizeItemIndex(this._getNormalizedItemIndex(value))
- },
- getItemElement: function(value) {
- if (this._isNormalisedItemIndex(value))
- return this._getItemByNormalizedIndex(value);
- if (this._isItemIndex(value))
- return this._getItemByNormalizedIndex(this._normalizeItemIndex(value));
- return $(value)
- },
- deleteItemAtIndex: DX.abstract,
- updateSelectionAfterDelete: DX.abstract,
- fetchSelectedItems: DX.abstract,
- selectedItemIndecies: DX.abstract,
- itemPlacementFunc: function(movingIndex, destinationIndex) {
- return this._itemsFromSameParent(movingIndex, destinationIndex) && movingIndex < destinationIndex ? "after" : "before"
- },
- moveItemAtIndexToIndex: DX.abstract,
- getSelectedItemsAfterReorderItem: function() {
- return this._list.option("selectedItems")
- },
- _isNormalisedItemIndex: function(index) {
- return $.isNumeric(index)
- },
- _isItemIndex: DX.abstract,
- _getNormalizedItemIndex: DX.abstract,
- _normalizeItemIndex: DX.abstract,
- _denormalizeItemIndex: DX.abstract,
- _getItemByNormalizedIndex: DX.abstract,
- _itemsFromSameParent: DX.abstract
- });
- ui.PlainListEditStrategy = ListEditStrategy.inherit({
- deleteItemAtIndex: function(index) {
- this._list.option("items").splice(index, 1)
- },
- updateSelectionAfterDelete: function(fromIndex) {
- var selectedItemIndices = this._list._selectedItemIndices;
- $.each(selectedItemIndices, function(i, index) {
- if (index > fromIndex)
- selectedItemIndices[i] -= 1
- })
- },
- fetchSelectedItems: function(indecies) {
- indecies = indecies || this._list._selectedItemIndices;
- var items = this._list.option("items"),
- selectedItems = [];
- $.each(indecies, function(_, index) {
- selectedItems.push(items[index])
- });
- return selectedItems
- },
- selectedItemIndecies: function() {
- var selectedIndices = [],
- items = this._list.option("items"),
- selected = this._list.option("selectedItems");
- $.each(selected, function(_, selectedItem) {
- var index = $.inArray(selectedItem, items);
- if (index !== -1)
- selectedIndices.push(index);
- else
- throw new Error("Item '" + selectedItem + "' you are trying to select does not exist");
- });
- return selectedIndices
- },
- moveItemAtIndexToIndex: function(movingIndex, destinationIndex) {
- var items = this._list.option("items"),
- movedItemData = items[movingIndex];
- items.splice(movingIndex, 1);
- items.splice(destinationIndex, 0, movedItemData)
- },
- _isItemIndex: function(index) {
- return $.isNumeric(index)
- },
- _getNormalizedItemIndex: function(itemElement) {
- return this._list._itemElements().index(itemElement)
- },
- _normalizeItemIndex: function(index) {
- return index
- },
- _denormalizeItemIndex: function(index) {
- return index
- },
- _getItemByNormalizedIndex: function(index) {
- return this._list._itemElements().eq(index)
- },
- _itemsFromSameParent: function() {
- return true
- }
- });
- var LIST_ITEM_CLASS = "dx-list-item",
- LIST_GROUP_CLASS = "dx-list-group";
- var SELECTION_SHIFT = 20,
- SELECTION_MASK = 0x8FF;
- var combineIndex = function(indices) {
- return (indices.group << SELECTION_SHIFT) + indices.item
- };
- var splitIndex = function(combinedIndex) {
- return {
- group: combinedIndex >> SELECTION_SHIFT,
- item: combinedIndex & SELECTION_MASK
- }
- };
- var createGroupSelection = function(group, selectedItems) {
- var groupItems = group.items,
- groupSelection = {
- key: group.key,
- items: []
- };
- $.each(selectedItems, function(_, itemIndex) {
- groupSelection.items.push(groupItems[itemIndex])
- });
- return groupSelection
- };
- var groupByKey = function(groups, key) {
- var length = groups.length;
- for (var i = 0; i < length; i++)
- if (groups[i].key === key)
- return groups[i]
- };
- ui.GroupedListEditStrategy = ListEditStrategy.inherit({
- _groupElements: function() {
- return this._list._itemContainer().find("." + LIST_GROUP_CLASS)
- },
- _groupItemElements: function($group) {
- return $group.find("." + LIST_ITEM_CLASS)
- },
- deleteItemAtIndex: function(index) {
- var indices = splitIndex(index),
- itemGroup = this._list.option("items")[indices.group].items;
- itemGroup.splice(indices.item, 1)
- },
- updateSelectionAfterDelete: function(fromIndex) {
- var deletedIndices = splitIndex(fromIndex),
- selectedItemIndices = this._list._selectedItemIndices;
- $.each(selectedItemIndices, function(i, index) {
- var indices = splitIndex(index);
- if (indices.group === deletedIndices.group && indices.item > deletedIndices.item)
- selectedItemIndices[i] -= 1
- })
- },
- fetchSelectedItems: function(indecies) {
- indecies = indecies || this._list._selectedItemIndices;
- var items = this._list.option("items"),
- selectedItems = [];
- indecies.sort(function(a, b) {
- return a - b
- });
- var currentGroupIndex = 0,
- groupSelectedIndices = [];
- $.each(indecies, function(_, combinedIndex) {
- var index = splitIndex(combinedIndex);
- if (index.group !== currentGroupIndex && groupSelectedIndices.length) {
- selectedItems.push(createGroupSelection(items[currentGroupIndex], groupSelectedIndices));
- groupSelectedIndices.length = 0
- }
- currentGroupIndex = index.group;
- groupSelectedIndices.push(index.item)
- });
- if (groupSelectedIndices.length)
- selectedItems.push(createGroupSelection(items[currentGroupIndex], groupSelectedIndices));
- return selectedItems
- },
- selectedItemIndecies: function() {
- var selectedIndices = [],
- items = this._list.option("items"),
- selected = this._list.option("selectedItems");
- $.each(selected, function(_, selectionInGroup) {
- var group = groupByKey(items, selectionInGroup.key),
- groupIndex = $.inArray(group, items);
- if (!group)
- throw new Error("Group with key '" + selectionInGroup.key + "' in which you are trying to select items does not exist.");
- $.each(selectionInGroup.items, function(_, selectedGroupItem) {
- var itemIndex = $.inArray(selectedGroupItem, group.items);
- if (itemIndex !== -1)
- selectedIndices.push(combineIndex({
- group: groupIndex,
- item: itemIndex
- }));
- else
- throw new Error("Item '" + selectedGroupItem + "' you are trying to select in group '" + selectionInGroup.key + "' does not exist");
- })
- });
- return selectedIndices
- },
- moveItemAtIndexToIndex: function(movingIndex, destinationIndex) {
- var items = this._list.option("items"),
- movingIndices = splitIndex(movingIndex),
- destinationIndices = splitIndex(destinationIndex),
- movingItemGroup = items[movingIndices.group].items,
- destinationItemGroup = items[destinationIndices.group].items,
- movedItemData = movingItemGroup[movingIndices.item];
- movingItemGroup.splice(movingIndices.item, 1);
- destinationItemGroup.splice(destinationIndices.item, 0, movedItemData)
- },
- getSelectedItemsAfterReorderItem: function(movingIndex, destinationIndex) {
- if (this._itemsFromSameParent(movingIndex, destinationIndex) || $.inArray(movingIndex, this._list._selectedItemIndices))
- return this.callBase();
- var items = this._list.option("items"),
- selectedItems = this._list.option("selectedItems"),
- movingIndices = splitIndex(movingIndex),
- destinationIndices = splitIndex(destinationIndex),
- movingSelectedItemGroup = selectedItems[movingIndices.group].items,
- destinationSelectedItemGroup = selectedItems[destinationIndices.group].items,
- movedItemData = items[movingIndices.group].items[movingIndices.item],
- movedItemSelectedIndex = $.inArray(movedItemData, movingSelectedItemGroup);
- movingSelectedItemGroup.splice(movedItemSelectedIndex, 1);
- destinationSelectedItemGroup.push(movedItemData);
- return selectedItems
- },
- _isItemIndex: function(index) {
- return $.isNumeric(index.group) && $.isNumeric(index.item)
- },
- _getNormalizedItemIndex: function(itemElement) {
- var $item = $(itemElement),
- $group = $item.closest("." + LIST_GROUP_CLASS);
- return combineIndex({
- group: this._groupElements().index($group),
- item: this._groupItemElements($group).index($item)
- })
- },
- _normalizeItemIndex: function(index) {
- return combineIndex(index)
- },
- _denormalizeItemIndex: function(index) {
- return splitIndex(index)
- },
- _getItemByNormalizedIndex: function(index) {
- var indices = splitIndex(index),
- $group = this._groupElements().eq(indices.group);
- return this._groupItemElements($group).eq(indices.item)
- },
- _itemsFromSameParent: function(firstIndex, secondIndex) {
- return splitIndex(firstIndex).group === splitIndex(secondIndex).group
- }
- })
- })(jQuery, DevExpress);
- /*! Module widgets-base, file ui.list.edit.decorators.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- events = ui.events,
- translator = DX.translator,
- fx = DX.fx,
- support = DX.support,
- utils = DX.utils;
- ui.ListEditDecoratorsRegistry = {};
- var registerDecorator = function(option, type, decoratorClass) {
- var decoratorsRegistry = ui.ListEditDecoratorsRegistry;
- var decoratorConfig = {};
- decoratorConfig[option] = decoratorsRegistry[option] ? decoratorsRegistry[option] : {};
- decoratorConfig[option][type] = decoratorClass;
- decoratorsRegistry = $.extend(decoratorsRegistry, decoratorConfig)
- };
- var LIST_ITEM_CONTENT_CLASS = "dx-list-item-content",
- LIST_ITEM_BAG_CONTAINER_CLASS = "dx-list-item-bag-container";
- var LIST_EDIT_DECORATOR = "dxListEditDecorator",
- SWIPE_START_EVENT_NAME = events.addNamespace("dxswipestart", LIST_EDIT_DECORATOR),
- SWIPE_UPDATE_EVENT_NAME = events.addNamespace("dxswipe", LIST_EDIT_DECORATOR),
- SWIPE_END_EVENT_NAME = events.addNamespace("dxswipeend", LIST_EDIT_DECORATOR),
- DRAG_START_EVENT_NAME = events.addNamespace("dxdragstart", LIST_EDIT_DECORATOR),
- DRAG_UPDATE_EVENT_NAME = events.addNamespace("dxdrag", LIST_EDIT_DECORATOR),
- DRAG_END_EVENT_NAME = events.addNamespace("dxdragend", LIST_EDIT_DECORATOR),
- POINTER_DOWN_EVENT_NAME = events.addNamespace("dxpointerdown", LIST_EDIT_DECORATOR),
- CLICK_EVENT_NAME = events.addNamespace("dxclick", LIST_EDIT_DECORATOR);
- var ListEditDecorator = DX.Class.inherit({
- ctor: function(list) {
- this._list = list;
- this._init()
- },
- _init: $.noop,
- _shouldHandleSwipe: false,
- _attachSwipeEvent: function(config) {
- var swipeConfig = {itemSizeFunc: $.proxy(function() {
- if (this._clearSwipeCache) {
- this._itemWidthCache = this._list._element().width();
- this._clearSwipeCache = false
- }
- return this._itemWidthCache
- }, this)};
- config.$itemElement.on(SWIPE_START_EVENT_NAME, swipeConfig, $.proxy(this._handleItemSwipeStart, this)).on(SWIPE_UPDATE_EVENT_NAME, $.proxy(this._handleItemSwipeUpdate, this)).on(SWIPE_END_EVENT_NAME, $.proxy(this._handleItemSwipeEnd, this))
- },
- _handleItemSwipeStart: function(e) {
- var $itemElement = $(e.currentTarget);
- if ($itemElement.is(".dx-state-disabled, .dx-state-disabled *")) {
- e.cancel = true;
- return
- }
- this._handleSwipeStart($itemElement, e)
- },
- _handleItemSwipeUpdate: function(e) {
- var $itemElement = $(e.currentTarget);
- this._handleSwipeUpdate($itemElement, e)
- },
- _handleItemSwipeEnd: function(e) {
- var $itemElement = $(e.currentTarget);
- this._handleSwipeEnd($itemElement, e);
- this._clearSwipeCache = true
- },
- beforeBag: $.noop,
- afterBag: $.noop,
- modifyElement: function(config) {
- if (this._shouldHandleSwipe) {
- this._attachSwipeEvent(config);
- this._clearSwipeCache = true
- }
- },
- handleClick: $.noop,
- handleHold: $.noop,
- _handleSwipeStart: $.noop,
- _handleSwipeUpdate: $.noop,
- _handleSwipeEnd: $.noop,
- dispose: $.noop
- });
- var MENU_POSITIONING_CLASS = "dx-list-menu-positioning";
- var MenuDecorator = ListEditDecorator.inherit({
- _menuEnabled: function() {
- return !!this._menuItems().length
- },
- _menuItems: function() {
- return this._list.option("editConfig.menuItems")
- },
- _deleteEnabled: function() {
- return this._list.option("editConfig.deleteEnabled")
- },
- _fireMenuAction: function($itemElement, action) {
- this._list._handleItemEventByHandler($itemElement, action)
- }
- });
- var SWITCHABLE_DELETE_READY_CLASS = "dx-list-switchable-delete-ready",
- SWITCHABLE_DELETE_TOP_SHIELD_CLASS = "dx-list-switchable-delete-top-shield",
- SWITCHABLE_DELETE_BOTTOM_SHIELD_CLASS = "dx-list-switchable-delete-bottom-shield",
- SWITCHABLE_DELETE_ITEM_CONTENT_SHIELD_CLASS = "dx-list-switchable-delete-item-content-shield";
- var SwitchableMenuDecorator = MenuDecorator.inherit({
- _init: function() {
- this._$topShield = $("<div />").addClass(SWITCHABLE_DELETE_TOP_SHIELD_CLASS);
- this._$bottomShield = $("<div />").addClass(SWITCHABLE_DELETE_BOTTOM_SHIELD_CLASS);
- this._$itemContentShield = $("<div />").addClass(SWITCHABLE_DELETE_ITEM_CONTENT_SHIELD_CLASS);
- this._$topShield.on(POINTER_DOWN_EVENT_NAME, $.proxy(this._cancelDeleteReadyItem, this));
- this._$bottomShield.on(POINTER_DOWN_EVENT_NAME, $.proxy(this._cancelDeleteReadyItem, this));
- this._list._element().append(this._$topShield.toggle(false)).append(this._$bottomShield.toggle(false));
- if (this._animatePrepareDeleteReady === DX.abstract)
- this._animatePrepareDeleteReady = function() {
- return $.when().promise()
- };
- if (this._animateForgetDeleteReady === DX.abstract)
- this._animateForgetDeleteReady = function() {
- return $.when().promise()
- };
- this._list._element().on("dxpreparetodelete", ".dx-list-item", $.proxy(function(e) {
- this._toggleDeleteReady($(e.currentTarget))
- }, this))
- },
- handleClick: function($itemElement) {
- return this._cancelDeleteReadyItem()
- },
- _cancelDeleteReadyItem: function() {
- if (!this._$readyToDeleteItem)
- return false;
- this._cancelDelete(this._$readyToDeleteItem);
- return true
- },
- _cancelDelete: function($itemElement) {
- this._toggleDeleteReady($itemElement, false)
- },
- _toggleDeleteReady: function($itemElement, readyToDelete) {
- if (readyToDelete === undefined)
- readyToDelete = !this._isReadyToDelete($itemElement);
- this._toggleShields($itemElement, readyToDelete);
- this._toggleScrolling(readyToDelete);
- this._cacheReadyToDeleteItem($itemElement, readyToDelete);
- this._animateToggleDelete($itemElement, readyToDelete)
- },
- _isReadyToDelete: function($itemElement) {
- return $itemElement.hasClass(SWITCHABLE_DELETE_READY_CLASS)
- },
- _toggleShields: function($itemElement, enabled) {
- this._$topShield.toggle(enabled);
- this._$bottomShield.toggle(enabled);
- if (enabled)
- this._updateShieldsHeight($itemElement);
- this._toggleContentShield($itemElement, enabled)
- },
- _updateShieldsHeight: function($itemElement) {
- var $list = this._list._element(),
- listTopOffset = $list.offset().top,
- listHeight = $list.outerHeight(),
- itemTopOffset = $itemElement.offset().top,
- itemHeight = $itemElement.outerHeight(),
- dirtyTopShieldHeight = itemTopOffset - listTopOffset,
- dirtyBottomShieldHeight = listHeight - itemHeight - dirtyTopShieldHeight;
- this._$topShield.height(Math.max(dirtyTopShieldHeight, 0));
- this._$bottomShield.height(Math.max(dirtyBottomShieldHeight, 0))
- },
- _toggleContentShield: function($itemElement, enabled) {
- if (enabled)
- $itemElement.find("." + LIST_ITEM_CONTENT_CLASS).append(this._$itemContentShield);
- else
- this._$itemContentShield.detach()
- },
- _toggleScrolling: function(readyToDelete) {
- var scrollView = this._list._element().dxScrollView("instance");
- if (readyToDelete) {
- this._scrollViewDisabled = scrollView.option("disabled");
- scrollView.option("disabled", true)
- }
- else
- scrollView.option("disabled", this._scrollViewDisabled)
- },
- _cacheReadyToDeleteItem: function($itemElement, cache) {
- if (cache)
- this._$readyToDeleteItem = $itemElement;
- else
- delete this._$readyToDeleteItem
- },
- _animateToggleDelete: function($itemElement, readyToDelete) {
- if (readyToDelete) {
- this._enablePositioning($itemElement);
- this._prepareDeleteReady($itemElement);
- this._animatePrepareDeleteReady($itemElement)
- }
- else {
- this._forgetDeleteReady($itemElement);
- this._animateForgetDeleteReady($itemElement).done($.proxy(this._disablePositioning, this, $itemElement))
- }
- },
- _enablePositioning: function($itemElement) {
- $itemElement.addClass(MENU_POSITIONING_CLASS)
- },
- _disablePositioning: function($itemElement) {
- $itemElement.removeClass(MENU_POSITIONING_CLASS)
- },
- _prepareDeleteReady: function($itemElement) {
- $itemElement.addClass(SWITCHABLE_DELETE_READY_CLASS)
- },
- _forgetDeleteReady: function($itemElement) {
- $itemElement.removeClass(SWITCHABLE_DELETE_READY_CLASS)
- },
- _animatePrepareDeleteReady: DX.abstract,
- _animateForgetDeleteReady: DX.abstract,
- _deleteItem: function($itemElement) {
- $itemElement = $itemElement || this._$readyToDeleteItem;
- if ($itemElement.is(".dx-state-disabled, .dx-state-disabled *"))
- return;
- this._cancelDelete($itemElement);
- this._list.deleteItem($itemElement)
- },
- _isRtlEnabled: function() {
- return this._list.option("rtlEnabled")
- },
- dispose: function() {
- if (this._$topShield)
- this._$topShield.remove();
- if (this._$bottomShield)
- this._$bottomShield.remove();
- this.callBase.apply(this, arguments)
- }
- });
- registerDecorator("menu", "_switchable", SwitchableMenuDecorator);
- var SWITCHABLE_DELETE_BUTTON_CONTAINER_CLASS = "dx-list-switchable-delete-button-container",
- SWITCHABLE_DELETE_BUTTON_WRAPPER_CLASS = "dx-list-switchable-delete-button-wrapper",
- SWITCHABLE_DELETE_BUTTON_INNER_WRAPPER_CLASS = "dx-list-switchable-delete-button-inner-wrapper",
- SWITCHABLE_DELETE_BUTTON_CLASS = "dx-list-switchable-delete-button",
- SWITCHABLE_DELETE_MENU_CLASS = "dx-list-switchable-delete-menu",
- SWITCHABLE_DELETE_BUTTON_ANIMATION_DURATION = 200;
- var SwitchableButtonDeleteDecorator = SwitchableMenuDecorator.inherit({
- _init: function() {
- this.callBase.apply(this, arguments);
- var $buttonContainer = $("<div >").addClass(SWITCHABLE_DELETE_BUTTON_CONTAINER_CLASS),
- $buttonWrapper = $("<div />").addClass(SWITCHABLE_DELETE_BUTTON_WRAPPER_CLASS),
- $buttonInnerWrapper = $("<div />").addClass(SWITCHABLE_DELETE_BUTTON_INNER_WRAPPER_CLASS),
- $button = $("<div />").addClass(SWITCHABLE_DELETE_BUTTON_CLASS);
- $button.dxButton({
- text: Globalize.localize("dxListEditDecorator-delete"),
- type: "danger",
- clickAction: $.proxy(function(e) {
- this._deleteItem();
- e.jQueryEvent.stopPropagation()
- }, this)
- });
- $buttonContainer.append($buttonWrapper);
- $buttonWrapper.append($buttonInnerWrapper);
- $buttonInnerWrapper.append($button);
- this._$buttonContainer = $buttonContainer
- },
- _enablePositioning: function($itemElement) {
- this.callBase.apply(this, arguments);
- fx.stop(this._$buttonContainer, true);
- this._$buttonContainer.appendTo($itemElement)
- },
- _disablePositioning: function() {
- this.callBase.apply(this, arguments);
- this._$buttonContainer.detach()
- },
- _animatePrepareDeleteReady: function() {
- var rtl = this._isRtlEnabled(),
- listWidth = this._list._element().width(),
- buttonWidth = this._buttonWidth(),
- fromValue = rtl ? listWidth : -buttonWidth,
- toValue = rtl ? listWidth - buttonWidth : 0;
- return fx.animate(this._$buttonContainer, {
- type: "custom",
- duration: SWITCHABLE_DELETE_BUTTON_ANIMATION_DURATION,
- from: {right: fromValue},
- to: {right: toValue}
- })
- },
- _animateForgetDeleteReady: function() {
- var rtl = this._isRtlEnabled(),
- listWidth = this._list._element().width(),
- buttonWidth = this._buttonWidth(),
- fromValue = rtl ? listWidth - buttonWidth : 0,
- toValue = rtl ? listWidth : -buttonWidth;
- return fx.animate(this._$buttonContainer, {
- type: "custom",
- duration: SWITCHABLE_DELETE_BUTTON_ANIMATION_DURATION,
- from: {right: fromValue},
- to: {right: toValue}
- })
- },
- _buttonWidth: function() {
- if (!this._buttonContainerWidth)
- this._buttonContainerWidth = this._$buttonContainer.outerWidth();
- return this._buttonContainerWidth
- },
- dispose: function() {
- if (this._$buttonContainer)
- this._$buttonContainer.remove();
- this.callBase.apply(this, arguments)
- }
- });
- registerDecorator("menu", "_switchableButton", SwitchableButtonDeleteDecorator);
- var TOGGLE_DELETE_SWITCH_CONTAINER_CLASS = "dx-list-toggle-delete-switch-container",
- TOGGLE_DELETE_SWITCH_CLASS = "dx-list-toggle-delete-switch";
- registerDecorator("delete", "toggle", SwitchableButtonDeleteDecorator.inherit({beforeBag: function(config) {
- var $itemElement = config.$itemElement,
- $container = config.$container;
- var $toggle = $("<div />").dxButton({
- icon: "toggle-delete",
- clickAction: $.proxy(function(e) {
- this._toggleDeleteReady($itemElement);
- e.jQueryEvent.stopPropagation()
- }, this)
- }).addClass(TOGGLE_DELETE_SWITCH_CLASS);
- $container.addClass(TOGGLE_DELETE_SWITCH_CONTAINER_CLASS);
- $container.append($toggle)
- }}));
- registerDecorator("delete", "slideButton", SwitchableButtonDeleteDecorator.inherit({
- _shouldHandleSwipe: true,
- _handleSwipeEnd: function($itemElement, args) {
- if (args.targetOffset !== 0)
- this._toggleDeleteReady($itemElement);
- return true
- }
- }));
- var SLIDE_MENU_WRAPPER_CLASS = "dx-list-slide-menu-wrapper",
- SLIDE_MENU_CONTENT_CLASS = "dx-list-slide-menu-content",
- SLIDE_MENU_BUTTONS_CONTAINER_CLASS = "dx-list-slide-menu-buttons-container",
- SLIDE_MENU_BUTTONS_CLASS = "dx-list-slide-menu-buttons",
- SLIDE_MENU_BUTTON_CLASS = "dx-list-slide-menu-button",
- SLIDE_MENU_BUTTON_MENU_CLASS = "dx-list-slide-menu-button-menu",
- SLIDE_MENU_BUTTON_DELETE_CLASS = "dx-list-slide-menu-button-delete",
- SLIDE_MENU_CLASS = "dx-list-slide-menu";
- registerDecorator("menu", "slide", SwitchableMenuDecorator.inherit({
- _shouldHandleSwipe: true,
- _init: function() {
- this.callBase.apply(this, arguments);
- this._$buttonsContainer = $("<div/>").addClass(SLIDE_MENU_BUTTONS_CONTAINER_CLASS);
- this._$buttons = $("<div/>").addClass(SLIDE_MENU_BUTTONS_CLASS).appendTo(this._$buttonsContainer);
- this._renderMenu();
- this._renderDeleteButton()
- },
- _renderMenu: function() {
- if (!this._menuEnabled())
- return;
- var menuItems = this._menuItems();
- if (menuItems.length === 1) {
- var menuItem = menuItems[0];
- this._renderMenuButton(menuItem.text, $.proxy(function() {
- this._fireAction(menuItem)
- }, this))
- }
- else {
- var $menu = $("<div />").addClass(SLIDE_MENU_CLASS);
- $menu.dxActionSheet({
- showTitle: false,
- items: menuItems,
- itemClickAction: $.proxy(function(args) {
- this._fireAction(args.itemData)
- }, this)
- });
- $menu.appendTo(this._list._element());
- this._menu = $menu.dxActionSheet("instance");
- var $menuButton = this._renderMenuButton(Globalize.localize("dxListEditDecorator-more"), $.proxy(this._menu.show, this._menu));
- this._menu.option("target", $menuButton)
- }
- },
- _renderMenuButton: function(text, action) {
- var $menuButton = $("<div/>").addClass(SLIDE_MENU_BUTTON_CLASS).addClass(SLIDE_MENU_BUTTON_MENU_CLASS).text(text);
- this._$buttons.append($menuButton);
- $menuButton.on(CLICK_EVENT_NAME, action);
- return $menuButton
- },
- _renderDeleteButton: function() {
- if (!this._deleteEnabled())
- return;
- var $deleteButton = $("<div/>").addClass(SLIDE_MENU_BUTTON_CLASS).addClass(SLIDE_MENU_BUTTON_DELETE_CLASS).text(Globalize.localize("dxListEditDecorator-delete"));
- $deleteButton.on(CLICK_EVENT_NAME, $.proxy(function() {
- this._deleteItem()
- }, this));
- this._$buttons.append($deleteButton)
- },
- _fireAction: function(menuItem) {
- this._fireMenuAction($(this._cachedNode), menuItem.action);
- this._cancelDeleteReadyItem()
- },
- modifyElement: function(config) {
- this.callBase.apply(this, arguments);
- var $itemElement = config.$itemElement;
- $itemElement.addClass(SLIDE_MENU_WRAPPER_CLASS).removeClass(LIST_ITEM_BAG_CONTAINER_CLASS);
- var $slideMenuContent = $("<div/>").addClass(SLIDE_MENU_CONTENT_CLASS).addClass(LIST_ITEM_BAG_CONTAINER_CLASS);
- $itemElement.wrapInner($slideMenuContent)
- },
- handleClick: function(_, e) {
- if ($(e.target).closest("." + SLIDE_MENU_CONTENT_CLASS).length)
- return this.callBase.apply(this, arguments);
- return true
- },
- _handleSwipeStart: function($itemElement) {
- this._enablePositioning($itemElement);
- this._cacheItemData($itemElement)
- },
- _handleSwipeUpdate: function($itemElement, args) {
- var rtl = this._isRtlEnabled(),
- signCorrection = rtl ? -1 : 1,
- offset = this._cachedItemWidth * args.offset,
- startOffset = this._isReadyToDelete($itemElement) ? -this._cachedButtonWidth * signCorrection : 0,
- correctedOffset = (offset + startOffset) * signCorrection,
- contentPosition = correctedOffset < 0 ? offset + startOffset : 0,
- buttonPosition = correctedOffset < 0 ? correctedOffset : 0;
- translator.move(this._$cachedContent, {left: contentPosition});
- this._$buttonsContainer.css(rtl ? "right" : "left", Math.max(this._cachedItemWidth + buttonPosition, this._minButtonContainerLeftOffset()));
- return true
- },
- _cacheItemData: function($itemElement) {
- if ($itemElement[0] === this._cachedNode)
- return;
- this._$cachedContent = $itemElement.find("." + SLIDE_MENU_CONTENT_CLASS);
- this._cachedItemWidth = $itemElement.outerWidth();
- this._cachedButtonWidth = this._cachedButtonWidth || $itemElement.find("." + SLIDE_MENU_BUTTONS_CLASS).outerWidth();
- if (this._$cachedContent.length)
- this._cachedNode = $itemElement[0]
- },
- _minButtonContainerLeftOffset: function() {
- return this._cachedItemWidth - this._cachedButtonWidth
- },
- _handleSwipeEnd: function($itemElement, args) {
- this._cacheItemData($itemElement);
- var signCorrection = this._isRtlEnabled() ? 1 : -1,
- offset = this._cachedItemWidth * args.offset,
- endedAtReadyToDelete = !this._isReadyToDelete($itemElement) && offset * signCorrection > this._cachedButtonWidth * .2,
- readyToDelete = args.targetOffset === signCorrection || endedAtReadyToDelete;
- this._toggleDeleteReady($itemElement, readyToDelete);
- return true
- },
- _enablePositioning: function($itemElement) {
- this.callBase.apply(this, arguments);
- this._$buttonsContainer.appendTo($itemElement)
- },
- _disablePositioning: function($itemElement) {
- this.callBase.apply(this, arguments);
- this._$buttonsContainer.detach()
- },
- _animatePrepareDeleteReady: function() {
- var rtl = this._isRtlEnabled(),
- directionCorrection = rtl ? 1 : -1;
- this._$buttonsContainer.css(rtl ? "left" : "right", "0");
- var contentAnimation = fx.animate(this._$cachedContent, {
- to: {left: this._cachedButtonWidth * directionCorrection},
- type: "slide",
- duration: 200
- });
- var direction = rtl ? "right" : "left",
- buttonToAnimation = {};
- buttonToAnimation[direction] = this._minButtonContainerLeftOffset();
- var buttonAnimation = fx.animate(this._$buttonsContainer, {
- to: buttonToAnimation,
- duration: 200
- });
- return $.when(contentAnimation, buttonAnimation).promise()
- },
- _animateForgetDeleteReady: function($itemElement) {
- this._cacheItemData($itemElement);
- var rtl = this._isRtlEnabled();
- this._$buttonsContainer.css(rtl ? "left" : "right", "0");
- var contentAnimation = fx.animate(this._$cachedContent, {
- to: {left: 0},
- type: "slide",
- duration: 200
- });
- var direction = rtl ? "right" : "left",
- buttonToAnimation = {};
- buttonToAnimation[direction] = this._cachedItemWidth;
- var buttonAnimation = fx.animate(this._$buttonsContainer, {
- to: buttonToAnimation,
- duration: 200,
- complete: $.proxy(function() {
- this._$buttonsContainer.css(direction, "100%")
- }, this)
- });
- return $.when(contentAnimation, buttonAnimation).promise()
- },
- dispose: function() {
- if (this._menu)
- this._menu._element().remove();
- if (this._$buttonsContainer)
- this._$buttonsContainer.remove();
- this.callBase.apply(this, arguments)
- }
- }));
- registerDecorator("delete", "swipe", ListEditDecorator.inherit({
- _shouldHandleSwipe: true,
- _renderItemPosition: function($itemElement, offset, animate) {
- var deferred = $.Deferred(),
- itemOffset = offset * this._itemElementWidth;
- if (animate)
- fx.animate($itemElement, {
- to: {left: itemOffset},
- type: "slide",
- complete: function() {
- deferred.resolve($itemElement, offset)
- }
- });
- else {
- translator.move($itemElement, {left: itemOffset});
- deferred.resolve()
- }
- return deferred.promise()
- },
- _handleSwipeStart: function($itemElement) {
- this._itemElementWidth = $itemElement.width();
- return true
- },
- _handleSwipeUpdate: function($itemElement, args) {
- this._renderItemPosition($itemElement, args.offset);
- return true
- },
- _handleSwipeEnd: function($itemElement, args) {
- var offset = args.targetOffset;
- this._renderItemPosition($itemElement, offset, true).done($.proxy(function($itemElement, offset) {
- if (Math.abs(offset))
- this._list.deleteItem($itemElement)
- }, this));
- return true
- }
- }));
- var HOLDDELETE_MENU = "dx-list-holddelete-menu",
- HOLDDELETE_MENUCONTENT = "dx-list-holddelete-menucontent";
- registerDecorator("menu", "hold", MenuDecorator.inherit({
- _init: function() {
- var $menu = $("<div/>").addClass(HOLDDELETE_MENU);
- this._list._element().append($menu);
- this._menu = this._renderOverlay($menu)
- },
- _renderOverlay: function($element) {
- return $element.dxOverlay({
- shading: false,
- deferRendering: true,
- closeOnTargetScroll: true,
- closeOnOutsideClick: function(e) {
- return !$(e.target).closest("." + HOLDDELETE_MENU).length
- },
- animation: {
- show: {
- type: "slide",
- duration: 300,
- from: {
- height: 0,
- opacity: 1
- },
- to: {
- height: $.proxy(function() {
- return this._$menuList.outerHeight()
- }, this),
- opacity: 1
- }
- },
- hide: {
- type: "slide",
- duration: 0,
- from: {opacity: 1},
- to: {opacity: 0}
- }
- },
- height: $.proxy(function() {
- return this._$menuList ? this._$menuList.outerHeight() : 0
- }, this),
- width: $.proxy(function() {
- return this._list._element().outerWidth()
- }, this),
- contentReadyAction: $.proxy(this._renderMenuContent, this)
- }).dxOverlay("instance")
- },
- _renderMenuContent: function(e) {
- var $overlayContent = e.component.content();
- var items = this._menuItems().slice();
- if (this._deleteEnabled())
- items.push({
- text: Globalize.localize("dxListEditDecorator-delete"),
- action: $.proxy(this._deleteItem, this)
- });
- this._$menuList = $("<div>").dxList({
- items: items,
- itemClickAction: $.proxy(this._handleMenuItemClick, this),
- height: "auto"
- });
- $overlayContent.addClass(HOLDDELETE_MENUCONTENT);
- $overlayContent.append(this._$menuList)
- },
- _handleMenuItemClick: function(args) {
- this._menu.hide();
- this._fireMenuAction(this._$itemWithMenu, args.itemData.action)
- },
- _deleteItem: function() {
- this._list.deleteItem(this._$itemWithMenu)
- },
- handleHold: function($itemElement) {
- this._$itemWithMenu = $itemElement;
- this._menu.option({position: {
- my: "top",
- at: "bottom",
- of: $itemElement,
- collision: "flip"
- }});
- this._menu.show();
- return true
- },
- dispose: function() {
- if (this._menu)
- this._menu._element().remove();
- this.callBase.apply(this, arguments)
- }
- }));
- var LIST_ITEM_SELECTED_CLASS = "dx-list-item-selected",
- SELECT_DECORATOR_ENABLED_CLASS = "dx-list-select-decorator-enabled",
- SELECT_CHECKBOX_CONTAINER_CLASS = "dx-list-select-checkbox-container",
- SELECT_CHECKBOX_CLASS = "dx-list-select-checkbox",
- SELECT_RADIO_BUTTON_CONTAINER_CLASS = "dx-list-select-radio-button-container",
- SELECT_RADIO_BUTTON_CLASS = "dx-list-select-radio-button";
- registerDecorator("selection", "control", ListEditDecorator.inherit({
- _init: function() {
- this.callBase.apply(this, arguments);
- var selectionMode = this._list.option("selectionMode");
- this._singleStrategy = selectionMode === "single";
- this._containerClass = this._singleStrategy ? SELECT_RADIO_BUTTON_CONTAINER_CLASS : SELECT_CHECKBOX_CONTAINER_CLASS;
- this._controlClass = this._singleStrategy ? SELECT_RADIO_BUTTON_CLASS : SELECT_CHECKBOX_CLASS;
- this._controlWidget = this._singleStrategy ? "dxRadioButton" : "dxCheckBox";
- this._list._element().addClass(SELECT_DECORATOR_ENABLED_CLASS)
- },
- beforeBag: function(config) {
- var $itemElement = config.$itemElement,
- $container = config.$container;
- var $control = $("<div />").addClass(this._controlClass);
- $control[this._controlWidget]({
- value: this._isSelected($itemElement),
- valueChangeAction: $.proxy(function(e) {
- this._processCheckedState($itemElement, e.value);
- if (e.jQueryEvent)
- e.jQueryEvent.stopPropagation()
- }, this)
- });
- $container.addClass(this._containerClass);
- $container.append($control)
- },
- modifyElement: function(config) {
- this.callBase.apply(this, arguments);
- var $itemElement = config.$itemElement,
- control = $itemElement.find("." + this._controlClass)[this._controlWidget]("instance");
- $itemElement.on("stateChanged", $.proxy(function() {
- control.option("value", this._isSelected($itemElement))
- }, this))
- },
- _isSelected: function($itemElement) {
- return $itemElement.hasClass(LIST_ITEM_SELECTED_CLASS)
- },
- _processCheckedState: function($itemElement, checked) {
- if (checked)
- this._list.selectItem($itemElement);
- else
- this._list.unselectItem($itemElement)
- },
- dispose: function() {
- this._list._element().removeClass(SELECT_DECORATOR_ENABLED_CLASS);
- this.callBase.apply(this, arguments)
- }
- }));
- registerDecorator("selection", "item", ui.ListEditDecoratorsRegistry.selection.control.inherit({handleClick: function($itemElement) {
- var newState = !this._isSelected($itemElement) || this._singleStrategy;
- this._processCheckedState($itemElement, newState);
- return true
- }}));
- var REORDER_HANDLE_CONTAINER_CLASS = "dx-list-reorder-handle-container",
- REORDER_HANDLE_CLASS = "dx-list-reorder-handle",
- REOREDERING_ITEM_CLASS = "dx-list-item-reordering",
- REOREDERING_ITEM_GHOST_CLASS = "dx-list-item-ghost-reordering",
- LIST_REORDER_COMPATIBILITY_MODE_CLASS = "dx-list-reorder-compatibility-mode";
- var fromRange = function(value, minValue, maxValue) {
- return Math.min(Math.max(value, minValue), maxValue)
- };
- var ReorderScrollAnimator = DX.Animator.inherit({
- ctor: function(strategy) {
- this.callBase();
- this._strategy = strategy
- },
- _isFinished: function() {
- return this._strategy.scrollFinished()
- },
- _step: function() {
- this._strategy.scrollByStep()
- }
- });
- registerDecorator("reorder", "default", ListEditDecorator.inherit({
- _init: function() {
- this._groupedEnabled = this._list.option("grouped");
- this._initAnimator()
- },
- _initAnimator: function() {
- this._scrollAnimator = new ReorderScrollAnimator(this)
- },
- _startAnimator: function() {
- if (!this._scrollAnimator.inProgress())
- this._scrollAnimator.start()
- },
- _stopAnimator: function() {
- this._scrollAnimator.stop()
- },
- afterBag: function(config) {
- var $itemElement = config.$itemElement,
- $container = config.$container;
- var $handle = $("<div>").addClass(REORDER_HANDLE_CLASS);
- $handle.on(DRAG_START_EVENT_NAME, {direction: "vertical"}, $.proxy(this._handleDragStart, this, $itemElement));
- $handle.on(DRAG_UPDATE_EVENT_NAME, $.proxy(this._handleDrag, this, $itemElement));
- $handle.on(DRAG_END_EVENT_NAME, $.proxy(this._handleDragEnd, this, $itemElement));
- $container.addClass(REORDER_HANDLE_CONTAINER_CLASS);
- $container.append($handle)
- },
- _handleDragStart: function($itemElement, e) {
- this._stopPreviousAnimation();
- e.targetElements = [];
- this._cacheItemsPositions();
- this._startPointerOffset = e.pageY - $itemElement.offset().top;
- this._elementHeight = $itemElement.outerHeight();
- var itemIndex = this._list.getFlatIndexByItemElement($itemElement);
- this._startIndex = itemIndex;
- this._lastIndex = itemIndex;
- this._cacheScrollData();
- this._createGhost($itemElement);
- $itemElement.addClass(REOREDERING_ITEM_CLASS);
- this._toggleCompatibilityMode(true)
- },
- _stopPreviousAnimation: function() {
- fx.stop(this._$ghostItem, true)
- },
- _toggleCompatibilityMode: function(enabled) {
- this._list._element().toggleClass(LIST_REORDER_COMPATIBILITY_MODE_CLASS, !support.transform3d && enabled)
- },
- _cacheItemsPositions: function() {
- this._itemPositions = [];
- $.each(this._list.itemElements(), $.proxy(function(index, item) {
- this._itemPositions.push($(item).position().top)
- }, this))
- },
- _getDraggingElementPosition: function() {
- return this._itemPositions[this._startIndex]
- },
- _getLastElementPosition: function() {
- return this._itemPositions[this._lastIndex]
- },
- _cacheScrollData: function() {
- this._list.updateDimensions();
- this._startScrollTop = this._list.scrollTop();
- this._scrollOffset = 0;
- this._scrollHeight = this._list.scrollHeight();
- this._clientHeight = this._list.clientHeight()
- },
- _scrollTop: function() {
- return this._startScrollTop + this._scrollOffset
- },
- _createGhost: function($itemElement) {
- this._$ghostItem = $itemElement.clone();
- this._$ghostItem.addClass(REOREDERING_ITEM_GHOST_CLASS).appendTo(this._list.itemsContainer());
- this._startGhostPosition = this._getDraggingElementPosition() - this._$ghostItem.position().top;
- translator.move(this._$ghostItem, {top: this._startGhostPosition})
- },
- _handleDrag: function($itemElement, e) {
- this._topOffset = e.offset.y;
- this._updateItemPositions();
- var pointerPosition = this._getPonterPosition();
- this._toggleScroll(pointerPosition)
- },
- _getPonterPosition: function() {
- return this._getDraggingElementPosition() + this._startPointerOffset + this._scrollOffset + this._topOffset
- },
- _toggleScroll: function(pointerPosition) {
- if (this._scrollHeight <= this._clientHeight)
- return;
- var minOffset = this._elementHeight * .7,
- topOffset = this._clientHeight - (pointerPosition - this._scrollTop()),
- topOffsetRatio = topOffset / minOffset,
- bottomOffset = pointerPosition - this._scrollTop(),
- bottomOffsetRatio = bottomOffset / minOffset;
- if (topOffsetRatio < 1) {
- this._stepSize = this._adjustRationIntoRange(topOffsetRatio);
- this._startAnimator()
- }
- else if (bottomOffsetRatio < 1) {
- this._stepSize = -this._adjustRationIntoRange(bottomOffsetRatio);
- this._startAnimator()
- }
- else
- this._stopAnimator()
- },
- _adjustRationIntoRange: function(ratio) {
- return fromRange(Math.round(Math.abs(ratio - 1) * 7), 1, 7)
- },
- _updateItemPositions: function() {
- this._updateGhostPosition();
- this._updateOthersPositions()
- },
- _updateGhostPosition: function() {
- translator.move(this._$ghostItem, {top: this._startGhostPosition + this._scrollOffset + this._topOffset})
- },
- _updateOthersPositions: function() {
- var currentIndex = this._findItemIndexByPosition(this._getPonterPosition());
- if (this._lastIndex === currentIndex || this._groupedEnabled && !this._sameParent(currentIndex))
- return;
- var currentIndexOffset = currentIndex - this._startIndex,
- currentDirection = utils.sign(currentIndexOffset),
- minIndex = Math.min(currentIndex, this._lastIndex),
- maxIndex = Math.max(currentIndex, this._lastIndex);
- for (var itemIndex = minIndex; itemIndex <= maxIndex; itemIndex++) {
- if (itemIndex === this._startIndex)
- continue;
- var $item = this._list.getItemElementByFlatIndex(itemIndex),
- itemIndexOffset = itemIndex - this._startIndex,
- itemDirection = utils.sign(itemIndexOffset),
- offsetsDifference = Math.abs(itemIndexOffset) <= Math.abs(currentIndexOffset),
- sameDirections = currentDirection === itemDirection,
- setupPosition = offsetsDifference && sameDirections,
- resetPosition = !offsetsDifference || !sameDirections;
- fx.stop($item);
- if (setupPosition)
- fx.animate($item, {
- type: "slide",
- to: {top: this._elementHeight * -currentDirection},
- duration: 300
- });
- if (resetPosition)
- fx.animate($item, {
- type: "slide",
- to: {top: 0},
- duration: 300
- })
- }
- this._lastIndex = currentIndex
- },
- _sameParent: function(index) {
- var $dragging = this._list.getItemElementByFlatIndex(this._startIndex),
- $over = this._list.getItemElementByFlatIndex(index);
- return $over.parent().get(0) === $dragging.parent().get(0)
- },
- scrollByStep: function() {
- this._scrollOffset += this._stepSize;
- this._list.scrollBy(this._stepSize);
- this._updateItemPositions()
- },
- scrollFinished: function() {
- var scrollTop = this._scrollTop(),
- rejectScrollTop = scrollTop <= 0 && this._stepSize < 0,
- rejectScrollBottom = scrollTop >= this._scrollHeight - this._clientHeight && this._stepSize > 0;
- return rejectScrollTop || rejectScrollBottom
- },
- _handleDragEnd: function($itemElement) {
- this._scrollAnimator.stop();
- fx.animate(this._$ghostItem, {
- type: "slide",
- to: {top: this._startGhostPosition + this._getLastElementPosition() - this._getDraggingElementPosition()},
- duration: 300
- }).done($.proxy(function() {
- $itemElement.removeClass(REOREDERING_ITEM_CLASS);
- this._resetPositions();
- this._list.reorderItem($itemElement, this._list.getItemElementByFlatIndex(this._lastIndex));
- this._deleteGhost();
- this._toggleCompatibilityMode(false)
- }, this))
- },
- _deleteGhost: function() {
- this._$ghostItem.remove()
- },
- _resetPositions: function() {
- var minIndex = Math.min(this._startIndex, this._lastIndex),
- maxIndex = Math.max(this._startIndex, this._lastIndex);
- for (var itemIndex = minIndex; itemIndex <= maxIndex; itemIndex++) {
- var $item = this._list.getItemElementByFlatIndex(itemIndex);
- translator.resetPosition($item)
- }
- },
- _findItemIndexByPosition: function(position) {
- var minIndex = 0;
- var maxIndex = this._itemPositions.length - 1;
- var currentIndex;
- var currentPosition;
- while (minIndex <= maxIndex) {
- currentIndex = (minIndex + maxIndex) / 2 | 0;
- currentPosition = this._itemPositions[currentIndex];
- if (currentPosition < position)
- minIndex = currentIndex + 1;
- else if (currentPosition > position)
- maxIndex = currentIndex - 1;
- else
- return currentIndex
- }
- return fromRange(minIndex, 0, Math.max(maxIndex, 0))
- }
- }))
- })(jQuery, DevExpress);
- /*! Module widgets-base, file ui.list.edit.provider.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- events = ui.events,
- utils = DX.utils;
- var editOptionsRegistry = [];
- var registerOption = function(enabledFunc, decoratorTypeFunc, decoratorSubTypeFunc) {
- editOptionsRegistry.push({
- enabled: enabledFunc,
- decoratorType: decoratorTypeFunc,
- decoratorSubType: decoratorSubTypeFunc
- })
- };
- registerOption(function(config) {
- return config.menuItems.length
- }, function() {
- return "menu"
- }, function(config) {
- return config.menuType
- });
- registerOption(function(config) {
- return !config.menuItems.length && config.deleteEnabled
- }, function(config, defaultConfig) {
- var deleteType = config.deleteMode !== defaultConfig.deleteMode ? config.deleteMode : config.deleteType;
- return deleteType === "toggle" || deleteType === "slideButton" || deleteType === "swipe" ? "delete" : "menu"
- }, function(config, defaultConfig) {
- var deleteType;
- if (config.deleteMode !== defaultConfig.deleteMode) {
- utils.logger.warn("'deleteMode' option is deprecated since 14.1. Use the 'deleteType' option instead.");
- deleteType = config.deleteMode
- }
- else
- deleteType = config.deleteType;
- if (deleteType === "slideItem")
- deleteType = "slide";
- return deleteType
- });
- registerOption(function(config) {
- return config.selectionEnabled
- }, function() {
- return "selection"
- }, function(config, defaultConfig) {
- var selectionType;
- if (config.selectionMode !== defaultConfig.selectionMode) {
- utils.logger.warn("'selectionMode' option is deprecated since 14.1. Use the 'selectionType' option instead.");
- selectionType = config.selectionMode
- }
- else
- selectionType = config.selectionType;
- return selectionType
- });
- registerOption(function(config) {
- return config.reorderEnabled
- }, function() {
- return "reorder"
- }, function() {
- return "default"
- });
- var LIST_ITEM_BAG_CONTAINER_CLASS = "dx-list-item-bag-container",
- LIST_ITEM_CONTENT_CLASS = "dx-list-item-content",
- LIST_ITEM_BEFORE_BAG_CLASS = "dx-list-item-before-bag",
- LIST_ITEM_AFTER_BAG_CLASS = "dx-list-item-after-bag",
- DECORATOR_BEFORE_BAG_CREATE_METHOD = "beforeBag",
- DECORATOR_AFTER_BAG_CREATE_METHOD = "afterBag",
- DECORATOR_MODIFY_ELEMENT_METHOD = "modifyElement";
- ui.ListEditProvider = DX.Class.inherit({
- ctor: function(list, config, defaultConfig) {
- this._list = list;
- this._config = config;
- this._defaultConfig = defaultConfig;
- if (this.isModifyingByDecorators())
- this._fetchRequiredDecorators()
- },
- dispose: function() {
- if (this._decorators && this._decorators.length)
- $.each(this._decorators, function(_, decorator) {
- decorator.dispose()
- })
- },
- isModifyingByDecorators: function(itemData) {
- return !(this.isRenderingByRenderer() || this.isRenderingByTemplate(itemData))
- },
- isRenderingByRenderer: function() {
- return !!this.getItemRenderer()
- },
- getItemRenderer: function() {
- return this._config.itemRender
- },
- isRenderingByTemplate: function(itemData) {
- return !!this.getItemTemplateName(itemData)
- },
- getItemTemplateName: function(itemData) {
- return itemData && itemData.editTemplate || this._config.itemTemplate
- },
- _fetchRequiredDecorators: function() {
- this._decorators = [];
- var config = this._config,
- defaultConfig = this._defaultConfig;
- $.each(editOptionsRegistry, $.proxy(function(_, option) {
- var optionEnabled = option.enabled(config, defaultConfig);
- if (optionEnabled) {
- var decoratorType = option.decoratorType(config, defaultConfig),
- decoratorSubType = option.decoratorSubType(config, defaultConfig),
- decorator = this._createDecorator(decoratorType, decoratorSubType);
- this._decorators.push(decorator)
- }
- }, this))
- },
- _createDecorator: function(type, subType) {
- var decoratorClass = this._findDecorator(type, subType);
- return new decoratorClass(this._list)
- },
- _findDecorator: function(type, subType) {
- var foundDecorator = ui.ListEditDecoratorsRegistry[type][subType];
- if (!foundDecorator)
- throw new Error("Decorator with editing type: \"" + type + "\" and sub type: \"" + subType + "\" not found");
- return foundDecorator
- },
- modifyItemElement: function(args) {
- var $itemElement = $(args.itemElement);
- $itemElement.addClass(LIST_ITEM_BAG_CONTAINER_CLASS);
- this._wrapContent($itemElement);
- var config = {$itemElement: $itemElement};
- this._prependBeforeBags($itemElement, config);
- this._appendAfterBags($itemElement, config);
- this._applyDecorators(DECORATOR_MODIFY_ELEMENT_METHOD, config)
- },
- _wrapContent: function($itemElement) {
- var $contentContainer = $("<div />").addClass(LIST_ITEM_CONTENT_CLASS);
- $itemElement.wrapInner($contentContainer)
- },
- _prependBeforeBags: function($itemElement, config) {
- var $beforeBags = this._collectDecoratorsMarkup(DECORATOR_BEFORE_BAG_CREATE_METHOD, config, LIST_ITEM_BEFORE_BAG_CLASS);
- $itemElement.prepend($beforeBags)
- },
- _appendAfterBags: function($itemElement, config) {
- var $afterBags = this._collectDecoratorsMarkup(DECORATOR_AFTER_BAG_CREATE_METHOD, config, LIST_ITEM_AFTER_BAG_CLASS);
- $itemElement.append($afterBags)
- },
- _collectDecoratorsMarkup: function(method, config, containerClass) {
- var $collector = $("<div />");
- $.each(this._decorators, function() {
- var $container = $("<div />").addClass(containerClass);
- this[method]($.extend({$container: $container}, config));
- if ($container.children().length)
- $collector.append($container)
- });
- return $collector.children()
- },
- _applyDecorators: function(method, config) {
- $.each(this._decorators, function() {
- this[method](config)
- })
- },
- _handlerExists: function(name) {
- if (!this._decorators)
- return false;
- var decorators = this._decorators,
- length = decorators.length;
- for (var i = 0; i < length; i++)
- if (decorators[i][name] !== $.noop)
- return true;
- return false
- },
- _handleEvent: function(name, $itemElement, e) {
- if (!this._decorators)
- return false;
- var response = false,
- decorators = this._decorators,
- length = decorators.length;
- for (var i = 0; i < length; i++) {
- response = decorators[i][name]($itemElement, e);
- if (response)
- break
- }
- return response
- },
- handleClick: function($itemElement, e) {
- return this._handleEvent("handleClick", $itemElement, e)
- },
- holdHandlerExists: function() {
- return this._handlerExists("handleHold")
- },
- handleHold: function($itemElement, e) {
- return this._handleEvent("handleHold", $itemElement, e)
- }
- })
- })(jQuery, DevExpress);
- /*! Module widgets-base, file ui.list.edit.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- utils = DX.utils,
- removeDublicates = utils.removeDublicates;
- var LIST_EDITING_CLASS = "dx-list-editing",
- LIST_ITEM_SELECTED_CLASS = "dx-list-item-selected",
- LIST_ITEM_RESPONSE_WAIT_CLASS = "dx-list-item-response-wait";
- DX.registerComponent("dxList", ui.dxList.inherit({
- _setDefaultOptions: function() {
- this.callBase();
- this.option({
- editEnabled: false,
- editConfig: {
- itemTemplate: null,
- itemRender: null,
- menuType: "hold",
- menuItems: [],
- deleteEnabled: false,
- deleteMode: "toggle",
- deleteType: "toggle",
- selectionEnabled: false,
- selectionMode: "item",
- selectionType: "item",
- reorderEnabled: false
- },
- itemDeleteAction: null,
- selectionMode: 'multi',
- selectedItems: [],
- itemSelectAction: null,
- itemUnselectAction: null,
- itemReorderAction: null
- })
- },
- _defaultOptionsRules: function() {
- return this.callBase().slice(0).concat([{
- device: {platform: "ios"},
- options: {editConfig: {
- deleteType: "slideButton",
- deleteMode: "slideButton"
- }}
- }, {
- device: {platform: "ios7"},
- options: {editConfig: {
- menuType: "slide",
- deleteType: "slideItem",
- deleteMode: "slideItem"
- }}
- }, {
- device: {platform: "android"},
- options: {editConfig: {
- deleteType: "swipe",
- deleteMode: "swipe"
- }}
- }, {
- device: {platform: "win8"},
- options: {editConfig: {
- deleteType: "hold",
- deleteMode: "hold"
- }}
- }, {
- device: {platform: "generic"},
- options: {editConfig: {
- deleteType: "slideItem",
- deleteMode: "slideItem"
- }}
- }])
- },
- _init: function() {
- this.callBase();
- this._initEditProvider();
- this._initEditStrategy(this.option("grouped"));
- this._initSelectedItems()
- },
- _initEditProvider: function() {
- var defaultConfig = this.initialOption("editConfig");
- this._editProvider = new ui.ListEditProvider(this, this.option("editConfig"), defaultConfig)
- },
- _disposeEditProvider: function() {
- if (this._editProvider)
- this._editProvider.dispose()
- },
- _refreshEditProvider: function() {
- this._disposeEditProvider();
- this._initEditProvider()
- },
- _initEditStrategy: function(grouped) {
- var strategy = grouped ? ui.GroupedListEditStrategy : ui.PlainListEditStrategy;
- this._editStrategy = new strategy(this)
- },
- _initSelectedItems: function() {
- this._selectedItemIndices = this._editStrategy.selectedItemIndecies(this.option("selectedItems"))
- },
- _clearSelectedItems: function() {
- this._selectedItemIndices = [];
- this.option("selectedItems", [])
- },
- _render: function() {
- this._renderEditing();
- this.callBase();
- this._normalizeSelectedItems()
- },
- _renderEditing: function() {
- this._element().toggleClass(LIST_EDITING_CLASS, this.option("editEnabled"))
- },
- _handleItemClick: function(e) {
- var $itemElement = $(e.currentTarget);
- if ($itemElement.is(".dx-state-disabled, .dx-state-disabled *"))
- return;
- var handledByEditProvider = this.option("editEnabled") && this._editProvider.handleClick($itemElement, e);
- if (handledByEditProvider)
- return;
- this.callBase.apply(this, arguments)
- },
- _shouldAttachHoldEvent: function() {
- return this.callBase.apply(this, arguments) || this._editProvider.holdHandlerExists()
- },
- _handleItemHold: function(e) {
- var $itemElement = $(e.currentTarget);
- if ($itemElement.is(".dx-state-disabled, .dx-state-disabled *"))
- return;
- var handledByEditProvider = this.option("editEnabled") && this._editProvider.handleHold($itemElement, e);
- if (handledByEditProvider)
- return;
- this.callBase.apply(this, arguments)
- },
- _getItemRenderer: function() {
- if (this.option("editEnabled") && this._editProvider.isRenderingByRenderer())
- return this._editProvider.getItemRenderer();
- return this.callBase.apply(this, arguments)
- },
- _getItemTemplateName: function(itemData) {
- if (this.option("editEnabled") && this._editProvider.isRenderingByTemplate(itemData))
- return this._editProvider.getItemTemplateName(itemData);
- return this.callBase.apply(this, arguments)
- },
- _postprocessRenderItem: function(args) {
- this.callBase.apply(this, arguments);
- var $itemElement = $(args.itemElement);
- if (this._isItemSelected(this._editStrategy.getNormalizedIndex($itemElement)))
- $itemElement.addClass(LIST_ITEM_SELECTED_CLASS);
- if (this.option("editEnabled") && this._editProvider.isModifyingByDecorators(args.itemData))
- this._editProvider.modifyItemElement(args)
- },
- _dispose: function() {
- this._disposeEditProvider();
- this.callBase.apply(this, arguments)
- },
- _optionChanged: function(name, value, prevValue) {
- switch (name) {
- case"rtlEnabled":
- this._refreshEditProvider();
- this.callBase.apply(this, arguments);
- break;
- case"items":
- this._clearSelectedItems();
- this.callBase.apply(this, arguments);
- break;
- case"grouped":
- this._clearSelectedItems();
- delete this._renderingGroupIndex;
- this._initEditStrategy(value);
- this.callBase.apply(this, arguments);
- break;
- case"editEnabled":
- this._clearSelectedItems();
- this._refreshEditProvider();
- this._invalidate();
- break;
- case"editConfig":
- this._refreshEditProvider();
- this._invalidate();
- break;
- case"selectionMode":
- this._refreshEditProvider();
- this._invalidate();
- break;
- case"selectedItems":
- this._normalizeSelectedItems();
- break;
- case"itemDeleteAction":
- case"itemSelectAction":
- case"itemUnselectAction":
- case"itemReorderAction":
- break;
- default:
- this.callBase.apply(this, arguments)
- }
- },
- _isItemSelected: function(index) {
- return $.inArray(index, this._selectedItemIndices) > -1
- },
- _normalizeSelectedItems: function() {
- if (this.option("selectionMode") === "single") {
- var newSelection = this._editStrategy.selectedItemIndecies(this.option("selectedItems"));
- if (newSelection.length > 1) {
- var normalizedSelection = [newSelection[0]];
- this.option("selectedItems", this._editStrategy.fetchSelectedItems(normalizedSelection))
- }
- else
- this._updateSelectedItems()
- }
- else
- this._updateSelectedItems()
- },
- _updateSelectedItems: function() {
- var that = this,
- oldSelection = this._selectedItemIndices.slice(),
- newSelection = this._editStrategy.selectedItemIndecies();
- var unselected = removeDublicates(oldSelection, newSelection);
- $.each(unselected, function(_, normalizedIndex) {
- that._unselectItem(normalizedIndex)
- });
- var selected = removeDublicates(newSelection, oldSelection);
- $.each(selected, function(_, normalizedIndex) {
- that._selectItem(normalizedIndex)
- })
- },
- _updateSelectionAfterDelete: function(fromIndex) {
- var that = this,
- itemIndex = $.inArray(fromIndex, this._selectedItemIndices);
- if (itemIndex > -1)
- this._selectedItemIndices.splice(itemIndex, 1);
- this._editStrategy.updateSelectionAfterDelete(fromIndex);
- this.option("selectedItems", this._editStrategy.fetchSelectedItems())
- },
- _selectItem: function(normalizedIndex) {
- var $itemElement = this._editStrategy.getItemElement(normalizedIndex);
- if (this.option("editEnabled") && normalizedIndex > -1 && !this._isItemSelected(normalizedIndex)) {
- $itemElement.addClass(LIST_ITEM_SELECTED_CLASS);
- this._selectedItemIndices.push(normalizedIndex);
- $itemElement.trigger("stateChanged");
- this._handleItemEvent($itemElement, "itemSelectAction", {}, {excludeValidators: ["gesture", "disabled"]})
- }
- },
- _unselectItem: function(normalizedIndex) {
- var $itemElement = this._editStrategy.getItemElement(normalizedIndex),
- itemSelectionIndex = $.inArray(normalizedIndex, this._selectedItemIndices);
- if (this.option("editEnabled") && itemSelectionIndex > -1) {
- $itemElement.removeClass(LIST_ITEM_SELECTED_CLASS);
- this._selectedItemIndices.splice(itemSelectionIndex, 1);
- $itemElement.trigger("stateChanged");
- this._handleItemEvent($itemElement, "itemUnselectAction", {}, {excludeValidators: ["gesture", "disabled"]})
- }
- },
- _deleteItemFromDS: function($item) {
- var that = this,
- deferred = $.Deferred(),
- disabledState = this.option("disabled"),
- dataStore = this._dataSource.store();
- this.option("disabled", true);
- if (!dataStore.remove)
- throw new Error("You have to implement 'remove' method in dataStore used by dxList to be able to delete items");
- dataStore.remove(dataStore.keyOf(this._getItemData($item))).done(function(key) {
- if (key !== undefined)
- deferred.resolveWith(that);
- else
- deferred.rejectWith(that)
- }).fail(function() {
- deferred.rejectWith(that)
- });
- deferred.always(function() {
- that.option("disabled", disabledState)
- });
- return deferred
- },
- _refreshLastPage: function() {
- this._expectLastItemLoading();
- return this._dataSource.load()
- },
- getFlatIndexByItemElement: function(itemElement) {
- return this._itemElements().index(itemElement)
- },
- getItemElementByFlatIndex: function(flatIndex) {
- var $itemElements = this._itemElements();
- if (flatIndex < 0 || flatIndex >= $itemElements.length)
- return $();
- return $itemElements.eq(flatIndex)
- },
- getItemByIndex: function(index) {
- return this._getItemData(this._itemElements().eq(index))
- },
- deleteItem: function(itemElement) {
- var that = this,
- deferred = $.Deferred(),
- $item = this._editStrategy.getItemElement(itemElement),
- index = this._editStrategy.getNormalizedIndex(itemElement),
- changingOption;
- if (this.option("editEnabled") && index > -1) {
- $item.addClass(LIST_ITEM_RESPONSE_WAIT_CLASS);
- if (this._dataSource) {
- changingOption = "dataSource";
- deferred = this._deleteItemFromDS($item)
- }
- else {
- changingOption = "items";
- deferred.resolveWith(this)
- }
- }
- else
- deferred.rejectWith(this);
- deferred.done(function() {
- $item.detach();
- that._editStrategy.deleteItemAtIndex(index);
- that.optionChanged.fireWith(that, [changingOption, that.option(changingOption)]);
- that._updateSelectionAfterDelete(index);
- that._handleItemEvent($item, "itemDeleteAction", {}, {excludeValidators: ["gesture", "disabled"]});
- that._renderEmptyMessage()
- }).fail(function() {
- $item.removeClass(LIST_ITEM_RESPONSE_WAIT_CLASS)
- });
- if (this._isLastPage() || this.option("grouped"))
- return deferred.promise();
- var pageRefreshDeffered = $.Deferred();
- deferred.done(function() {
- that._refreshLastPage().done(function() {
- pageRefreshDeffered.resolveWith(that)
- })
- }).fail(function() {
- pageRefreshDeffered.rejectWith(that)
- });
- return pageRefreshDeffered.promise()
- },
- isItemSelected: function(itemElement) {
- return this._isItemSelected(this._editStrategy.getNormalizedIndex(itemElement))
- },
- selectItem: function(itemElement) {
- if (!this.option("editEnabled"))
- return;
- var itemIndex = this._editStrategy.getNormalizedIndex(itemElement);
- if (itemIndex === -1)
- return;
- var itemSelectionIndex = $.inArray(itemIndex, this._selectedItemIndices);
- if (itemSelectionIndex !== -1)
- return;
- if (this.option("selectionMode") === "single")
- this.option("selectedItems", this._editStrategy.fetchSelectedItems([itemIndex]));
- else {
- var newSelectedIndices = this._selectedItemIndices.slice();
- newSelectedIndices.push(itemIndex);
- this.option("selectedItems", this._editStrategy.fetchSelectedItems(newSelectedIndices))
- }
- },
- unselectItem: function(itemElement) {
- if (!this.option("editEnabled"))
- return;
- var itemIndex = this._editStrategy.getNormalizedIndex(itemElement);
- if (itemIndex === -1)
- return;
- var itemSelectionIndex = $.inArray(itemIndex, this._selectedItemIndices);
- if (itemSelectionIndex === -1)
- return;
- var newSelectedIndices = this._selectedItemIndices.slice();
- newSelectedIndices.splice(itemSelectionIndex, 1);
- this.option("selectedItems", this._editStrategy.fetchSelectedItems(newSelectedIndices))
- },
- reorderItem: function(itemElement, toItemElement) {
- var deferred = $.Deferred(),
- that = this,
- strategy = this._editStrategy,
- $movingItem = strategy.getItemElement(itemElement),
- $destinationItem = strategy.getItemElement(toItemElement),
- movingIndex = strategy.getNormalizedIndex(itemElement),
- destinationIndex = strategy.getNormalizedIndex(toItemElement),
- changingOption;
- var canMoveItems = movingIndex > -1 && destinationIndex > -1 && movingIndex !== destinationIndex;
- if (this.option("editEnabled") && canMoveItems)
- if (this._dataSource) {
- changingOption = "dataSource";
- deferred.resolveWith(this)
- }
- else {
- changingOption = "items";
- deferred.resolveWith(this)
- }
- else
- deferred.rejectWith(this);
- return deferred.promise().done(function() {
- $destinationItem[strategy.itemPlacementFunc(movingIndex, destinationIndex)]($movingItem);
- var newSelectedItems = strategy.getSelectedItemsAfterReorderItem(movingIndex, destinationIndex);
- strategy.moveItemAtIndexToIndex(movingIndex, destinationIndex);
- that._selectedItemIndices = strategy.selectedItemIndecies(newSelectedItems);
- that.option("selectedItems", strategy.fetchSelectedItems());
- that.optionChanged.fireWith(that, [changingOption, that.option(changingOption)]);
- that._handleItemEvent($movingItem, "itemReorderAction", {
- fromIndex: strategy.getIndex(movingIndex),
- toIndex: strategy.getIndex(destinationIndex)
- }, {excludeValidators: ["gesture", "disabled"]})
- })
- }
- }))
- })(jQuery, DevExpress);
- /*! Module widgets-base, file ui.gallery.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- utils = DX.utils,
- events = ui.events,
- fx = DX.fx,
- translator = DX.translator,
- GALLERY_CLASS = "dx-gallery",
- GALLERY_WRAPPER_CLASS = GALLERY_CLASS + "-wrapper",
- GALLERY_LOOP_CLASS = "dx-gallery-loop",
- GALLERY_ITEM_CONTAINER_CLASS = GALLERY_CLASS + "-container",
- GALLERY_ACTIVE_CLASS = GALLERY_CLASS + "-active",
- GALLERY_ITEM_CLASS = GALLERY_CLASS + "-item",
- GALLERY_LOOP_ITEM_CLASS = GALLERY_ITEM_CLASS + "-loop",
- GALLERY_ITEM_SELECTOR = "." + GALLERY_ITEM_CLASS,
- GALLERY_ITEM_SELECTED_CLASS = GALLERY_ITEM_CLASS + "-selected",
- GALLERY_INDICATOR_CLASS = GALLERY_CLASS + "-indicator",
- GALLERY_INDICATOR_ITEM_CLASS = GALLERY_INDICATOR_CLASS + "-item",
- GALLERY_INDICATOR_ITEM_SELECTOR = "." + GALLERY_INDICATOR_ITEM_CLASS,
- GALLERY_INDICATOR_ITEM_SELECTED_CLASS = GALLERY_INDICATOR_ITEM_CLASS + "-selected",
- GALLERY_ITEM_DATA_KEY = "dxGalleryItemData";
- DX.registerComponent("dxGalleryNavButton", ui.Widget.inherit({
- _setDefaultOptions: function() {
- this.callBase();
- this.option({
- direction: "next",
- clickAction: null,
- hoverStateEnabled: true
- })
- },
- _render: function() {
- this.callBase();
- var that = this,
- $element = this._element(),
- eventName = events.addNamespace("dxclick", this.NAME);
- $element.addClass(GALLERY_CLASS + "-nav-button-" + this.option("direction")).off(eventName).on(eventName, function(e) {
- that._createActionByOption("clickAction")({jQueryEvent: e})
- })
- },
- _optionChanged: function(name, value, prevValue) {
- switch (name) {
- case"clickAction":
- case"direction":
- this._invalidate();
- break;
- default:
- this.callBase(name, value, prevValue)
- }
- }
- }));
- DX.registerComponent("dxGallery", ui.CollectionContainerWidget.inherit({
- _activeStateUnit: GALLERY_ITEM_SELECTOR,
- _setDefaultOptions: function() {
- this.callBase();
- this.option({
- activeStateEnabled: false,
- animationDuration: 400,
- loop: false,
- swipeEnabled: true,
- indicatorEnabled: true,
- showIndicator: true,
- selectedIndex: 0,
- slideshowDelay: 0,
- showNavButtons: false
- })
- },
- _dataSourceOptions: function() {
- return {paginate: false}
- },
- _itemContainer: function() {
- return this._$container
- },
- _itemClass: function() {
- return GALLERY_ITEM_CLASS
- },
- _itemDataKey: function() {
- return GALLERY_ITEM_DATA_KEY
- },
- _itemWidth: function() {
- if (!this._itemWidthCache)
- this._itemWidthCache = this._itemElements().first().outerWidth();
- return this._itemWidthCache
- },
- _clearItemWidthCache: function() {
- delete this._itemWidthCache
- },
- _itemsCount: function() {
- return (this.option("items") || []).length
- },
- _offsetDirection: function() {
- return this.option("rtlEnabled") ? -1 : 1
- },
- _itemRenderDefault: function(item, index, itemElement) {
- itemElement.append($("<img />").attr("src", String(item)))
- },
- _renderSelectedIndex: $.noop,
- _render: function() {
- this._element().addClass(GALLERY_CLASS);
- this._element().toggleClass(GALLERY_LOOP_CLASS, this.option("loop"));
- this._renderDragHandler();
- this._renderWrapper();
- this._renderItemContainer();
- this.callBase();
- this._renderContainerPosition();
- this._renderItemPositions();
- this._renderIndicator();
- this._renderSelectedIndicatorItem();
- this._renderUserInteraction();
- this._renderNavButtons();
- this._setupSlideShow();
- this._reviseDimensions()
- },
- _dimensionChanged: function() {
- this._clearItemWidthCache();
- this._renderDuplicateItems();
- this._renderItemPositions();
- this._renderContainerPosition()
- },
- _renderDragHandler: function() {
- var eventName = events.addNamespace("dragstart", this.NAME);
- this._element().off(eventName).on(eventName, "img", function() {
- return false
- })
- },
- _renderWrapper: function() {
- if (this._$wrapper)
- return;
- this._$wrapper = $("<div />").addClass(GALLERY_WRAPPER_CLASS).appendTo(this._element())
- },
- _renderItems: function(items) {
- this.callBase(items);
- this._renderDuplicateItems()
- },
- _renderItemContainer: function() {
- if (this._$container)
- return;
- this._$container = $("<div>").addClass(GALLERY_ITEM_CONTAINER_CLASS).appendTo(this._$wrapper)
- },
- _renderDuplicateItems: function() {
- var items = this.option("items") || [],
- itemsCount = items.length;
- if (!itemsCount)
- return;
- this._element().find("." + GALLERY_LOOP_ITEM_CLASS).remove();
- var itemsPerPage = this._element().width() / this._itemWidth(),
- duplicateCount = Math.min(itemsPerPage, itemsCount);
- for (var i = 0; i < duplicateCount; i++)
- this._renderItem(0, items[i]).addClass(GALLERY_LOOP_ITEM_CLASS);
- this._renderItem(0, items[this._itemsCount() - 1]).addClass(GALLERY_LOOP_ITEM_CLASS)
- },
- _renderItemPositions: function() {
- var itemWidth = this._itemWidth(),
- loopItemsCount = this._element().find("." + GALLERY_LOOP_ITEM_CLASS).length,
- lastItemDuplicateIndex = this._itemsCount() + loopItemsCount - 1,
- offsetDirection = this._offsetDirection();
- this._itemElements().each(function(index) {
- var realIndex = index;
- if (index === lastItemDuplicateIndex)
- realIndex = -1;
- translator.move($(this), {left: offsetDirection * realIndex * itemWidth})
- })
- },
- _renderContainerPosition: function(offset, animate) {
- offset = offset || 0;
- var that = this,
- itemWidth = this._itemWidth(),
- selectedIndex = this.option("selectedIndex"),
- targetIndex = offset - selectedIndex,
- targetPosition = this._offsetDirection() * targetIndex * itemWidth,
- positionReady;
- if (animate) {
- that._startSwipe();
- positionReady = that._animate(targetPosition).done($.proxy(that._endSwipe, that))
- }
- else {
- translator.move(this._$container, {left: targetPosition});
- positionReady = $.Deferred().resolveWith(that)
- }
- return positionReady.promise()
- },
- _startSwipe: function() {
- this._element().addClass(GALLERY_ACTIVE_CLASS)
- },
- _endSwipe: function() {
- this._element().removeClass(GALLERY_ACTIVE_CLASS)
- },
- _animate: function(targetPosition, extraConfig) {
- var that = this,
- animationComplete = $.Deferred();
- fx.animate(this._$container, $.extend({
- type: "slide",
- to: {left: targetPosition},
- duration: that.option("animationDuration"),
- complete: function() {
- animationComplete.resolveWith(that)
- }
- }, extraConfig || {}));
- return animationComplete
- },
- _reviseDimensions: function() {
- var that = this,
- $firstItem = that._itemElements().first();
- if (!$firstItem)
- return;
- if (!that.option("height"))
- that.option("height", $firstItem.outerHeight());
- if (!that.option("width"))
- that.option("width", $firstItem.outerWidth());
- this._dimensionChanged()
- },
- _renderIndicator: function() {
- if (!this.option("showIndicator")) {
- this._cleanIndicators();
- return
- }
- var indicator = this._$indicator = $("<div>").addClass(GALLERY_INDICATOR_CLASS).appendTo(this._$wrapper);
- $.each(this.option("items") || [], function() {
- $("<div>").addClass(GALLERY_INDICATOR_ITEM_CLASS).appendTo(indicator)
- })
- },
- _cleanIndicators: function() {
- if (this._$indicator)
- this._$indicator.remove()
- },
- _renderSelectedIndicatorItem: function() {
- var selectedIndex = this.option("selectedIndex");
- this._itemElements().removeClass(GALLERY_ITEM_SELECTED_CLASS).eq(selectedIndex).addClass(GALLERY_ITEM_SELECTED_CLASS);
- this._element().find(GALLERY_INDICATOR_ITEM_SELECTOR).removeClass(GALLERY_INDICATOR_ITEM_SELECTED_CLASS).eq(selectedIndex).addClass(GALLERY_INDICATOR_ITEM_SELECTED_CLASS)
- },
- _renderUserInteraction: function() {
- var that = this,
- rootElement = that._element(),
- swipeEnabled = that.option("swipeEnabled") && this._itemsCount() > 1,
- cursor = swipeEnabled ? "pointer" : "default";
- rootElement.dxSwipeable({
- disabled: this.option("disabled") || !swipeEnabled,
- startAction: $.proxy(that._handleSwipeStart, that),
- updateAction: $.proxy(that._handleSwipeUpdate, that),
- endAction: $.proxy(that._handleSwipeEnd, that),
- itemSizeFunc: $.proxy(that._itemWidth, that)
- });
- var indicatorSelectAction = this._createAction(this._handleIndicatorSelect);
- rootElement.find(GALLERY_INDICATOR_ITEM_SELECTOR).off(events.addNamespace("dxclick", this.NAME)).on(events.addNamespace("dxclick", this.NAME), function(e) {
- indicatorSelectAction({jQueryEvent: e})
- })
- },
- _handleIndicatorSelect: function(args) {
- var e = args.jQueryEvent,
- instance = args.component;
- if (events.needSkipEvent(e))
- return;
- if (!instance.option("indicatorEnabled"))
- return;
- var index = $(e.target).index();
- instance._renderContainerPosition(instance.option("selectedIndex") - index, true).done(function() {
- this._suppressRenderItemPositions = true;
- instance.option("selectedIndex", index)
- })
- },
- _renderNavButtons: function() {
- var that = this;
- if (!that.option("showNavButtons")) {
- that._cleanNavButtons();
- return
- }
- that._prevNavButton = $("<div />").dxGalleryNavButton({
- direction: "prev",
- clickAction: function() {
- that.prevItem(true)
- }
- }).appendTo(this._$wrapper);
- that._nextNavButton = $("<div />").dxGalleryNavButton({
- direction: "next",
- clickAction: function() {
- that.nextItem(true)
- }
- }).appendTo(this._$wrapper);
- this._renderNavButtonsVisibility()
- },
- _cleanNavButtons: function() {
- if (this._prevNavButton)
- this._prevNavButton.remove();
- if (this._prevNavButton)
- this._nextNavButton.remove()
- },
- _renderNavButtonsVisibility: function() {
- if (!this.option("showNavButtons"))
- return;
- var selectedIndex = this.option("selectedIndex"),
- loop = this.option("loop"),
- itemsCount = this._itemsCount();
- this._prevNavButton.show();
- this._nextNavButton.show();
- if (loop)
- return;
- var nextHidden = itemsCount < 2 || selectedIndex === itemsCount - 1,
- prevHidden = itemsCount < 2 || selectedIndex === 0;
- if (prevHidden)
- this._prevNavButton.hide();
- if (nextHidden)
- this._nextNavButton.hide()
- },
- _setupSlideShow: function() {
- var that = this,
- slideshowDelay = that.option("slideshowDelay");
- if (!slideshowDelay)
- return;
- clearTimeout(that._slideshowTimer);
- that._slideshowTimer = setTimeout(function() {
- if (that._userInteraction) {
- that._setupSlideShow();
- return
- }
- that.nextItem(true).done(that._setupSlideShow)
- }, slideshowDelay)
- },
- _handleSwipeStart: function(e) {
- var itemsCount = this._itemsCount();
- if (!itemsCount) {
- e.jQueryEvent.cancel = true;
- return
- }
- this._stopItemAnimations();
- this._startSwipe();
- this._userInteraction = true;
- if (!this.option("loop")) {
- var selectedIndex = this.option("selectedIndex"),
- startOffset = itemsCount - selectedIndex - 1,
- endOffset = selectedIndex,
- rtlEnabled = this.option("rtlEnabled");
- e.jQueryEvent.maxLeftOffset = rtlEnabled ? endOffset : startOffset;
- e.jQueryEvent.maxRightOffset = rtlEnabled ? startOffset : endOffset
- }
- },
- _stopItemAnimations: function() {
- if (fx.isAnimating(this._$container))
- fx.stop(this._$container, true)
- },
- _handleSwipeUpdate: function(e) {
- this._renderContainerPosition(this._offsetDirection() * e.jQueryEvent.offset)
- },
- _handleSwipeEnd: function(e) {
- var targetOffset = e.jQueryEvent.targetOffset * this._offsetDirection();
- this._renderContainerPosition(targetOffset, true).done(function() {
- var selectedIndex = this.option("selectedIndex"),
- newIndex = this._fitIndex(selectedIndex - targetOffset);
- this._suppressRenderItemPositions = true;
- this.option("selectedIndex", newIndex);
- this._renderContainerPosition();
- this._userInteraction = false;
- this._setupSlideShow()
- })
- },
- _flipIndex: function(index) {
- if (!this.option("loop"))
- return index;
- var itemsCount = this._itemsCount();
- index = index % itemsCount;
- if (index > (itemsCount + 1) / 2)
- index -= itemsCount;
- if (index < -(itemsCount - 1) / 2)
- index += itemsCount;
- return index
- },
- _fitIndex: function(index) {
- if (!this.option("loop"))
- return index;
- var itemsCount = this._itemsCount();
- index = index % itemsCount;
- if (index < 0)
- index += itemsCount;
- return index
- },
- _clean: function() {
- this.callBase();
- this._cleanIndicators();
- this._cleanNavButtons()
- },
- _dispose: function() {
- clearTimeout(this._slideshowTimer);
- this.callBase()
- },
- _handleSelectedIndexChanged: function() {
- if (!this._suppressRenderItemPositions)
- this._renderContainerPosition();
- this._suppressRenderItemPositions = false;
- this._renderSelectedIndicatorItem();
- this._renderNavButtonsVisibility()
- },
- _visibilityChanged: function(visible) {
- if (visible)
- this._dimensionChanged()
- },
- _optionChanged: function(name, value) {
- switch (name) {
- case"width":
- this.callBase.apply(this, arguments);
- this._dimensionChanged();
- break;
- case"animationDuration":
- this._renderNavButtonsVisibility();
- break;
- case"loop":
- this._element().toggleClass(GALLERY_LOOP_CLASS, value);
- this._renderNavButtonsVisibility();
- return;
- case"selectedIndex":
- this._handleSelectedIndexChanged();
- this.callBase.apply(this, arguments);
- return;
- case"showIndicator":
- this._renderIndicator();
- return;
- case"showNavButtons":
- this._renderNavButtons();
- return;
- case"slideshowDelay":
- this._setupSlideShow();
- return;
- case"swipeEnabled":
- case"indicatorEnabled":
- this._renderUserInteraction();
- return;
- default:
- this.callBase.apply(this, arguments)
- }
- },
- goToItem: function(itemIndex, animation) {
- var d = new $.Deferred,
- selectedIndex = this.option("selectedIndex"),
- itemsCount = this._itemsCount();
- itemIndex = this._fitIndex(itemIndex);
- if (itemIndex > itemsCount - 1 || itemIndex < 0)
- return d.resolveWith(this).promise();
- this._renderContainerPosition(selectedIndex - itemIndex, animation).done(function() {
- this._suppressRenderItemPositions = true;
- this.option("selectedIndex", itemIndex);
- d.resolveWith(this)
- });
- return d.promise()
- },
- prevItem: function(animation) {
- return this.goToItem(this.option("selectedIndex") - 1, animation)
- },
- nextItem: function(animation) {
- return this.goToItem(this.option("selectedIndex") + 1, animation)
- }
- }))
- })(jQuery, DevExpress);
- /*! Module widgets-base, file ui.overlay.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- utils = DX.utils,
- events = ui.events,
- fx = DX.fx,
- translator = DX.translator;
- var OVERLAY_CLASS = "dx-overlay",
- OVERLAY_WRAPPER_CLASS = "dx-overlay-wrapper",
- OVERLAY_CONTENT_CLASS = "dx-overlay-content",
- OVERLAY_SHADER_CLASS = "dx-overlay-shader",
- OVERLAY_MODAL_CLASS = "dx-overlay-modal",
- RTL_DIRECTION_CLASS = "dx-rtl",
- ACTIONS = ["showingAction", "shownAction", "hidingAction", "hiddenAction", "positioningAction", "positionedAction"],
- FIRST_Z_INDEX = 1000,
- Z_INDEX_STACK = [],
- DISABLED_STATE_CLASS = "dx-state-disabled";
- var realDevice = DX.devices.real(),
- android4_0nativeBrowser = realDevice.platform === "android" && /^4\.0(\.\d)?/.test(realDevice.version.join(".")) && navigator.userAgent.indexOf("Chrome") === -1;
- var forceRepaint = function($element) {
- $element.width();
- if (android4_0nativeBrowser) {
- var $parents = $element.parents(),
- inScrollView = $parents.is(".dx-scrollable-native");
- if (!inScrollView) {
- $parents.css("backface-visibility", "hidden");
- $parents.css("backface-visibility");
- $parents.css("backface-visibility", "visible")
- }
- }
- };
- var getElement = function(value) {
- return $(value instanceof $.Event ? value.target : value)
- };
- DX.registerComponent("dxOverlay", ui.Widget.inherit({
- _setDefaultOptions: function() {
- this.callBase();
- this.option({
- activeStateEnabled: false,
- visible: false,
- deferRendering: true,
- shading: true,
- shadingColor: "",
- position: {
- my: "center",
- at: "center",
- of: window
- },
- width: function() {
- return $(window).width() * 0.8
- },
- height: function() {
- return $(window).height() * 0.8
- },
- animation: {
- show: {
- type: "pop",
- duration: 400
- },
- hide: {
- type: "pop",
- duration: 400,
- to: {
- opacity: 0,
- scale: 0
- },
- from: {
- opacity: 1,
- scale: 1
- }
- }
- },
- closeOnOutsideClick: false,
- showingAction: null,
- shownAction: null,
- hidingAction: null,
- hiddenAction: null,
- contentTemplate: "template",
- targetContainer: undefined,
- hideTopOverlayHandler: undefined,
- closeOnTargetScroll: false,
- positioningAction: null,
- positionedAction: null
- })
- },
- _defaultOptionsRules: function() {
- return this.callBase().slice(0).concat([{
- device: function(device) {
- var realDevice = DX.devices.real(),
- realPlatform = realDevice.platform,
- realVersion = realDevice.version;
- return realPlatform === "android" && (realVersion[0] < 4 || realVersion[0] == 4 && realVersion[1] <= 1)
- },
- options: {animation: {
- show: {
- type: "fade",
- duration: 400
- },
- hide: {
- type: "fade",
- duration: 400,
- to: {opacity: 0},
- from: {opacity: 1}
- }
- }}
- }])
- },
- _optionsByReference: function() {
- return $.extend(this.callBase(), {animation: true})
- },
- _wrapper: function() {
- return this._$wrapper
- },
- _container: function() {
- return this._$container
- },
- _init: function() {
- this.callBase();
- this._initActions();
- this._initCloseOnOutsideClickHandler();
- this._$wrapper = $("<div>").addClass(OVERLAY_WRAPPER_CLASS);
- this._$container = $("<div>").addClass(OVERLAY_CONTENT_CLASS);
- var $element = this._element();
- this._$wrapper.addClass($element.attr("class"));
- $element.addClass(OVERLAY_CLASS);
- this._$wrapper.on("MSPointerDown", $.noop)
- },
- _clean: $.noop,
- _initOptions: function(options) {
- this._initTargetContainer(options.targetContainer);
- this._initHideTopOverlayHandler(options.hideTopOverlayHandler);
- this.callBase(options)
- },
- _initTargetContainer: function(targetContainer) {
- targetContainer = targetContainer === undefined ? DX.overlayTargetContainer() : targetContainer;
- var $element = this._element(),
- $targetContainer = $element.closest(targetContainer);
- if (!$targetContainer.length)
- $targetContainer = $(targetContainer).first();
- this._$targetContainer = $targetContainer.length ? $targetContainer : $element.parent()
- },
- _targetContainer: function() {
- return this._$targetContainer
- },
- _initHideTopOverlayHandler: function(handler) {
- this._hideTopOverlayHandler = handler !== undefined ? handler : $.proxy(this._defaultHideTopOverlayHandler, this)
- },
- _defaultHideTopOverlayHandler: function() {
- this.hide()
- },
- _initActions: function() {
- this._actions = {};
- $.each(ACTIONS, $.proxy(function(_, action) {
- this._actions[action] = this._createActionByOption(action) || $.noop
- }, this))
- },
- _visibilityChanged: function(visible) {
- if (visible)
- this._dimensionChanged()
- },
- _dimensionChanged: function() {
- this._renderGeometry()
- },
- _initCloseOnOutsideClickHandler: function() {
- this._documentDownHandler = $.proxy(function() {
- this._handleDocumentDown.apply(this, arguments)
- }, this)
- },
- _handleDocumentDown: function(e) {
- if (!this._isTopOverlay())
- return;
- var closeOnOutsideClick = this.option("closeOnOutsideClick");
- if ($.isFunction(closeOnOutsideClick))
- closeOnOutsideClick = closeOnOutsideClick(e);
- if (closeOnOutsideClick) {
- var $container = this._$container,
- outsideClick = !$container.is(e.target) && !$.contains($container.get(0), e.target);
- if (outsideClick) {
- e.preventDefault();
- this.hide()
- }
- }
- },
- _isTopOverlay: function() {
- var zIndexStack = this._zIndexStack();
- return zIndexStack[zIndexStack.length - 1] === this._zIndex
- },
- _zIndexStack: function() {
- return Z_INDEX_STACK
- },
- _zIndexInitValue: function() {
- return FIRST_Z_INDEX
- },
- _renderVisibilityAnimate: function() {
- var visible = this.option("visible");
- if (visible)
- this._showTimestamp = $.now();
- this._stopAnimation();
- if (visible)
- return this._makeVisible();
- else
- return this._makeHidden()
- },
- _updateRegistration: function(enabled) {
- var zIndexStack = this._zIndexStack();
- if (enabled) {
- if (!this._zIndex) {
- var length = zIndexStack.length;
- this._zIndex = (length ? zIndexStack[length - 1] : this._zIndexInitValue()) + 1;
- zIndexStack.push(this._zIndex)
- }
- }
- else if (this._zIndex) {
- var index = $.inArray(this._zIndex, zIndexStack);
- zIndexStack.splice(index, 1);
- delete this._zIndex
- }
- },
- _normalizePosition: function() {
- this._position = this.option("position")
- },
- _makeVisible: function() {
- this._normalizePosition();
- var that = this,
- deferred = $.Deferred(),
- animation = that.option("animation") || {},
- showAnimation = animation.show,
- completeShowAnimation = showAnimation && showAnimation.complete || $.noop;
- this._updateRegistration(true);
- if (showAnimation && showAnimation.to) {
- showAnimation = $.extend({type: "slide"}, showAnimation);
- $.extend(showAnimation.to, {position: this._position})
- }
- if (this._isHidingActionCancelled) {
- delete this._isHidingActionCancelled;
- deferred.resolve()
- }
- else {
- this._actions.showingAction();
- this._$wrapper.css("z-index", this._zIndex);
- this._$container.css("z-index", this._zIndex);
- this._toggleVisibility(true);
- this._animate(showAnimation, function() {
- completeShowAnimation.apply(this, arguments);
- that._actions.shownAction();
- deferred.resolve()
- })
- }
- return deferred.promise()
- },
- _makeHidden: function() {
- var that = this,
- deferred = $.Deferred(),
- animation = this.option("animation") || {},
- hideAnimation = animation.hide,
- completeHideAnimation = hideAnimation && hideAnimation.complete || $.noop;
- var hidingArgs = {cancel: false};
- this._actions.hidingAction(hidingArgs);
- if (hidingArgs.cancel) {
- this._isHidingActionCancelled = true;
- this.option("visible", true);
- deferred.resolve()
- }
- else {
- this._toggleShading(false);
- this._animate(hideAnimation, function() {
- that._toggleVisibility(false);
- completeHideAnimation.apply(this, arguments);
- that._updateRegistration(false);
- that._actions.hiddenAction();
- deferred.resolve()
- })
- }
- return deferred.promise()
- },
- _animate: function(animation, completeCallback) {
- if (animation)
- fx.animate(this._$container, $.extend({}, animation, {complete: completeCallback}));
- else
- completeCallback()
- },
- _stopAnimation: function() {
- fx.stop(this._$container, true)
- },
- _toggleVisibility: function(visible) {
- this._stopAnimation();
- if (!visible)
- utils.triggerHidingEvent(this.content());
- this.callBase.apply(this, arguments);
- this._$container.toggle(visible);
- this._toggleShading(visible);
- if (visible) {
- this._renderContent();
- this._moveToTargetContainer();
- this._renderGeometry();
- utils.triggerShownEvent(this.content())
- }
- else
- this._moveFromTargetContainer();
- this._toggleSubscriptions(visible);
- this._updateRegistration(visible)
- },
- _toggleShading: function(visible) {
- this._$wrapper.toggleClass(OVERLAY_MODAL_CLASS, this.option("shading") && !this.option("targetContainer"));
- this._$wrapper.toggleClass(OVERLAY_SHADER_CLASS, visible && this.option("shading"));
- this._$wrapper.css("background-color", this.option("shading") ? this.option("shadingColor") : "")
- },
- _toggleSubscriptions: function(enabled) {
- this._toggleHideTopOverlayCallback(enabled);
- this._toggleDocumentDownHandler(enabled);
- this._toggleParentsScrollSubscription(enabled)
- },
- _toggleHideTopOverlayCallback: function(subscribe) {
- if (!this._hideTopOverlayHandler)
- return;
- if (subscribe)
- DX.hideTopOverlayCallback.add(this._hideTopOverlayHandler);
- else
- DX.hideTopOverlayCallback.remove(this._hideTopOverlayHandler)
- },
- _toggleDocumentDownHandler: function(enabled) {
- var that = this,
- eventName = events.addNamespace("dxpointerdown", that.NAME);
- if (enabled)
- $(document).on(eventName, this._documentDownHandler);
- else
- $(document).off(eventName, this._documentDownHandler)
- },
- _toggleParentsScrollSubscription: function(subscribe) {
- var position = this._position;
- if (!position || !position.of)
- return;
- var that = this,
- closeOnScroll = that.option("closeOnTargetScroll"),
- scrollEventName = events.addNamespace("scroll", that.NAME),
- $parents = getElement(position.of).parents().add(window);
- that._proxiedTargetScrollHandler = that._proxiedTargetScrollHandler || function() {
- return that._targetScrollHandler.apply(that, arguments)
- };
- $parents[subscribe && closeOnScroll ? "on" : "off"](scrollEventName, that._proxiedTargetScrollHandler)
- },
- _targetScrollHandler: function(e) {
- var closeOnScroll = this.option("closeOnTargetScroll"),
- closeHandled = false;
- if ($.isFunction(closeOnScroll))
- closeHandled = closeOnScroll(e);
- if (!closeHandled)
- this.hide()
- },
- _renderContent: function() {
- if (this._contentAlreadyRendered || !this.option("visible") && this.option("deferRendering"))
- return;
- this._contentAlreadyRendered = true;
- this.callBase()
- },
- _renderContentImpl: function(template) {
- var $element = this._element(),
- contentTemplate = template || this._getTemplate(this.option("contentTemplate"));
- this._$container.append($element.contents()).appendTo($element);
- if (contentTemplate)
- contentTemplate.render(this.content())
- },
- _fireContentReadyAction: function() {
- if (this.option("visible"))
- this._moveToTargetContainer();
- this.callBase.apply(this, arguments)
- },
- _moveFromTargetContainer: function() {
- this._$container.appendTo(this._element());
- this._detachWrapperToTargetContainer()
- },
- _detachWrapperToTargetContainer: function() {
- this._$wrapper.detach()
- },
- _moveToTargetContainer: function() {
- this._attachWrapperToTargetContainer();
- this._$container.appendTo(this._$wrapper)
- },
- _attachWrapperToTargetContainer: function() {
- var $element = this._element();
- if (this._$targetContainer && !(this._$targetContainer[0] === $element.parent()[0]))
- this._$wrapper.appendTo(this._$targetContainer);
- else
- this._$wrapper.appendTo($element)
- },
- _renderGeometry: function() {
- if (this.option("visible"))
- this._renderGeometryImpl()
- },
- _renderGeometryImpl: function() {
- this._stopAnimation();
- this._normalizePosition();
- this._renderShading();
- this._renderDimensions();
- this._renderPosition()
- },
- _renderShading: function() {
- var $wrapper = this._$wrapper,
- $targetContainer = this._getTargetContainer();
- $wrapper.css("position", $targetContainer.get(0) === window ? "fixed" : "absolute");
- if (this.option("shading"))
- $wrapper.show();
- this._renderShadingDimensions();
- this._renderShadingPosition()
- },
- _renderShadingPosition: function() {
- if (this.option("shading")) {
- var $targetContainer = this._getTargetContainer();
- DX.position(this._$wrapper, {
- my: "top left",
- at: "top left",
- of: $targetContainer
- })
- }
- },
- _renderShadingDimensions: function() {
- if (this.option("shading")) {
- var $targetContainer = this._getTargetContainer();
- this._$wrapper.css({
- width: $targetContainer.outerWidth(),
- height: $targetContainer.outerHeight()
- })
- }
- },
- _getTargetContainer: function() {
- var position = this._position,
- targetContainer = this.option("targetContainer"),
- positionOf = position ? position.of : null;
- return getElement(targetContainer || positionOf)
- },
- _renderDimensions: function() {
- this._$container.outerWidth(this.option("width")).outerHeight(this.option("height"))
- },
- _renderPosition: function() {
- translator.resetPosition(this._$container);
- var position = this._position,
- containerPosition = DX.calculatePosition(this._$container, position);
- this._actions.positioningAction({position: containerPosition});
- var resultPosition = DX.position(this._$container, containerPosition);
- this._actions.positionedAction({position: resultPosition});
- forceRepaint(this._$container)
- },
- _dispose: function() {
- this._stopAnimation();
- this._toggleSubscriptions(false);
- this._updateRegistration(false);
- this._actions = null;
- this.callBase();
- this._$wrapper.remove();
- this._$container.remove()
- },
- _toggleDisabledState: function(value) {
- this.callBase.apply(this, arguments);
- this._$container.toggleClass(DISABLED_STATE_CLASS, value)
- },
- _toggleRTLDirection: function(rtl) {
- this._$container.toggleClass(RTL_DIRECTION_CLASS, rtl)
- },
- _optionChanged: function(name, value) {
- if ($.inArray(name, ACTIONS) > -1) {
- this._initActions();
- return
- }
- switch (name) {
- case"shading":
- case"shadingColor":
- this._toggleShading(this.option("visible"));
- break;
- case"width":
- case"height":
- case"position":
- this._renderGeometry();
- break;
- case"visible":
- this._renderVisibilityAnimate(value).done($.proxy(function() {
- if (!this._animateDeferred)
- return;
- this._animateDeferred.resolveWith(this);
- delete this._animateDeferred
- }, this));
- break;
- case"targetContainer":
- this._initTargetContainer(value);
- this._invalidate();
- break;
- case"deferRendering":
- case"contentTemplate":
- this._invalidate();
- break;
- case"closeOnOutsideClick":
- this._toggleDocumentDownHandler(this.option("visible"));
- break;
- case"closeOnTargetScroll":
- this._toggleParentsScrollSubscription(this.option("visible"));
- break;
- case"animation":
- break;
- case"rtlEnabled":
- this._toggleRTLDirection(value);
- break;
- default:
- this.callBase.apply(this, arguments)
- }
- },
- toggle: function(showing) {
- showing = showing === undefined ? !this.option("visible") : showing;
- if (showing === this.option("visible"))
- return $.Deferred().resolve().promise();
- var animateDeferred = $.Deferred();
- this._animateDeferred = animateDeferred;
- this.option("visible", showing);
- return animateDeferred.promise()
- },
- show: function() {
- return this.toggle(true)
- },
- hide: function() {
- return this.toggle(false)
- },
- content: function() {
- return this._$container
- },
- repaint: function() {
- this._renderGeometry()
- }
- }));
- ui.dxOverlay.__internals = {
- OVERLAY_CLASS: OVERLAY_CLASS,
- OVERLAY_WRAPPER_CLASS: OVERLAY_WRAPPER_CLASS,
- OVERLAY_CONTENT_CLASS: OVERLAY_CONTENT_CLASS,
- OVERLAY_SHADER_CLASS: OVERLAY_SHADER_CLASS,
- OVERLAY_MODAL_CLASS: OVERLAY_MODAL_CLASS
- }
- })(jQuery, DevExpress);
- /*! Module widgets-base, file ui.toast.js */
- (function($, DX, undefined) {
- var ui = DX.ui;
- var TOAST_CLASS = "dx-toast",
- TOAST_CLASS_PREFIX = TOAST_CLASS + "-",
- TOAST_WRAPPER_CLASS = TOAST_CLASS_PREFIX + "wrapper",
- TOAST_CONTENT_CLASS = TOAST_CLASS_PREFIX + "content",
- TOAST_MESSAGE_CLASS = TOAST_CLASS_PREFIX + "message",
- TOAST_ICON_CLASS = TOAST_CLASS_PREFIX + "icon",
- WIDGET_NAME = "dxToast",
- toastTypes = ["info", "warning", "error", "success"],
- Z_INDEX_STACK = [],
- FIRST_Z_INDEX = 9000;
- DX.registerComponent(WIDGET_NAME, ui.dxOverlay.inherit({
- _setDefaultOptions: function() {
- this.callBase();
- this.option({
- message: "",
- type: "info",
- displayTime: 2000,
- position: {
- my: "bottom center",
- at: "bottom center",
- of: window,
- offset: "0 -20"
- },
- animation: {
- show: {
- type: "fade",
- duration: 400,
- from: 0,
- to: 1
- },
- hide: {
- type: "fade",
- duration: 400,
- to: 0
- }
- },
- shading: false,
- height: "auto"
- })
- },
- _defaultOptionsRules: function() {
- return this.callBase().slice(0).concat([{
- device: {platform: "win8"},
- options: {
- position: {
- my: "top center",
- at: "top center",
- of: window,
- offset: "0 0"
- },
- width: function() {
- return $(window).width()
- }
- }
- }])
- },
- _renderContentImpl: function() {
- if (this.option("message"))
- this._message = $("<div>").addClass(TOAST_MESSAGE_CLASS).text(this.option("message")).appendTo(this.content());
- if ($.inArray(this.option("type").toLowerCase(), toastTypes) > -1)
- this.content().prepend($("<div>").addClass(TOAST_ICON_CLASS));
- this.callBase()
- },
- _render: function() {
- this.callBase();
- this._element().addClass(TOAST_CLASS);
- this._wrapper().addClass(TOAST_WRAPPER_CLASS);
- this._$container.addClass(TOAST_CLASS_PREFIX + String(this.option("type")).toLowerCase());
- this.content().addClass(TOAST_CONTENT_CLASS)
- },
- _makeVisible: function() {
- return this.callBase.apply(this, arguments).done($.proxy(function() {
- clearTimeout(this._hideTimeout);
- this._hideTimeout = setTimeout($.proxy(function() {
- this.hide()
- }, this), this.option("displayTime"))
- }, this))
- },
- _zIndexStack: function() {
- return Z_INDEX_STACK
- },
- _zIndexInitValue: function() {
- return FIRST_Z_INDEX
- },
- _dispose: function() {
- clearTimeout(this._hideTimeout);
- this.callBase()
- },
- _optionChanged: function(name, value, prevValue) {
- switch (name) {
- case"type":
- this._$container.removeClass(TOAST_CLASS_PREFIX + prevValue);
- this._$container.addClass(TOAST_CLASS_PREFIX + String(value).toLowerCase());
- break;
- case"message":
- if (this._message)
- this._message.text(value);
- break;
- case"displayTime":
- break;
- default:
- this.callBase.apply(this, arguments)
- }
- }
- }));
- ui.dxToast.__internals = {
- TOAST_CLASS: TOAST_CLASS,
- TOAST_WRAPPER_CLASS: TOAST_WRAPPER_CLASS,
- TOAST_CONTENT_CLASS: TOAST_CONTENT_CLASS,
- TOAST_MESSAGE_CLASS: TOAST_MESSAGE_CLASS,
- TOAST_ICON_CLASS: TOAST_ICON_CLASS,
- TOAST_CLASS_PREFIX: TOAST_CLASS_PREFIX,
- WIDGET_NAME: WIDGET_NAME
- }
- })(jQuery, DevExpress);
- /*! Module widgets-base, file ui.popup.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- events = ui.events,
- translator = DX.translator;
- var POPUP_CLASS = "dx-popup",
- POPUP_WRAPPER_CLASS = "dx-popup-wrapper",
- POPUP_FULL_SCREEN_CLASS = "dx-popup-fullscreen",
- POPUP_CONTENT_CLASS = "dx-popup-content",
- POPUP_DRAGGABLE_CLASS = "dx-popup-draggable",
- POPUP_TITLE_CLASS = "dx-popup-title",
- POPUP_TITLE_SELECTOR = "." + POPUP_TITLE_CLASS,
- POPUP_TITLE_CLOSEBUTTON_CLASS = "dx-closebutton",
- POPUP_TITLE_HAS_BUTTON_CLASS = "dx-popup-title-has-button",
- POPUP_BOTTOM_CLASS = "dx-popup-bottom",
- TOOLBAR_LEFT_CLASS = "dx-toolbar-before",
- TOOLBAR_RIGHT_CLASS = "dx-toolbar-after",
- OVERLAY_CONTENT_SELECTOR = ".dx-overlay-content",
- MIN_POPUP_STICK_SIZE = 40;
- var getButtonContainer = function(force) {
- var device = DX.devices.current(force),
- container = {
- cancel: {subclass: "dx-popup-cancel"},
- clear: {subclass: "dx-popup-clear"},
- done: {subclass: "dx-popup-done"}
- };
- if (device.ios) {
- $.extend(container.cancel, {
- parent: POPUP_TITLE_SELECTOR,
- wraperClass: TOOLBAR_LEFT_CLASS
- });
- $.extend(container.clear, {
- parent: POPUP_TITLE_SELECTOR,
- wraperClass: TOOLBAR_RIGHT_CLASS
- });
- $.extend(container.done, {wraperClass: POPUP_BOTTOM_CLASS})
- }
- if (device.android || device.platform === "desktop" || device.win8 || device.tizen || device.generic) {
- $.extend(container.cancel, {wraperClass: POPUP_BOTTOM_CLASS});
- $.extend(container.clear, {wraperClass: POPUP_BOTTOM_CLASS});
- $.extend(container.done, {wraperClass: POPUP_BOTTOM_CLASS})
- }
- return container
- };
- DX.registerComponent("dxPopup", ui.dxOverlay.inherit({
- _setDefaultOptions: function() {
- this.callBase();
- this.option({
- title: "",
- showTitle: true,
- fullScreen: false,
- titleTemplate: "title",
- dragEnabled: false,
- cancelButton: null,
- doneButton: null,
- clearButton: null,
- closeButton: null
- })
- },
- _defaultOptionsRules: function() {
- return this.callBase().slice(0).concat([{
- device: {platform: "win8"},
- options: {width: function() {
- return $(window).width()
- }}
- }, {
- device: {
- platform: "win8",
- phone: true
- },
- options: {position: {
- my: "top center",
- at: "top center",
- of: window,
- offset: "0 0"
- }}
- }, {
- device: [{platform: "ios"}, {platform: "ios7"}],
- options: {animation: this._iosAnimation}
- }, {
- device: function(device) {
- return DX.devices.real().platform === "generic" && device.platform === "generic"
- },
- options: {dragEnabled: true}
- }])
- },
- _iosAnimation: {
- show: {
- type: "slide",
- duration: 400,
- from: {position: {
- my: "top",
- at: "bottom",
- of: window
- }},
- to: {position: {
- my: "center",
- at: "center",
- of: window
- }}
- },
- hide: {
- type: "slide",
- duration: 400,
- from: {
- opacity: 1,
- position: {
- my: "center",
- at: "center",
- of: window
- }
- },
- to: {
- opacity: 1,
- position: {
- my: "top",
- at: "bottom",
- of: window
- }
- }
- }
- },
- _init: function() {
- this.callBase();
- this._$content = this._container().wrapInner($("<div />").addClass(POPUP_CONTENT_CLASS)).children().eq(0)
- },
- _render: function() {
- this._element().addClass(POPUP_CLASS);
- this._wrapper().addClass(POPUP_WRAPPER_CLASS);
- this._container().toggleClass(POPUP_DRAGGABLE_CLASS, this.option("dragEnabled")).toggleClass(POPUP_FULL_SCREEN_CLASS, this.option("fullScreen"));
- this.callBase()
- },
- _renderContentImpl: function() {
- this.callBase(this.option("_templates").content);
- this._renderTitle();
- this._renderDrag();
- this._renderButtons()
- },
- _renderTitle: function() {
- if (this.option("showTitle")) {
- this._$title = this._$title || $("<div />").addClass(POPUP_TITLE_CLASS);
- this._$title.empty();
- this._element().append(this._$title);
- if (this.option("title"))
- this._defaultTitleRender();
- else {
- var titleTemplate = this._getTemplateByOption("titleTemplate");
- if (titleTemplate)
- titleTemplate.render(this._$title)
- }
- this._$title.prependTo(this._container())
- }
- else if (this._$title)
- this._$title.detach()
- },
- _renderDrag: function() {
- if (!this._$title)
- return;
- var startEventName = events.addNamespace("dxdragstart", this.NAME),
- updateEventName = events.addNamespace("dxdrag", this.NAME);
- this._$title.off(startEventName).off(updateEventName);
- if (!this.option("dragEnabled"))
- return;
- this._$title.on(startEventName, $.proxy(this._handleTitleDragStart, this)).on(updateEventName, $.proxy(this._handleTitleDragUpdate, this))
- },
- _handleTitleDragStart: function(e) {
- e.targetElements = [];
- this._prevOffset = {
- x: 0,
- y: 0
- };
- this._dragHandled = true;
- var position = translator.locate(this._container()),
- allowedOffsets = this._allowedOffsets();
- e.maxLeftOffset = position.left + allowedOffsets.left;
- e.maxRightOffset = -position.left + allowedOffsets.right;
- e.maxTopOffset = position.top + allowedOffsets.top;
- e.maxBottomOffset = -position.top + allowedOffsets.bottom
- },
- _handleTitleDragUpdate: function(e) {
- var position = translator.locate(this._container()),
- offset = e.offset,
- prevOffset = this._prevOffset;
- translator.move(this._container(), {
- left: position.left + (offset.x - prevOffset.x),
- top: position.top + (offset.y - prevOffset.y)
- });
- this._prevOffset = offset
- },
- _allowedOffsets: function() {
- var $container = this._container(),
- $targetContainer = this._targetContainer(),
- containerWidth = $container.outerWidth(),
- targetContainerWidth = $targetContainer.width(),
- targetContainerHeight = $targetContainer.height();
- return {
- top: 0,
- bottom: targetContainerHeight - MIN_POPUP_STICK_SIZE,
- left: containerWidth - MIN_POPUP_STICK_SIZE,
- right: targetContainerWidth - MIN_POPUP_STICK_SIZE
- }
- },
- _renderButtons: function() {
- var buttonsName = DX.devices.current().win8 ? ["Close", "Done", "Clear", "Cancel"] : ["Close", "Cancel", "Clear", "Done"];
- buttonsName.extractButtonName = this.option("rtlEnabled") ? buttonsName.pop : buttonsName.shift;
- while (!!buttonsName.length) {
- var buttonName = buttonsName.extractButtonName();
- this["_render" + buttonName + "Button"]()
- }
- },
- _defaultTitleRender: function() {
- this._$title.text(this.option("title"))
- },
- _renderCloseButton: function() {
- var renderButtonRequired = !this.option("_templates").title && !!this.option("closeButton") && this.option("showTitle");
- this._$title && this._$title.toggleClass(POPUP_TITLE_HAS_BUTTON_CLASS, renderButtonRequired);
- if (renderButtonRequired) {
- var clickAction = this._createButtonAction();
- $("<div/>").addClass(POPUP_TITLE_CLOSEBUTTON_CLASS).on(ui.events.addNamespace("dxclick", this.NAME + "TitleCloseButton"), function(e) {
- clickAction({jQueryEvent: e})
- }).appendTo(this._$title)
- }
- },
- _renderCancelButton: function() {
- this._renderSpecificButton(this.option("cancelButton"), {
- type: "cancel",
- text: Globalize.localize("Cancel")
- })
- },
- _renderClearButton: function() {
- this._renderSpecificButton(this.option("clearButton"), {
- type: "clear",
- text: Globalize.localize("Clear")
- })
- },
- _renderDoneButton: function() {
- this._renderSpecificButton(this.option("doneButton"), {
- type: "done",
- text: Globalize.localize("Done")
- })
- },
- _renderSpecificButton: function(show, buttonConfig) {
- var renderParams = this._getRenderButtonParams(buttonConfig.type);
- this._removeButton(renderParams);
- this._wrapper().toggleClass(POPUP_CLASS + "-" + buttonConfig.type + "-visible", !!show);
- if (!show)
- return;
- var userButtonOptions = this.option(buttonConfig.type + "Button");
- this._renderButton({
- text: userButtonOptions.text || buttonConfig.text,
- clickAction: this._createButtonAction(userButtonOptions.clickAction)
- }, renderParams)
- },
- _createButtonAction: function(clickAction) {
- return this._createAction(clickAction, {afterExecute: function(e) {
- e.component.hide()
- }})
- },
- _getRenderButtonParams: function(type) {
- return $.extend({}, getButtonContainer()[type])
- },
- _renderButton: function(buttonParams, renderParams) {
- var $button = $("<div/>").addClass(renderParams.subclass).dxButton(buttonParams),
- $parentContainer = renderParams.parent ? this._container().find(renderParams.parent) : this._container(),
- $buttonContainer = this._container().find("." + renderParams.wraperClass);
- if (!$buttonContainer.length)
- $buttonContainer = $("<div/>").addClass(renderParams.wraperClass).appendTo($parentContainer);
- $button.appendTo($buttonContainer);
- this._container().find("." + POPUP_BOTTOM_CLASS).addClass(renderParams.subclass)
- },
- _removeButton: function(params) {
- var removeSelector = "." + (params.subclass || params.wraperClass);
- if (this.content())
- this.content().removeClass(params.subclass);
- this._container().find(removeSelector).remove()
- },
- _renderGeometryImpl: function() {
- this.callBase.apply(this, arguments);
- this._setContentHeight()
- },
- _renderDimensions: function() {
- if (this.option("fullScreen"))
- this._container().css({
- width: "100%",
- height: "100%"
- });
- else
- this.callBase.apply(this, arguments)
- },
- _renderShadingDimensions: function() {
- if (this.option("fullScreen"))
- this._wrapper().css({
- width: "100%",
- height: "100%"
- });
- else
- this.callBase.apply(this, arguments)
- },
- _renderPosition: function() {
- if (this.option("fullScreen"))
- translator.move(this._container(), {
- top: 0,
- left: 0
- });
- else if (this._dragHandled) {
- var $container = this._container(),
- position = translator.locate($container),
- allowedOffsets = this._allowedOffsets();
- translator.move($container, {
- top: Math.min(Math.max(-allowedOffsets.top, position.top), allowedOffsets.bottom),
- left: Math.min(Math.max(-allowedOffsets.left, position.left), allowedOffsets.right)
- })
- }
- else
- this.callBase.apply(this, arguments)
- },
- _setContentHeight: function() {
- if (!this._$content)
- return;
- var contentHeight = this._$container.height(),
- hasBottomButtons = this.option("cancelButton") || this.option("doneButton") || this.option("clearButton"),
- $bottomButtons = this._$wrapper.find(".dx-popup-bottom");
- if (this._$title)
- contentHeight -= this._$title.outerHeight(true) || 0;
- if (hasBottomButtons) {
- var bottomButtonsMargin = $bottomButtons.outerHeight(true) || 0;
- contentHeight -= bottomButtonsMargin;
- this._$content.css("margin-bottom", bottomButtonsMargin)
- }
- if (this.option("height") === "auto")
- this._$content.css("height", "auto");
- else if (contentHeight > 0)
- this._$content.css("height", contentHeight)
- },
- _optionChanged: function(name, value) {
- switch (name) {
- case"visible":
- delete this._dragHandled;
- this.callBase.apply(this, arguments);
- break;
- case"showTitle":
- case"title":
- case"titleTemplate":
- this._renderTitle();
- this._renderCloseButton();
- this._setContentHeight();
- break;
- case"dragEnabled":
- this._renderDrag();
- break;
- case"cancelButton":
- this._renderCancelButton();
- break;
- case"clearButton":
- this._renderClearButton();
- break;
- case"doneButton":
- this._renderDoneButton();
- break;
- case"closeButton":
- this._renderCloseButton();
- break;
- case"height":
- this.callBase.apply(this, arguments);
- this._setContentHeight();
- break;
- case"fullScreen":
- this._container().toggleClass(POPUP_FULL_SCREEN_CLASS, value);
- this._refresh();
- break;
- default:
- this.callBase.apply(this, arguments)
- }
- },
- content: function() {
- return this._$content
- },
- container: function() {
- return this._$container
- }
- }));
- ui.dxPopup.__internals = {
- POPUP_CLASS: POPUP_CLASS,
- POPUP_WRAPPER_CLASS: POPUP_WRAPPER_CLASS,
- POPUP_CONTENT_CLASS: POPUP_CONTENT_CLASS,
- POPUP_FULL_SCREEN_CLASS: POPUP_FULL_SCREEN_CLASS,
- POPUP_TITLE_CLASS: POPUP_TITLE_CLASS,
- POPUP_TITLE_CLOSEBUTTON_CLASS: POPUP_TITLE_CLOSEBUTTON_CLASS,
- POPUP_TITLE_HAS_BUTTON_CLASS: POPUP_TITLE_HAS_BUTTON_CLASS
- }
- })(jQuery, DevExpress);
- /*! Module widgets-base, file ui.popover.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- fx = DX.fx;
- var POPOVER_CLASS = "dx-popover",
- POPOVER_WRAPPER_CLASS = "dx-popover-wrapper",
- POPOVER_ARROW_CLASS = "dx-popover-arrow",
- POPOVER_WITHOUT_TITLE_CLASS = "dx-popover-without-title",
- POSITION_FLIP_MAP = {
- left: "right",
- top: "bottom",
- right: "left",
- bottom: "top"
- },
- POSITION_ALIASES = {
- top: {
- my: "bottom center",
- at: "top center"
- },
- bottom: {
- my: "top center",
- at: "bottom center"
- },
- right: {
- my: "left center",
- at: "right center"
- },
- left: {
- my: "right center",
- at: "left center"
- },
- topNone: {
- my: "bottom center",
- at: "top center",
- collision: "none"
- },
- bottomNone: {
- my: "top center",
- at: "bottom center",
- collision: "none"
- },
- rightNone: {
- my: "left center",
- at: "right center",
- collision: "none"
- },
- leftNone: {
- my: "right center",
- at: "left center",
- collision: "none"
- }
- },
- DEFAULT_VIEWPORT_OFFSET = "10 10";
- DX.registerComponent("dxPopover", ui.dxPopup.inherit({
- _setDefaultOptions: function() {
- this.callBase();
- this.option({
- target: window,
- shading: false,
- position: 'bottom',
- closeOnOutsideClick: $.proxy(this._isOutsideClick, this),
- animation: {
- show: {
- type: "fade",
- from: 0,
- to: 1
- },
- hide: {
- type: "fade",
- to: 0
- }
- },
- showTitle: false,
- width: "auto",
- height: "auto",
- dragEnabled: false,
- fullScreen: false,
- closeOnTargetScroll: true
- })
- },
- _defaultOptionsRules: function() {
- return []
- },
- _render: function() {
- this._element().addClass(POPOVER_CLASS);
- this._wrapper().addClass(POPOVER_WRAPPER_CLASS);
- this._renderArrow();
- this.callBase()
- },
- _renderArrow: function() {
- this._$arrow = $("<div>").addClass(POPOVER_ARROW_CLASS).appendTo(this._wrapper())
- },
- _setContentHeight: function(fullUpdate) {
- if (fullUpdate)
- this.callBase()
- },
- _updateContentSize: function(containerLocation) {
- if (!this._$content)
- return;
- var positionAt = this._position.at.split(" ")[0];
- if (containerLocation.h.oversize > 0 && (positionAt === "left" || positionAt === "right")) {
- var newContainerWidth = this._$container.width() - containerLocation.h.oversize;
- this._$container.width(newContainerWidth)
- }
- if (containerLocation.v.oversize > 0 && (positionAt === "top" || positionAt === "bottom")) {
- var titleSize = this._$title ? this._$title.outerHeight() : 0,
- newContainerHeight = this._$container.height() - containerLocation.v.oversize;
- this._$container.height(newContainerHeight);
- this._$content.outerHeight(newContainerHeight - titleSize)
- }
- },
- _isOutsideClick: function(e) {
- return !$(e.target).closest(this.option("target")).length
- },
- _animate: function(animation) {
- if (animation)
- DX.fx.animate(this._$arrow, $.extend({}, animation, {complete: $.noop}));
- if (animation && animation.to)
- $.extend(animation.to, {position: this._contentPosition});
- this.callBase.apply(this, arguments)
- },
- _stopAnimation: function() {
- this.callBase.apply(this, arguments);
- fx.stop(this._$arrow)
- },
- _renderTitle: function() {
- this._wrapper().toggleClass(POPOVER_WITHOUT_TITLE_CLASS, !this.option("showTitle"));
- this.callBase()
- },
- _isPopoverLargerThanTarget: function() {
- var position = this._position.at.split(" ")[0],
- $target = $(this._position.of),
- popoverSize,
- targetSize;
- switch (position) {
- case"top":
- case"bottom":
- popoverSize = this._$container.width();
- targetSize = $target.outerWidth() + this._$arrow.width();
- break;
- case"left":
- case"right":
- popoverSize = this._$container.height();
- targetSize = $target.outerHeight() + this._$arrow.height();
- break
- }
- return popoverSize > targetSize / 2
- },
- _renderPosition: function() {
- this.callBase();
- this._renderOverlayPosition();
- this._renderArrowPosition()
- },
- _renderOverlayPosition: function() {
- this._setContentHeight(true);
- this._togglePositionClass("dx-position-" + this._positionAlias);
- DX.translator.move(this._$arrow, {
- left: 0,
- top: 0
- });
- DX.translator.move(this._$container, {
- left: 0,
- top: 0
- });
- var contentPosition = $.extend({}, this._position);
- var containerPosition = $.extend({}, contentPosition, {offset: this._$arrow.width() + " " + this._$arrow.height()}),
- containerLocation = DX.calculatePosition(this._$container, containerPosition),
- isFlippedByVertical = containerLocation.v.flip,
- isFlippedByHorizontal = containerLocation.h.flip;
- this._updateContentSize(containerLocation);
- if (this._position.collision === "flip")
- contentPosition.collision = "fit";
- var positionClass = "dx-position-" + (isFlippedByVertical || isFlippedByHorizontal ? POSITION_FLIP_MAP[this._positionAlias] : this._positionAlias);
- this._togglePositionClass(positionClass);
- if (isFlippedByVertical || isFlippedByHorizontal)
- $.extend(contentPosition, {
- my: contentPosition.at,
- at: contentPosition.my
- });
- contentPosition.offset = this._updateContentOffset(isFlippedByVertical, isFlippedByHorizontal, contentPosition.offset);
- DX.position(this._$container, contentPosition);
- this._contentPosition = contentPosition
- },
- _renderArrowPosition: function() {
- var isPopoverLarger = this._isPopoverLargerThanTarget(),
- contentPositionMy = this._contentPosition.my.split(" ")[0],
- contentPositionAt = this._contentPosition.at.split(" ")[0];
- var arrowPosition;
- if (isPopoverLarger)
- arrowPosition = {
- my: contentPositionMy,
- at: contentPositionAt,
- of: $(this.option("target"))
- };
- else {
- var arrowPosition = contentPositionAt;
- arrowPosition = {
- my: contentPositionAt,
- at: contentPositionMy,
- of: this._$container,
- offset: this._updateArrowOffset(arrowPosition)
- }
- }
- arrowPosition.my += " center";
- arrowPosition.at += " center";
- DX.position(this._$arrow, arrowPosition)
- },
- _renderShadingPosition: function() {
- if (this.option("shading"))
- this._$wrapper.css({
- top: 0,
- left: 0
- })
- },
- _renderShadingDimensions: function() {
- if (this.option("shading"))
- this._$wrapper.css({
- width: "100%",
- height: "100%"
- })
- },
- _togglePositionClass: function(positionClass) {
- this._$wrapper.removeClass("dx-position-left dx-position-right dx-position-top dx-position-bottom");
- this._$wrapper.addClass(positionClass)
- },
- _normalizePosition: function() {
- var position = this.option("position");
- if (DX.utils.isString(position))
- position = $.extend({}, POSITION_ALIASES[position]);
- if (!position.of)
- position.of = this.option("target");
- if (!position.collision)
- position.collision = "flip";
- if (!position.boundaryOffset)
- position.boundaryOffset = DEFAULT_VIEWPORT_OFFSET;
- this._positionAlias = position.at.split(" ")[0];
- this._position = position
- },
- _getOffsetObject: function(offset) {
- var result = DX.utils.stringPairToObject(offset);
- return {
- h: result.x,
- v: result.y
- }
- },
- _updateContentOffset: function(isFlippedByVertical, isFlippedByHorizontal, offsetString) {
- var position = this._positionAlias,
- offset = this._getOffsetObject(offsetString);
- var isTopPosition = position === "top" && !isFlippedByVertical || position === "bottom" && isFlippedByVertical,
- isBottomPosition = position === "bottom" && !isFlippedByVertical || position === "top" && isFlippedByVertical,
- isLeftPosition = position === "left" && !isFlippedByHorizontal || position === "right" && isFlippedByHorizontal,
- isRightPosition = position === "right" && !isFlippedByHorizontal || position === "left" && isFlippedByHorizontal;
- if (isTopPosition)
- return offset.h + " " + (offset.v - (this._$arrow.height() - 1));
- if (isBottomPosition)
- return offset.h + " " + (offset.v + (this._$arrow.height() - 1));
- if (isLeftPosition)
- return offset.h - (this._$arrow.width() - 1) + " " + offset.v;
- if (isRightPosition)
- return offset.h + (this._$arrow.width() - 1) + " " + offset.v
- },
- _updateArrowOffset: function(position) {
- switch (position) {
- case"top":
- return "0 -1";
- case"bottom":
- return "0 1";
- case"left":
- return "-1 0";
- case"right":
- return "1 0"
- }
- },
- _optionChanged: function(name, value) {
- switch (name) {
- case"showTitle":
- case"title":
- case"titleTemplate":
- this.callBase.apply(this, arguments);
- this._normalizePosition();
- this._renderPosition();
- break;
- case"target":
- this._normalizePosition();
- this._renderPosition();
- break;
- case"fullScreen":
- if (value)
- this.option("fullScreen", false);
- break;
- default:
- this.callBase.apply(this, arguments)
- }
- }
- }));
- ui.dxPopover.__internals = {
- POPOVER_CLASS: POPOVER_CLASS,
- POPOVER_WRAPPER_CLASS: POPOVER_WRAPPER_CLASS,
- POPOVER_ARROW_CLASS: POPOVER_ARROW_CLASS,
- POPOVER_WITHOUT_TITLE_CLASS: POPOVER_WITHOUT_TITLE_CLASS,
- DEFAULT_VIEWPORT_OFFSET: DEFAULT_VIEWPORT_OFFSET
- }
- })(jQuery, DevExpress);
- /*! Module widgets-base, file ui.tooltip.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- TOOLTIP_CLASS = "dx-tooltip",
- TOOLTIP_WRAPPER_CLASS = TOOLTIP_CLASS + "-wrapper";
- DX.registerComponent("dxTooltip", ui.dxPopover.inherit({
- _setDefaultOptions: function() {
- this.callBase();
- this.option({
- showTitle: false,
- title: undefined,
- titleTemplate: undefined
- })
- },
- _render: function() {
- this._element().addClass(TOOLTIP_CLASS);
- this._wrapper().addClass(TOOLTIP_WRAPPER_CLASS);
- this.callBase()
- }
- }));
- ui.dxTooltip.__internals = {
- TOOLTIP_CLASS: TOOLTIP_CLASS,
- TOOLTIP_WRAPPER_CLASS: TOOLTIP_WRAPPER_CLASS
- }
- })(jQuery, DevExpress);
- /*! Module widgets-base, file ui.slider.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- events = ui.events,
- fx = DX.fx,
- utils = DX.utils,
- translator = DX.translator,
- transionEndEventName = DX.support.transitionEndEventName;
- var SLIDER_CLASS = "dx-slider",
- SLIDER_WRAPPER_CLASS = SLIDER_CLASS + "-wrapper",
- SLIDER_HANDLE_CLASS = SLIDER_CLASS + "-handle",
- SLIDER_HANDLE_SELECTOR = "." + SLIDER_HANDLE_CLASS,
- SLIDER_BAR_CLASS = SLIDER_CLASS + "-bar",
- SLIDER_RANGE_CLASS = SLIDER_CLASS + "-range",
- SLIDER_RANGE_VISIBLE_CLASS = SLIDER_RANGE_CLASS + "-visible",
- SLIDER_LABEL_CLASS = SLIDER_CLASS + "-label",
- SLIDER_LABEL_POSITION_CLASS_PREFIX = SLIDER_LABEL_CLASS + "-position-",
- SLIDER_TOOLTIP_CLASS = SLIDER_CLASS + "-tooltip",
- SLIDER_TOOLTIP_POSITION_CLASS_PREFIX = SLIDER_TOOLTIP_CLASS + "-position-",
- SLIDER_TOOLTIP_ON_HOVER_ENABLED = SLIDER_TOOLTIP_CLASS + "-on-hover-enabled";
- DX.registerComponent("dxSliderHandle", ui.Widget.inherit({
- _setDefaultOptions: function() {
- this.callBase();
- this.option({
- activeStateEnabled: false,
- hoverStateEnabled: false,
- value: 50,
- tooltipEnabled: false,
- tooltipFormat: function(v) {
- return v
- },
- tooltipPosition: "top",
- tooltipShowMode: "onHover",
- tooltipFitIn: null
- })
- },
- _render: function() {
- this.callBase();
- this._element().addClass(SLIDER_HANDLE_CLASS);
- this._renderTooltip()
- },
- _renderTooltip: function() {
- if (this.option("tooltipEnabled")) {
- if (!this._$tooltip) {
- this._$tooltip = $("<div>").appendTo(this._element()).dxTooltip({
- visible: true,
- height: undefined,
- target: this._element(),
- closeOnOutsideClick: false,
- closeOnTargetScroll: false,
- targetContainer: this._element(),
- hideTopOverlayHandler: null
- });
- this._tooltip = this._$tooltip.dxTooltip("instance")
- }
- this._renderTooltipPosition();
- this._renderTooltipShowMode();
- this._renderValue()
- }
- else
- this._removeTooltip()
- },
- _visibilityChanged: function() {
- this._dimensionChanged()
- },
- _dimensionChanged: function() {
- this._repaintTooltip()
- },
- _removeTooltip: function() {
- if (!this._$tooltip)
- return;
- this._$tooltip.remove();
- delete this._$tooltip;
- delete this._tooltip
- },
- _renderTooltipPosition: function() {
- if (!this._tooltip)
- return;
- var position = this.option("tooltipPosition");
- if ($.type(position) === "string")
- position = position + "None";
- this._tooltip.option("position", position)
- },
- _repaintTooltip: function() {
- if (this._tooltip)
- this._tooltip.repaint()
- },
- _renderValue: function() {
- if (!this._tooltip)
- return;
- var format = this.option("tooltipFormat"),
- value = format(this.option("value"));
- this._tooltip.content().html(value);
- this._fitTooltipPosition()
- },
- _renderTooltipShowMode: function() {
- this._element().toggleClass("dx-slider-tooltip-on-hover", /^onhover$/i.test(this.option("tooltipShowMode")))
- },
- _fitTooltipPosition: function() {
- if (!this._$tooltip)
- return;
- var $tooltipContent = this._tooltip.content().parent(),
- tooltipWidth = $tooltipContent.outerWidth(),
- $boundElement = this.option("tooltipFitIn"),
- boundElementWidth = $boundElement.outerWidth(),
- boundElementLeft = $boundElement.offset().left,
- boundElementRight = boundElementLeft + boundElementWidth,
- $element = this._element(),
- elementWidth = $element.outerWidth(),
- elementLeft = $element.offset().left,
- elementRight = elementLeft + elementWidth,
- idealOffset = Math.round(elementWidth / 2 - tooltipWidth / 2),
- minOffset = Math.ceil(boundElementLeft - elementLeft),
- maxOffset = Math.floor(boundElementRight - elementRight) + idealOffset * 2,
- newOffset = Math.min(Math.max(minOffset, idealOffset), maxOffset);
- translator.move($tooltipContent, {left: newOffset})
- },
- _optionChanged: function(name, value, prevValue) {
- switch (name) {
- case"tooltipFormat":
- this._renderValue();
- break;
- case"value":
- this._renderValue();
- break;
- case"tooltipEnabled":
- this._renderTooltip();
- break;
- case"tooltipPosition":
- this._renderTooltipPosition();
- break;
- case"tooltipShowMode":
- this._renderTooltipShowMode();
- break;
- case"tooltipFitIn":
- this._fitTooltipPosition();
- break;
- default:
- this.callBase.apply(this, arguments)
- }
- },
- fitTooltipPosition: function() {
- this._fitTooltipPosition()
- },
- repaint: function() {
- this._repaintTooltip();
- this._renderTooltipPosition();
- this._fitTooltipPosition()
- }
- }));
- DX.registerComponent("dxSlider", ui.dxEditor.inherit({
- _activeStateUnit: SLIDER_HANDLE_SELECTOR,
- _setDefaultOptions: function() {
- this.callBase();
- this.option({
- min: 0,
- max: 100,
- step: 1,
- value: 50,
- showRange: true,
- tooltip: {
- enabled: false,
- format: function(value) {
- return value
- },
- position: "top",
- showMode: "onHover"
- },
- label: {
- visible: false,
- position: "bottom",
- format: function(value) {
- return value
- }
- }
- })
- },
- _render: function() {
- this._element().addClass(SLIDER_CLASS);
- this._renderBar();
- this._renderRange();
- this._renderWrapper();
- this._$wrapper.dxSwipeable({
- elastic: false,
- startAction: $.proxy(this._handleSwipeStart, this),
- updateAction: $.proxy(this._handleSwipeUpdate, this),
- endAction: $.proxy(this._handleSwipeEnd, this),
- itemSizeFunc: $.proxy(this._itemWidthFunc, this)
- });
- this._renderHandle();
- this.callBase();
- this._renderValue();
- this._renderLabels();
- this._renderStartHandler()
- },
- _visibilityChanged: function() {
- this.repaint()
- },
- _renderWrapper: function() {
- this._$wrapper = $("<div>").addClass(SLIDER_WRAPPER_CLASS).append(this._$bar).appendTo(this._element())
- },
- _renderBar: function() {
- this._$bar = $("<div>").addClass(SLIDER_BAR_CLASS);
- this._$bar.off(transionEndEventName + "." + this.NAME).on(transionEndEventName, $.proxy(this._fitHandleTooltipPosition, this))
- },
- _renderRange: function() {
- this._$selectedRange = $("<div>").addClass(SLIDER_RANGE_CLASS).appendTo(this._$bar);
- this._renderRangeVisibility()
- },
- _renderRangeVisibility: function() {
- this._$selectedRange.toggleClass(SLIDER_RANGE_VISIBLE_CLASS, Boolean(this.option("showRange")))
- },
- _renderHandle: function() {
- this._$handle = this._renderHandleImpl(this.option("value"), this._$handle)
- },
- _renderHandleImpl: function(value, $element) {
- var $handle = $element || $("<div>").appendTo(this._$selectedRange),
- format = this._normalizeFormat(this.option("tooltip.format")),
- tooltipEnabled = this.option("tooltip.enabled"),
- tooltipPosition = this.option("tooltip.position");
- this._element().toggleClass(SLIDER_TOOLTIP_ON_HOVER_ENABLED, tooltipEnabled && DX.devices.real().platform !== "ios").toggleClass(SLIDER_TOOLTIP_POSITION_CLASS_PREFIX + "bottom", tooltipEnabled && tooltipPosition === "bottom").toggleClass(SLIDER_TOOLTIP_POSITION_CLASS_PREFIX + "top", tooltipEnabled && tooltipPosition === "top");
- return $handle.dxSliderHandle({
- value: value,
- tooltipEnabled: tooltipEnabled,
- tooltipPosition: tooltipPosition,
- tooltipFormat: format,
- tooltipShowMode: this.option("tooltip.showMode"),
- tooltipFitIn: this._element()
- })
- },
- _renderLabels: function() {
- this._element().removeClass(SLIDER_LABEL_POSITION_CLASS_PREFIX + "bottom").removeClass(SLIDER_LABEL_POSITION_CLASS_PREFIX + "top");
- if (this.option("label.visible")) {
- var min = this.option("min"),
- max = this.option("max"),
- position = this.option("label.position"),
- format = this._normalizeFormat(this.option("label.format"));
- if (!this._$minLabel)
- this._$minLabel = $("<div>").addClass(SLIDER_LABEL_CLASS).appendTo(this._$wrapper);
- this._$minLabel.html(format(min));
- if (!this._$maxLabel)
- this._$maxLabel = $("<div>").addClass(SLIDER_LABEL_CLASS).appendTo(this._$wrapper);
- this._$maxLabel.html(format(max));
- this._element().addClass(SLIDER_LABEL_POSITION_CLASS_PREFIX + position)
- }
- else {
- if (this._$minLabel) {
- this._$minLabel.remove();
- delete this._$minLabel
- }
- if (this._$maxLabel) {
- this._$maxLabel.remove();
- delete this._$maxLabel
- }
- }
- },
- _normalizeFormat: function(formatSource) {
- var format = formatSource;
- if (typeof formatSource === "string")
- format = function(value) {
- return Globalize.format(value, formatSource)
- };
- else if ($.isFunction(formatSource))
- format = $.proxy(format, this);
- else
- format = function(value) {
- return value
- };
- return format
- },
- _renderDimensions: function() {
- this.callBase();
- if (this._$bar) {
- var barMarginWidth = this._$bar.outerWidth(true) - this._$bar.outerWidth();
- this._$bar.width(this.option("width") - barMarginWidth)
- }
- },
- _renderStartHandler: function() {
- var eventName = events.addNamespace("dxpointerdown", this.NAME),
- startAction = this._createAction($.proxy(this._handleStart, this), {excludeValidators: ["gesture"]});
- this._element().off(eventName).on(eventName, function(e) {
- e.preventDefault();
- startAction({jQueryEvent: e})
- })
- },
- _itemWidthFunc: function() {
- return this._element().width() / this._swipePixelRatio()
- },
- _handleSwipeStart: function(e) {
- var rtlEnabled = this.option("rtlEnabled"),
- startOffset,
- endOffset;
- this._startOffset = this._currentRatio;
- startOffset = this._startOffset * this._swipePixelRatio();
- endOffset = (1 - this._startOffset) * this._swipePixelRatio();
- e.jQueryEvent.maxLeftOffset = rtlEnabled ? endOffset : startOffset;
- e.jQueryEvent.maxRightOffset = rtlEnabled ? startOffset : endOffset;
- this._swipeHandled = true
- },
- _handleSwipeEnd: function(e) {
- var offsetDirection = this.option("rtlEnabled") ? -1 : 1;
- delete this._swipeHandled;
- this._changeValueOnSwipe(this._startOffset + offsetDirection * e.jQueryEvent.targetOffset / this._swipePixelRatio());
- delete this._startOffset;
- this._renderValue()
- },
- _activeHandle: function() {
- return this._$handle
- },
- _handleSwipeUpdate: function(e) {
- this._valueChangeEventInstance = e;
- this._updateHandlePosition(e)
- },
- _updateHandlePosition: function(e) {
- var offsetDirection = this.option("rtlEnabled") ? -1 : 1;
- var newRatio = this._startOffset + offsetDirection * e.jQueryEvent.offset / this._swipePixelRatio();
- this._$selectedRange.width(newRatio * 100 + "%");
- this._changeValueOnSwipe(newRatio)
- },
- _swipePixelRatio: function() {
- var min = this.option("min"),
- max = this.option("max"),
- step = this._valueStep();
- return (max - min) / step
- },
- _valueStep: function() {
- var step = this.option("step");
- if (!step || isNaN(step))
- step = 1;
- step = parseFloat(step.toFixed(5));
- if (step === 0)
- step = 0.00001;
- return step
- },
- _changeValueOnSwipe: function(ratio) {
- var min = this.option("min"),
- max = this.option("max"),
- step = this._valueStep(),
- newChange = ratio * (max - min),
- newValue = min + newChange;
- if (step < 0)
- return;
- if (newValue === max || newValue === min)
- this.option("value", newValue);
- else {
- var stepChunks = (step + "").split('.'),
- exponent = stepChunks.length > 1 ? stepChunks[1].length : exponent;
- newValue = Number((Math.round(newChange / step) * step + min).toFixed(exponent));
- this.option("value", Math.max(Math.min(newValue, max), min))
- }
- },
- _handleStart: function(args) {
- var e = args.jQueryEvent;
- if (events.needSkipEvent(e))
- return;
- this._feedbackOn(this._activeHandle(), true);
- this._currentRatio = (ui.events.eventData(e).x - this._$bar.offset().left) / this._$bar.width();
- if (this.option("rtlEnabled"))
- this._currentRatio = 1 - this._currentRatio;
- this._valueChangeEventInstance = e;
- this._changeValueOnSwipe(this._currentRatio)
- },
- _renderValue: function() {
- var val = this.option("value"),
- min = this.option("min"),
- max = this.option("max");
- if (min > max)
- return;
- if (val < min) {
- this.option("value", min);
- this._currentRatio = 0;
- return
- }
- if (val > max) {
- this.option("value", max);
- this._currentRatio = 1;
- return
- }
- var ratio = min === max ? 0 : (val - min) / (max - min);
- this._animateRange({width: ratio * 100 + "%"});
- this._currentRatio = ratio;
- this._activeHandle().dxSliderHandle("option", "value", this.option("value"))
- },
- _animateRange: function(configTo) {
- fx.stop(this._$selectedRange);
- if (!this._swipeHandled)
- fx.animate(this._$selectedRange, {
- type: "custom",
- duration: 100,
- to: configTo,
- complete: $.proxy(this._fitHandleTooltipPosition, this)
- })
- },
- _fitHandleTooltipPosition: function() {
- if (this._activeHandle())
- this._activeHandle().dxSliderHandle("fitTooltipPosition")
- },
- _repaintHandle: function() {
- this._$handle.dxSliderHandle("repaint")
- },
- _optionChanged: function(name) {
- switch (name) {
- case"visible":
- this.callBase.apply(this, arguments);
- this._renderHandle();
- this._repaintHandle();
- break;
- case"min":
- case"max":
- this._renderValue();
- this._renderLabels();
- break;
- case"step":
- this._renderValue();
- break;
- case"value":
- this._renderValue();
- this.callBase.apply(this, arguments);
- break;
- case"showRange":
- this._renderRangeVisibility();
- break;
- case"tooltip":
- this._renderHandle();
- break;
- case"label":
- this._renderLabels();
- break;
- case"rtlEnabled":
- this._toggleRTLDirection();
- this._renderValue();
- break;
- default:
- this.callBase.apply(this, arguments)
- }
- },
- _dispose: function() {
- fx.stop(this._$selectedRange);
- this.callBase.apply(this, arguments)
- },
- _refresh: function() {
- this._renderDimensions();
- this._renderValue();
- this._renderHandle()
- },
- _feedbackOff: function(immediate, isGestureStart) {
- if (immediate && !isGestureStart)
- return;
- this.callBase.apply(this, arguments)
- }
- }))
- })(jQuery, DevExpress);
- /*! Module widgets-base, file ui.rangeSlider.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- events = ui.events;
- var SLIDER_HANDLE_CLASS = "dx-slider-handle",
- RANGE_SLIDER_CLASS = "dx-range-slider",
- RANGE_SLIDER_START_HANDLE_CLASS = RANGE_SLIDER_CLASS + "-start-handle";
- DX.registerComponent("dxRangeSlider", ui.dxSlider.inherit({
- _setDefaultOptions: function() {
- this.callBase();
- this.option({
- start: 40,
- end: 60,
- value: 50
- })
- },
- _render: function() {
- this.callBase();
- this._element().addClass(RANGE_SLIDER_CLASS)
- },
- _renderHandle: function() {
- this._$handleStart = this._renderHandleImpl(this.option("start"), this._$handleStart).addClass(RANGE_SLIDER_START_HANDLE_CLASS);
- this._$handleEnd = this._renderHandleImpl(this.option("end"), this._$handleEnd)
- },
- _handleStart: function(args) {
- var e = args.jQueryEvent,
- $range = this._$selectedRange,
- rangeWidth = $range.width(),
- eventOffsetX = events.eventData(e).x - this._$bar.offset().left,
- startHandleX = $range.position().left,
- endHandleX = $range.position().left + rangeWidth,
- rtlEnabled = this.option("rtlEnabled"),
- startHandleIsClosest = (rtlEnabled ? -1 : 1) * ((startHandleX + endHandleX) / 2 - eventOffsetX) > 0;
- this._feedbackOff(true, true);
- this._capturedHandle = startHandleIsClosest ? this._$handleStart : this._$handleEnd;
- this.callBase(args)
- },
- _activeHandle: function() {
- return this._capturedHandle
- },
- _updateHandlePosition: function(e) {
- var rtlEnabled = this.option("rtlEnabled"),
- offsetDirection = rtlEnabled ? -1 : 1,
- max = this.option("max"),
- min = this.option("min");
- var newRatio = this._startOffset + offsetDirection * e.jQueryEvent.offset / this._swipePixelRatio(),
- newRatio = newRatio.toPrecision(12),
- newValue = newRatio * (max - min) + min;
- this._updateSelectedRangePosition(newRatio, newRatio);
- this._changeValueOnSwipe(newRatio);
- var startValue = this.option("start"),
- endValue = this.option("end"),
- $nextHandle;
- if (startValue === endValue) {
- if (newValue < startValue)
- $nextHandle = this._$handleStart;
- else
- $nextHandle = this._$handleEnd;
- if ($nextHandle && $nextHandle !== this._capturedHandle) {
- this._updateSelectedRangePosition((startValue - min) / (max - min), (endValue - min) / (max - min));
- this._feedbackOff(true, true);
- this._feedbackOn($nextHandle, true);
- this._capturedHandle = $nextHandle
- }
- this._updateSelectedRangePosition(newRatio, newRatio);
- this._changeValueOnSwipe(newRatio)
- }
- },
- _updateSelectedRangePosition: function(leftRatio, rightRatio) {
- var rtlEnabled = this.option("rtlEnabled"),
- moveRight = this._capturedHandle === this._$handleStart && rtlEnabled || this._capturedHandle === this._$handleEnd && !rtlEnabled;
- var prop = moveRight ? "right" : "left";
- if (rtlEnabled ^ moveRight)
- this._$selectedRange.css(prop, 100 - rightRatio * 100 + "%");
- else
- this._$selectedRange.css(prop, leftRatio * 100 + "%")
- },
- _changeValueOnSwipe: function(ratio) {
- this._suppressValueChangeAction();
- this.callBase(ratio);
- this._resumeValueChangeAction();
- var option = this._capturedHandle === this._$handleStart ? "start" : "end",
- start = this.option("start"),
- end = this.option("end"),
- newValue = this.option("value"),
- max = this.option("max"),
- min = this.option("min");
- if (start > max) {
- start = max;
- this.option("start", max)
- }
- if (start < min) {
- start = min;
- this.option("start", min)
- }
- if (end > max) {
- end = max;
- this.option("end", max)
- }
- if (newValue > end && option === "start")
- newValue = end;
- if (newValue < start && option === "end")
- newValue = start;
- this.option(option, newValue)
- },
- _renderValue: function() {
- var valStart = this.option("start"),
- valEnd = this.option("end"),
- min = this.option("min"),
- max = this.option("max"),
- rtlEnabled = this.option("rtlEnabled");
- valStart = Math.max(min, Math.min(valStart, max));
- valEnd = Math.max(valStart, Math.min(valEnd, max));
- this.option("start", valStart);
- this.option("end", valEnd);
- var ratio1 = max === min ? 0 : (valStart - min) / (max - min),
- ratio2 = max === min ? 0 : (valEnd - min) / (max - min);
- var startOffset = parseFloat((ratio1 * 100).toPrecision(12)) + "%",
- endOffset = parseFloat(((1 - ratio2) * 100).toPrecision(12)) + "%";
- this._animateRange({
- right: rtlEnabled ? startOffset : endOffset,
- left: rtlEnabled ? endOffset : startOffset
- });
- this._renderHandle()
- },
- _repaintHandle: function() {
- this._$handleStart.dxSliderHandle("repaint");
- this._$handleEnd.dxSliderHandle("repaint")
- },
- _optionChanged: function(name) {
- switch (name) {
- case"start":
- case"end":
- this._renderValue();
- this._createActionByOption("valueChangeAction")({
- start: this.option("start"),
- end: this.option("end")
- });
- break;
- default:
- this.callBase.apply(this, arguments)
- }
- }
- }))
- })(jQuery, DevExpress);
- /*! Module widgets-base, file ui.calendar.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- fx = DX.fx,
- support = DX.support,
- events = ui.events,
- utils = DX.utils,
- CALENDAR_CLASS = "dx-calendar",
- CALENDAR_BODY_CLASS = "dx-calendar-body",
- CALENDAR_NAVIGATOR_CLASS = "dx-calendar-navigator",
- CALENDAR_OTHER_MONTH_CLASS = "dx-calendar-other-month",
- CALENDAR_EMPTY_CELL_CLASS = "dx-calendar-empty-cell",
- CALENDAR_DISABLED_NAVIGATOR_LINK_CLASS = "dx-calendar-disabled-navigator-link",
- CALENDAR_TODAY_CLASS = "dx-calendar-today",
- CALENDAR_SELECTED_DATE_CLASS = "dx-calendar-selected-date",
- CALENDAR_CONTOURED_DATE_CLASS = "dx-calendar-contoured-date",
- CALENDAR_NAVIGATOR_PREVIOUS_YEAR_CLASS = "dx-calendar-navigator-previous-year",
- CALENDAR_NAVIGATOR_PREVIOUS_MONTH_CLASS = "dx-calendar-navigator-previous-month",
- CALENDAR_NAVIGATOR_NEXT_MONTH_CLASS = "dx-calendar-navigator-next-month",
- CALENDAR_NAVIGATOR_NEXT_YEAR_CLASS = "dx-calendar-navigator-next-year",
- CALENDAR_MONTHVIEW_VALUECHANGED_EVENT_NAME = "dxCalendar.MonthView.ValueChanged",
- CALENDAR_MONTHVIEW_CONTOUREDDATECHANGED_EVENT_NAME = "dxCalendar.MonthView.ContouredDateChanged",
- CALENDAR_DXCLICK_EVENT_NAME = events.addNamespace("dxclick", "dxCalendar"),
- CALENDAR_BLUR_EVENT_NAME = events.addNamespace("blur", "dxCalendar");
- var BaseView = DX.Class.inherit({
- ctor: function(options) {
- this.date = options.date || new Date;
- this.rtl = options.rtl
- },
- render: function(rootElement) {
- this.rootElement = rootElement;
- this.renderCore()
- },
- renderCore: $.noop
- }),
- views = {MonthView: BaseView.inherit({
- ctor: function(options) {
- options = options || {};
- this.callBase(options);
- this.firstDayOfWeek = options.firstDayOfWeek || 0;
- if (options.keyDownProcessor && !options.disabled)
- this.keyDownProcessor = options.keyDownProcessor.reinitialize(this.keyDownHandler, this);
- if (options.contouredDate)
- this.contouredDate = this.calculateContouredDate(options.contouredDate, options.value);
- this.weeks = 6;
- this.days = 7;
- this.initialValue = options.value;
- this.keyboardNavigationUsed = options.keyboardNavigationUsed;
- this.min = options.min;
- this.max = options.max;
- this.disabled = options.disabled
- },
- dispose: function() {
- if (this.keyDownProcessor)
- this.keyDownProcessor.dispose();
- $(this.table).remove()
- },
- detachKeyDownProcessor: function() {
- var processor = this.keyDownProcessor;
- this.keyDownProcessor = undefined;
- return processor
- },
- renderCore: function() {
- var that = this;
- this.table = document.createElement("table");
- this.renderHeader();
- this.renderBody();
- this.setValue(this.initialValue);
- if (!this.disabled)
- $(this.table).off(CALENDAR_DXCLICK_EVENT_NAME).on(CALENDAR_DXCLICK_EVENT_NAME, "td", function(e) {
- that.cellClickHandler(e)
- });
- if (!this.keyDownProcessor && !this.disabled) {
- this.table.setAttribute("tabindex", -1);
- this.keyDownProcessor = new ui.HierarchicalKeyDownProcessor({
- element: this.table,
- handler: this.keyDownHandler,
- context: this
- })
- }
- this.setContouredDate(this.contouredDate, true);
- this.rootElement.appendChild(this.table)
- },
- renderHeader: function() {
- var that = this,
- header = this.table.createTHead(),
- headerRow = header.insertRow(-1),
- th,
- caption;
- this.iterateDays(function(i) {
- th = document.createElement("th");
- caption = document.createTextNode(that.getDayCaption(that.firstDayOfWeek + i));
- th.appendChild(caption);
- headerRow.appendChild(th)
- })
- },
- renderBody: function() {
- var that = this,
- tbody = document.createElement("tbody"),
- i,
- row,
- cell,
- cellDate,
- caption,
- today = new Date;
- this.table.appendChild(tbody);
- for (i = 0; i < this.weeks; ++i) {
- row = tbody.insertRow(-1);
- this.iterateDays(function(j) {
- cell = row.insertCell(-1);
- cellDate = that.getDate(i, j);
- if (utils.sameMonthAndYear(cellDate, today) && cellDate.getDate() === today.getDate())
- cell.setAttribute("class", CALENDAR_TODAY_CLASS);
- if (!utils.dateInRange(cellDate, that.min, that.max))
- cell.setAttribute("class", CALENDAR_EMPTY_CELL_CLASS);
- else if (cellDate.getMonth() !== that.date.getMonth())
- cell.setAttribute("class", CALENDAR_OTHER_MONTH_CLASS);
- cell.setAttribute("data-value", that.getShortDate(cellDate));
- caption = document.createTextNode(cellDate.getDate());
- cell.appendChild(caption)
- })
- }
- },
- getDayCaption: function(day) {
- day = day < 7 ? day : Math.abs(day % 7);
- return Globalize.culture().calendar.days.namesShort[day]
- },
- getNavigatorCaption: function() {
- var navigatorMonth = Globalize.culture().calendar.months.names[this.date.getMonth()],
- navigatorYear = this.date.getFullYear();
- return this.rtl ? navigatorYear + " " + navigatorMonth : navigatorMonth + " " + navigatorYear
- },
- getDate: function(week, day) {
- var firstDay = utils.getFirstMonthDate(this.date),
- firstMonthDayPosition = firstDay.getDay() - this.firstDayOfWeek,
- firstWeekDay = 7 * week - firstMonthDayPosition;
- firstWeekDay = firstMonthDayPosition < 0 ? firstWeekDay - 7 : firstWeekDay;
- firstDay.setDate(firstDay.getDate() + firstWeekDay + day);
- return firstDay
- },
- getShortDate: function(date) {
- return date.getFullYear() + "/" + date.getMonth() + "/" + date.getDate()
- },
- getDateFromShortDate: function(shortDate) {
- var dateParts = shortDate.split("/");
- return new Date(dateParts[0], dateParts[1], dateParts[2])
- },
- iterateDays: function(delegate) {
- var i = this.rtl ? this.days - 1 : 0;
- while (this.rtl ? i >= 0 : i < this.days) {
- delegate(i);
- this.rtl ? --i : ++i
- }
- },
- cellClickHandler: function(e) {
- var cellDate = this.getDateFromShortDate(e.target.getAttribute("data-value"));
- if (utils.dateInRange(cellDate, this.min, this.max)) {
- if (this.table.getAttribute("tabindex") && this.table !== document.activeElement)
- $(this.table).focus();
- this.setValue(cellDate, e.target)
- }
- },
- keyDownHandler: function(options) {
- var dayDifference,
- contouredDate;
- switch (options.key) {
- case"leftArrow":
- this.keyboardNavigationUsed = true;
- dayDifference = this.rtl ? 1 : -1;
- break;
- case"rightArrow":
- this.keyboardNavigationUsed = true;
- dayDifference = this.rtl ? -1 : 1;
- break;
- case"upArrow":
- this.keyboardNavigationUsed = true;
- dayDifference = -7;
- break;
- case"downArrow":
- this.keyboardNavigationUsed = true;
- dayDifference = 7;
- break;
- case"enter":
- this.keyboardNavigationUsed = true;
- if (this.contouredDate)
- this.setValue(this.contouredDate, this.tryGetCell(this.contouredDate));
- return;
- default:
- return
- }
- options.originalEvent.stopPropagation();
- options.originalEvent.preventDefault();
- contouredDate = this.calculateContouredDate(this.contouredDate, this.value);
- this.setContouredDate(new Date(contouredDate.getFullYear(), contouredDate.getMonth(), contouredDate.getDate() + dayDifference))
- },
- calculateContouredDate: function(contouredDate, value) {
- var calculatedContouredDate;
- if (utils.sameMonthAndYear(contouredDate, this.date))
- calculatedContouredDate = contouredDate;
- if (!calculatedContouredDate && utils.sameMonthAndYear(value, this.date))
- calculatedContouredDate = value;
- return calculatedContouredDate || utils.getFirstMonthDate(this.date)
- },
- setContouredDate: function(date, suppressChangedEvent) {
- if (this.keyboardNavigationUsed) {
- date = utils.normalizeDate(date, this.min, this.max);
- var dateCell;
- if (this.contouredDate) {
- dateCell = this.tryGetCell(this.contouredDate);
- if (dateCell)
- dateCell.removeClass(CALENDAR_CONTOURED_DATE_CLASS)
- }
- this.contouredDate = date;
- dateCell = this.tryGetCell(this.contouredDate);
- if (dateCell)
- dateCell.addClass(CALENDAR_CONTOURED_DATE_CLASS);
- if (!suppressChangedEvent)
- $(this.table).trigger(CALENDAR_MONTHVIEW_CONTOUREDDATECHANGED_EVENT_NAME, date)
- }
- },
- setValue: function(value, cell) {
- if (this.value !== value) {
- this.value = value;
- this.onValueChanged(value, cell)
- }
- },
- tryGetCell: function(date) {
- var foundCell = date ? $(this.table).find("td[data-value='" + this.getShortDate(date) + "']") : [];
- return foundCell.length > 0 ? foundCell : undefined
- },
- onValueChanged: function(newValue, selectedCell) {
- $(this.selectedCell).removeClass(CALENDAR_SELECTED_DATE_CLASS);
- this.selectedCell = selectedCell || this.tryGetCell(newValue);
- $(this.selectedCell).addClass(CALENDAR_SELECTED_DATE_CLASS);
- if (selectedCell) {
- this.setContouredDate(newValue);
- $(this.rootElement).trigger(CALENDAR_MONTHVIEW_VALUECHANGED_EVENT_NAME, newValue)
- }
- }
- })};
- DX.registerComponent("dxCalendar", ui.dxEditor.inherit({
- _setDefaultOptions: function() {
- this.callBase();
- this.option({
- monthViewType: views.MonthView,
- firstDayOfWeek: 1,
- min: undefined,
- max: undefined
- })
- },
- _initOptions: function(options) {
- options.currentDate = utils.normalizeDate(options.currentDate || options.value || new Date, options.min, options.max);
- this.callBase(options)
- },
- _clean: function() {
- if (!this.option("keyDownProcessor") && this._keyDownProcessor)
- this._keyDownProcessor.dispose();
- if (this._view)
- this._view.dispose();
- this.callBase()
- },
- _refresh: function() {
- this._render()
- },
- _render: function() {
- var that = this,
- viewKeyDownProcessor;
- this.callBase();
- this._element().addClass(CALENDAR_CLASS);
- this._initializeKeyDownProcessor();
- this._oldView = this._view;
- viewKeyDownProcessor = this._oldView ? this._oldView.detachKeyDownProcessor() : this._keyDownProcessor.attachChildProcessor();
- this._view = this._initializeMonthView(viewKeyDownProcessor);
- this._renderNavigator();
- if (!this._body) {
- this._body = $("<div />").addClass(CALENDAR_BODY_CLASS);
- this._element().append(this._body)
- }
- this._renderMonthView();
- if (!this._swipeable)
- this._swipeable = this._element().dxSwipeable({
- elastic: false,
- startAction: function(e) {
- that._handleSwipeStart(e)
- },
- updateAction: $.noop,
- endAction: function(e) {
- that._handleSwipeEnd(e)
- },
- itemWidthFunc: function() {
- return this._element().width()
- }
- }).dxSwipeable("instance")
- },
- _initializeKeyDownProcessor: function() {
- var that = this;
- this._keyDownProcessor = this._keyDownProcessor || this.option("keyDownProcessor");
- if (!this._keyDownProcessor) {
- this._element().attr("tabindex", -1).on(CALENDAR_DXCLICK_EVENT_NAME, function() {
- that._element().focus()
- }).on(CALENDAR_BLUR_EVENT_NAME, function() {
- that._view.setContouredDate(undefined)
- });
- this._keyDownProcessor = new ui.HierarchicalKeyDownProcessor({element: this._element()})
- }
- this._keyDownProcessor.reinitialize(this._keyDownHandler, this)
- },
- _keyDownHandler: function(options) {
- var monthDifference;
- switch (options.key) {
- case"leftArrow":
- if (options.ctrl)
- monthDifference = this.option("rtlEnabled") ? 1 : -1;
- break;
- case"rightArrow":
- if (options.ctrl)
- monthDifference = this.option("rtlEnabled") ? -1 : 1;
- break;
- case"pageUp":
- monthDifference = -1;
- break;
- case"pageDown":
- monthDifference = 1;
- break;
- default:
- break
- }
- if (monthDifference) {
- options.originalEvent.stopPropagation();
- options.originalEvent.preventDefault();
- this._navigate(monthDifference)
- }
- else
- return true
- },
- _handleSwipeStart: function(e) {
- this._swipeInProgress = true
- },
- _handleSwipeEnd: function(e) {
- if (this._swipeInProgress) {
- this._swipeInProgress = false;
- if (e.jQueryEvent.targetOffset !== 0)
- this._navigate(this.option("rtlEnabled") ? e.jQueryEvent.targetOffset : -e.jQueryEvent.targetOffset)
- }
- },
- _initializeMonthView: function(keyDownProcessor) {
- var monthViewType = this.option("monthViewType");
- return new monthViewType({
- date: this.option("currentDate"),
- min: this.option("min"),
- max: this.option("max"),
- firstDayOfWeek: this.option("firstDayOfWeek"),
- value: this.option("value"),
- rtl: this.option("rtlEnabled"),
- disabled: this.option("disabled") || DevExpress.designMode,
- keyDownProcessor: keyDownProcessor,
- contouredDate: this._oldView ? this._oldView.contouredDate : undefined,
- keyboardNavigationUsed: this._oldView ? this._oldView.keyboardNavigationUsed : undefined
- })
- },
- _renderNavigator: function() {
- var that = this,
- previousYearLinkDelta = this.option("rtlEnabled") ? 12 : -12,
- previousMonthLinkDelta = this.option("rtlEnabled") ? 1 : -1,
- nextMonthLinkDelta = this.option("rtlEnabled") ? -1 : 1,
- nextYearLinkDelta = this.option("rtlEnabled") ? -12 : 12;
- if (this._navigator)
- this._navigatorCaption.html(this._view.getNavigatorCaption());
- else {
- this._previousYearLink = $("<a href='javascript:void(0)'></a>").addClass(CALENDAR_NAVIGATOR_PREVIOUS_YEAR_CLASS);
- this._previousMonthLink = $("<a href='javascript:void(0)'></a>").addClass(CALENDAR_NAVIGATOR_PREVIOUS_MONTH_CLASS);
- this._navigatorCaption = $("<span />").html(this._view.getNavigatorCaption()),
- this._nextMonthLink = $("<a href='javascript:void(0)'></a>").addClass(CALENDAR_NAVIGATOR_NEXT_MONTH_CLASS);
- this._nextYearLink = $("<a href='javascript:void(0)'></a>").addClass(CALENDAR_NAVIGATOR_NEXT_YEAR_CLASS);
- if (!(this.option("disabled") || DevExpress.designMode)) {
- this._previousYearLink.off(CALENDAR_DXCLICK_EVENT_NAME).on(CALENDAR_DXCLICK_EVENT_NAME, function() {
- that._navigate(previousYearLinkDelta)
- });
- this._previousMonthLink.off(CALENDAR_DXCLICK_EVENT_NAME).on(CALENDAR_DXCLICK_EVENT_NAME, function() {
- that._navigate(previousMonthLinkDelta)
- });
- this._nextMonthLink.off(CALENDAR_DXCLICK_EVENT_NAME).on(CALENDAR_DXCLICK_EVENT_NAME, function() {
- that._navigate(nextMonthLinkDelta)
- });
- this._nextYearLink.off(CALENDAR_DXCLICK_EVENT_NAME).on(CALENDAR_DXCLICK_EVENT_NAME, function() {
- that._navigate(nextYearLinkDelta)
- })
- }
- this._navigator = $("<div />").addClass(CALENDAR_NAVIGATOR_CLASS).append(this._previousYearLink).append(this._previousMonthLink).append(this._navigatorCaption).append(this._nextMonthLink).append(this._nextYearLink);
- this._element().append(this._navigator)
- }
- this._applyNavigatorLinkVisibility(this._previousYearLink, previousYearLinkDelta);
- this._applyNavigatorLinkVisibility(this._previousMonthLink, previousMonthLinkDelta);
- this._applyNavigatorLinkVisibility(this._nextMonthLink, nextMonthLinkDelta);
- this._applyNavigatorLinkVisibility(this._nextYearLink, nextYearLinkDelta)
- },
- _applyNavigatorLinkVisibility: function(link, monthDifference) {
- if (this._canNavigate(monthDifference))
- link.removeClass(CALENDAR_DISABLED_NAVIGATOR_LINK_CLASS);
- else
- link.addClass(CALENDAR_DISABLED_NAVIGATOR_LINK_CLASS)
- },
- _renderMonthView: function() {
- var that = this,
- transitions;
- this._view.render(this._body[0]);
- this._element().off(CALENDAR_MONTHVIEW_VALUECHANGED_EVENT_NAME).on(CALENDAR_MONTHVIEW_VALUECHANGED_EVENT_NAME, function(event, newValue) {
- that.option("value", newValue)
- });
- this._element().off(CALENDAR_MONTHVIEW_CONTOUREDDATECHANGED_EVENT_NAME).on(CALENDAR_MONTHVIEW_CONTOUREDDATECHANGED_EVENT_NAME, function(event, date) {
- if (date)
- if (!utils.sameMonthAndYear(that.option("currentDate"), date))
- that.option("currentDate", utils.getFirstMonthDate(date))
- });
- if (this._oldView) {
- this._initalizeViewDimensions();
- this.animating = true;
- transitions = this._getViewChangeAnimation(this._oldView, this._view, this._viewWidth, this.option("rtlEnabled"));
- transitions.oldView.then(transitions.newView).then($.proxy(this._stopAnimationCallback, this))
- }
- },
- _initalizeViewDimensions: function() {
- this._viewWidth = this._viewWidth || this._body.width();
- this._viewHeight = this._viewHeight || this._body.height()
- },
- _canNavigate: function(monthDifference) {
- var date = this.option("currentDate"),
- testCurrentDate = monthDifference < 0 ? new Date(date.getFullYear(), date.getMonth() + monthDifference + 1, 0) : new Date(date.getFullYear(), date.getMonth() + monthDifference, 1);
- return utils.dateInRange(testCurrentDate, this.option("min"), this.option("max"))
- },
- _navigate: function(monthDifference) {
- if (this._canNavigate(monthDifference))
- this.option("currentDate", new Date(this.option("currentDate").getFullYear(), this.option("currentDate").getMonth() + monthDifference, 1))
- },
- _stopAnimationCallback: function() {
- this._forceStopAnimation();
- this._oldView.dispose();
- this._oldView = undefined
- },
- _forceStopAnimation: function() {
- if (this.animating) {
- fx.stop($(this._oldView.table), true);
- fx.stop($(this._view.table), true);
- this.animating = false
- }
- },
- _getViewChangeAnimation: function(oldView, newView, width, rtl) {
- var transitionProperties = this._getViewChangeAnimationProperties(oldView, newView, width, rtl);
- return {
- oldView: fx.animate($(oldView.table), transitionProperties.oldViewAnimation),
- newView: fx.animate($(newView.table), transitionProperties.newViewAnimation)
- }
- },
- _getViewChangeAnimationProperties: function(oldView, newView, width, rtl) {
- var type = "slide",
- duration = oldView.date === newView.date ? 0 : 300,
- easing = "cubic-bezier(.40, .80, .60, 1)",
- oldViewAnimation = {
- type: type,
- duration: duration,
- easing: support.transition ? easing : undefined
- },
- newViewAnimation = {
- type: type,
- duration: duration,
- easing: support.transition ? easing : undefined
- };
- if (newView.date > oldView.date && !rtl || newView.date < oldView.date && rtl) {
- oldViewAnimation.from = {left: 0};
- oldViewAnimation.to = {left: -width};
- newViewAnimation.from = {left: width};
- newViewAnimation.to = {left: 0}
- }
- else {
- oldViewAnimation.from = {left: 0};
- oldViewAnimation.to = {left: width};
- newViewAnimation.from = {left: -width};
- newViewAnimation.to = {left: 0}
- }
- return {
- oldViewAnimation: oldViewAnimation,
- newViewAnimation: newViewAnimation
- }
- },
- _invalidate: function() {
- this._forceStopAnimation();
- this.callBase()
- },
- _optionChanged: function(name, value, previousValue) {
- var normalizedDate;
- switch (name) {
- case"monthViewType":
- case"keyDownProcessor":
- break;
- case"currentDate":
- this._forceStopAnimation();
- normalizedDate = utils.normalizeDate(value, this.option("min"), this.option("max"));
- this.option("currentDate", new Date(normalizedDate.getFullYear(), normalizedDate.getMonth(), 1));
- case"min":
- case"max":
- case"firstDayOfWeek":
- case"rtlEnabled":
- this._invalidate();
- break;
- case"value":
- if (!value || utils.sameMonthAndYear(this._view.date, value)) {
- normalizedDate = utils.normalizeDate(value, this.option("min"), this.option("max"));
- this._view.setValue(normalizedDate);
- this.option("value", normalizedDate)
- }
- else
- this.option("currentDate", utils.getFirstMonthDate(value));
- default:
- this.callBase.apply(this, arguments)
- }
- }
- }));
- ui.dxCalendar.__internals = {
- BaseView: BaseView,
- views: views,
- CALENDAR_CLASS: CALENDAR_CLASS,
- CALENDAR_BODY_CLASS: CALENDAR_BODY_CLASS,
- CALENDAR_NAVIGATOR_CLASS: CALENDAR_NAVIGATOR_CLASS,
- CALENDAR_OTHER_MONTH_CLASS: CALENDAR_OTHER_MONTH_CLASS,
- CALENDAR_DISABLED_NAVIGATOR_LINK_CLASS: CALENDAR_DISABLED_NAVIGATOR_LINK_CLASS,
- CALENDAR_EMPTY_CELL_CLASS: CALENDAR_EMPTY_CELL_CLASS,
- CALENDAR_TODAY_CLASS: CALENDAR_TODAY_CLASS,
- CALENDAR_SELECTED_DATE_CLASS: CALENDAR_SELECTED_DATE_CLASS,
- CALENDAR_CONTOURED_DATE_CLASS: CALENDAR_CONTOURED_DATE_CLASS,
- CALENDAR_NAVIGATOR_PREVIOUS_YEAR_CLASS: CALENDAR_NAVIGATOR_PREVIOUS_YEAR_CLASS,
- CALENDAR_NAVIGATOR_PREVIOUS_MONTH_CLASS: CALENDAR_NAVIGATOR_PREVIOUS_MONTH_CLASS,
- CALENDAR_NAVIGATOR_NEXT_MONTH_CLASS: CALENDAR_NAVIGATOR_NEXT_MONTH_CLASS,
- CALENDAR_NAVIGATOR_NEXT_YEAR_CLASS: CALENDAR_NAVIGATOR_NEXT_YEAR_CLASS,
- CALENDAR_MONTHVIEW_VALUECHANGED_EVENT_NAME: CALENDAR_MONTHVIEW_VALUECHANGED_EVENT_NAME,
- CALENDAR_MONTHVIEW_CONTOUREDDATECHANGED_EVENT_NAME: CALENDAR_MONTHVIEW_CONTOUREDDATECHANGED_EVENT_NAME
- }
- })(jQuery, DevExpress);
- /*! Module widgets-base, file ui.calendarPicker.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- utils = DX.utils,
- events = ui.events,
- CALENDAR_PICKER_CLASS = "dx-calendar-picker",
- CALENDAR_PICKER_CALENDAR_CONTAINER_CLASS = CALENDAR_PICKER_CLASS + "-calendar-container",
- CALENDAR_PICKER_OVERLAY = CALENDAR_PICKER_CLASS + "-overlay",
- CALENDAR_PICKER_INPUT_WRAPPER_CLASS = CALENDAR_PICKER_CLASS + "-input-wrapper",
- CALENDAR_PICKER_INPUT_WIDER_THAN_CALENDAR_CONTAINER_CLASS = CALENDAR_PICKER_CLASS + "-input-wider-than-calendar-container",
- CALENDAR_PICKER_POSITION_CLASS_PREFIX = CALENDAR_PICKER_CLASS + "-",
- CALENDAR_PICKER_DXPOINTERUP_EVENT_NAME = events.addNamespace("dxpointerup", "dxCalendarPicker"),
- getLongestCaptionIndex = function(captionArray) {
- var longestIndex = 0,
- longestCaptionLength = 0,
- i;
- for (i = 0; i < captionArray.length; ++i)
- if (captionArray[i].length > longestCaptionLength) {
- longestIndex = i;
- longestCaptionLength = captionArray[i].length
- }
- return longestIndex
- },
- expandPattern = function(pattern) {
- return pattern.length === 1 ? Globalize.culture().calendar.patterns[pattern] : pattern
- },
- formatUsesMonthName = function(format) {
- return expandPattern(format).indexOf("MMMM") !== -1
- },
- formatUsesDayName = function(format) {
- return expandPattern(format).indexOf("dddd") !== -1
- },
- getLongestDate = function(format, monthNames, dayNames) {
- var longestDate = new Date(1888, formatUsesMonthName(format) ? getLongestCaptionIndex(monthNames) : 9, 28 - 7, 23, 59, 59, 999);
- if (formatUsesDayName(format))
- longestDate.setDate(longestDate.getDate() - longestDate.getDay() + getLongestCaptionIndex(dayNames));
- return longestDate
- };
- ui.calculateMaximumDateFormatWidth = function(format, customFontStyles, rootElement) {
- if (!rootElement || $(rootElement).is(":visible")) {
- var width,
- ieRoundingError = 2,
- longestTextDiv = $("<div>" + Globalize.format(getLongestDate(format, Globalize.culture().calendar.months.names, Globalize.culture().calendar.days.names), format) + "</div>").css({
- visibility: "hidden",
- "white-space": "nowrap",
- position: "absolute",
- float: "left"
- });
- if (customFontStyles)
- longestTextDiv.css(customFontStyles);
- longestTextDiv.appendTo(rootElement ? $(rootElement) : $("body"));
- width = longestTextDiv.width() + ieRoundingError;
- longestTextDiv.remove();
- return width
- }
- };
- ui.dxCalendarPicker = ui.dxDropDownEditor.inherit({
- NAME: "dxDateBox",
- _setDefaultOptions: function() {
- this.callBase();
- this.option({
- valueChangeEvent: "keyup keydown keypress",
- formatString: Globalize.culture().calendar.patterns["d"],
- formatWidthCalculator: ui.calculateMaximumDateFormatWidth,
- closeOnValueChange: true
- })
- },
- _formatWidthCalculator: function() {
- var $bearingElement = this._element().find(".dx-texteditor-input"),
- buttonWidth = this._button.outerWidth(),
- bearingElementPaddings = $bearingElement.innerWidth() - $bearingElement.width(),
- formatCalculator = this.option("formatWidthCalculator"),
- width;
- if (formatCalculator)
- width = bearingElementPaddings + buttonWidth + formatCalculator(this.option("formatString"), {
- "font-style": $bearingElement.css("font-style"),
- "font-variant": $bearingElement.css("font-variant"),
- "font-weight": $bearingElement.css("font-weight"),
- "font-size": $bearingElement.css("font-size"),
- "font-family": $bearingElement.css("font-family"),
- "letter-spacing": $bearingElement.css("letter-spacing")
- }, this._element());
- return width
- },
- _clean: function() {
- if (this._keyDownProcessor)
- this._keyDownProcessor.dispose();
- if (this._calendarKeyDownProcessor)
- this._calendarKeyDownProcessor.dispose();
- if (this._calendarContainer)
- this._calendarContainer.remove();
- this.callBase()
- },
- _render: function() {
- this.callBase();
- this._element().addClass(CALENDAR_PICKER_CLASS);
- this._keyDownProcessor = new ui.HierarchicalKeyDownProcessor({
- element: this._input(),
- handler: this._keyDownHandler,
- context: this
- });
- this._calendarKeyDownProcessor = this._keyDownProcessor.attachChildProcessor()
- },
- _calculateWidth: function(rawValue) {
- return this.callBase() || this._formatWidthCalculator()
- },
- _keyDownHandler: function(options) {
- switch (options.key) {
- case"escape":
- options.originalEvent.preventDefault();
- this._blur();
- return;
- default:
- if (this._calendarContainer && $(this._calendarContainer).is(":visible"))
- return true;
- return
- }
- },
- _applyDropDownDirectionClasses: function(directions, calendarInnerWidth) {
- if (this._element().width() > calendarInnerWidth)
- this._dropDown._wrapper().addClass(CALENDAR_PICKER_INPUT_WIDER_THAN_CALENDAR_CONTAINER_CLASS);
- else
- this._dropDown._wrapper().removeClass(CALENDAR_PICKER_INPUT_WIDER_THAN_CALENDAR_CONTAINER_CLASS);
- this._cleanDirections(this._dropDown._wrapper()).addClass(directions.horizontalClass + " " + directions.verticalClass)
- },
- _cleanDirections: function(element) {
- return element.removeClass(CALENDAR_PICKER_POSITION_CLASS_PREFIX + "left " + CALENDAR_PICKER_POSITION_CLASS_PREFIX + "right " + CALENDAR_PICKER_POSITION_CLASS_PREFIX + "top " + CALENDAR_PICKER_POSITION_CLASS_PREFIX + "bottom")
- },
- _createDropDown: function() {
- var that = this,
- horizontalAlign = this.option("rtlEnabled") ? "right" : "left",
- verticalAlign = "bottom";
- this.callBase({
- position: {
- my: horizontalAlign + " " + DX.inverseAlign(verticalAlign),
- at: horizontalAlign + " " + verticalAlign
- },
- positioningAction: function(options) {
- if (that._calendarContainer)
- that._applyDropDownDirectionClasses({
- horizontalClass: CALENDAR_PICKER_POSITION_CLASS_PREFIX + (options.position.h.flip ? horizontalAlign : DX.inverseAlign(horizontalAlign)),
- verticalClass: CALENDAR_PICKER_POSITION_CLASS_PREFIX + (options.position.v.flip ? DX.inverseAlign(verticalAlign) : verticalAlign)
- }, that._calendarContainer.innerWidth())
- }
- })
- },
- _closeOutsideDropDownHandler: function(e, ignoreContainerClicks) {
- this.callBase(e, true)
- },
- _renderDropDownContent: function() {
- var that = this;
- this._calendarContainer = $("<div />").addClass(CALENDAR_PICKER_CALENDAR_CONTAINER_CLASS);
- this._calendar = this._calendarContainer.dxCalendar($.extend(this.option("calendarOptions"), {
- value: this.option("value"),
- rtlEnabled: this.option("rtlEnabled"),
- keyDownProcessor: this._calendarKeyDownProcessor,
- min: this.option("min"),
- max: this.option("max")
- })).dxCalendar("instance");
- this._calendarContainer.on(CALENDAR_PICKER_DXPOINTERUP_EVENT_NAME, function(e) {
- that._calendarContainerPointerUpHandler(e)
- });
- return [this._calendarContainer]
- },
- _showDropDown: function() {
- if (!this._dropDownVisible()) {
- var containerRendered = this._dropDownContainerRendered;
- this.callBase();
- if (!containerRendered) {
- this._calendar.optionChanged.add($.proxy(this._calendarOptionChangedCallback, this));
- this._dropDown._wrapper().addClass(CALENDAR_PICKER_OVERLAY)
- }
- }
- },
- _calendarContainerPointerUpHandler: function(e) {
- e.dxPreventBlur = true
- },
- _calendarOptionChangedCallback: function(name, value, previousValue) {
- switch (name) {
- case"value":
- this.option("value", value);
- default:
- break
- }
- },
- _optionValuesEqual: function(name, oldValue, newValue) {
- if (name === "value" && newValue === null)
- return false;
- return this.callBase.apply(this, arguments)
- },
- _renderValue: function(formattedValue) {
- this.callBase(Globalize.format(this.option("value"), this.option("formatString")))
- },
- _handleValueChangeEvent: function(e, formattedValue) {
- this._suppressUpdateValue();
- var date = Globalize.parseDate(this._input().val(), this.option("formatString"));
- this.callBase(e, date);
- this._resumeUpdateValue()
- },
- _blur: function() {
- this._input().blur()
- },
- _visibilityChanged: function(visible) {
- if (visible)
- this._renderDimensions()
- },
- _optionChanged: function(name, value, previousValue) {
- var that = this,
- normalizedDate;
- switch (name) {
- case"min":
- case"max":
- case"formatString":
- case"calendarOptions":
- this._invalidate();
- break;
- case"type":
- case"formatWidthCalculator":
- case"closeOnValueChange":
- break;
- case"value":
- if (value) {
- normalizedDate = utils.normalizeDate(value, this.option("min"), this.option("max"));
- this.option("value", normalizedDate);
- if (this._calendar)
- this._calendar.option("value", value);
- if (this._dropDownVisible() && this.option("closeOnValueChange"))
- setTimeout($.proxy(that._hideDropDown, that), 50)
- }
- default:
- this.callBase.apply(this, arguments)
- }
- }
- });
- DX.registerComponent("dxDateBoxTypeCalendarForDebugTests", ui.dxCalendarPicker.inherit({NAME: "dxDateBoxTypeCalendarForDebugTests"}));
- ui.dxCalendarPicker.__internals = {
- getLongestCaptionIndex: getLongestCaptionIndex,
- getLongestDate: getLongestDate,
- calculateMaximumDateFormatWidth: ui.calculateMaximumDateFormatWidth,
- CALENDAR_PICKER_OVERLAY: CALENDAR_PICKER_OVERLAY,
- CALENDAR_PICKER_INPUT_WIDER_THAN_CALENDAR_CONTAINER_CLASS: CALENDAR_PICKER_INPUT_WIDER_THAN_CALENDAR_CONTAINER_CLASS,
- CALENDAR_PICKER_INPUT_WRAPPER_CLASS: CALENDAR_PICKER_INPUT_WRAPPER_CLASS,
- CALENDAR_PICKER_POSITION_CLASS_PREFIX: CALENDAR_PICKER_POSITION_CLASS_PREFIX
- }
- })(jQuery, DevExpress);
- /*! Module widgets-base, file ui.calendarPickerTimeBox.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- events = ui.events,
- CALENDAR_PICKER_TIME_BOX_CLASS = "dx-calendar-picker-time-box",
- TEXTEDITOR_INPUT_WRAPPER_CLASS = "dx-texteditor-input-wrapper",
- CALENDAR_PICKER_TIME_BOX_DXCLICK_EVENT_NAME = events.addNamespace("dxclick", "dxCalendarPickerTimeBox");
- DX.registerComponent("dxCalendarPickerTimeBox", ui.dxTextEditor.inherit({
- _processingKeyPress: undefined,
- _setDefaultOptions: function() {
- this.callBase();
- this.option({
- valueChangeEvent: "keyup keydown keypress",
- formatString: Globalize.culture().calendar.patterns["t"],
- formatWidthCalculator: ui.calculateMaximumDateFormatWidth
- })
- },
- _formatWidthCalculator: function() {
- var $element = this._element(),
- $bearingElement = $element.find(".dx-texteditor-input"),
- paddingWidth = $element.innerWidth() - $element.width(),
- formatWidthCalculator = this.option("formatWidthCalculator"),
- width;
- if (formatWidthCalculator)
- width = paddingWidth + formatWidthCalculator(this.option("formatString"), {
- "font-style": $bearingElement.css("font-style"),
- "font-variant": $bearingElement.css("font-variant"),
- "font-weight": $bearingElement.css("font-weight"),
- "font-size": $bearingElement.css("font-size"),
- "font-family": $bearingElement.css("font-family"),
- "letter-spacing": $bearingElement.css("letter-spacing")
- });
- return width
- },
- _render: function() {
- var that = this,
- $element = this._element();
- $element.addClass(CALENDAR_PICKER_TIME_BOX_CLASS);
- this.callBase();
- $element.off(CALENDAR_PICKER_TIME_BOX_DXCLICK_EVENT_NAME).on(CALENDAR_PICKER_TIME_BOX_DXCLICK_EVENT_NAME, function() {
- that.focus()
- });
- this._repositionIcon($element.width())
- },
- _calculateWidth: function(rawValue) {
- var width = this.callBase();
- if (!width)
- width = this._formatWidthCalculator();
- return width
- },
- _renderValue: function(formattedValue) {
- this.callBase(Globalize.format(this.option("value"), this.option("formatString")))
- },
- _renderInput: function() {
- this.callBase();
- this._element().addClass(TEXTEDITOR_INPUT_WRAPPER_CLASS)
- },
- _repositionIcon: function(inputWidth) {
- if (this.option("rtlEnabled"))
- return;
- var ie8 = DX.browser.msie && DX.browser.version < 9,
- backgroundPosition = ie8 ? [this._element().css("backgroundPositionX"), this._element().css("backgroundPositionY")] : this._element().css("background-position").split(" ");
- this._iconWidth = this._iconWidth || parseInt(backgroundPosition[0], 10);
- if (ie8) {
- this._element().css("backgroundPositionX", inputWidth + this._iconWidth + "px");
- this._element().css("backgroundPositionY", backgroundPosition[1])
- }
- else
- this._element().css("background-position", inputWidth + this._iconWidth + "px " + backgroundPosition[1])
- },
- _handleValueChangeEvent: function(e, formattedValue) {
- this._suppressUpdateValue();
- var time = Globalize.parseDate(this._input().val(), this.option("formatString"));
- this.callBase(e, time);
- this._resumeUpdateValue()
- },
- _optionChanged: function(name, value, previousValue) {
- switch (name) {
- case"formatWidthCalculator":
- break;
- case"formatString":
- this._invalidate();
- break;
- case"width":
- this.callBase.apply(this, arguments);
- this._repositionIcon(this._element().width());
- break;
- default:
- this.callBase.apply(this, arguments)
- }
- }
- }));
- ui.dxCalendarPickerTimeBox.__internals = {TEXTEDITOR_INPUT_WRAPPER_CLASS: TEXTEDITOR_INPUT_WRAPPER_CLASS}
- })(jQuery, DevExpress);
- /*! Module widgets-base, file ui.dateBox.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- events = ui.events,
- support = DX.support,
- devices = DX.devices,
- globalize = Globalize;
- var DATEBOX_CLASS = "dx-datebox",
- DATEPICKER_CLASS = "dx-datepicker",
- DATEPICKER_WRAPPER_CLASS = "dx-datepicker-wrapper",
- DATEPICKER_ROLLER_CONTAINER_CLASS = "dx-datepicker-rollers",
- DATEPICKER_ROLLER_CLASS = "dx-datepicker-roller",
- DATEPICKER_ROLLER_ACTIVE_CLASS = "dx-state-active",
- DATEPICKER_ROLLER_CURRENT_CLASS = "dx-datepicker-roller-current",
- DATEPICKER_ROLLER_ITEM_CLASS = "dx-datepicker-item",
- DATEPICKER_ROLLER_ITEM_SELECTED_CLASS = "dx-datepicker-item-selected",
- DATEPICKER_ROLLER_ITEM_SELECTED_FRAME_CLASS = "dx-datepicker-item-selected-frame",
- DATEPICKER_ROLLER_ITEM_SELECTED_BORDER_CLASS = "dx-datepicker-item-selected-border",
- DATEPICKER_ROLLER_BUTTON_UP_CLASS = "dx-datepicker-button-up",
- DATEPICKER_ROLLER_BUTTON_DOWN_CLASS = "dx-datepicker-button-down",
- DATEPICKER_FORMATTER_CONTAINER = "dx-datepicker-formatter-container",
- DATEPICKER_VALUE_FORMATTER = "dx-datepicker-value-formatter",
- DATEPICKER_NAME_FORMATTER = "dx-datepicker-name-formatter",
- SUPPORTED_FORMATS = ["date", "time", "datetime"],
- DEFAULT_FORMATTER = function(value) {
- return value
- },
- DATE_COMPONENT_TEXT_FORMATTER = function(value, name) {
- var $container = $("<div>").addClass(DATEPICKER_FORMATTER_CONTAINER);
- $("<span>").text(value).addClass(DATEPICKER_VALUE_FORMATTER).appendTo($container);
- $("<span>").text(name).addClass(DATEPICKER_NAME_FORMATTER).appendTo($container);
- return $container
- },
- YEAR = "year",
- MONTH = "month",
- DAY = "day",
- HOURS = "hours",
- MINUTES = "minutes",
- SECONDS = "seconds",
- MILLISECONDS = "milliseconds",
- TEN_YEARS = 1000 * 60 * 60 * 24 * 365 * 10;
- var DATE_COMPONENTS_INFO = {};
- DATE_COMPONENTS_INFO[YEAR] = {
- getter: "getFullYear",
- setter: "setFullYear",
- possibleFormats: ["yy", "yyyy"],
- formatter: DEFAULT_FORMATTER,
- startValue: undefined,
- endValue: undefined
- };
- DATE_COMPONENTS_INFO[DAY] = {
- getter: "getDate",
- setter: "setDate",
- possibleFormats: ["d", "dd"],
- formatter: function(value, showNames, date) {
- if (!showNames)
- return value;
- var formatDate = new Date(date.getTime());
- formatDate.setDate(value);
- return DATE_COMPONENT_TEXT_FORMATTER(value, globalize.culture().calendar.days.names[formatDate.getDay()])
- },
- startValue: 1,
- endValue: undefined
- };
- DATE_COMPONENTS_INFO[MONTH] = {
- getter: "getMonth",
- setter: "setMonth",
- possibleFormats: ["M", "MM", "MMM", "MMMM"],
- formatter: function(value, showNames) {
- var monthName = globalize.culture().calendar.months.names[value];
- return showNames ? DATE_COMPONENT_TEXT_FORMATTER(value + 1, monthName) : monthName
- },
- startValue: 0,
- endValue: 11
- };
- DATE_COMPONENTS_INFO[HOURS] = {
- getter: "getHours",
- setter: "setHours",
- possibleFormats: ["H", "HH", "h", "hh"],
- formatter: function(value) {
- return globalize.format(new Date(0, 0, 0, value), "HH")
- },
- startValue: 0,
- endValue: 23
- };
- DATE_COMPONENTS_INFO[MINUTES] = {
- getter: "getMinutes",
- setter: "setMinutes",
- possibleFormats: ["m", "mm"],
- formatter: function(value) {
- return globalize.format(new Date(0, 0, 0, 0, value), "mm")
- },
- startValue: 0,
- endValue: 59
- };
- DATE_COMPONENTS_INFO[SECONDS] = {
- getter: "getSeconds",
- setter: "setSeconds",
- possibleFormats: ["s", "ss"],
- formatter: function(value) {
- return globalize.format(new Date(0, 0, 0, 0, 0, value), "ss")
- },
- startValue: 0,
- endValue: 59
- };
- DATE_COMPONENTS_INFO[MILLISECONDS] = {
- getter: "getMilliseconds",
- setter: "setMilliseconds",
- possibleFormats: ["f", "ff", "fff"],
- formatter: function(value) {
- return globalize.format(new Date(0, 0, 0, 0, 0, 0, value), "fff")
- },
- startValue: 0,
- endValue: 999
- };
- var dateCopmotents = function() {
- return [YEAR, DAY, MONTH, DAY]
- };
- var FORMATS_INFO = {
- date: {
- standardPattern: "yyyy-MM-dd",
- components: dateCopmotents()
- },
- time: {
- standardPattern: "HH:mm",
- components: [HOURS, MINUTES]
- },
- datetime: {
- standardPattern: "yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'",
- components: dateCopmotents().concat([HOURS, MINUTES, SECONDS, MILLISECONDS])
- },
- "datetime-local": {
- standardPattern: "yyyy'-'MM'-'dd'T'HH':'mm",
- components: dateCopmotents().concat([HOURS, MINUTES, SECONDS])
- }
- },
- FORMATS_MAP = {
- date: "d",
- time: "t",
- datetime: "S",
- "datetime-local": "f"
- };
- var toStandardDateFormat = function(date, mode, pattern) {
- pattern = pattern || FORMATS_INFO[mode].standardPattern;
- var datePattern = FORMATS_INFO[mode].standardPattern;
- return Globalize.format(date, pattern)
- };
- (function androidFormatDetection() {
- var androidFormatPattern = "yyyy'-'MM'-'dd'T'HH':'mm'Z'";
- var $input = $("<input>").attr("type", "datetime");
- $input.val(toStandardDateFormat(new Date, "datetime", androidFormatPattern));
- if (!$input.val())
- FORMATS_INFO.datetime.standardPattern = androidFormatPattern
- })();
- var fromStandardDateFormat = function(date) {
- return Globalize.parseDate(date, FORMATS_INFO["datetime"].standardPattern) || Globalize.parseDate(date, FORMATS_INFO["datetime-local"].standardPattern) || Globalize.parseDate(date, FORMATS_INFO["time"].standardPattern) || Globalize.parseDate(date, FORMATS_INFO["date"].standardPattern) || Date.parse && Date.parse(date) && new Date(Date.parse(date))
- };
- var getMaxMonthDay = function(year, month) {
- return new Date(year, month + 1, 0).getDate()
- };
- var mergeDates = function(target, source, format) {
- if (!source)
- return undefined;
- if (isNaN(target.getTime()))
- target = new Date(0, 0, 0, 0, 0, 0);
- var formatInfo = FORMATS_INFO[format];
- $.each(formatInfo.components, function() {
- var componentInfo = DATE_COMPONENTS_INFO[this];
- target[componentInfo.setter](source[componentInfo.getter]())
- });
- return target
- };
- DX.registerComponent("dxDatePickerRoller", ui.dxScrollable.inherit({
- _setDefaultOptions: function() {
- this.callBase();
- this.option({
- clickableItems: false,
- showScrollbar: false,
- useNative: false,
- selectedIndex: 0,
- items: []
- })
- },
- _defaultOptionsRules: function() {
- return this.callBase().slice(0).concat([{
- device: {platform: "win8"},
- options: {clickableItems: true}
- }, {
- device: {platform: "generic"},
- options: {scrollByContent: true}
- }])
- },
- _init: function() {
- this.callBase();
- this._renderSelectedItemFrame();
- this._renderControlButtons()
- },
- _render: function() {
- this.callBase();
- $.each(this._strategy._scrollers, function(index, scroller) {
- scroller._correctLocation = $.noop
- });
- this._element().addClass(DATEPICKER_ROLLER_CLASS);
- this._renderItems();
- this._renderSelectedValue();
- this._renderItemsClick();
- this._wrapAction("_endAction", $.proxy(this._handleEndAction, this))
- },
- _wrapAction: function(actionName, callback) {
- var strategy = this._strategy,
- originalAction = strategy[actionName];
- strategy[actionName] = function() {
- callback.apply(this, arguments);
- return originalAction.apply(this, arguments)
- }
- },
- _renderItems: function() {
- var items = this.option("items") || [],
- $items = $();
- this._$content.empty();
- $.each(items, function() {
- $items = $items.add($("<div>").addClass(DATEPICKER_ROLLER_ITEM_CLASS).append(this))
- });
- this._$content.append($items);
- this._$items = $items;
- this.update()
- },
- _renderSelectedItemFrame: function() {
- $("<div>").addClass(DATEPICKER_ROLLER_ITEM_SELECTED_FRAME_CLASS).append($("<div>").addClass(DATEPICKER_ROLLER_ITEM_SELECTED_BORDER_CLASS)).appendTo(this._$container)
- },
- _renderControlButtons: function() {
- $("<div>").addClass(DATEPICKER_ROLLER_BUTTON_UP_CLASS).insertAfter(this._$container).dxButton({clickAction: $.proxy(this._handleUpButtonClick, this)});
- $("<div>").addClass(DATEPICKER_ROLLER_BUTTON_DOWN_CLASS).insertAfter(this._$container).dxButton({clickAction: $.proxy(this._handleDownButtonClick, this)})
- },
- _renderSelectedValue: function(selectedIndex) {
- if (selectedIndex === undefined)
- selectedIndex = this.option("selectedIndex");
- selectedIndex = this._fitIndex(selectedIndex);
- var correctedPosition = this._getItemPosition(selectedIndex);
- this.option().selectedIndex = selectedIndex;
- this._moveTo({top: correctedPosition});
- this._renderActiveStateItem()
- },
- _fitIndex: function(index) {
- var items = this.option("items") || [],
- itemCount = items.length;
- if (index >= itemCount)
- return itemCount - 1;
- if (index < 0)
- return 0;
- return index
- },
- _renderItemsClick: function() {
- var itemSelector = "." + DATEPICKER_ROLLER_ITEM_CLASS,
- eventName = events.addNamespace("dxclick", this.NAME);
- this._element().off(eventName, itemSelector);
- if (this.option("clickableItems"))
- this._element().on(eventName, itemSelector, $.proxy(this._handleItemClick, this))
- },
- _handleItemClick: function(e) {
- this._renderSelectedValue(this._itemElementIndex(this._closestItemElement(e)))
- },
- _itemElementIndex: function(itemElement) {
- return this._itemElements().index(itemElement)
- },
- _closestItemElement: function(e) {
- return e.currentTarget
- },
- _itemElements: function() {
- return this._element().find("." + DATEPICKER_ROLLER_ITEM_CLASS)
- },
- _renderActiveStateItem: function() {
- var selectedIndex = this.option("selectedIndex");
- $.each(this._$items, function(index) {
- $(this).toggleClass(DATEPICKER_ROLLER_ITEM_SELECTED_CLASS, selectedIndex === index)
- })
- },
- _handleUpButtonClick: function() {
- this._animation = true;
- this.option("selectedIndex", this.option("selectedIndex") - 1)
- },
- _handleDownButtonClick: function() {
- this._animation = true;
- this.option("selectedIndex", this.option("selectedIndex") + 1)
- },
- _getItemPosition: function(index) {
- return Math.round(this._itemHeight() * index)
- },
- _moveTo: function(targetLocation) {
- targetLocation = this._normalizeLocation(targetLocation);
- var location = this._location(),
- delta = {
- x: -(location.left - targetLocation.left),
- y: -(location.top - targetLocation.top)
- };
- if (this._isVisible() && (delta.x || delta.y)) {
- this._strategy._prepareDirections(true);
- if (this._animation) {
- DX.fx.animate(this._$content, {
- duration: 200,
- type: "slide",
- to: {top: targetLocation.top}
- });
- delete this._animation
- }
- else
- this._strategy.handleMove({delta: delta})
- }
- },
- _handleEndAction: function() {
- if (this._changedByIndex) {
- this._changedByIndex = false;
- this._renderSelectedValue();
- return
- }
- var ratio = -this._location().top / this._itemHeight(),
- selectedIndex = Math.round(ratio);
- this._animation = true;
- this._renderSelectedValue(selectedIndex)
- },
- _itemHeight: function() {
- var $item = this._$items.first(),
- height = $item.outerHeight() + parseFloat($item.css("margin-top") || 0);
- return height
- },
- _toggleActive: function(state) {
- this._element().toggleClass(DATEPICKER_ROLLER_ACTIVE_CLASS, state)
- },
- _isVisible: function() {
- return this._$container.is(":visible")
- },
- _optionChanged: function(name) {
- switch (name) {
- case"selectedIndex":
- this._renderSelectedValue();
- this._changedByIndex = true;
- this._strategy.update();
- this._strategy.handleEnd({velocity: {
- x: 0,
- y: 0
- }});
- break;
- case"items":
- this._renderItems();
- this._renderSelectedValue();
- break;
- case"clickableItems":
- this._renderItemsClick();
- break;
- default:
- this.callBase.apply(this, arguments)
- }
- }
- }));
- DX.registerComponent("dxDatePicker", ui.dxPopup.inherit({
- _valueOption: function() {
- return new Date(this.option("value")) == "Invalid Date" ? new Date : new Date(this.option("value"))
- },
- _setDefaultOptions: function() {
- this.callBase();
- this.option({
- minDate: new Date(1),
- maxDate: new Date($.now() + TEN_YEARS),
- format: "date",
- value: new Date,
- culture: Globalize.culture().name,
- showNames: false,
- cancelButton: {
- icon: "close",
- clickAction: $.proxy(function() {
- this._value = this._valueOption()
- }, this)
- },
- doneButton: {
- icon: "save",
- clickAction: $.proxy(function() {
- this.option("value", new Date(this._value));
- this.hide()
- }, this)
- }
- })
- },
- _defaultOptionsRules: function() {
- return this.callBase().slice(0).concat([{
- device: {platform: "win8"},
- options: {showNames: true}
- }, {
- device: {
- platform: "win8",
- phone: true
- },
- options: {fullScreen: true}
- }, {
- device: function(device) {
- return device.platform !== "win8"
- },
- options: {
- width: 333,
- height: 331
- }
- }, {
- device: function(device) {
- return device.platform === "generic"
- },
- options: {
- width: "auto",
- height: "auto"
- }
- }])
- },
- _render: function() {
- this._value = this._valueOption();
- this.callBase();
- this._element().addClass(DATEPICKER_CLASS);
- this._wrapper().addClass(DATEPICKER_WRAPPER_CLASS)
- },
- _renderContentImpl: function() {
- this.callBase();
- this._renderRollers()
- },
- _renderRollers: function() {
- var that = this;
- if (!that._$rollersContainer)
- that._$rollersContainer = $("<div>").appendTo(that.content()).addClass(DATEPICKER_ROLLER_CONTAINER_CLASS);
- that._$rollersContainer.empty();
- that._createRollerConfigs();
- that._rollers = {};
- $.each(that._rollerConfigs, function(name) {
- var $roller = $("<div>").appendTo(that._$rollersContainer).addClass(DATEPICKER_ROLLER_CLASS + "-" + that._rollerConfigs[name].type).dxDatePickerRoller({
- items: that._rollerConfigs[name].displayItems,
- selectedIndex: that._rollerConfigs[name].selectedIndex,
- showScrollbar: false,
- startAction: function(e) {
- var roller = e.component;
- roller._toggleActive(true);
- that._setActiveRoller(that._rollerConfigs[name], roller.option("selectedIndex"))
- },
- endAction: function(e) {
- var roller = e.component;
- that._setRollerState(that._rollerConfigs[name], roller.option("selectedIndex"));
- roller._toggleActive(false)
- }
- });
- that._rollers[that._rollerConfigs[name].type] = $roller.dxDatePickerRoller("instance")
- })
- },
- _setActiveRoller: function(currentRoller) {
- var activeRoller = currentRoller && this._rollers[currentRoller.type];
- $.each(this._rollers, function() {
- this._$element.toggleClass(DATEPICKER_ROLLER_CURRENT_CLASS, this === activeRoller)
- })
- },
- _refreshRollers: function() {
- var that = this;
- $.each(this._rollers, function(type) {
- var correctIndex = that._rollerConfigs[type].getIndex(that._value);
- this.update();
- this._renderSelectedValue(correctIndex)
- })
- },
- _setRollerState: function(roller, selectedIndex) {
- if (selectedIndex !== roller.selectedIndex) {
- var value = roller.valueItems[selectedIndex],
- setValue = roller.setValue,
- currentDate = this._value.getDate();
- if (roller.type === MONTH) {
- currentDate = Math.min(currentDate, getMaxMonthDay(this._value.getFullYear(), value));
- this._value.setDate(currentDate)
- }
- else if (roller.type === YEAR) {
- currentDate = Math.min(currentDate, getMaxMonthDay(value, this._value.getMonth()));
- this._value.setDate(currentDate)
- }
- this._value[setValue](value);
- roller.selectedIndex = selectedIndex
- }
- if (roller.type === YEAR) {
- this._refreshMonthRoller();
- this._refreshDayRoller()
- }
- if (roller.type === MONTH)
- this._refreshDayRoller()
- },
- _refreshMonthRoller: function() {
- var monthRoller = this._rollers[MONTH];
- if (monthRoller) {
- this._createRollerConfig(MONTH);
- var monthRollerConfig = this._rollerConfigs[MONTH];
- this._deferredRenderMonthTimeout = window.setTimeout(function() {
- if (monthRollerConfig.displayItems.length === monthRoller.option("items").length)
- return;
- monthRoller.option({
- items: monthRollerConfig.displayItems,
- selectedIndex: monthRollerConfig.selectedIndex
- })
- }, 100)
- }
- },
- _refreshDayRoller: function() {
- var dayRoller = this._rollers[DAY];
- if (dayRoller) {
- this._createRollerConfig(DAY);
- var dayRollerConfig = this._rollerConfigs[DAY];
- this._deferredRenderDayTimeout = window.setTimeout(function() {
- if (dayRollerConfig.displayItems.length === dayRoller.option("items").length)
- return;
- dayRoller.option({
- items: dayRollerConfig.displayItems,
- selectedIndex: dayRollerConfig.selectedIndex
- })
- }, 100)
- }
- },
- _createRollerConfigs: function(format) {
- var that = this;
- format = format || that.option("format");
- that._rollerConfigs = {};
- $.each(that._getFormatPattern(format).split(/\W+/), function(_, formatPart) {
- $.each(DATE_COMPONENTS_INFO, function(componentName, componentInfo) {
- if ($.inArray(formatPart, componentInfo.possibleFormats) > -1)
- that._createRollerConfig(componentName)
- })
- })
- },
- _getFormatPattern: function(format) {
- var culture = Globalize.culture(this.option("culture")),
- result = "";
- if (format === "date")
- result = culture.calendar.patterns.d;
- else if (format === "time")
- result = culture.calendar.patterns.t;
- else if (format === "datetime")
- result = [culture.calendar.patterns.d, culture.calendar.patterns.t].join(" ");
- return result
- },
- _createRollerConfig: function(componentName) {
- var componentInfo = DATE_COMPONENTS_INFO[componentName],
- valueRange = this._calculateRollerConfigValueRange(componentName),
- startValue = valueRange.startValue,
- endValue = valueRange.endValue,
- formatter = componentInfo.formatter,
- showNames = this.option("showNames"),
- curDate = this._value;
- var config = {
- type: componentName,
- setValue: componentInfo.setter,
- valueItems: [],
- displayItems: [],
- getIndex: function(value) {
- return value[componentInfo.getter]() - startValue
- }
- };
- for (var i = startValue; i <= endValue; i++) {
- config.valueItems.push(i);
- config.displayItems.push(formatter(i, showNames, curDate))
- }
- config.selectedIndex = config.getIndex(this._value);
- this._rollerConfigs[componentName] = config
- },
- _calculateRollerConfigValueRange: function(componentName) {
- var curDate = this._value,
- minDate = this.option("minDate"),
- maxDate = this.option("maxDate"),
- minYear = curDate.getFullYear() === minDate.getFullYear(),
- minMonth = minYear && curDate.getMonth() === minDate.getMonth(),
- maxYear = curDate.getFullYear() === maxDate.getFullYear(),
- maxMonth = maxYear && curDate.getMonth() === maxDate.getMonth(),
- componentInfo = DATE_COMPONENTS_INFO[componentName],
- startValue = componentInfo.startValue,
- endValue = componentInfo.endValue;
- if (componentName === YEAR) {
- startValue = minDate.getFullYear();
- endValue = maxDate.getFullYear()
- }
- if (componentName === MONTH) {
- if (minYear)
- startValue = minDate.getMonth();
- if (maxYear)
- endValue = maxDate.getMonth()
- }
- if (componentName === DAY) {
- endValue = getMaxMonthDay(curDate.getFullYear(), curDate.getMonth());
- if (minMonth)
- startValue = minDate.getDate();
- if (maxYear)
- endValue = maxDate.getDate()
- }
- return {
- startValue: startValue,
- endValue: endValue
- }
- },
- _optionChanged: function(name, value, prevValue) {
- switch (name) {
- case"showNames":
- case"minDate":
- case"maxDate":
- case"culture":
- case"format":
- this._renderRollers();
- break;
- case"visible":
- this.callBase(name, value, prevValue);
- if (value) {
- this._refreshRollers();
- this._setActiveRoller()
- }
- break;
- case"value":
- this._value = this._valueOption();
- this._renderRollers();
- break;
- default:
- this.callBase(name, value, prevValue)
- }
- },
- _dispose: function() {
- clearTimeout(this._deferredRenderDayTimeout);
- clearTimeout(this._deferredRenderMonthTimeout);
- this.callBase()
- }
- }));
- DX.registerComponent("dxDateBox", ui.dxTextEditor.inherit({
- ctor: function(element, options) {
- options = options || {};
- var preferCalendar = devices.current().platform === "generic" && (options.format === "date" || !options.format),
- useCalendar = options && options.useCalendar;
- if (useCalendar === undefined)
- useCalendar = preferCalendar;
- if (useCalendar)
- new ui.dxCalendarPicker(element, options);
- else
- this.callBase(element, options)
- },
- _setDefaultOptions: function() {
- this.callBase();
- this.option({
- format: "date",
- value: new Date,
- min: new Date(1),
- max: new Date($.now() + TEN_YEARS),
- useCalendar: false,
- useNativePicker: true
- })
- },
- _defaultOptionsRules: function() {
- return this.callBase().slice(0).concat([{
- device: function(device) {
- return device.win8 || device.android && (device.version[0] < 4 || device.version[0] == 4 && device.version[1] < 4)
- },
- options: {useNativePicker: false}
- }])
- },
- _init: function() {
- this.callBase();
- this._initFormat()
- },
- _render: function() {
- this.callBase();
- this._element().addClass(DATEBOX_CLASS);
- this._renderDatePicker()
- },
- _renderDatePicker: function() {
- if (this._usingNativeDatePicker() || this.option("readOnly")) {
- if (this._datePicker) {
- this._datePicker._element().remove();
- this._datePicker = null
- }
- return
- }
- var datePickerOptions = {
- value: this.option("value"),
- format: this.option("format"),
- title: this._getDataPickerTitle(),
- minDate: this.option("min"),
- maxDate: this.option("max")
- };
- if (this._datePicker)
- this._datePicker.option(datePickerOptions);
- else {
- this._datePicker = $("<div>").appendTo(this._element()).dxDatePicker($.extend(datePickerOptions, {hidingAction: $.proxy(function(e) {
- this.option("value", e.component.option("value"))
- }, this)})).dxDatePicker("instance");
- var inputClickAction = this._createAction(function(e) {
- e.component._datePicker.show()
- });
- this._input().on(events.addNamespace("dxclick", this.NAME), function(e) {
- return inputClickAction({jQuery: e})
- })
- }
- },
- _renderFocusEvent: function() {
- this.callBase();
- this._input().on('focus', $.proxy(function() {
- this._togglePlaceholderVisibility(false)
- }, this))
- },
- _initFormat: function() {
- var format = this.option("format");
- if ($.inArray(format, SUPPORTED_FORMATS) === -1) {
- format = "date";
- this.option("format", format)
- }
- else if (format === "datetime" && !support.inputType(format))
- format = "datetime-local";
- this.option("mode", format)
- },
- _usingNativeDatePicker: function() {
- return support.inputType(this.option("mode")) && this.option("useNativePicker")
- },
- _readOnlyPropValue: function() {
- if (this._usingNativeDatePicker())
- return this.callBase();
- return true
- },
- _handleValueChangeEvent: function() {
- var value = fromStandardDateFormat(this._input().val()),
- modelValue = new Date(this.option("value") && this.option("value").valueOf()),
- newValue = mergeDates(modelValue, value, this.option("mode"));
- this.option({value: newValue});
- if (newValue !== modelValue)
- this._renderValue()
- },
- _renderValue: function() {
- var mode = this.option("mode"),
- patternKey = FORMATS_MAP[mode],
- pattern = support.inputType(mode) ? false : globalize.culture().calendar.patterns[patternKey],
- value = toStandardDateFormat(this.option("value"), mode, pattern);
- this._input().val(value);
- this._togglePlaceholderVisibility(value === "" || value === null)
- },
- _renderProps: function() {
- this.callBase();
- this._input().attr("autocomplete", "off")
- },
- _getDataPickerTitle: function() {
- var result = this.option("placeholder");
- if (!result) {
- var format = this.option("format");
- if (format === "time")
- result = Globalize.localize("dxDateBox-simulatedDataPickerTitleTime");
- else if (format === "date")
- result = Globalize.localize("dxDateBox-simulatedDataPickerTitleDate");
- else if (format === "datetime")
- result = Globalize.localize("dxDateBox-simulatedDataPickerTitleDateTime")
- }
- return result
- },
- _optionChanged: function(name, value, prevValue) {
- switch (name) {
- case"useCalendar":
- break;
- case"format":
- this._initFormat();
- this._renderValue();
- this._renderDatePicker();
- break;
- case"readOnly":
- this._invalidate();
- break;
- case"useNativePicker":
- this._renderDatePicker();
- this._renderProps();
- break;
- case"placeholder":
- if (this._datePicker)
- this._datePicker.option("title", this._getDataPickerTitle());
- break;
- case"type":
- throw new Error("type cannot be changed after instantiation");
- break;
- case"min":
- case"max":
- if (this._datePicker)
- this._datePicker.option(name + "Date", value);
- break;
- case"value":
- this._renderValue();
- this._renderDatePicker();
- default:
- this.callBase(name, value, prevValue)
- }
- }
- }));
- ui.dxDatePicker.__internals = {
- DATEPICKER_CLASS: DATEPICKER_CLASS,
- DATEPICKER_WRAPPER_CLASS: DATEPICKER_WRAPPER_CLASS,
- DATEPICKER_ROLLER_CONTAINER_CLASS: DATEPICKER_ROLLER_CONTAINER_CLASS,
- DATEPICKER_ROLLER_CLASS: DATEPICKER_ROLLER_CLASS,
- DATEPICKER_ROLLER_ACTIVE_CLASS: DATEPICKER_ROLLER_ACTIVE_CLASS,
- DATEPICKER_ROLLER_ITEM_CLASS: DATEPICKER_ROLLER_ITEM_CLASS,
- DATEPICKER_ROLLER_ITEM_SELECTED_CLASS: DATEPICKER_ROLLER_ITEM_SELECTED_CLASS,
- DATEPICKER_ROLLER_ITEM_SELECTED_FRAME_CLASS: DATEPICKER_ROLLER_ITEM_SELECTED_FRAME_CLASS,
- DATEPICKER_ROLLER_ITEM_SELECTED_BORDER_CLASS: DATEPICKER_ROLLER_ITEM_SELECTED_BORDER_CLASS,
- DATEPICKER_ROLLER_BUTTON_UP_CLASS: DATEPICKER_ROLLER_BUTTON_UP_CLASS,
- DATEPICKER_ROLLER_BUTTON_DOWN_CLASS: DATEPICKER_ROLLER_BUTTON_DOWN_CLASS,
- DATEPICKER_ROLLER_CURRENT_CLASS: DATEPICKER_ROLLER_CURRENT_CLASS
- };
- ui.dxDateBox.__internals = {
- toStandardDateFormat: toStandardDateFormat,
- fromStandardDateFormat: fromStandardDateFormat,
- FORMATS_MAP: FORMATS_MAP
- }
- })(jQuery, DevExpress);
- /*! Module widgets-base, file ui.loadIndicator.js */
- (function($, DX, undefined) {
- var ui = DX.ui;
- var LOADINDICATOR_CLASS = "dx-loadindicator",
- LOADINDICATOR_WRAPPER = "dx-loadindicator-wrapper",
- LOADINDICATOR_ICON = "dx-loadindicator-icon",
- LOADINDICATOR_SEGMENT = "dx-loadindicator-segment",
- LOADINDICATOR_SEGMENT_N = "dx-loadindicator-segment",
- LOADINDICATOR_SEGMENT_WIN8 = "dx-loadindicator-win8-segment",
- LOADINDICATOR_SEGMENT_N_WIN8 = "dx-loadindicator-win8-segment",
- LOADINDICATOR_INNER_SEGMENT_WIN8 = "dx-loadindicator-win8-inner-segment",
- LOADINDICATOR_IMAGE = "dx-loadindicator-image";
- DX.registerComponent("dxLoadIndicator", ui.Widget.inherit({
- _setDefaultOptions: function() {
- this.callBase();
- this.option({
- indicatorSrc: "",
- hoverStateEnabled: false
- })
- },
- _defaultOptionsRules: function() {
- return this.callBase().slice(0).concat([{
- device: function() {
- var realDevice = DevExpress.devices.real(),
- obsoleteAndroid = realDevice.platform === "android" && !/chrome/i.test(navigator.userAgent);
- return DevExpress.browser.msie && DevExpress.browser.version < 10 || obsoleteAndroid
- },
- options: {viaImage: true}
- }])
- },
- _init: function() {
- this.callBase();
- this._element().addClass(LOADINDICATOR_CLASS)
- },
- _render: function() {
- this._renderWrapper();
- this._renderMarkup();
- this.callBase()
- },
- _renderWrapper: function() {
- this._$wrapper = $("<div>").addClass(LOADINDICATOR_WRAPPER);
- this._element().append(this._$wrapper)
- },
- _renderMarkup: function() {
- if (DX.support.animation && !this.option("viaImage") && !this.option("indicatorSrc"))
- this._renderMarkupForAnimation();
- else
- this._renderMarkupForImage()
- },
- _renderMarkupForAnimation: function() {
- this._$indicator = $("<div>").addClass(LOADINDICATOR_ICON);
- for (var i = 15; i >= 0; --i) {
- var $segment = $("<div>").addClass(LOADINDICATOR_SEGMENT).addClass(LOADINDICATOR_SEGMENT_N + i);
- this._$indicator.append($segment)
- }
- for (var i = 1; i <= 5; ++i) {
- var $innerSegment = $("<div>").addClass(LOADINDICATOR_INNER_SEGMENT_WIN8),
- $segment = $("<div>").addClass(LOADINDICATOR_SEGMENT_WIN8).addClass(LOADINDICATOR_SEGMENT_N_WIN8 + i);
- $segment.append($innerSegment);
- this._$indicator.append($segment)
- }
- this._$wrapper.append(this._$indicator)
- },
- _renderMarkupForImage: function() {
- var indicatorSrc = this.option("indicatorSrc");
- this._$wrapper.addClass(LOADINDICATOR_IMAGE);
- if (indicatorSrc)
- this._$wrapper.css("background-image", "url(" + indicatorSrc + ")")
- },
- _renderDimensions: function() {
- this.callBase();
- this._updateContentSize()
- },
- _updateContentSize: function() {
- var $element = this._element(),
- width = this.option("width"),
- height = this.option("height");
- if (width || height) {
- width = this._element().width();
- height = this._element().height();
- var minDimention = Math.min(height, width);
- this._$wrapper.css({
- height: minDimention,
- width: minDimention,
- "margin-top": (height - minDimention) / 2,
- "margin-left": (width - minDimention) / 2
- });
- if (this._$indicator)
- this._$indicator.find("." + LOADINDICATOR_SEGMENT).css("border-width", 0.125 * minDimention)
- }
- },
- _clean: function() {
- this.callBase();
- this._removeMarkupForAnimation();
- this._removeMarkupForImage()
- },
- _removeMarkupForAnimation: function() {
- if (this._$indicator)
- this._$indicator.remove()
- },
- _removeMarkupForImage: function() {
- this._$wrapper.css("background-image", "none")
- },
- _optionChanged: function(name) {
- switch (name) {
- case"indicatorSrc":
- this._invalidate();
- break;
- default:
- this.callBase.apply(this, arguments)
- }
- }
- }))
- })(jQuery, DevExpress);
- /*! Module widgets-base, file ui.loadPanel.js */
- (function($, DX, undefined) {
- var ui = DX.ui;
- var LOADPANEL_CLASS = "dx-loadpanel",
- LOADPANEL_WRAPPER_CLASS = "dx-loadpanel-wrapper",
- LOADPANEL_INDICATOR_CLASS = "dx-loadpanel-indicator",
- LOADPANEL_MESSAGE_CLASS = "dx-loadpanel-message",
- LOADPANEL_CONTENT_CLASS = "dx-loadpanel-content",
- LOADPANEL_CONTENT_WRAPPER_CLASS = "dx-loadpanel-content-wrapper",
- LOADPANEL_PANE_HIDDEN_CLASS = "dx-loadpanel-pane-hidden";
- DX.registerComponent("dxLoadPanel", ui.dxOverlay.inherit({
- _setDefaultOptions: function() {
- this.callBase();
- this.option({
- message: Globalize.localize("Loading"),
- width: 222,
- height: 90,
- animation: null,
- showIndicator: true,
- indicatorSrc: "",
- showPane: true,
- delay: 0
- })
- },
- _init: function() {
- this.callBase.apply(this, arguments);
- this._$contentWrapper = $("<div>").addClass(LOADPANEL_CONTENT_WRAPPER_CLASS);
- this._$contentWrapper.appendTo(this._container())
- },
- _render: function() {
- this.callBase();
- this._element().addClass(LOADPANEL_CLASS);
- this._wrapper().addClass(LOADPANEL_WRAPPER_CLASS)
- },
- _renderContentImpl: function() {
- this.callBase();
- this.content().addClass(LOADPANEL_CONTENT_CLASS);
- this._togglePaneVisible();
- this._cleanPreviousContent();
- this._renderLoadIndicator();
- this._renderMessage()
- },
- _makeVisible: function() {
- var delay = this.option("delay");
- if (!delay)
- return this.callBase();
- var deferred = $.Deferred();
- var callBase = $.proxy(this.callBase, this);
- this._clearShowTimeout();
- this._showTimeout = setTimeout(function() {
- callBase().done(function() {
- deferred.resolve()
- })
- }, delay);
- return deferred.promise()
- },
- _makeHidden: function() {
- this._clearShowTimeout();
- return this.callBase()
- },
- _clearShowTimeout: function() {
- clearTimeout(this._showTimeout)
- },
- _renderMessage: function() {
- var message = this.option("message");
- if (!message)
- return;
- var $message = $("<div>").addClass(LOADPANEL_MESSAGE_CLASS).text(message);
- this._$contentWrapper.append($message)
- },
- _renderLoadIndicator: function() {
- if (!this.option("showIndicator"))
- return;
- this._$indicator = $("<div>").addClass(LOADPANEL_INDICATOR_CLASS).dxLoadIndicator({indicatorSrc: this.option("indicatorSrc")}).appendTo(this._$contentWrapper)
- },
- _cleanPreviousContent: function() {
- this.content().find("." + LOADPANEL_MESSAGE_CLASS).remove();
- this.content().find("." + LOADPANEL_INDICATOR_CLASS).remove()
- },
- _togglePaneVisible: function() {
- this.content().toggleClass(LOADPANEL_PANE_HIDDEN_CLASS, !this.option("showPane"))
- },
- _optionChanged: function(name, value) {
- switch (name) {
- case"delay":
- break;
- case"message":
- case"showIndicator":
- this._cleanPreviousContent();
- this._renderLoadIndicator();
- this._renderMessage();
- break;
- case"showPane":
- this._togglePaneVisible();
- break;
- case"indicatorSrc":
- if (this._$indicator)
- this._$indicator.dxLoadIndicator({indicatorSrc: this.option("indicatorSrc")});
- break;
- default:
- this.callBase.apply(this, arguments)
- }
- },
- _dispose: function() {
- this._clearShowTimeout();
- this.callBase()
- },
- _defaultHideTopOverlayHandler: $.noop
- }));
- ui.dxLoadPanel.__internals = {
- LOADPANEL_CLASS: LOADPANEL_CLASS,
- LOADPANEL_WRAPPER_CLASS: LOADPANEL_WRAPPER_CLASS,
- LOADPANEL_MESSAGE_CLASS: LOADPANEL_MESSAGE_CLASS,
- LOADPANEL_CONTENT_CLASS: LOADPANEL_CONTENT_CLASS,
- LOADPANEL_PANE_HIDDEN_CLASS: LOADPANEL_PANE_HIDDEN_CLASS
- }
- })(jQuery, DevExpress);
- /*! Module widgets-base, file ui.lookup.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- utils = DX.utils,
- dataUtils = DX.data.utils,
- events = ui.events;
- var LOOKUP_CLASS = "dx-lookup",
- LOOKUP_SELECTED_CLASS = LOOKUP_CLASS + "-selected",
- LOOKUP_SEARCH_CLASS = LOOKUP_CLASS + "-search",
- LOOKUP_SEARCH_WRAPPER_CLASS = LOOKUP_CLASS + "-search-wrapper",
- LOOKUP_FIELD_CLASS = LOOKUP_CLASS + "-field",
- LOOKUP_FIELD_WRAPPER_CLASS = LOOKUP_FIELD_CLASS + "-wrapper",
- LOOKUP_POPUP_CLASS = LOOKUP_CLASS + "-popup",
- LOOKUP_POPUP_WRAPPER_CLASS = LOOKUP_POPUP_CLASS + "-wrapper",
- LOOKUP_POPUP_SEARCH_CLASS = LOOKUP_POPUP_CLASS + "-search",
- LOOKUP_POPOVER_MODE = LOOKUP_CLASS + "-popover-mode",
- LOOKUP_EMPTY_CLASS = LOOKUP_CLASS + "-empty",
- LIST_ITEM_SELECTOR = ".dx-list-item",
- LIST_ITEM_DATA_KEY = "dxListItemData",
- POPUP_HIDE_TIMEOUT = 200;
- DX.registerComponent("dxLookup", ui.dxEditor.inherit({
- _deprecatedOptions: {
- shownAction: {
- since: "14.1",
- message: "Use the 'openAction' option instead."
- },
- hiddenAction: {
- since: "14.1",
- message: "Use the 'closeAction' option instead."
- }
- },
- _optionAliases: {
- openAction: "shownAction",
- closeAction: "hiddenAction"
- },
- _setDefaultOptions: function() {
- this.callBase();
- this.option({
- items: [],
- dataSource: null,
- value: undefined,
- displayValue: undefined,
- title: "",
- titleTemplate: "title",
- valueExpr: null,
- displayExpr: "this",
- placeholder: Globalize.localize("Select"),
- searchPlaceholder: Globalize.localize("Search"),
- searchEnabled: true,
- noDataText: Globalize.localize("dxCollectionContainerWidget-noDataText"),
- searchTimeout: 1000,
- minFilterLength: 0,
- fullScreen: false,
- valueChangeAction: null,
- itemTemplate: "item",
- itemRender: null,
- showCancelButton: true,
- cancelButtonText: Globalize.localize("Cancel"),
- showClearButton: false,
- clearButtonText: Globalize.localize("Clear"),
- showDoneButton: false,
- doneButtonText: Globalize.localize("Done"),
- contentReadyAction: null,
- shownAction: null,
- openAction: null,
- hiddenAction: null,
- closeAction: null,
- popupWidth: function() {
- return $(window).width() * 0.8
- },
- popupHeight: function() {
- return $(window).height() * 0.8
- },
- shading: true,
- closeOnOutsideClick: false,
- position: undefined,
- animation: undefined,
- pullRefreshEnabled: false,
- autoPagingEnabled: true,
- useNativeScrolling: true,
- pullingDownText: Globalize.localize("dxList-pullingDownText"),
- pulledDownText: Globalize.localize("dxList-pulledDownText"),
- refreshingText: Globalize.localize("dxList-refreshingText"),
- pageLoadingText: Globalize.localize("dxList-pageLoadingText"),
- scrollAction: null,
- pullRefreshAction: null,
- pageLoadingAction: null,
- showNextButton: false,
- nextButtonText: Globalize.localize("dxList-nextButtonText"),
- grouped: false,
- groupTemplate: "group",
- groupRender: null,
- usePopover: false
- })
- },
- _defaultOptionsRules: function() {
- return this.callBase().slice(0).concat([{
- device: function(device) {
- return !DX.support.nativeScrolling
- },
- options: {useNativeScrolling: false}
- }, {
- device: function(device) {
- return !DX.support.nativeScrolling && !DX.devices.isSimulator() && DX.devices.real().platform === "generic" && device.platform === "generic"
- },
- options: {
- showNextButton: true,
- autoPagingEnabled: false
- }
- }, {
- device: {
- platform: "win8",
- phone: true
- },
- options: {
- showCancelButton: false,
- fullScreen: true
- }
- }, {
- device: {
- platform: "win8",
- phone: false
- },
- options: {popupWidth: function() {
- return $(window).width()
- }}
- }, {
- device: [{
- platform: "ios",
- phone: true
- }, {
- platform: "ios7",
- phone: true
- }],
- options: {fullScreen: true}
- }, {
- device: [{
- platform: "ios",
- tablet: true
- }, {
- platform: "ios7",
- tablet: true
- }],
- options: {
- popupWidth: function() {
- return Math.min($(window).width(), $(window).height()) * 0.4
- },
- popupHeight: function() {
- return Math.min($(window).width(), $(window).height()) * 0.4
- },
- usePopover: true
- }
- }])
- },
- _optionsByReference: function() {
- return $.extend(this.callBase(), {value: true})
- },
- _init: function() {
- this.callBase();
- this._initDataSource();
- this._searchTimer = null;
- this._compileValueGetter();
- this._compileDisplayGetter();
- this._suppressValueChangeAction();
- if (!this._dataSource)
- this._itemsToDataSource()
- },
- _compileValueGetter: function() {
- this._valueGetter = dataUtils.compileGetter(this._valueGetterExpr())
- },
- _valueGetterExpr: function() {
- return this.option("valueExpr") || "this"
- },
- _compileDisplayGetter: function() {
- this._displayGetter = dataUtils.compileGetter(this.option("displayExpr"))
- },
- _itemsToDataSource: function() {
- this._dataSource = new DevExpress.data.DataSource(this.option("items"))
- },
- _render: function() {
- this.callBase();
- this._element().addClass(LOOKUP_CLASS).toggleClass(LOOKUP_POPOVER_MODE, this.option("usePopover"));
- this._renderField();
- this._needRenderContent = true;
- this._calcSelectedItem($.proxy(this._setFieldText, this))
- },
- _renderContent: $.noop,
- _renderContentImpl: $.noop,
- _renderField: function() {
- var that = this,
- fieldClickAction = this._createAction(this._handleFieldClick);
- this._$fieldWrapper = $("<div>").addClass(LOOKUP_FIELD_WRAPPER_CLASS);
- this._$field = $("<div>").addClass(LOOKUP_FIELD_CLASS).appendTo(this._$fieldWrapper).on(events.addNamespace("dxclick", this.NAME), function(e) {
- if (that.option("readOnly"))
- return;
- fieldClickAction({jQueryEvent: e})
- });
- this._$fieldWrapper.appendTo(this._element())
- },
- _handleFieldClick: function(args) {
- var that = args.component;
- that._renderContentIfNeed();
- that._setListDataSource();
- that._refreshSelected();
- that._popup.show();
- that._lastSelectedItem = that._selectedItem
- },
- _renderContentIfNeed: function() {
- if (this._needRenderContent) {
- this._renderPopup();
- this._needRenderContent = false
- }
- },
- _renderPopup: function() {
- var $popup = $("<div>").addClass(LOOKUP_POPUP_CLASS).appendTo(this._element());
- var popupOptions = {
- rtlEnabled: this.option("rtlEnabled"),
- showTitle: true,
- title: this.option("title"),
- titleTemplate: this._getTemplateByOption("titleTemplate"),
- contentReadyAction: $.proxy(this._popupContentReadyAction, this),
- cancelButton: this._getCancelButtonConfig(),
- doneButton: this._getDoneButtonConfig(),
- clearButton: this._getClearButtonConfig(),
- shownAction: this._createActionByOption("shownAction"),
- hiddenAction: this._createActionByOption("hiddenAction")
- };
- this._popup = this.option("usePopover") && !this.option("fullScreen") ? this._createPopover($popup, popupOptions) : this._createPopup($popup, popupOptions);
- this._setPopupOption("position", "position");
- this._setPopupOption("animation", "animation");
- this._setPopupOption("popupWidth", "width");
- this._setPopupOption("popupHeight", "height");
- this._popup._wrapper().addClass(LOOKUP_POPUP_WRAPPER_CLASS).toggleClass(LOOKUP_POPUP_SEARCH_CLASS, this.option("searchEnabled"))
- },
- _setPopupOption: function(option, popupOption) {
- var option = this.option(option);
- option = option === undefined ? this._popup.initialOption(popupOption) : option;
- this._popup.option(popupOption, option)
- },
- _createPopover: function($element, options) {
- return $element.dxPopover($.extend(options, {target: this._element()})).dxPopover("instance")
- },
- _createPopup: function($element, options) {
- return $element.dxPopup($.extend(options, {
- fullScreen: this.option("fullScreen"),
- shading: this.option("shading"),
- closeOnOutsideClick: this.option("closeOnOutsideClick")
- })).dxPopup("instance")
- },
- _getCancelButtonConfig: function() {
- return this.option("showCancelButton") ? {text: this.option("cancelButtonText")} : null
- },
- _getDoneButtonConfig: function() {
- return this.option("showDoneButton") ? {
- text: this.option("doneButtonText"),
- clickAction: $.proxy(function() {
- this.option("value", this._valueGetter(this._lastSelectedItem))
- }, this)
- } : null
- },
- _getClearButtonConfig: function() {
- return this.option("showClearButton") ? {
- text: this.option("clearButtonText"),
- clickAction: $.proxy(function() {
- this.option("value", undefined)
- }, this)
- } : null
- },
- _renderCancelButton: function() {
- this._popup && this._popup.option("cancelButton", this._getCancelButtonConfig())
- },
- _renderDoneButton: function() {
- this._popup && this._popup.option("doneButton", this._getDoneButtonConfig())
- },
- _renderClearButton: function() {
- this._popup && this._popup.option("clearButton", this._getClearButtonConfig())
- },
- _popupContentReadyAction: function() {
- this._renderSearch();
- this._renderList()
- },
- _renderSearch: function() {
- this._$search = $("<div>").addClass(LOOKUP_SEARCH_CLASS).dxTextBox({
- mode: "search",
- placeholder: this._getSearchPlaceholder(),
- valueChangeEvent: "change input",
- valueChangeAction: $.proxy(this._searchChangedHandler, this),
- rtlEnabled: this.option("rtlEnabled")
- }).appendTo(this._popup.content()).wrap($("<div>").addClass(LOOKUP_SEARCH_WRAPPER_CLASS).toggle(this.option("searchEnabled")));
- this._search = this._$search.dxTextBox("instance")
- },
- _getSearchPlaceholder: function() {
- var minFilterLength = this.option("minFilterLength"),
- placeholder = this.option("searchPlaceholder");
- if (minFilterLength && placeholder === Globalize.localize("Search"))
- return utils.stringFormat(Globalize.localize("dxLookup-searchPlaceholder"), minFilterLength);
- return placeholder
- },
- _renderList: function() {
- this._list = $("<div>").appendTo(this._popup.content()).dxList({
- _templates: this.option("_templates"),
- dataSource: null,
- itemClickAction: $.proxy(function(e) {
- this._toggleSelectedClass(e.jQueryEvent);
- this._updateOptions(e)
- }, this),
- itemRenderedAction: $.proxy(function(e) {
- this._setSelectedClass(e.itemElement, e.itemData)
- }, this),
- itemRender: this._getItemRender(),
- itemTemplate: this._getTemplateByOption("itemTemplate"),
- noDataText: this.option("noDataText"),
- pullRefreshEnabled: this.option("pullRefreshEnabled"),
- autoPagingEnabled: this.option("autoPagingEnabled"),
- useNativeScrolling: this.option("useNativeScrolling"),
- pullingDownText: this.option("pullingDownText"),
- pulledDownText: this.option("pulledDownText"),
- refreshingText: this.option("refreshingText"),
- pageLoadingText: this.option("pageLoadingText"),
- scrollAction: this.option("scrollAction"),
- pullRefreshAction: this.option("pullRefreshAction"),
- pageLoadingAction: this.option("pageLoadingAction"),
- showNextButton: this.option("showNextButton"),
- nextButtonText: this.option("nextButtonText"),
- grouped: this.option("grouped"),
- groupTemplate: this._getTemplateByOption("groupTemplate"),
- groupRender: this.option("groupRender"),
- rtlEnabled: this.option("rtlEnabled")
- }).data("dxList");
- if (this._needSetItemRenderToList) {
- this._updateListItemRender();
- this._needSetItemRenderToList = false
- }
- this._setListDataSource();
- this._list.option("contentReadyAction", this.option("contentReadyAction"));
- this._list._fireContentReadyAction()
- },
- _setListDataSource: function(force) {
- if (!this._list)
- return;
- var needsToLoad = this._search.option("value").length >= this.option("minFilterLength"),
- dataSourceLoaded = !!this._list.option("dataSource"),
- skip = needsToLoad === dataSourceLoaded;
- if (!force && skip)
- return;
- this._list.option("dataSource", needsToLoad ? this._dataSource : null);
- if (!needsToLoad)
- this._list.option("items", undefined)
- },
- _refreshSelected: function() {
- var that = this;
- if (!that._list)
- return;
- $.each(this._list._element().find(LIST_ITEM_SELECTOR), function() {
- var item = $(this);
- that._setSelectedClass(item, item.data(LIST_ITEM_DATA_KEY))
- })
- },
- _calcSelectedItem: function(callback) {
- var ds = this._dataSource,
- store,
- valueExpr,
- thisWidget = this,
- value = this._unwrapedValue();
- function handleLoadSuccess(result) {
- thisWidget._selectedItem = result;
- callback()
- }
- if (!ds || value === undefined) {
- this._selectedItem = undefined;
- callback();
- return
- }
- store = ds.store();
- valueExpr = this._valueGetterExpr();
- this._loadSingle(valueExpr, value).done(function(result) {
- handleLoadSuccess(result)
- })
- },
- _unwrapedValue: function() {
- var value = this.option("value");
- var valueExpr = this._valueGetterExpr();
- if (!this._dataSource && valueExpr !== "this")
- return value;
- var key = this._dataSource.store().key();
- if (key && typeof value === "object")
- value = value[key];
- return $.isFunction(value) ? value() : value
- },
- _setFieldText: function(text) {
- if (!arguments.length)
- text = this._getDisplayText();
- this._$field.text(text);
- this.option("displayValue", text);
- this._toggleEmptyClass()
- },
- _getDisplayText: function() {
- if (this.option("value") === undefined || !this._dataSource)
- return this.option("placeholder");
- return this._displayGetter(this._selectedItem) || this.option("placeholder")
- },
- _searchChangedHandler: function() {
- if (!this._search)
- return;
- var searchValue = this._search.option("value"),
- needsToLoad = searchValue.length >= this.option("minFilterLength");
- clearTimeout(this._searchTimer);
- this._search.option("placeholder", this._getSearchPlaceholder());
- if (!needsToLoad) {
- this._setListDataSource();
- return
- }
- if (this.option("searchTimeout"))
- this._searchTimer = setTimeout($.proxy(this._doSearch, this, searchValue), this.option("searchTimeout"));
- else
- this._doSearch(searchValue)
- },
- _doSearch: function(searchValue) {
- if (!this._dataSource)
- return;
- if (!arguments.length)
- searchValue = this.option("searchEnabled") ? this._search.option("value") : "";
- this._filterStore(searchValue).done($.proxy(function() {
- if (this._dataSource.items().length)
- this._setListDataSource()
- }, this))
- },
- _filterStore: function(searchValue) {
- if (!this._dataSource.searchExpr())
- this._dataSource.searchExpr(this.option("displayExpr"));
- this._dataSource.searchValue(searchValue);
- this._dataSource.pageIndex(0);
- return this._dataSource.load()
- },
- _updateOptions: function(e) {
- if (this._lastSelectedItem === e.itemData)
- this._updateAndHidePopup();
- this._lastSelectedItem = e.itemData;
- if (!this.option("showDoneButton"))
- this._updateAndHidePopup()
- },
- _setSelectedClass: function(item, itemData) {
- itemData = this._valueGetter(itemData);
- var value = this.option("value");
- var dataSourceKey = this._dataSource && this._dataSource.key();
- var selected = this._optionValuesEqual("value", itemData, value);
- if (dataSourceKey && !selected && value) {
- var valueKey = utils.unwrapObservable(value[dataSourceKey]);
- var itemDataKey = utils.unwrapObservable(itemData[dataSourceKey]) || itemData;
- selected = valueKey === itemDataKey
- }
- item.toggleClass(LOOKUP_SELECTED_CLASS, selected)
- },
- _getItemRender: function() {
- var templateName = this.option("itemTemplate");
- if (!templateName || !(templateName in this.option("_templates")))
- return this.option("itemRender") || $.proxy(this._displayGetter, this)
- },
- _toggleSelectedClass: function(e) {
- var $selectedItem = this._list._element().find("." + LOOKUP_SELECTED_CLASS);
- if ($selectedItem.length)
- $selectedItem.removeClass(LOOKUP_SELECTED_CLASS);
- $(e.target).closest(LIST_ITEM_SELECTOR).addClass(LOOKUP_SELECTED_CLASS)
- },
- _toggleEmptyClass: function() {
- var empty = !this._selectedItem;
- this._element().toggleClass(LOOKUP_EMPTY_CLASS, empty)
- },
- _hidePopup: function() {
- this._popup.hide()
- },
- _updateAndHidePopup: function() {
- this.option("value", this._valueGetter(this._lastSelectedItem));
- clearTimeout(this._hidePopupTimer);
- this._hidePopupTimer = setTimeout($.proxy(this._hidePopup, this), POPUP_HIDE_TIMEOUT);
- this._setFieldText(this._displayGetter(this._lastSelectedItem))
- },
- _updateListItemRender: function() {
- if (this._list)
- this._list.option("itemRender", this._getItemRender());
- else
- this._needSetItemRenderToList = true
- },
- _updateListItemTemplate: function() {
- if (this._list)
- this._list.option("itemTemplate", this.option("itemTemplate"))
- },
- _clean: function() {
- if (this._popup)
- this._popup._element().remove();
- if (this._$field)
- this._$field.remove();
- if (this._$fieldWrapper)
- this._$fieldWrapper.remove()
- },
- _dispose: function() {
- clearTimeout(this._searchTimer);
- clearTimeout(this._hidePopupTimer);
- $(window).off(events.addNamespace("popstate", this.NAME));
- this.callBase()
- },
- _changeListOption: function(name, value) {
- if (this._list)
- this._list.option(name, value)
- },
- _changePopupOption: function(name, value) {
- if (this._popup)
- this._popup.option(name, value)
- },
- _optionChanged: function(name, value, previousValue) {
- switch (name) {
- case"valueExpr":
- case"value":
- this._calcSelectedItem($.proxy(function() {
- if (name === "value")
- this._raiseValueChangeAction(value, previousValue, {selectedItem: this._selectedItem});
- this._compileValueGetter();
- this._compileDisplayGetter();
- this._refreshSelected();
- this._setFieldText()
- }, this));
- break;
- case"displayExpr":
- this._compileDisplayGetter();
- this._updateListItemRender();
- this._refreshSelected();
- this._setFieldText();
- break;
- case"displayValue":
- break;
- case"itemRender":
- this._updateListItemRender();
- case"itemTemplate":
- this._updateListItemTemplate();
- break;
- case"items":
- case"dataSource":
- if (name === "items")
- this._itemsToDataSource();
- else
- this._initDataSource();
- this._setListDataSource(true);
- this._compileValueGetter();
- this._calcSelectedItem($.proxy(this._setFieldText, this));
- break;
- case"searchEnabled":
- if (this._$search)
- this._$search.toggle(value);
- if (this._popup)
- this._popup._wrapper().toggleClass(LOOKUP_POPUP_SEARCH_CLASS, value);
- break;
- case"minFilterLength":
- this._setListDataSource();
- this._setFieldText();
- this._searchChangedHandler();
- break;
- case"placeholder":
- this._setFieldText();
- break;
- case"searchPlaceholder":
- if (this._$search)
- this._$search.dxTextBox("instance").option("placeholder", value);
- break;
- case"shownAction":
- case"hiddenAction":
- case"openAction":
- case"closeAction":
- case"animation":
- this._renderPopup();
- break;
- case"title":
- case"titleTemplate":
- this._changePopupOption(name, value);
- break;
- case"position":
- case"shading":
- case"closeOnOutsideClick":
- if (!this.option("usePopover"))
- this._changePopupOption(name, value);
- break;
- case"fullScreen":
- if (this._popup)
- if (!this.option("usePopover"))
- this._popup.option(name, value);
- else
- this._renderPopup();
- break;
- case"clearButtonText":
- case"showClearButton":
- this._renderClearButton();
- break;
- case"cancelButtonText":
- case"showCancelButton":
- this._renderCancelButton();
- break;
- case"doneButtonText":
- case"showDoneButton":
- this._renderDoneButton();
- break;
- case"popupWidth":
- this._changePopupOption("width", value === "auto" ? this.initialOption("popupWidth") : value);
- break;
- case"popupHeight":
- this._changePopupOption("height", value === "auto" ? this.initialOption("popupHeight") : value);
- break;
- case"usePopover":
- this._invalidate();
- break;
- case"pullRefreshEnabled":
- case"autoPagingEnabled":
- case"useNativeScrolling":
- case"pullingDownText":
- case"pulledDownText":
- case"refreshingText":
- case"pageLoadingText":
- case"scrollAction":
- case"pullRefreshAction":
- case"pageLoadingAction":
- case"showNextButton":
- case"nextButtonText":
- case"grouped":
- case"groupRender":
- case"noDataText":
- case"contentReadyAction":
- this._changeListOption(name, value);
- break;
- case"groupTemplate":
- this._changeListOption(name, this._getTemplateByOption(name));
- case"searchTimeout":
- break;
- default:
- this.callBase.apply(this, arguments)
- }
- },
- open: function() {
- this._renderContentIfNeed();
- this._popup.show()
- },
- close: function() {
- this._renderContentIfNeed();
- this._popup.hide()
- }
- }).include(ui.DataHelperMixin))
- })(jQuery, DevExpress);
- /*! Module widgets-base, file ui.autocomplete.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- events = ui.events,
- utils = DX.utils;
- var KEY_DOWN = 40,
- KEY_UP = 38,
- KEY_ENTER = 13,
- KEY_ESC = 27,
- KEY_RIGHT = 39,
- KEY_TAB = 9,
- AUTOCOMPLETE_CLASS = "dx-autocomplete",
- AUTOCOMPLETE_POPUP_WRAPPER_CLASS = "dx-autocomplete-popup-wrapper",
- SELECTED_ITEM_CLASS = "dx-autocomplete-selected",
- SELECTED_ITEM_SELECTOR = "." + SELECTED_ITEM_CLASS,
- LIST_SELECTOR = ".dx-list",
- LIST_ITEM_SELECTOR = ".dx-list-item",
- LIST_ITEM_DATA_KEY = "dxListItemData",
- SEARCH_MODES = ["startswith", "contains", "endwith", "notcontains"],
- AUTOCOMPLETE_KEYDOWN_EVENT_NAME = events.addNamespace("keydown", "dxAutocomplete"),
- AUTOCOMPLETE_KEYUP_EVENT_NAME = events.addNamespace("keyup", "dxAutocomplete"),
- AUTOCOMPLETE_FOCUSIN_EVENT_NAME = events.addNamespace("focusin", "dxAutocomplete"),
- AUTOCOMPLETE_FOCUSOUT_EVENT_NAME = events.addNamespace("focusout", "dxAutocomplete");
- DX.registerComponent("dxAutocomplete", ui.dxDropDownEditor.inherit({
- _setDefaultOptions: function() {
- this.callBase();
- this.option({
- value: "",
- items: [],
- dataSource: null,
- itemTemplate: "item",
- itemRender: null,
- minSearchLength: 1,
- searchTimeout: 0,
- searchMode: "contains",
- displayExpr: "this",
- valueChangeEvent: "change keyup",
- shouldActivateFocusOut: true,
- maxLength: null
- })
- },
- _listElement: function() {
- return this._dropDown.content().find(LIST_SELECTOR)
- },
- _listItemElement: function() {
- return this._dropDown.content().find(LIST_ITEM_SELECTOR)
- },
- _listSelectedItemElement: function() {
- return this._dropDown.content().find(this._getSelectedItemSelector())
- },
- _init: function() {
- this.callBase();
- this._validateSearchMode();
- this._compileDisplayGetter();
- this._initDataSource();
- this._fillDataSourceFromItemsIfNeeded()
- },
- _fillDataSourceFromItemsIfNeeded: function() {
- if (!this.option("dataSource") && this.option("items"))
- this._itemsToDataSource()
- },
- _validateSearchMode: function() {
- var searchMode = this.option("searchMode"),
- normalizedSearchMode = searchMode.toLowerCase();
- if ($.inArray(normalizedSearchMode, SEARCH_MODES) > -1)
- return;
- throw Error(DX.utils.stringFormat("Search mode \"{0}\" is unavailable", searchMode));
- },
- _compileDisplayGetter: function() {
- this._displayGetter = DX.data.utils.compileGetter(this.option("displayExpr"))
- },
- _render: function() {
- this.callBase();
- this._element().addClass(AUTOCOMPLETE_CLASS);
- this._renderInputEvents()
- },
- _renderDimensions: function() {
- this.callBase();
- if (this._dropDown)
- this._dropDown.option("width", this.option("width"))
- },
- _renderContentImpl: function() {
- this._caretPosition = {
- start: 0,
- end: 0
- };
- this._renderDropDownContainer()
- },
- _renderButton: function(hideButton) {
- this.callBase(hideButton === false ? false : true)
- },
- _renderInputEvents: function() {
- this._input().on(AUTOCOMPLETE_KEYDOWN_EVENT_NAME, $.proxy(this._handleInputKeyDown, this)).on(AUTOCOMPLETE_KEYUP_EVENT_NAME, $.proxy(this._handleInputKeyUp, this)).on(AUTOCOMPLETE_FOCUSIN_EVENT_NAME, $.proxy(function() {
- this._setFocusSelection()
- }, this)).on(AUTOCOMPLETE_FOCUSOUT_EVENT_NAME, $.proxy(function() {
- if (this.option("shouldActivateFocusOut"))
- this._hideDropDown();
- this._toggleElementSelectedClass(false)
- }, this))
- },
- _setFocusSelection: function() {
- this._toggleElementSelectedClass(true)
- },
- _hasUpdateEvent: function(eventName) {
- return eventName && this.option("valueUpdateEvent").indexOf(eventName) !== -1
- },
- _handleInputKeyDown: function(e) {
- var $list = this._listElement(),
- preventedKeys = [KEY_TAB, KEY_UP, KEY_DOWN],
- key = e.which;
- if ($list.is(":hidden"))
- return;
- if ($.inArray(key, preventedKeys) > -1)
- e.preventDefault();
- else if (key !== KEY_ENTER)
- this._toggleElementSelectedClass(true)
- },
- _handleInputKeyUp: function(e) {
- var key = e.which;
- this._caretPosition = {
- start: this._input().prop("selectionStart"),
- end: this._input().prop("selectionEnd")
- };
- switch (key) {
- case KEY_DOWN:
- this._handleInputDownKey();
- break;
- case KEY_UP:
- this._handleInputUpKey();
- break;
- case KEY_ENTER:
- this._handleInputEnterKey();
- break;
- case KEY_RIGHT:
- case KEY_TAB:
- this._handleInputCompleteKeys();
- break;
- case KEY_ESC:
- this._hideDropDown();
- break;
- default:
- return
- }
- },
- _handleInputDownKey: function() {
- var $selectedItem = this._listSelectedItemElement(),
- $nextItem;
- if ($selectedItem.length) {
- $nextItem = $selectedItem.next();
- if ($nextItem.length)
- $nextItem.addClass(this._getSelectedItemClass());
- else
- this._toggleElementSelectedClass(true);
- $selectedItem.removeClass(this._getSelectedItemClass());
- this._list.scrollToItem($nextItem)
- }
- else {
- this._listItemElement().first().addClass(this._getSelectedItemClass());
- this._list.scrollToItem(this._listItemElement().first());
- this._toggleElementSelectedClass(false)
- }
- },
- _handleInputUpKey: function() {
- var $selectedItem = this._listSelectedItemElement(),
- $prevItem,
- $list = this._listElement();
- if ($list.is(":hidden"))
- return;
- if (!$selectedItem.length) {
- this._listItemElement().last().addClass(this._getSelectedItemClass());
- this._list.scrollToItem(this._listItemElement().last());
- this._toggleElementSelectedClass(false);
- return
- }
- $selectedItem.removeClass(this._getSelectedItemClass());
- $prevItem = $selectedItem.prev();
- if ($prevItem.length) {
- $prevItem.addClass(this._getSelectedItemClass());
- this._list.scrollToItem($prevItem)
- }
- else
- this._toggleElementSelectedClass(true)
- },
- _handleInputEnterKey: function() {
- var $selectedItem = this._listSelectedItemElement(),
- receivedValue;
- if (!$selectedItem.length) {
- this._hideDropDown();
- return
- }
- receivedValue = this._selectedItemDataGetter();
- this._caretPosition = {
- start: receivedValue.length,
- end: receivedValue.length
- };
- this.option("value", receivedValue);
- this._hideDropDown();
- this._input().blur()
- },
- _handleInputCompleteKeys: function() {
- var $list = this._listElement(),
- newValue,
- receivedValue;
- if ($list.is(":hidden"))
- return;
- receivedValue = this._selectedItemDataGetter();
- newValue = receivedValue.length ? receivedValue : this._dataSource.items()[0];
- this._caretPosition = {
- start: newValue.length,
- end: newValue.length
- };
- newValue = this._displayGetter(newValue);
- this.option("value", newValue);
- this._hideDropDown()
- },
- _toggleElementSelectedClass: function(isToggle) {
- this._element().toggleClass(this._getSelectedItemClass(), isToggle)
- },
- _selectedItemDataGetter: function() {
- var $selectedItem = this._listSelectedItemElement();
- return $selectedItem.length ? this._displayGetter($selectedItem.data(LIST_ITEM_DATA_KEY)) : []
- },
- _createDropDown: function() {
- var popupWidth = this.option("width"),
- vOffset = 0,
- hOffset = 0;
- if (DX.devices.current().win8)
- vOffset = -6;
- else if (DX.devices.current().platform === "generic" || DX.devices.current().tizen)
- vOffset = -1;
- this._dropDown = $("<div>").appendTo(this._element()).dxPopup({
- rtlEnabled: this.option("rtlEnabled"),
- shading: false,
- closeOnOutsideClick: false,
- closeOnTargetScroll: true,
- showTitle: false,
- width: popupWidth,
- showingAction: $.proxy(this._dimensionChanged, this),
- deferRendering: false,
- shownAction: this.option("openAction"),
- hiddenAction: this.option("closeAction"),
- position: {
- my: "left top",
- at: "left bottom",
- of: this._$element,
- offset: {
- h: hOffset,
- v: vOffset
- },
- collision: "flip"
- },
- animation: {
- show: {
- type: "pop",
- duration: 400,
- from: {
- opacity: 0,
- scale: 1
- },
- to: {
- opacity: 1,
- scale: 1
- }
- },
- hide: {
- type: "fade",
- duration: 400,
- from: 1,
- to: 0
- }
- }
- }).dxPopup("instance");
- this._dropDown._wrapper().addClass(AUTOCOMPLETE_POPUP_WRAPPER_CLASS);
- this._renderList()
- },
- _dimensionChanged: function() {
- this._calculatePopupDimensions()
- },
- _calculatePopupDimensions: function() {
- this._calculatePopupHeight();
- this._calculatePopupWidth()
- },
- _calculatePopupHeight: function() {
- var popup = this._dropDown;
- popup.option("height", "auto");
- var list = this._list;
- this._heightApplyingTimer = setTimeout(function() {
- var popupHeight = popup.container().outerHeight();
- var maxHeight = $(window).height() * 0.5;
- popup.option("height", Math.min(popupHeight, maxHeight));
- list.updateDimensions()
- })
- },
- _calculatePopupWidth: function() {
- var textWidth = this._element().outerWidth();
- this._dropDown.option("width", textWidth)
- },
- _getSelectedItemClass: function() {
- return SELECTED_ITEM_CLASS
- },
- _getSelectedItemSelector: function() {
- return SELECTED_ITEM_SELECTOR
- },
- _renderList: function() {
- this._list = $("<div>").appendTo(this._dropDown.content()).dxList({
- _templates: this.option("_templates"),
- itemClickAction: $.proxy(this._handleListItemClick, this),
- itemTemplate: this._getTemplateByOption("itemTemplate"),
- itemRender: this._getItemRender(),
- noDataText: "",
- showNextButton: false,
- autoPagingEnabled: false,
- dataSource: this._dataSource,
- indicateLoading: false
- }).dxList("instance")
- },
- _getItemRender: function() {
- var templateName = this.option("itemTemplate");
- if (!templateName || !(templateName in this.option("_templates")))
- return this.option("itemRender") || $.proxy(this._displayGetter, this)
- },
- _handleListItemClick: function(e) {
- var value = this._displayGetter(e.itemData);
- this._caretPosition = {
- start: value.length,
- end: value.length
- };
- this.option("value", value);
- this._hideDropDown();
- this._input().blur()
- },
- _itemsToDataSource: function() {
- this._dataSource = new DevExpress.data.DataSource(this.option("items"));
- return this._dataSource
- },
- _filterDataSource: function() {
- this._reloadDataSource(this.option("value"));
- this._clearSearchTimer()
- },
- _reloadDataSource: function(searchValue, searchMethod) {
- var that = this,
- ds = that._dataSource;
- ds.searchExpr(that.option("displayExpr"));
- ds.searchOperation(searchMethod || that.option("searchMode"));
- ds.searchValue(searchValue);
- that._dataSource.pageIndex(0);
- that._dataSource.load().done(function() {
- that._refreshVisibility()
- })
- },
- _refreshVisibility: function() {
- var canFilter = this.option("value").length >= this.option("minSearchLength"),
- dataSource = this._dataSource,
- items = dataSource && dataSource.items(),
- hasResults = items.length;
- if (canFilter && hasResults)
- if (items.length === 1 && this._displayGetter(items[0]) === this.option("value"))
- this._hideDropDown();
- else if (this._displayGetter(items[0]).length < this.option("value").length)
- this._hideDropDown();
- else {
- this._dropDown._refresh();
- this._dropDown.show();
- this._calculatePopupHeight()
- }
- else
- this._hideDropDown()
- },
- _closeOutsideDropDownHandler: function(e, ignoreContainerClicks) {
- this.callBase(e, true)
- },
- _clean: function() {
- this.callBase();
- delete this._dropDown
- },
- _dispose: function() {
- clearTimeout(this._heightApplyingTimer);
- this._clearSearchTimer();
- this.callBase()
- },
- _optionChanged: function(name, value) {
- switch (name) {
- case"items":
- case"dataSource":
- if (name === "items")
- this._itemsToDataSource();
- else
- this._initDataSource();
- case"itemTemplate":
- case"itemRender":
- this._list.option(name, value);
- break;
- case"searchMode":
- this._validateSearchMode();
- break;
- case"displayExpr":
- this._compileDisplayGetter();
- this._list.option("itemRender", this._getItemRender());
- break;
- case"minSearchLength":
- case"searchTimeout":
- break;
- case"shouldActivateFocusOut":
- this._invalidate();
- break;
- default:
- this.callBase.apply(this, arguments)
- }
- },
- _handleValueChangeEvent: function() {
- var prevValue = this.option("value");
- this.callBase.apply(this, arguments);
- if (prevValue !== this.option("value"))
- this._applyFilter()
- },
- _applyFilter: function() {
- var canFilter = this.option("value").length >= this.option("minSearchLength");
- if (!canFilter) {
- this._clearSearchTimer();
- this._hideDropDown();
- return
- }
- if (this.option("searchTimeout") > 0) {
- if (!this._searchTimer)
- this._searchTimer = setTimeout($.proxy(this._filterDataSource, this), this.option("searchTimeout"))
- }
- else
- this._filterDataSource()
- },
- _clearSearchTimer: function() {
- clearTimeout(this._searchTimer);
- delete this._searchTimer
- }
- }).include(ui.DataHelperMixin))
- })(jQuery, DevExpress);
- /*! Module widgets-base, file ui.selectBox.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- events = ui.events,
- WIDGET_CLASS = "dx-selectbox",
- POPUP_CLASS = "dx-selectbox-popup",
- SELECTBOX_SELECTED_CLASS = "dx-selectbox-selected",
- SELECTBOX_MULTISELECT_CLASS = "dx-selectbox-multiselect",
- SELECTBOX_CONTAINER_CLASS = "dx-selectbox-container",
- SELECTBOX_ARROW_CLASS = "dx-selectbox-arrow",
- SELECTBOX_ARROW_CONTAINER_CLASS = "dx-selectbox-arrow-container",
- SELECTBOX_TAG_CONTAINER_CLASS = "dx-selectbox-tag-container",
- SELECTBOX_TAG_ITEM_CLASS = "dx-selectbox-tag-item",
- SELECTBOX_TAG_ITEM_CONTAINER_CLASS = "dx-selectbox-tag-item-container",
- SELECTBOX_TAG_ITEM_CLOSE_BUTTON_CLASS = "dx-selectbox-tag-item-close-button",
- EMPTY_INPUT_CLASS = "dx-texteditor-empty",
- LIST_ITEM_DATA_KEY = "dxListItemData",
- LIST_ITEM_SELECTOR = ".dx-list-item",
- TEXTEDITOR_BORDER_SELECTOR = ".dx-texteditor-border";
- DX.registerComponent("dxSelectBox", ui.dxAutocomplete.inherit({
- _setDefaultOptions: function() {
- this.callBase();
- this.option({
- items: [],
- value: undefined,
- valueChangeAction: null,
- placeholder: Globalize.localize("Select"),
- valueExpr: null,
- multiSelectEnabled: false,
- values: [],
- valueChangeEvent: "",
- fieldTemplate: null,
- displayValue: undefined,
- tooltipEnabled: false,
- shouldActivateFocusOut: false
- })
- },
- _optionsByReference: function() {
- return $.extend(this.callBase(), {value: true})
- },
- _init: function() {
- this.callBase();
- if (!this._dataSource)
- this._itemsToDataSource();
- this._selectedItems = []
- },
- _itemsToDataSource: function() {
- this._dataSource = new DevExpress.data.DataSource(this.option("items"))
- },
- _getValueWidth: function(value) {
- var $div = $("<div>").html(value).css({
- width: "auto",
- position: "fixed",
- top: "-3000px",
- left: "-3000px"
- }).appendTo("body");
- return $div.width()
- },
- _setTooltip: function(value) {
- if (!this.option("tooltipEnabled"))
- return;
- if (this._$element.context.scrollWidth <= this._getValueWidth(value))
- this._$element.context.title = value;
- else
- this._$element.context.title = ""
- },
- _render: function() {
- this._compileValueGetter();
- this.callBase();
- var value = this.option("value");
- if (value)
- this._searchValue(value).done($.proxy(this._updateTextBox, this));
- else
- this._updateTextBox();
- var multiSelectEnabled = this.option("multiSelectEnabled");
- this._element().toggleClass(SELECTBOX_MULTISELECT_CLASS, multiSelectEnabled);
- this._$placeholder = this._$container.find(".dx-placeholder").eq(0);
- if (multiSelectEnabled)
- this._renderTags();
- this._setWidgetClasses();
- this._setTooltip(this.option("value"));
- this._shouldHide = false
- },
- _renderTags: function() {
- var that = this;
- if (that._$tagContainer)
- that._$tagContainer.remove();
- that._$tagContainer = $("<div>").addClass(SELECTBOX_TAG_CONTAINER_CLASS);
- var values = that.option("values") || [];
- var clickEventName = events.addNamespace("dxclick", that.NAME);
- var itemLoadDeferreds = [];
- that._selectedItems = [];
- $.each(values, function(index, value) {
- var displayValue;
- var $container = $("<div>").addClass(SELECTBOX_TAG_ITEM_CONTAINER_CLASS),
- $tag = $("<div>").addClass(SELECTBOX_TAG_ITEM_CLASS).appendTo($container),
- $close = $("<div>").addClass(SELECTBOX_TAG_ITEM_CLOSE_BUTTON_CLASS).appendTo($container);
- itemLoadDeferreds.push(that._searchValue(value).done(function(result) {
- displayValue = that._displayGetter(result);
- $tag.append(displayValue);
- that._selectedItems.push(result)
- }));
- $close.off(clickEventName).on(clickEventName, $.proxy(that._deleteTag, that));
- $container.appendTo(that._$tagContainer)
- });
- that._$tagContainer.appendTo(that._$container);
- that._element().toggleClass(EMPTY_INPUT_CLASS, !values.length);
- that._input().val(values.length ? " " : null);
- $.when.apply($, itemLoadDeferreds).done(function() {
- that._renderInputTemplate()
- });
- values.length > 0 ? that._$placeholder.hide() : that._$placeholder.show()
- },
- _deleteTag: function(event) {
- event.stopPropagation();
- var $item = $(event.currentTarget.parentElement),
- index = $item.index(),
- values = this.option("values");
- this.option().value = this.option("values")[index];
- values.splice(index, 1);
- this.option("values", values)
- },
- _renderInput: function(inputContainer) {
- this._$container = inputContainer || $("<div>");
- this._$container.addClass(SELECTBOX_CONTAINER_CLASS);
- this._element().append(this._$container);
- this.callBase(this._$container)
- },
- _renderInputTemplate: function() {
- var fieldTemplate = this._getTemplateByOption("fieldTemplate");
- if (this.option("fieldTemplate") && fieldTemplate) {
- this._$container.empty();
- var templateData = this.option("multiSelectEnabled") ? this._selectedItems : this._selectedItem;
- fieldTemplate.render(this._$container, templateData);
- if (!this._input().length)
- DX.utils.logger.warn("A template should contain dxTextBox widget")
- }
- },
- _handleValueChangeEvent: function(e) {
- var args = [e];
- if (!this._input().val())
- args.push(undefined);
- this.callBase.apply(this, args)
- },
- _renderButton: function(hideButton) {
- this.callBase(false)
- },
- _renderValue: function(formattedValue) {
- if (this.option("value") !== undefined) {
- var callBase = $.proxy(this.callBase, this);
- this._searchValue(this.option("value")).done($.proxy(function(result) {
- if (result === undefined)
- result = this.option("value");
- this._selectedItem = result;
- this.option("displayValue", this._displayGetter(result));
- this._setTooltip(result);
- if (this.option("fieldTemaplte"))
- this._renderInputTemplate();
- else
- callBase(this._displayGetter(result))
- }, this))
- }
- else {
- this._selectedItem = null;
- this.option("displayValue", null);
- this._setTooltip(null);
- this.callBase(null)
- }
- },
- _readOnlyPropValue: function() {
- return true
- },
- _createDropDown: function() {
- var that = this;
- this.callBase();
- this._dropDown.beginUpdate();
- if (DX.devices.current().win8) {
- var popupPosition = this._dropDown.option("position");
- $.extend(popupPosition, {
- at: "left top",
- offset: {
- h: 0,
- v: 0
- }
- });
- this._dropDown.option("position", popupPosition)
- }
- this._dropDown.option("closeOnOutsideClick", $.proxy(this._closeOutsideDropDownHandler, this));
- this._dropDown.endUpdate()
- },
- _setWidgetClasses: function() {
- var $selectbox = this._element(),
- $popup = this._dropDown._element();
- $selectbox.addClass(WIDGET_CLASS);
- $popup.addClass(POPUP_CLASS)
- },
- _pointerDownHandler: function() {
- if (this._dropDown.option("visible"))
- this._shouldHide = true
- },
- _clickHandler: function() {
- if (!this._dropDown.option("visible") && !this._shouldHide) {
- if (!this.option("readOnly"))
- this._showDropDown()
- }
- else
- this._shouldHide = false
- },
- _applyFilter: $.noop,
- _updateTextBox: function(result) {
- var that = this,
- clickEventName = events.addNamespace("dxclick", this.NAME),
- pointerDownEventName = events.addNamespace("dxpointerdown", this.NAME);
- this._clickAction = this._createAction(function() {
- that._clickHandler()
- });
- this._selectedItem = result;
- this._renderInputTemplate();
- this._$container.off(clickEventName).off(pointerDownEventName).on(clickEventName, function() {
- that._clickAction()
- }).on(pointerDownEventName, $.proxy(this._pointerDownHandler, this))
- },
- _compileValueGetter: function() {
- this._valueGetter = DX.data.utils.compileGetter(this._valueGetterExpr())
- },
- _valueGetterExpr: function() {
- return this.option("valueExpr") || this._dataSource && this._dataSource._store._key || "this"
- },
- _setSelectedClass: function(item, itemData) {
- itemData = itemData;
- if (this.option("multiSelectEnabled"))
- $.each(this._getSelected(), function() {
- $(this).addClass(SELECTBOX_SELECTED_CLASS)
- });
- else {
- item = item || this._getSelected();
- if (item === null)
- return;
- var selected = itemData !== undefined ? this._optionValuesEqual("value", this._valueGetter(itemData), this.option("value")) : true;
- item.toggleClass(SELECTBOX_SELECTED_CLASS, selected)
- }
- },
- _getSelected: function() {
- var items = [],
- listElement = this._list._element(),
- values = this.option("multiSelectEnabled") ? this.option("values") : [this.option("value")],
- valueGetter = this._valueGetter;
- $.each(this._list.option("items"), function(index, val) {
- if ($.inArray(valueGetter(val), values) !== -1)
- items.push(listElement.find(LIST_ITEM_SELECTOR).eq(index))
- });
- if (!this.option("multiSelectEnabled"))
- return items[0] || null;
- return items
- },
- _removeSelectedClass: function() {
- this._list._element().find("." + SELECTBOX_SELECTED_CLASS).removeClass(SELECTBOX_SELECTED_CLASS)
- },
- _updateSelectedItems: function(item, itemData) {
- this._removeSelectedClass();
- this._setSelectedClass(item, itemData)
- },
- _handleListItemClick: function(e) {
- this._hideDropDown();
- this._shouldHide = false;
- if (this.option("multiSelectEnabled")) {
- this.option().value = this._valueGetter(e.itemData);
- this._addTagValue(this.option("value"))
- }
- else
- this.option("value", this._valueGetter(e.itemData))
- },
- _handleInputEnterKey: function() {
- this.callBase();
- if (this.option("multiSelectEnabled") && this.option("value"))
- this._addTagValue(this.option("value"))
- },
- _selectedItemDataGetter: function() {
- var $selectedItem = this._listSelectedItemElement();
- return $selectedItem.length ? this._valueGetter($selectedItem.data(LIST_ITEM_DATA_KEY)) : []
- },
- _addTagValue: function(value) {
- var values = this.option("values") || [],
- newValues = [];
- if ($.inArray(value, values) === -1) {
- newValues.push.apply(newValues, values);
- newValues.push(value);
- this.option("values", newValues)
- }
- },
- _searchValue: function(value) {
- var valueExpr = this._valueGetterExpr();
- return this._loadSingle(valueExpr, value)
- },
- _changeValueExpr: function() {
- this._compileValueGetter();
- this.option("value", this._valueGetter(this._selectedItem))
- },
- _getSelectedItemClass: function() {
- return SELECTBOX_SELECTED_CLASS
- },
- _getSelectedItemSelector: function() {
- return "." + SELECTBOX_SELECTED_CLASS
- },
- _renderList: function() {
- this.callBase();
- this._list.option({
- autoPagingEnabled: true,
- itemRenderedAction: $.proxy(function(e) {
- this._setSelectedClass(e.itemElement, e.itemData)
- }, this)
- })
- },
- _hideOnBlur: function() {
- return false
- },
- _handleClearValue: function() {
- if (this.option("multiSelectEnabled"))
- this.option("values", []);
- this.option("value", null)
- },
- _optionChanged: function(name, value, previousValue) {
- switch (name) {
- case"value":
- this.callBase.apply(this, arguments);
- this._updateSelectedItems();
- this._renderInputTemplate();
- break;
- case"displayValue":
- break;
- case"tooltipEnabled":
- this._setTooltip(this.option("value"));
- break;
- case"valueExpr":
- this._changeValueExpr();
- break;
- case"displayExpr":
- this._compileDisplayGetter();
- this._refresh();
- break;
- case"fieldTemplate":
- this._renderInputTemplate();
- break;
- case"values":
- if (this.option("multiSelectEnabled")) {
- this._renderTags();
- this._updateSelectedItems();
- this._raiseValueChangeAction(this.option("value"), previousValue, {values: value})
- }
- break;
- case"multiSelectEnabled":
- this._refresh();
- break;
- default:
- this.callBase.apply(this, arguments)
- }
- }
- }))
- })(jQuery, DevExpress);
- /*! Module widgets-base, file ui.multiView.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- events = ui.events,
- utils = DX.utils,
- fx = DX.fx,
- translator = DX.translator;
- var MULTIVIEW_CLASS = "dx-multiview",
- MULTIVIEW_WRAPPER_CLASS = "dx-multiview-wrapper",
- MULTIVIEW_ITEM_CONTAINER_CLASS = "dx-multiview-item-container",
- MULTIVIEW_ITEM_CLASS = "dx-multiview-item",
- MULTIVIEW_ITEM_HIDDEN_CLASS = "dx-multiview-item-hidden",
- MULTIVIEW_ITEM_DATA_KEY = "dxMultiViewItemData";
- var position = function($element) {
- return translator.locate($element).left
- };
- var move = function($element, position) {
- translator.move($element, {left: position})
- };
- var animation = {
- moveTo: function($element, position, completeAction) {
- fx.animate($element, {
- type: "slide",
- to: {left: position},
- duration: 200,
- complete: completeAction
- })
- },
- complete: function($element) {
- fx.stop($element, true)
- }
- };
- DX.registerComponent("dxMultiView", ui.CollectionContainerWidget.inherit({
- _setDefaultOptions: function() {
- this.callBase();
- this.option({
- selectedIndex: 0,
- swipeEnabled: true,
- animationEnabled: true,
- loop: false
- })
- },
- _itemClass: function() {
- return MULTIVIEW_ITEM_CLASS
- },
- _itemDataKey: function() {
- return MULTIVIEW_ITEM_DATA_KEY
- },
- _itemContainer: function() {
- return this._$itemContainer
- },
- _selectionByClickEnabled: function() {
- return false
- },
- _itemWidth: function() {
- if (!this._itemWidthValue)
- this._itemWidthValue = this._$wrapper.width();
- return this._itemWidthValue
- },
- _clearItemWidthCache: function() {
- delete this._itemWidthValue
- },
- _itemsCount: function() {
- return this.option("items").length
- },
- _normalizeIndex: function(index) {
- var count = this._itemsCount();
- if (index < 0)
- index = index + count;
- if (index >= count)
- index = index - count;
- return index
- },
- _init: function() {
- this.callBase.apply(this, arguments);
- var $element = this._element();
- $element.addClass(MULTIVIEW_CLASS);
- this._$wrapper = $("<div>").addClass(MULTIVIEW_WRAPPER_CLASS);
- this._$wrapper.appendTo($element);
- this._$itemContainer = $("<div>").addClass(MULTIVIEW_ITEM_CONTAINER_CLASS);
- this._$itemContainer.appendTo(this._$wrapper);
- this._initSwipeable()
- },
- _dimensionChanged: function() {
- this._clearItemWidthCache()
- },
- _renderSelectedIndex: function(selectedIndex) {
- this._updateItems(selectedIndex)
- },
- _updateItems: function(selectedIndex, newIndex) {
- this._updateItemsPosition(selectedIndex, newIndex);
- this._updateItemsVisibility(selectedIndex, newIndex)
- },
- _updateItemsVisibility: function(selectedIndex, newIndex) {
- var $itemElements = this._itemElements();
- $itemElements.each(function(itemIndex, item) {
- var $item = $(item),
- isHidden = itemIndex !== selectedIndex && itemIndex !== newIndex;
- $item.toggleClass(MULTIVIEW_ITEM_HIDDEN_CLASS, isHidden)
- })
- },
- _updateItemsPosition: function(selectedIndex, newIndex) {
- var $itemElements = this._itemElements(),
- positionSign = -this._animationDirection(newIndex, selectedIndex);
- move($itemElements.eq(selectedIndex), 0);
- move($itemElements.eq(newIndex), positionSign * 100 + "%")
- },
- _updateSelectedIndex: function(newIndex, prevIndex) {
- animation.complete(this._$itemContainter);
- this._updateItems(prevIndex, newIndex);
- var animationDirection = this._animationDirection(newIndex, prevIndex);
- this._animateItemContainer(animationDirection * this._itemWidth(), $.proxy(function() {
- move(this._$itemContainer, 0);
- this._updateItems(newIndex);
- this._$itemContainer.width()
- }, this))
- },
- _animateItemContainer: function(position, completeCallback) {
- if (this.option("animationEnabled"))
- animation.moveTo(this._$itemContainer, position, completeCallback);
- else
- completeCallback()
- },
- _animationDirection: function(newIndex, prevIndex) {
- var containerPosition = position(this._$itemContainer),
- indexDifference = (prevIndex - newIndex) * this._getRTLSignCorrection(),
- isSwipePresent = containerPosition !== 0,
- directionSignVariable = isSwipePresent ? containerPosition : indexDifference;
- return utils.sign(directionSignVariable)
- },
- _initSwipeable: function() {
- this._element().dxSwipeable({
- disabled: !this.option("swipeEnabled"),
- elastic: false,
- itemSizeFunc: $.proxy(this._itemWidth, this),
- startAction: $.proxy(function(args) {
- this._handleSwipeStart(args.jQueryEvent)
- }, this),
- updateAction: $.proxy(function(args) {
- this._handleSwipeUpdate(args.jQueryEvent)
- }, this),
- endAction: $.proxy(function(args) {
- this._handleSwipeEnd(args.jQueryEvent)
- }, this)
- })
- },
- _handleSwipeStart: function(e) {
- animation.complete(this._$itemContainer);
- var selectedIndex = this.option("selectedIndex"),
- loop = this.option("loop"),
- lastIndex = this._itemsCount() - 1,
- rtl = this.option("rtlEnabled");
- e.maxLeftOffset = loop || (rtl ? selectedIndex > 0 : selectedIndex < lastIndex);
- e.maxRightOffset = loop || (rtl ? selectedIndex < lastIndex : selectedIndex > 0)
- },
- _handleSwipeUpdate: function(e) {
- var offset = e.offset,
- swipeDirection = utils.sign(offset) * this._getRTLSignCorrection();
- move(this._$itemContainer, offset * 100 + "%");
- if (swipeDirection !== this._swipeDirection) {
- this._swipeDirection = swipeDirection;
- var selectedIndex = this.option("selectedIndex"),
- newIndex = this._normalizeIndex(selectedIndex - swipeDirection);
- this._updateItems(selectedIndex, newIndex)
- }
- },
- _handleSwipeEnd: function(e) {
- var targetOffset = e.targetOffset * this._getRTLSignCorrection();
- if (targetOffset)
- this.option("selectedIndex", this._normalizeIndex(this.option("selectedIndex") - targetOffset));
- else
- this._animateItemContainer(0, $.noop);
- delete this._swipeDirection
- },
- _getRTLSignCorrection: function() {
- return this.option("rtlEnabled") ? -1 : 1
- },
- _visibilityChanged: function(visible) {
- if (visible)
- this._clearItemWidthCache()
- },
- _optionChanged: function(name, value, prevValue) {
- switch (name) {
- case"loop":
- case"animationEnabled":
- break;
- case"swipeEnabled":
- this._element().dxSwipeable("option", "disabled", !value);
- break;
- default:
- this.callBase.apply(this, arguments)
- }
- }
- }));
- ui.dxMultiView.__internals = {animation: animation}
- })(jQuery, DevExpress);
- DevExpress.MOD_WIDGETS_BASE = true
- }
- if (!DevExpress.MOD_WIDGETS_MOBILE) {
- if (!DevExpress.MOD_WIDGETS_BASE)
- throw Error('Required module is not referenced: widgets-base');
- /*! Module widgets-mobile, file ui.switch.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- events = ui.events,
- fx = DX.fx;
- var SWITCH_CLASS = "dx-switch",
- SWITCH_WRAPPER_CLASS = SWITCH_CLASS + "-wrapper",
- SWITCH_CONTAINER_CLASS = SWITCH_CLASS + "-container",
- SWITCH_INNER_CLASS = SWITCH_CLASS + "-inner",
- SWITCH_HANDLE_CLASS = SWITCH_CLASS + "-handle",
- SWITCH_ON_VALUE_CLASS = SWITCH_CLASS + "-on-value",
- SWITCH_ON_CLASS = SWITCH_CLASS + "-on",
- SWITCH_OFF_CLASS = SWITCH_CLASS + "-off",
- SWITCH_ANIMATION_DURATION = 100;
- DX.registerComponent("dxSwitch", ui.dxEditor.inherit({
- _setDefaultOptions: function() {
- this.callBase();
- this.option({
- hoverStateEnabled: true,
- onText: Globalize.localize("dxSwitch-onText"),
- offText: Globalize.localize("dxSwitch-offText"),
- value: false
- })
- },
- _init: function() {
- this.callBase();
- this._animating = false;
- this._animationDuration = SWITCH_ANIMATION_DURATION
- },
- _recreateValueChangeAction: function() {
- this._valueChangeAction = this._createActionByOption("valueChangeAction", {excludeValidators: ["gesture"]})
- },
- _render: function() {
- var element = this._element();
- this._$switchInner = $("<div>").addClass(SWITCH_INNER_CLASS);
- this._$handle = $("<div>").addClass(SWITCH_HANDLE_CLASS).appendTo(this._$switchInner);
- this._$labelOn = $("<div>").addClass(SWITCH_ON_CLASS).prependTo(this._$switchInner);
- this._$labelOff = $("<div>").addClass(SWITCH_OFF_CLASS).appendTo(this._$switchInner);
- this._$switchContainer = $("<div>").addClass(SWITCH_CONTAINER_CLASS).append(this._$switchInner);
- this._$switchWrapper = $("<div>").addClass(SWITCH_WRAPPER_CLASS).append(this._$switchContainer);
- element.addClass(SWITCH_CLASS).append(this._$switchWrapper);
- element.dxSwipeable({
- elastic: false,
- startAction: $.proxy(this._handleSwipeStart, this),
- updateAction: $.proxy(this._handleSwipeUpdate, this),
- endAction: $.proxy(this._handleSwipeEnd, this)
- });
- this._renderLabels();
- this.callBase();
- this._updateMarginBound();
- this._renderValue();
- this._renderClick()
- },
- _updateMarginBound: function() {
- this._marginBound = this._$switchContainer.outerWidth(true) - this._$handle.outerWidth()
- },
- _marginDirection: function() {
- return this.option("rtlEnabled") ? "Right" : "Left"
- },
- _offsetDirection: function() {
- return this.option("rtlEnabled") ? -1 : 1
- },
- _renderPosition: function(state, swipeOffset) {
- var stateInt = state ? 1 : 0,
- marginDirection = this._marginDirection(),
- resetMarginDirection = marginDirection === "Left" ? "Right" : "Left";
- this._$switchInner.css("margin" + marginDirection, this._marginBound * (stateInt + swipeOffset - 1));
- this._$switchInner.css("margin" + resetMarginDirection, 0)
- },
- _validateValue: function() {
- var check = this.option("value");
- if (typeof check !== "boolean")
- this._options["value"] = !!check
- },
- _renderClick: function() {
- var eventName = events.addNamespace("dxclick", this.NAME),
- clickAction = this._createAction($.proxy(this._handleClick, this));
- this._element().off(eventName).on(eventName, function(e) {
- clickAction({jQueryEvent: e})
- })
- },
- _handleClick: function(args) {
- var e = args.jQueryEvent;
- this._valueChangeEventInstance = e;
- if (this._animating || this._swiping)
- return;
- this._animating = true;
- var that = this,
- startValue = this.option("value"),
- endValue = !startValue,
- marginDirection = this._marginDirection(),
- resetMarginDirection = marginDirection === "Left" ? "Right" : "Left",
- fromConfig = {},
- toConfig = {};
- this._$switchInner.css("margin" + resetMarginDirection, 0);
- fromConfig["margin" + marginDirection] = (Number(startValue) - 1) * this._marginBound;
- toConfig["margin" + marginDirection] = (Number(endValue) - 1) * this._marginBound;
- fx.animate(this._$switchInner, {
- from: fromConfig,
- to: toConfig,
- duration: this._animationDuration,
- complete: function() {
- that._animating = false;
- that.option("value", endValue)
- }
- })
- },
- _handleSwipeStart: function(e) {
- var state = this.option("value"),
- rtlEnabled = this.option("rtlEnabled"),
- maxOffOffset = rtlEnabled ? 0 : 1,
- maxOnOffset = rtlEnabled ? 1 : 0;
- e.jQueryEvent.maxLeftOffset = state ? maxOffOffset : maxOnOffset;
- e.jQueryEvent.maxRightOffset = state ? maxOnOffset : maxOffOffset;
- this._swiping = true;
- this._feedbackShow(this._element())
- },
- _handleSwipeUpdate: function(e) {
- this._renderPosition(this.option("value"), this._offsetDirection() * e.jQueryEvent.offset)
- },
- _handleSwipeEnd: function(e) {
- var that = this,
- offsetDirection = this._offsetDirection(),
- toConfig = {};
- toConfig["margin" + this._marginDirection()] = this._marginBound * (that.option("value") + offsetDirection * e.jQueryEvent.targetOffset - 1);
- fx.animate(this._$switchInner, {
- to: toConfig,
- duration: that._animationDuration,
- complete: function() {
- that._swiping = false;
- var pos = that.option("value") + offsetDirection * e.jQueryEvent.targetOffset;
- that.option("value", Boolean(pos));
- that._feedbackOff()
- }
- })
- },
- _renderValue: function() {
- this._validateValue();
- var val = this.option("value");
- this._renderPosition(val, 0);
- this._element().toggleClass(SWITCH_ON_VALUE_CLASS, val)
- },
- _renderLabels: function() {
- this._$labelOn.text(this.option("onText"));
- this._$labelOff.text(this.option("offText"))
- },
- _visibilityChanged: function(visible) {
- if (visible)
- this.repaint()
- },
- _feedbackOff: function() {
- if (this._swiping) {
- this._clearTimers();
- return
- }
- this.callBase.apply(this, arguments)
- },
- _optionChanged: function(name, value, prevValue) {
- switch (name) {
- case"visible":
- case"width":
- this._refresh();
- break;
- case"onText":
- case"offText":
- this._renderLabels();
- break;
- case"value":
- this._renderValue();
- this.callBase(name, value, prevValue);
- break;
- default:
- this.callBase(name, value, prevValue)
- }
- }
- }))
- })(jQuery, DevExpress);
- /*! Module widgets-mobile, file ui.pivotTabs.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- fx = DX.fx,
- utils = DX.utils,
- translator = DX.translator,
- events = ui.events;
- var PIVOT_TABS_CLASS = "dx-pivottabs",
- PIVOT_TAB_CLASS = "dx-pivottabs-tab",
- PIVOT_TAB_SELECTED_CLASS = "dx-pivottabs-tab-selected",
- PIVOT_GHOST_TAB_CLASS = "dx-pivottabs-ghosttab",
- PIVOT_TAB_DATA_KEY = "dxPivotTabData",
- PIVOT_TAB_MOVE_DURATION = 200,
- PIVOT_TAB_MOVE_EASING = "cubic-bezier(.40, .80, .60, 1)";
- var animation = {
- moveTo: function($tab, position, completeAction) {
- return fx.animate($tab, {
- type: "slide",
- to: {left: position},
- duration: PIVOT_TAB_MOVE_DURATION,
- easing: PIVOT_TAB_MOVE_EASING,
- complete: completeAction
- })
- },
- slideAppear: function($tab, position) {
- return fx.animate($tab, {
- type: "slide",
- to: {
- left: position,
- opacity: 1
- },
- duration: PIVOT_TAB_MOVE_DURATION,
- easing: PIVOT_TAB_MOVE_EASING
- })
- },
- slideDisappear: function($tab, position) {
- return fx.animate($tab, {
- type: "slide",
- to: {
- left: position,
- opacity: 0
- },
- duration: PIVOT_TAB_MOVE_DURATION,
- easing: PIVOT_TAB_MOVE_EASING
- })
- },
- complete: function(elements) {
- if (!elements)
- return;
- $.each(elements, function(_, $element) {
- fx.stop($element, true)
- })
- },
- stop: function(elements) {
- if (!elements)
- return;
- $.each(elements, function(_, $element) {
- fx.stop($element)
- })
- }
- };
- DX.registerComponent("dxPivotTabs", ui.CollectionContainerWidget.inherit({
- _setDefaultOptions: function() {
- this.callBase();
- this.option({
- selectedIndex: 0,
- prepareAction: null,
- updatePositionAction: null,
- rollbackAction: null
- })
- },
- _itemClass: function() {
- return PIVOT_TAB_CLASS
- },
- _itemDataKey: function() {
- return PIVOT_TAB_DATA_KEY
- },
- _itemContainer: function() {
- return this._element()
- },
- _elementWidth: function() {
- if (!this._elementWidthCache)
- this._elementWidthCache = this._element().width();
- return this._elementWidthCache
- },
- _clearElementWidthCache: function() {
- delete this._elementWidthCache
- },
- _itemWidths: function() {
- if (!this._itemWidthsCache) {
- var $tabs = this._itemElements(),
- widths = [];
- $tabs.each(function() {
- widths.push($(this).outerWidth())
- });
- this._itemWidthsCache = widths
- }
- return this._itemWidthsCache
- },
- _init: function() {
- this.callBase();
- this._initGhostTab();
- this._initSwipeHandlers();
- this._initActions()
- },
- _dimensionChanged: function() {
- this._clearElementWidthCache();
- this._cleanPositionCache();
- this._updateTabsPositions()
- },
- _initGhostTab: function() {
- this._$ghostTab = $("<div>").addClass(PIVOT_GHOST_TAB_CLASS)
- },
- _initActions: function() {
- var excludeValidators = {excludeValidators: ["gesture"]};
- this._updatePositionAction = this._createActionByOption("updatePositionAction", excludeValidators);
- this._rollbackAction = this._createActionByOption("rollbackAction", excludeValidators);
- this._prepareAction = this._createActionByOption("prepareAction", excludeValidators)
- },
- _render: function() {
- this._element().addClass(PIVOT_TABS_CLASS);
- this.callBase();
- this._renderGhostTab()
- },
- _renderGhostTab: function() {
- this._itemContainer().append(this._$ghostTab);
- this._toggleGhostTab(false)
- },
- _toggleGhostTab: function(visible) {
- var $ghostTab = this._$ghostTab;
- if (visible) {
- this._updateGhostTabContent();
- $ghostTab.css("opacity", 1)
- }
- else
- $ghostTab.css("opacity", 0)
- },
- _isGhostTabVisible: function() {
- return this._$ghostTab.css("opacity") == 1
- },
- _updateGhostTabContent: function(prevIndex) {
- prevIndex = prevIndex === undefined ? this._previousIndex() : prevIndex;
- var $ghostTab = this._$ghostTab,
- $items = this._itemElements();
- $ghostTab.html($items.eq(prevIndex).html())
- },
- _updateTabsPositions: function(offset) {
- var $tabs = this._allTabElements(),
- offset = this._applyOffsetBoundaries(offset),
- isPrevSwipeHandled = this.option("rtlEnabled") ^ offset > 0 && offset !== 0,
- tabPositions = this._calculateTabPositions(isPrevSwipeHandled ? "replace" : "append");
- this._moveTabs(tabPositions, offset);
- this._toggleGhostTab(isPrevSwipeHandled)
- },
- _moveTabs: function(positions, offset) {
- offset = offset || 0;
- var $tabs = this._allTabElements();
- $tabs.each(function(index) {
- translator.move($(this), {left: positions[index] + offset})
- })
- },
- _applyOffsetBoundaries: function(offset) {
- offset = offset || 0;
- var maxOffset = offset > 0 ? this._maxRightOffset : this._maxLeftOffset;
- return offset * maxOffset
- },
- _animateRollback: function() {
- var that = this,
- $tabs = this._itemElements(),
- positions = this._calculateTabPositions("prepend");
- if (this._isGhostTabVisible()) {
- this._swapGhostWithTab($tabs.eq(this._previousIndex()));
- animation.moveTo(this._$ghostTab, positions[this._indexBoundary()], function() {
- that._toggleGhostTab(false)
- })
- }
- $tabs.each(function(index) {
- animation.moveTo($(this), positions[index])
- })
- },
- _animateComplete: function(newIndex, currentIndex) {
- var that = this,
- $tabs = this._itemElements(),
- isPrevSwipeHandled = this._isGhostTabVisible();
- $tabs.eq(currentIndex).removeClass(PIVOT_TAB_SELECTED_CLASS);
- var animations = isPrevSwipeHandled ? this._animateIndexDecreasing(newIndex) : this._animateIndexIncreasing(newIndex);
- $tabs.eq(newIndex).addClass(PIVOT_TAB_SELECTED_CLASS)
- },
- _animateIndexDecreasing: function(newIndex) {
- var $tabs = this._itemElements(),
- positions = this._calculateTabPositions("append", newIndex),
- animations = [];
- $tabs.each(function(index) {
- animations.push(animation.moveTo($(this), positions[index]))
- });
- animations.push(animation.slideDisappear(this._$ghostTab, positions[this._indexBoundary()]));
- return $.when.apply($, animations)
- },
- _animateIndexIncreasing: function(newIndex) {
- var that = this,
- $tabs = this._itemElements(),
- positions = this._calculateTabPositions("prepend", newIndex),
- previousIndex = this._previousIndex(newIndex),
- $prevTab = $tabs.eq(previousIndex),
- prevTabPosition = translator.locate($prevTab).left,
- rtl = this.option("rtlEnabled"),
- bound = rtl ? this._elementWidth() - this._itemWidths()[previousIndex] : 0,
- isNextSwipeHandled = (prevTabPosition - bound) * this._getRTLSignCorrection() < 0,
- animations = [];
- if (!isNextSwipeHandled)
- this._moveTabs(this._calculateTabPositions("append", previousIndex));
- this._updateGhostTabContent(previousIndex);
- this._swapGhostWithTab($tabs.eq(previousIndex));
- $tabs.each(function(index) {
- var $tab = $(this),
- newPosition = positions[index];
- animations.push(index === previousIndex ? animation.slideAppear($tab, newPosition) : animation.moveTo($tab, newPosition))
- });
- animations.push(animation.moveTo(this._$ghostTab, positions[this._indexBoundary()], function() {
- that._toggleGhostTab(false)
- }));
- return $.when.apply($, animations)
- },
- _swapGhostWithTab: function($tab) {
- var $ghostTab = this._$ghostTab,
- lastTabPosition = translator.locate($tab).left,
- lastTabOpacity = $tab.css("opacity");
- translator.move($tab, {left: translator.locate($ghostTab).left});
- $tab.css("opacity", $ghostTab.css("opacity"));
- translator.move($ghostTab, {left: lastTabPosition});
- $ghostTab.css("opacity", lastTabOpacity)
- },
- _calculateTabPositions: function(ghostPosition, index) {
- index = index === undefined ? this.option("selectedIndex") : index;
- var mark = index + ghostPosition;
- if (this._calculetedPositionsMark !== mark) {
- this._calculetedPositions = this._calculateTabPositionsImpl(index, ghostPosition);
- this._calculetedPositionsMark = mark
- }
- return this._calculetedPositions
- },
- _calculateTabPositionsImpl: function(currentIndex, ghostPosition) {
- var prevIndex = this._normalizeIndex(currentIndex - 1),
- $tabs = this._itemElements(),
- widths = this._itemWidths();
- var rtl = this.option("rtlEnabled"),
- signCorrection = this._getRTLSignCorrection(),
- tabsContainerWidth = this._elementWidth(),
- nextPosition = rtl ? tabsContainerWidth : 0,
- positions = [];
- var calculateTabPosition = function(currentIndex, width) {
- var rtlOffset = rtl * width;
- positions.splice(currentIndex, 0, nextPosition - rtlOffset);
- nextPosition += width * signCorrection
- };
- $.each(widths.slice(currentIndex), calculateTabPosition);
- $.each(widths.slice(0, currentIndex), calculateTabPosition);
- switch (ghostPosition) {
- case"replace":
- var lastTabPosition = positions[prevIndex];
- positions.splice(prevIndex, 1, rtl ? tabsContainerWidth : -widths[prevIndex]);
- positions.push(lastTabPosition);
- break;
- case"prepend":
- positions.push(rtl ? tabsContainerWidth : -widths[prevIndex]);
- break;
- case"append":
- positions.push(nextPosition - widths[currentIndex] * rtl);
- break
- }
- return positions
- },
- _allTabElements: function() {
- return this._itemContainer().find("." + PIVOT_TAB_CLASS + ", ." + PIVOT_GHOST_TAB_CLASS)
- },
- _initSwipeHandlers: function() {
- this._element().on(events.addNamespace("dxswipestart", this.NAME), {itemSizeFunc: $.proxy(this._elementWidth, this)}, $.proxy(this._swipeStartHandler, this)).on(events.addNamespace("dxswipe", this.NAME), $.proxy(this._swipeUpdateHandler, this)).on(events.addNamespace("dxswipeend", this.NAME), $.proxy(this._swipeEndHandler, this))
- },
- _swipeStartHandler: function(e) {
- this._prepareAnimation();
- this._prepareAction();
- e.maxLeftOffset = 1;
- e.maxRightOffset = 1;
- if (DX.designMode || this.option("disabled") || this._indexBoundary() <= 1)
- e.cancel = true;
- else
- this._swipeGestureRunning = true
- },
- _prepareAnimation: function() {
- this._stopAnimation()
- },
- _stopAnimation: function() {
- animation.complete(this._allTabElements())
- },
- _swipeUpdateHandler: function(e) {
- var offset = e.offset;
- this._updateTabsPositions(offset);
- this._updatePositionAction({offset: offset})
- },
- _swipeEndHandler: function(e) {
- var targetOffset = e.targetOffset * this._getRTLSignCorrection();
- if (targetOffset === 0) {
- this._animateRollback();
- this._rollbackAction()
- }
- else {
- var newIndex = this._normalizeIndex(this.option("selectedIndex") - targetOffset);
- this.option("selectedIndex", newIndex)
- }
- this._swipeGestureRunning = false
- },
- _previousIndex: function(atIndex) {
- atIndex = atIndex === undefined ? this.option("selectedIndex") : atIndex;
- return this._normalizeIndex(atIndex - 1)
- },
- _normalizeIndex: function(index) {
- var boundary = this._indexBoundary();
- if (index < 0)
- index = boundary + index;
- if (index >= boundary)
- index = index - boundary;
- return index
- },
- _indexBoundary: function() {
- return this.option("items").length
- },
- _renderSelectedIndex: function(current) {
- this._calculateMaxOffsets(current);
- this._updateTabsPositions();
- this._itemElements().eq(current).addClass(PIVOT_TAB_SELECTED_CLASS)
- },
- _updateSelectedIndex: function(current) {
- this._calculateMaxOffsets(current)
- },
- _calculateMaxOffsets: function(index) {
- var $tabs = this._itemElements(),
- currentTabWidth = this._itemWidths()[index],
- prevTabWidth = this._itemWidths()[this._previousIndex(index)],
- rtl = this.option("rtlEnabled");
- this._maxLeftOffset = rtl ? prevTabWidth : currentTabWidth;
- this._maxRightOffset = rtl ? currentTabWidth : prevTabWidth
- },
- _itemRenderDefault: function(item, index, $itemElement) {
- var $itemText = $("<span>").text(item.title);
- $itemElement.html($itemText)
- },
- _getRTLSignCorrection: function() {
- return this.option("rtlEnabled") ? -1 : 1
- },
- _visibilityChanged: function(visible) {
- if (visible)
- this._dimensionChanged()
- },
- _clean: function() {
- animation.stop(this._allTabElements());
- this._clearElementWidthCache();
- this._cleanPositionCache();
- this.callBase()
- },
- _cleanPositionCache: function() {
- delete this._itemWidthsCache;
- delete this._calculetedPositionsMark
- },
- _optionChanged: function(name, value, prevValue) {
- switch (name) {
- case"selectedIndex":
- if (!this._swipeGestureRunning)
- this._prepareAnimation();
- if (this._itemElements().length)
- this._animateComplete(value, prevValue);
- this.callBase.apply(this, arguments);
- break;
- case"items":
- case"rtlEnabled":
- this._cleanPositionCache();
- this.callBase.apply(this, arguments);
- break;
- case"prepareAction":
- case"updatePositionAction":
- case"rollbackAction":
- this._initActions();
- break;
- default:
- this.callBase.apply(this, arguments)
- }
- },
- prepare: function() {
- this._prepareAnimation()
- },
- updatePosition: function(offset) {
- this._updateTabsPositions(offset)
- },
- rollback: function() {
- this._animateRollback()
- }
- }));
- ui.dxPivotTabs.__internals = {animation: animation}
- })(jQuery, DevExpress);
- /*! Module widgets-mobile, file ui.pivot.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- events = ui.events,
- fx = DX.fx,
- translator = DX.translator;
- var PIVOT_CLASS = "dx-pivot",
- PIVOT_WRAPPER_CLASS = "dx-pivot-wrapper",
- PIVOT_TABS_CONTAINER_CLASS = "dx-pivottabs-container",
- PIVOT_ITEM_CONTAINER_CLASS = "dx-pivot-itemcontainer",
- PIVOT_ITEM_WRAPPER_CLASS = "dx-pivot-itemwrapper",
- PIVOT_ITEM_CLASS = "dx-pivot-item",
- PIVOT_ITEM_HIDDEN_CLASS = "dx-pivot-item-hidden",
- PIVOT_ITEM_DATA_KEY = "dxPivotItemData",
- PIVOT_RETURN_BACK_DURATION = 200,
- PIVOT_SLIDE_AWAY_DURATION = 50,
- PIVOT_SLIDE_BACK_DURATION = 250,
- PIVOT_SLIDE_BACK_EASING = "cubic-bezier(.10, 1, 0, 1)";
- var animation = {
- returnBack: function($element) {
- fx.animate($element, {
- type: "slide",
- to: {left: 0},
- duration: PIVOT_RETURN_BACK_DURATION
- })
- },
- slideAway: function($element, position, completeAction) {
- fx.animate($element, {
- type: "slide",
- to: {left: position},
- duration: PIVOT_SLIDE_AWAY_DURATION,
- complete: completeAction
- })
- },
- slideBack: function($element) {
- fx.animate($element, {
- type: "slide",
- to: {left: 0},
- easing: PIVOT_SLIDE_BACK_EASING,
- duration: PIVOT_SLIDE_BACK_DURATION
- })
- },
- complete: function($element) {
- fx.stop($element, true)
- },
- stop: function($element) {
- fx.stop($element)
- }
- };
- DX.registerComponent("dxPivot", ui.CollectionContainerWidget.inherit({
- _setDefaultOptions: function() {
- this.callBase();
- this.option({selectedIndex: 0})
- },
- _itemClass: function() {
- return PIVOT_ITEM_CLASS
- },
- _itemDataKey: function() {
- return PIVOT_ITEM_DATA_KEY
- },
- _itemContainer: function() {
- return this._$itemWrapper
- },
- _elementWidth: function() {
- if (!this._elementWidthCache)
- this._elementWidthCache = this._element().width();
- return this._elementWidthCache
- },
- _clearElementWidthCache: function() {
- delete this._elementWidthCache
- },
- _init: function() {
- this.callBase();
- this._initWrapper();
- this._initTabs();
- this._initItemContainer();
- this._clearItemsCache();
- this._initSwipeHandlers()
- },
- _dimensionChanged: function() {
- this._clearElementWidthCache()
- },
- _initWrapper: function() {
- this._$wrapper = $("<div>").addClass(PIVOT_WRAPPER_CLASS).appendTo(this._element())
- },
- _initItemContainer: function() {
- var $itemContainer = $("<div>").addClass(PIVOT_ITEM_CONTAINER_CLASS);
- this._$wrapper.append($itemContainer);
- this._$itemWrapper = $("<div>").addClass(PIVOT_ITEM_WRAPPER_CLASS);
- $itemContainer.append(this._$itemWrapper)
- },
- _clearItemsCache: function() {
- this._itemsCache = []
- },
- _initTabs: function() {
- var that = this,
- $tabsContainer = $("<div>").addClass(PIVOT_TABS_CONTAINER_CLASS);
- this._$wrapper.append($tabsContainer);
- $tabsContainer.dxPivotTabs({
- items: this.option("items"),
- selectedIndex: this.option("selectedIndex"),
- prepareAction: function() {
- that._prepareAnimation()
- },
- updatePositionAction: function(args) {
- that._updateContentPosition(args.offset)
- },
- rollbackAction: function() {
- that._animateRollback()
- },
- itemSelectAction: function(args) {
- that.option("selectedIndex", args.selectedIndex)
- }
- });
- this._tabs = $tabsContainer.dxPivotTabs("instance")
- },
- _render: function() {
- this._element().addClass(PIVOT_CLASS);
- this.callBase()
- },
- _renderCurrentContent: function(currentIndex, previousIndex) {
- var itemsCache = this._itemsCache;
- itemsCache[previousIndex] = this._selectedItemElement();
- itemsCache[previousIndex].addClass(PIVOT_ITEM_HIDDEN_CLASS);
- if (itemsCache[currentIndex])
- itemsCache[currentIndex].removeClass(PIVOT_ITEM_HIDDEN_CLASS);
- else
- this._renderContent();
- this._fireSelectItemEvent(currentIndex, previousIndex)
- },
- _updateContentPosition: function(offset) {
- translator.move(this._$itemWrapper, {left: this._calculatePixelOffset(offset)})
- },
- _animateRollback: function() {
- animation.returnBack(this._$itemWrapper)
- },
- _animateComplete: function(newIndex, currentIndex) {
- var $itemWrapper = this._$itemWrapper,
- rtlSignCorrection = this._getRTLSignCorrection(),
- intermediatePosition = this._elementWidth() * (this._isPrevSwipeHandled() ? 1 : -1) * rtlSignCorrection;
- animation.slideAway($itemWrapper, intermediatePosition, $.proxy(function() {
- translator.move($itemWrapper, {left: -intermediatePosition});
- this._renderCurrentContent(newIndex, currentIndex)
- }, this));
- animation.slideBack($itemWrapper)
- },
- _calculatePixelOffset: function(offset) {
- offset = offset || 0;
- return offset * this._elementWidth()
- },
- _isPrevSwipeHandled: function() {
- var wrapperOffset = translator.locate(this._$itemWrapper).left,
- rtl = this.option("rtlEnabled");
- return rtl ^ wrapperOffset > 0 && wrapperOffset !== 0
- },
- _initSwipeHandlers: function() {
- this._element().on(events.addNamespace("dxswipestart", this.NAME), {itemSizeFunc: $.proxy(this._elementWidth, this)}, $.proxy(this._swipeStartHandler, this)).on(events.addNamespace("dxswipe", this.NAME), $.proxy(this._swipeUpdateHandler, this)).on(events.addNamespace("dxswipeend", this.NAME), $.proxy(this._swipeEndHandler, this))
- },
- _swipeStartHandler: function(e) {
- this._prepareAnimation();
- this._tabs.prepare();
- if (DX.designMode || this.option("disabled") || this._indexBoundary() <= 1)
- e.cancel = true;
- else
- this._swipeGestureRunning = true;
- e.maxLeftOffset = 1;
- e.maxRightOffset = 1
- },
- _prepareAnimation: function() {
- this._stopAnimation()
- },
- _stopAnimation: function() {
- animation.complete(this._$itemWrapper)
- },
- _swipeUpdateHandler: function(e) {
- var offset = e.offset;
- this._updateContentPosition(offset);
- this._tabs.updatePosition(offset)
- },
- _swipeEndHandler: function(e) {
- var targetOffset = e.targetOffset * this._getRTLSignCorrection();
- if (targetOffset === 0) {
- this._animateRollback();
- this._tabs.rollback()
- }
- else {
- var newIndex = this._normalizeIndex(this.option("selectedIndex") - targetOffset);
- this.option("selectedIndex", newIndex)
- }
- this._swipeGestureRunning = false
- },
- _renderSelectedIndex: $.noop,
- _normalizeIndex: function(index) {
- var boundary = this._indexBoundary();
- if (index < 0)
- index = boundary + index;
- if (index >= boundary)
- index = index - boundary;
- return index
- },
- _indexBoundary: function() {
- return this.option("items").length
- },
- _renderContentImpl: function() {
- var items = this.option("items"),
- selectedIndex = this.option("selectedIndex");
- if (items.length)
- this._renderItems([items[selectedIndex]])
- },
- _selectedItemElement: function() {
- return this._$itemWrapper.children(":not(." + PIVOT_ITEM_HIDDEN_CLASS + ")")
- },
- _getRTLSignCorrection: function() {
- return this.option("rtlEnabled") ? -1 : 1
- },
- _clean: function() {
- animation.stop(this._$itemWrapper);
- this.callBase()
- },
- _refresh: function() {
- this._tabs._refresh();
- this.callBase()
- },
- _optionChanged: function(name, value, prevValue) {
- switch (name) {
- case"disabled":
- this._tabs.option("disabled", value);
- this.callBase.apply(this, arguments);
- break;
- case"selectedIndex":
- if (!this._swipeGestureRunning)
- this._prepareAnimation();
- this._animateComplete(value, prevValue);
- this._tabs.option("selectedIndex", value);
- break;
- case"items":
- this._tabs.option("items", value);
- this._clearItemsCache();
- this.callBase.apply(this, arguments);
- break;
- case"rtlEnabled":
- this._tabs.option("rtlEnabled", value);
- this._clearItemsCache();
- this.callBase.apply(this, arguments);
- break;
- default:
- this.callBase.apply(this, arguments)
- }
- }
- }));
- ui.dxPivot.__internals = {animation: animation}
- })(jQuery, DevExpress);
- /*! Module widgets-mobile, file ui.tileView.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- utils = DX.utils;
- var TILEVIEW_CLASS = "dx-tileview",
- TILEVIEW_CONTAINER_CLASS = "dx-tileview-wrapper",
- TILEVIEW_ITEM_CLASS = "dx-tile",
- TILEVIEW_ITEM_SELECTOR = "." + TILEVIEW_ITEM_CLASS,
- TILEVIEW_ITEM_DATA_KEY = "dxTileData";
- DX.registerComponent("dxTileView", ui.CollectionContainerWidget.inherit({
- _activeStateUnit: TILEVIEW_ITEM_SELECTOR,
- _deprecatedOptions: {listHeight: {
- since: "14.1",
- message: "Use the 'height' option instead"
- }},
- _optionAliases: {listHeight: "height"},
- _setDefaultOptions: function() {
- this.callBase();
- this.option({
- hoverStateEnabled: true,
- items: null,
- showScrollbar: false,
- height: 500,
- baseItemWidth: 100,
- baseItemHeight: 100,
- itemMargin: 20,
- indicateLoading: true
- })
- },
- _itemClass: function() {
- return TILEVIEW_ITEM_CLASS
- },
- _itemDataKey: function() {
- return TILEVIEW_ITEM_DATA_KEY
- },
- _itemContainer: function() {
- return this._$container
- },
- _init: function() {
- this.callBase();
- this._initScrollView()
- },
- _handleDataSourceLoadingChanged: function(isLoading) {
- var scrollView = this._scrollView;
- if (!scrollView)
- return;
- if (isLoading && this.option("indicateLoading"))
- scrollView.startLoading();
- else
- scrollView.finishLoading()
- },
- _hideLoadingIfLoadIndicationOff: function() {
- if (!this.option("indicateLoading"))
- this._handleDataSourceLoadingChanged(false)
- },
- _initScrollView: function() {
- this._scrollView = this._element().dxScrollView({
- direction: "horizontal",
- scrollByContent: true
- }).dxScrollView("instance");
- this._$container = this._scrollView.content();
- this._$container.addClass(TILEVIEW_CONTAINER_CLASS);
- this._scrollView.option("updateAction", $.proxy(this._renderGeometry, this))
- },
- _render: function() {
- this.callBase();
- this._element().addClass(TILEVIEW_CLASS);
- this.cellsPerColumn = 1;
- this._updateScrollView();
- this._fireContentReadyAction()
- },
- _renderContent: function() {
- this._renderContentImpl()
- },
- _updateScrollView: function() {
- this._scrollView.option({
- rtlEnabled: this.option("rtlEnabled"),
- showScrollbar: this.option("showScrollbar"),
- disabled: this.option("disabled")
- });
- this._scrollView.update();
- this._indicateLoadingIfAlreadyStarted()
- },
- _indicateLoadingIfAlreadyStarted: function() {
- if (this._dataSource && this._dataSource.isLoading())
- this._handleDataSourceLoadingChanged(true)
- },
- _renderGeometry: function() {
- var items = this.option("items") || [],
- maxItemHeight = Math.max.apply(Math, $.map(items || [], function(item) {
- return Math.round(item.heightRatio || 1)
- }));
- this.cellsPerColumn = Math.floor(this._element().height() / (this.option("baseItemHeight") + this.option("itemMargin")));
- this.cellsPerColumn = Math.max(this.cellsPerColumn, maxItemHeight);
- this.cells = [];
- this.cells.push(new Array(this.cellsPerColumn));
- this._arrangeItems(items);
- this._$container.width(this.cells.length * this.option("baseItemWidth") + (this.cells.length + 1) * this.option("itemMargin"))
- },
- _arrangeItems: function(items) {
- var that = this,
- offsetCorrection = this.option("rtlEnabled") ? this._$container.width() : 0;
- $.each(items, function(index, item) {
- var currentItem = {};
- currentItem.widthRatio = item.widthRatio || 1;
- currentItem.heightRatio = item.heightRatio || 1;
- currentItem.text = item.text || "";
- currentItem.widthRatio = currentItem.widthRatio <= 0 ? 0 : Math.round(currentItem.widthRatio);
- currentItem.heightRatio = currentItem.heightRatio <= 0 ? 0 : Math.round(currentItem.heightRatio);
- var $item = that._itemElements().eq(index),
- itemPosition = that._getItemPosition(currentItem);
- if (itemPosition.x === -1)
- itemPosition.x = that.cells.push(new Array(that.cellsPerColumn)) - 1;
- that._occupyCells(currentItem, itemPosition);
- that._arrangeItem($item, currentItem, itemPosition, offsetCorrection)
- })
- },
- _getItemPosition: function(item) {
- var position = {
- x: -1,
- y: 0
- };
- for (var col = 0; col < this.cells.length; col++) {
- for (var row = 0; row < this.cellsPerColumn; row++)
- if (this._itemFit(col, row, item)) {
- position.x = col;
- position.y = row;
- break
- }
- if (position.x > -1)
- break
- }
- return position
- },
- _itemFit: function(column, row, item) {
- var result = true;
- if (row + item.heightRatio > this.cellsPerColumn)
- return false;
- for (var columnIndex = column; columnIndex < column + item.widthRatio; columnIndex++)
- for (var rowIndex = row; rowIndex < row + item.heightRatio; rowIndex++)
- if (this.cells.length - 1 < columnIndex)
- this.cells.push(new Array(this.cellsPerColumn));
- else if (this.cells[columnIndex][rowIndex]) {
- result = false;
- break
- }
- return result
- },
- _occupyCells: function(item, itemPosition) {
- for (var i = itemPosition.x; i < itemPosition.x + item.widthRatio; i++)
- for (var j = itemPosition.y; j < itemPosition.y + item.heightRatio; j++)
- this.cells[i][j] = true
- },
- _arrangeItem: function($item, item, itemPosition, offsetCorrection) {
- var baseItemHeight = this.option("baseItemHeight"),
- baseItemWidth = this.option("baseItemWidth"),
- itemMargin = this.option("itemMargin"),
- leftOffset;
- if (!offsetCorrection)
- leftOffset = itemPosition.x * baseItemWidth + (itemPosition.x + 1) * itemMargin;
- else {
- var startOffsetPosition = itemPosition.x * baseItemWidth,
- itemBasePartWidth = baseItemWidth + itemMargin,
- itemWidth = itemBasePartWidth * item.widthRatio,
- subitemMarginsWidth = itemPosition.x * itemMargin;
- leftOffset = offsetCorrection - (startOffsetPosition + itemWidth + subitemMarginsWidth)
- }
- $item.css({
- height: item.heightRatio * baseItemHeight + (item.heightRatio - 1) * itemMargin,
- width: item.widthRatio * baseItemWidth + (item.widthRatio - 1) * itemMargin,
- top: itemPosition.y * baseItemHeight + (itemPosition.y + 1) * itemMargin,
- left: leftOffset,
- display: item.widthRatio <= 0 || item.heightRatio <= 0 ? "none" : ""
- })
- },
- _optionChanged: function(name, value) {
- switch (name) {
- case"showScrollbar":
- this._initScrollView();
- break;
- case"disabled":
- this._scrollView.option("disabled", value);
- break;
- case"baseItemWidth":
- case"baseItemHeight":
- case"itemMargin":
- this._renderGeometry();
- break;
- case"height":
- this.callBase.apply(this, arguments);
- this._renderGeometry();
- this._scrollView.update();
- break;
- case"indicateLoading":
- this._hideLoadingIfLoadIndicationOff();
- break;
- default:
- this.callBase.apply(this, arguments)
- }
- },
- scrollPosition: function() {
- return this._scrollView.scrollOffset().left
- }
- }))
- })(jQuery, DevExpress);
- /*! Module widgets-mobile, file ui.actionSheet.js */
- (function($, DX, undefined) {
- var ui = DX.ui;
- var ACTION_SHEET_CLASS = "dx-action-sheet",
- ACTION_SHEET_CONTAINER_CLASS = "dx-action-sheet-container",
- ACTION_SHEET_POPUP_WRAPPER_CLASS = "dx-action-sheet-popup-wrapper",
- ACTION_SHEET_POPOVER_WRAPPER_CLASS = "dx-action-sheet-popover-wrapper",
- ACTION_SHEET_CANCEL_BUTTON_CLASS = "dx-action-sheet-cancel",
- ACTION_SHEET_ITEM_CLASS = "dx-action-sheet-item",
- ACTION_SHEET_ITEM_DATA_KEY = "dxActionSheetItemData",
- ACTION_SHEET_WITHOUT_TITLE_CLASS = "dx-action-sheet-without-title";
- DX.registerComponent("dxActionSheet", ui.CollectionContainerWidget.inherit({
- _setDefaultOptions: function() {
- this.callBase();
- this.option({
- usePopover: false,
- target: null,
- title: "",
- showTitle: true,
- showCancelButton: true,
- cancelText: Globalize.localize("Cancel"),
- cancelClickAction: null,
- visible: false,
- noDataText: ""
- })
- },
- _defaultOptionsRules: function() {
- return this.callBase().slice(0).concat([{
- device: [{
- platform: "ios",
- tablet: true
- }, {
- platform: "ios7",
- tablet: true
- }],
- options: {usePopover: true}
- }])
- },
- _itemContainer: function() {
- return this._$itemContainer
- },
- _itemClass: function() {
- return ACTION_SHEET_ITEM_CLASS
- },
- _itemDataKey: function() {
- return ACTION_SHEET_ITEM_DATA_KEY
- },
- _toggleVisibility: $.noop,
- _renderDimensions: $.noop,
- _render: function() {
- this._element().addClass(ACTION_SHEET_CLASS);
- this._createItemContainer();
- this._renderPopup()
- },
- _createItemContainer: function() {
- this._$itemContainer = $("<div>").addClass(ACTION_SHEET_CONTAINER_CLASS);
- this._renderDisabled()
- },
- _renderDisabled: function() {
- this._$itemContainer.toggleClass("dx-state-disabled", this.option("disabled"))
- },
- _renderPopup: function() {
- this._$popup = $("<div>").appendTo(this._element());
- this._popup = this._isPopoverMode() ? this._createPopover() : this._createPopup();
- this._renderPopupTitle();
- this._mapPopupOption("visible")
- },
- _mapPopupOption: function(optionName) {
- this._popup.option(optionName, this.option(optionName))
- },
- _isPopoverMode: function() {
- return this.option("usePopover") && this.option("target")
- },
- _renderPopupTitle: function() {
- this._mapPopupOption("showTitle");
- this._popup._wrapper().toggleClass(ACTION_SHEET_WITHOUT_TITLE_CLASS, !this.option("showTitle"))
- },
- _clean: function() {
- if (this._$popup)
- this._$popup.remove();
- this.callBase()
- },
- _createPopover: function() {
- var popover = this._$popup.dxPopover({
- _templates: this.option("_templates"),
- rtlEnabled: this.option("rtlEnabled"),
- showTitle: true,
- title: this.option("title"),
- width: this.option("width") || 200,
- height: this.option("height") || "auto",
- target: this.option("target"),
- hiddenAction: $.proxy(this.hide, this),
- contentReadyAction: $.proxy(this._popupContentReadyAction, this)
- }).dxPopover("instance");
- popover._wrapper().addClass(ACTION_SHEET_POPOVER_WRAPPER_CLASS);
- return popover
- },
- _createPopup: function() {
- var popup = this._$popup.dxPopup({
- _templates: this.option("_templates"),
- rtlEnabled: this.option("rtlEnabled"),
- dragEnabled: false,
- title: this.option("title"),
- width: this.option("width") || "100%",
- height: this.option("height") || "auto",
- contentReadyAction: $.proxy(this._popupContentReadyAction, this),
- position: {
- my: "bottom",
- at: "bottom",
- of: window
- },
- animation: {
- show: {
- type: "slide",
- duration: 400,
- from: {position: {
- my: "top",
- at: "bottom",
- of: window
- }},
- to: {position: {
- my: "bottom",
- at: "bottom",
- of: window
- }}
- },
- hide: {
- type: "slide",
- duration: 400,
- from: {position: {
- my: "bottom",
- at: "bottom",
- of: window
- }},
- to: {position: {
- my: "top",
- at: "bottom",
- of: window
- }}
- }
- }
- }).dxPopup("instance");
- popup.optionChanged.add($.proxy(function(name, value) {
- if (name !== "visible")
- return;
- this.option("visible", value)
- }, this));
- popup._wrapper().addClass(ACTION_SHEET_POPUP_WRAPPER_CLASS);
- return popup
- },
- _popupContentReadyAction: function() {
- this._popup.content().append(this._$itemContainer);
- this._attachClickEvent();
- this._attachHoldEvent();
- this._renderContent();
- this._renderCancelButton()
- },
- _renderCancelButton: function() {
- if (this._isPopoverMode())
- return;
- if (this._$cancelButton)
- this._$cancelButton.remove();
- if (this.option("showCancelButton")) {
- var cancelClickAction = new DX.Action($.proxy(this.hide, this), {beforeExecute: this.option("cancelClickAction")});
- this._$cancelButton = $("<div>").addClass(ACTION_SHEET_CANCEL_BUTTON_CLASS).appendTo(this._popup.content()).dxButton({
- text: this.option("cancelText"),
- clickAction: function(e) {
- cancelClickAction.execute(e)
- }
- })
- }
- },
- _handleItemClick: function(e) {
- this.callBase(e);
- if (!$(e.target).is(".dx-state-disabled, .dx-state-disabled *"))
- this.hide()
- },
- _handleItemHold: function(e) {
- this.callBase(e);
- if (!$(e.target).is(".dx-state-disabled, .dx-state-disabled *"))
- this.hide()
- },
- _itemRenderDefault: function(item, index, itemElement) {
- itemElement.dxButton(item)
- },
- _optionChanged: function(name, value) {
- switch (name) {
- case"width":
- case"height":
- case"visible":
- case"title":
- this._mapPopupOption(name);
- break;
- case"disabled":
- this._renderDisabled();
- break;
- case"showTitle":
- this._renderPopupTitle();
- break;
- case"showCancelButton":
- case"cancelClickAction":
- case"cancelText":
- this._renderCancelButton();
- break;
- case"target":
- case"usePopover":
- case"items":
- this._invalidate();
- break;
- default:
- this.callBase.apply(this, arguments)
- }
- },
- toggle: function(showing) {
- var that = this,
- d = $.Deferred();
- that._popup.toggle(showing).done(function() {
- that.option("visible", showing);
- d.resolveWith(that)
- });
- return d.promise()
- },
- show: function() {
- return this.toggle(true)
- },
- hide: function() {
- return this.toggle(false)
- }
- }))
- })(jQuery, DevExpress);
- /*! Module widgets-mobile, file ui.dropDownMenu.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- events = ui.events;
- var DROP_DOWN_MENU_CLASS = "dx-dropdownmenu",
- DROP_DOWN_MENU_POPUP_CLASS = "dx-dropdownmenu-popup",
- DROP_DOWN_MENU_POPUP_WRAPPER_CLASS = DROP_DOWN_MENU_POPUP_CLASS + "-wrapper",
- DROP_DOWN_MENU_LIST_CLASS = "dx-dropdownmenu-list",
- DROP_DOWN_MENU_BUTTON_CLASS = "dx-dropdownmenu-button";
- DX.registerComponent("dxDropDownMenu", ui.Widget.inherit({
- _setDefaultOptions: function() {
- this.callBase();
- this.option({
- items: [],
- itemClickAction: null,
- dataSource: null,
- itemTemplate: "item",
- itemRender: null,
- buttonText: "",
- buttonIcon: "overflow",
- buttonIconSrc: null,
- buttonClickAction: null,
- usePopover: false,
- hoverStateEnabled: true
- })
- },
- _defaultOptionsRules: function() {
- return this.callBase().slice(0).concat([{
- device: [{platform: "ios"}, {platform: "ios7"}],
- options: {usePopover: true}
- }])
- },
- _init: function() {
- this.callBase();
- this._initDataSource();
- this._initItemClickAction()
- },
- _initItemClickAction: function() {
- this._itemClickAction = this._createActionByOption("itemClickAction")
- },
- _render: function() {
- this._element().addClass(DROP_DOWN_MENU_CLASS);
- this._renderButton();
- this._renderClick();
- this.callBase()
- },
- _clean: function() {
- this._popup._element().remove()
- },
- _renderContentImpl: function() {
- this._renderPopup()
- },
- _renderButton: function() {
- var buttonIconSrc = this.option("buttonIconSrc"),
- buttonIcon = this.option("buttonIcon");
- this._button = this._element().addClass(DROP_DOWN_MENU_BUTTON_CLASS).dxButton({
- text: this.option("buttonText"),
- icon: buttonIcon,
- iconSrc: buttonIconSrc,
- clickAction: this.option("buttonClickAction")
- }).dxButton("instance")
- },
- _renderClick: function() {
- var action = this._createAction(this._handleButtonClick),
- eventName = events.addNamespace("dxclick", this.NAME);
- this._element().off(eventName).on(eventName, function(e) {
- action({jQueryEvent: e})
- })
- },
- _handleButtonClick: function(e) {
- e.component._popup.toggle()
- },
- _renderList: function(instance) {
- var $content = instance.content(),
- that = this;
- that._list = $content.addClass(DROP_DOWN_MENU_LIST_CLASS).dxList({
- _templates: this.option("_templates"),
- autoPagingEnabled: false,
- indicateLoading: false,
- noDataText: "",
- itemRender: that.option("itemRender"),
- itemTemplate: that._getTemplateByOption("itemTemplate"),
- itemClickAction: function(e) {
- that._popup.hide();
- that._itemClickAction(e)
- }
- }).data("dxList");
- that._setListDataSource();
- that._attachListClick();
- var listMaxHeight = $(window).height() * 0.5;
- if ($content.height() > listMaxHeight)
- $content.height(listMaxHeight)
- },
- _toggleVisibility: function(visible) {
- this.callBase(visible);
- this._button.option("visible", visible)
- },
- _attachListClick: function() {
- var action = this._createAction(this._handleListClick);
- this._list._element().off("." + this.NAME).on(events.addNamespace("dxclick", this.NAME), function(e) {
- action({jQueryEvent: e})
- })
- },
- _handleListClick: function(e) {
- e.component._popup.hide()
- },
- _renderPopup: function() {
- var $popup = this._$popup = $("<div>").appendTo(this._element());
- var popupOptions = {
- contentReadyAction: $.proxy(this._popupContentReadyHandler, this),
- deferRendering: false
- };
- this._popup = this._createPopover($popup, popupOptions);
- this._popup._wrapper().addClass(DROP_DOWN_MENU_POPUP_WRAPPER_CLASS);
- this._popup._wrapper().toggleClass(DROP_DOWN_MENU_POPUP_CLASS, !this.option("usePopover"))
- },
- _popupContentReadyHandler: function() {
- var popup = this._$popup.dxPopover("instance");
- this._renderList(popup)
- },
- _createPopover: function($element, popupOptions) {
- return $element.dxPopover($.extend(popupOptions, {
- target: this._element(),
- rtlEnabled: this.option("rtlEnabled")
- })).dxPopover("instance")
- },
- _setListDataSource: function() {
- if (this._list)
- this._list.option("dataSource", this._dataSource || this.option("items"))
- },
- _optionChanged: function(name, value) {
- if (/^button/.test(name)) {
- this._renderButton();
- return
- }
- switch (name) {
- case"items":
- case"dataSource":
- this._refreshDataSource();
- this._setListDataSource();
- break;
- case"itemRender":
- case"itemTemplate":
- if (this._list)
- this._list.option(name, value);
- break;
- case"itemClickAction":
- this._initItemClickAction();
- break;
- case"usePopover":
- this._invalidate();
- break;
- default:
- this.callBase.apply(this, arguments)
- }
- }
- }).include(ui.DataHelperMixin))
- })(jQuery, DevExpress);
- /*! Module widgets-mobile, file ui.panorama.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- events = ui.events,
- fx = DX.fx,
- translator = DX.translator,
- utils = DX.utils;
- var PANORAMA_CLASS = "dx-panorama",
- PANORAMA_WRAPPER_CLASS = "dx-panorama-wrapper",
- PANORAMA_TITLE_CLASS = "dx-panorama-title",
- PANORAMA_GHOST_TITLE_CLASS = "dx-panorama-ghosttitle",
- PANORAMA_ITEMS_CONTAINER_CLASS = "dx-panorama-itemscontainer",
- PANORAMA_ITEM_CLASS = "dx-panorama-item",
- PANORAMA_GHOST_ITEM_CLASS = "dx-panorama-ghostitem",
- PANORAMA_ITEM_HEADER_CLASS = "dx-panorama-item-header",
- PANORAMA_ITEM_DATA_KEY = "dxPanoramaItemData",
- PANORAMA_ITEM_MARGIN_SCALE = .02,
- PANORAMA_TITLE_MARGIN_SCALE = .02,
- PANORAMA_BACKGROUND_MOVE_DURATION = 300,
- PANORAMA_BACKGROUND_MOVE_EASING = "cubic-bezier(.40, .80, .60, 1)",
- PANORAMA_TITLE_MOVE_DURATION = 300,
- PANORAMA_TITLE_MOVE_EASING = "cubic-bezier(.40, .80, .60, 1)",
- PANORAMA_ITEM_MOVE_DURATION = 300,
- PANORAMA_ITEM_MOVE_EASING = "cubic-bezier(.40, .80, .60, 1)";
- var moveBackground = function($element, position) {
- $element.css("background-position", position + "px 0%")
- };
- var position = function($element) {
- return translator.locate($element).left
- };
- var move = function($element, position) {
- translator.move($element, {left: position})
- };
- var animation = {
- backgroundMove: function($element, position, completeAction) {
- return fx.animate($element, {
- to: {"background-position": position + "px 0%"},
- duration: PANORAMA_BACKGROUND_MOVE_DURATION,
- easing: PANORAMA_BACKGROUND_MOVE_EASING,
- complete: completeAction
- })
- },
- titleMove: function($title, position, completeAction) {
- return fx.animate($title, {
- type: "slide",
- to: {left: position},
- duration: PANORAMA_TITLE_MOVE_DURATION,
- easing: PANORAMA_TITLE_MOVE_EASING,
- complete: completeAction
- })
- },
- itemMove: function($item, position, completeAction) {
- return fx.animate($item, {
- type: "slide",
- to: {left: position},
- duration: PANORAMA_ITEM_MOVE_DURATION,
- easing: PANORAMA_ITEM_MOVE_EASING,
- complete: completeAction
- })
- }
- };
- var endAnimation = function(elements) {
- if (!elements)
- return;
- $.each(elements, function(_, element) {
- fx.stop(element, true)
- })
- };
- var PanoramaItemsRenderStrategy = DX.Class.inherit({
- ctor: function(panorama) {
- this._panorama = panorama
- },
- init: $.noop,
- render: $.noop,
- allItemElements: function() {
- return this._panorama._itemElements()
- },
- updatePositions: DX.abstract,
- animateRollback: DX.abstract,
- detectBoundsTransition: DX.abstract,
- animateComplete: DX.abstract,
- _getRTLSignCorrection: function() {
- return this._panorama._getRTLSignCorrection()
- },
- _isRTLEnabled: function() {
- return this._panorama.option("rtlEnabled")
- },
- _itemMargin: function() {
- return this._containerWidth() * PANORAMA_ITEM_MARGIN_SCALE
- },
- _containerWidth: function() {
- return this._panorama._elementWidth()
- },
- _itemWidth: function() {
- return this._panorama._itemWidth()
- },
- _indexBoundary: function() {
- return this._panorama._indexBoundary()
- },
- _normalizeIndex: function(index) {
- return this._panorama._normalizeIndex(index)
- },
- _startNextPosition: function() {
- if (this._isRTLEnabled())
- return this._containerWidth() - (this._itemMargin() + this._itemWidth());
- else
- return this._itemMargin()
- },
- _startPrevPosition: function() {
- if (this._isRTLEnabled())
- return this._containerWidth();
- else
- return -this._itemWidth()
- }
- });
- var PanoramaOneAndLessItemsRenderStrategy = PanoramaItemsRenderStrategy.inherit({
- updatePositions: function() {
- var $items = this._panorama._itemElements(),
- startPosition = this._startNextPosition();
- $items.each(function() {
- move($(this), startPosition)
- })
- },
- animateRollback: $.noop,
- detectBoundsTransition: $.noop,
- animateComplete: $.noop
- });
- var PanoramaTwoItemsRenderStrategy = PanoramaItemsRenderStrategy.inherit({
- init: function() {
- this._initGhostItem()
- },
- render: function() {
- this._renderGhostItem()
- },
- _initGhostItem: function() {
- this._$ghostItem = $("<div>").addClass(PANORAMA_GHOST_ITEM_CLASS)
- },
- _renderGhostItem: function() {
- this._panorama._itemContainer().append(this._$ghostItem);
- this._toggleGhostItem(false)
- },
- _toggleGhostItem: function(visible) {
- var $ghostItem = this._$ghostItem;
- if (visible)
- $ghostItem.css("opacity", 1);
- else
- $ghostItem.css("opacity", 0)
- },
- _updateGhostItemContent: function(index) {
- if (index !== false && index !== this._prevGhostIndex) {
- this._$ghostItem.html(this._panorama._itemElements().eq(index).html());
- this._prevGhostIndex = index
- }
- },
- _isGhostItemVisible: function() {
- return this._$ghostItem.css("opacity") == 1
- },
- _swapGhostWithItem: function($item) {
- var $ghostItem = this._$ghostItem,
- lastItemPosition = position($item);
- move($item, position($ghostItem));
- move($ghostItem, lastItemPosition)
- },
- allItemElements: function() {
- return this._panorama._itemContainer().find("." + PANORAMA_ITEM_CLASS + ", ." + PANORAMA_GHOST_ITEM_CLASS)
- },
- updatePositions: function(offset) {
- var $items = this.allItemElements(),
- selectedIndex = this._panorama.option("selectedIndex"),
- adjustedOffset = offset * this._getRTLSignCorrection(),
- isGhostReplaceLast = adjustedOffset > 0 && selectedIndex === 0 || adjustedOffset < 0 && selectedIndex === 1,
- isGhostReplaceFirst = adjustedOffset < 0 && selectedIndex === 0 || adjustedOffset > 0 && selectedIndex === 1,
- ghostPosition = isGhostReplaceLast && "replaceLast" || isGhostReplaceFirst && "replaceFirst",
- ghostContentIndex = isGhostReplaceLast && 1 || isGhostReplaceFirst && 0,
- positions = this._calculateItemPositions(selectedIndex, ghostPosition);
- this._updateGhostItemContent(ghostContentIndex);
- this._toggleGhostItem(isGhostReplaceLast || isGhostReplaceFirst);
- $items.each(function(index) {
- move($(this), positions[index] + offset)
- })
- },
- animateRollback: function(currentIndex) {
- var that = this,
- $items = this._panorama._itemElements(),
- startPosition = this._startNextPosition(),
- signCorrection = this._getRTLSignCorrection(),
- offset = (position($items.eq(currentIndex)) - startPosition) * signCorrection,
- ghostOffset = (position(this._$ghostItem) - startPosition) * signCorrection,
- positions = this._calculateItemPositions(currentIndex, ghostOffset > 0 ? "prepend" : "append"),
- isLastReplasedByGhost = currentIndex === 0 && offset > 0 && ghostOffset > 0 || currentIndex === 1 && ghostOffset < 0;
- if (isLastReplasedByGhost)
- this._swapGhostWithItem($items.eq(1));
- else
- this._swapGhostWithItem($items.eq(0));
- $items.each(function(index) {
- animation.itemMove($(this), positions[index])
- });
- animation.itemMove(this._$ghostItem, positions[2], function() {
- that._toggleGhostItem(false)
- })
- },
- detectBoundsTransition: function(newIndex, currentIndex) {
- var ghostLocation = position(this._$ghostItem),
- startPosition = this._startNextPosition(),
- rtl = this._isRTLEnabled();
- if (newIndex === 0 && rtl ^ ghostLocation < startPosition)
- return "left";
- if (currentIndex === 0 && rtl ^ ghostLocation > startPosition)
- return "right"
- },
- animateComplete: function(boundCross, newIndex, currentIndex) {
- var that = this,
- ghostPosition = !boundCross ^ !(currentIndex === 0) ? "prepend" : "append",
- $items = this._panorama._itemElements(),
- positions = this._calculateItemPositions(newIndex, ghostPosition),
- animations = [];
- $items.each(function(index) {
- animations.push(animation.itemMove($(this), positions[index]))
- });
- animations.push(animation.itemMove(this._$ghostItem, positions[2], function() {
- that._toggleGhostItem(false)
- }));
- return $.when.apply($, animations)
- },
- _calculateItemPositions: function(atIndex, ghostPosition) {
- var positions = [],
- $items = this._panorama._itemElements(),
- itemMargin = this._itemMargin(),
- itemWidth = this._itemWidth(),
- itemPositionOffset = (itemWidth + itemMargin) * this._getRTLSignCorrection(),
- normalFlow = atIndex === 0,
- prevPosition = this._startPrevPosition(),
- nextPosition = this._startNextPosition();
- positions.push(nextPosition);
- nextPosition += itemPositionOffset;
- if (normalFlow)
- positions.push(nextPosition);
- else
- positions.splice(0, 0, nextPosition);
- nextPosition += itemPositionOffset;
- switch (ghostPosition) {
- case"replaceFirst":
- positions.push(positions[0]);
- if (normalFlow)
- positions[0] = nextPosition;
- else
- positions[0] = prevPosition;
- break;
- case"replaceLast":
- if (normalFlow)
- positions.splice(1, 0, prevPosition);
- else
- positions.splice(1, 0, nextPosition);
- break;
- case"prepend":
- positions.push(prevPosition);
- break;
- case"append":
- positions.push(nextPosition);
- break
- }
- return positions
- }
- });
- var PanoramaThreeAndMoreItemsRenderStrategy = PanoramaItemsRenderStrategy.inherit({
- updatePositions: function(offset) {
- var $items = this._panorama._itemElements(),
- movingBack = offset * this._getRTLSignCorrection() < 0,
- positions = this._calculateItemPositions(this._panorama.option("selectedIndex"), movingBack);
- $items.each(function(index) {
- move($(this), positions[index] + offset)
- })
- },
- animateRollback: function(selectedIndex) {
- var $items = this._panorama._itemElements(),
- positions = this._calculateItemPositions(selectedIndex),
- animatingItems = [selectedIndex, this._normalizeIndex(selectedIndex + 1)];
- if (this._isRTLEnabled() ^ position($items.eq(selectedIndex)) > this._startNextPosition())
- animatingItems.push(this._normalizeIndex(selectedIndex - 1));
- $items.each(function(index) {
- var $item = $(this);
- if ($.inArray(index, animatingItems) !== -1)
- animation.itemMove($item, positions[index]);
- else
- move($item, positions[index])
- })
- },
- detectBoundsTransition: function(newIndex, currentIndex) {
- var lastIndex = this._indexBoundary() - 1;
- if (currentIndex === lastIndex && newIndex === 0)
- return "left";
- if (currentIndex === 0 && newIndex === lastIndex)
- return "right"
- },
- animateComplete: function(boundCross, newIndex, currentIndex) {
- var animations = [],
- $items = this._panorama._itemElements(),
- positions = this._calculateItemPositions(newIndex);
- var transitionBack = this._normalizeIndex(currentIndex - 1) === newIndex,
- cyclingItemIndex = $items.length === 3 && transitionBack ? this._normalizeIndex(currentIndex + 1) : null,
- cyclingItemPosition = positions[this._indexBoundary()];
- var animatingItems = [newIndex, currentIndex],
- backAnimatedItemIndex = transitionBack ? currentIndex : newIndex;
- if (!transitionBack)
- animatingItems.push(this._normalizeIndex(backAnimatedItemIndex + 1));
- $items.each(function(index) {
- var $item = $(this);
- if ($.inArray(index, animatingItems) === -1) {
- move($item, positions[index]);
- return
- }
- animations.push(index !== cyclingItemIndex ? animation.itemMove($item, positions[index]) : animation.itemMove($item, cyclingItemPosition, function() {
- move($item, positions[index])
- }))
- });
- return $.when.apply($, animations)
- },
- _calculateItemPositions: function(atIndex, movingBack) {
- var previousIndex = this._normalizeIndex(atIndex - 1),
- $items = this._panorama._itemElements(),
- itemMargin = this._itemMargin(),
- itemWidth = this._itemWidth(),
- itemPositionOffset = (itemWidth + itemMargin) * this._getRTLSignCorrection(),
- positions = [],
- prevPosition = this._startPrevPosition(),
- nextPosition = this._startNextPosition();
- for (var i = atIndex; i !== previousIndex; i = this._normalizeIndex(i + 1)) {
- positions[i] = nextPosition;
- nextPosition += itemPositionOffset
- }
- if (movingBack) {
- positions[previousIndex] = nextPosition;
- nextPosition += itemPositionOffset
- }
- else
- positions[previousIndex] = prevPosition;
- positions.push(nextPosition);
- return positions
- }
- });
- DX.registerComponent("dxPanorama", ui.CollectionContainerWidget.inherit({
- _setDefaultOptions: function() {
- this.callBase();
- this.option({
- selectedIndex: 0,
- title: "panorama",
- backgroundImage: {
- url: null,
- width: 0,
- height: 0
- }
- })
- },
- _itemClass: function() {
- return PANORAMA_ITEM_CLASS
- },
- _itemDataKey: function() {
- return PANORAMA_ITEM_DATA_KEY
- },
- _itemContainer: function() {
- return this._$itemsContainer
- },
- _selectionByClickEnabled: function() {
- return false
- },
- _itemWidth: function() {
- if (!this._itemWidthCache)
- this._itemWidthCache = this._itemElements().eq(0).outerWidth();
- return this._itemWidthCache
- },
- _clearItemWidthCache: function() {
- delete this._itemWidthCache
- },
- _elementWidth: function() {
- if (!this._elementWidthCache)
- this._elementWidthCache = this._element().width();
- return this._elementWidthCache
- },
- _clearElementWidthCache: function() {
- delete this._elementWidthCache
- },
- _titleWidth: function() {
- if (!this._titleWidthCache)
- this._titleWidthCache = this._$title.outerWidth();
- return this._titleWidthCache
- },
- _clearTitleWidthCache: function() {
- delete this._titleWidthCache
- },
- _init: function() {
- this.callBase();
- this._initItemsRenderStrategy();
- this._initWrapper();
- this._initTitle();
- this._initItemsContainer();
- this._initSwipeHandlers()
- },
- _dimensionChanged: function() {
- this._clearItemWidthCache();
- this._clearElementWidthCache();
- this._clearTitleWidthCache();
- this._updatePositions()
- },
- _initWrapper: function() {
- this._$wrapper = $("<div>").addClass(PANORAMA_WRAPPER_CLASS).appendTo(this._element())
- },
- _initItemsRenderStrategy: function() {
- var itemsRenderStrategy;
- switch (this.option("items").length) {
- case 0:
- case 1:
- itemsRenderStrategy = PanoramaOneAndLessItemsRenderStrategy;
- break;
- case 2:
- itemsRenderStrategy = PanoramaTwoItemsRenderStrategy;
- break;
- default:
- itemsRenderStrategy = PanoramaThreeAndMoreItemsRenderStrategy
- }
- this._itemsRenderStrategy = new itemsRenderStrategy(this);
- this._itemsRenderStrategy.init()
- },
- _initBackgroundImage: function() {
- var bgUrl = this.option("backgroundImage.url");
- if (bgUrl)
- this._element().css("background-image", "url(" + bgUrl + ")")
- },
- _initTitle: function() {
- this._$title = $("<div>").addClass(PANORAMA_TITLE_CLASS);
- this._$ghostTitle = $("<div>").addClass(PANORAMA_GHOST_TITLE_CLASS);
- this._$wrapper.append(this._$title);
- this._$wrapper.append(this._$ghostTitle);
- this._updateTitle()
- },
- _updateTitle: function() {
- var title = this.option("title");
- this._$title.text(title);
- this._$ghostTitle.text(title);
- this._toggleGhostTitle(false)
- },
- _toggleGhostTitle: function(visible) {
- var $ghostTitle = this._$ghostTitle;
- if (visible)
- $ghostTitle.css("opacity", 1);
- else
- $ghostTitle.css("opacity", 0)
- },
- _getRTLSignCorrection: function() {
- return this.option("rtlEnabled") ? -1 : 1
- },
- _initItemsContainer: function() {
- this._$itemsContainer = $("<div>").addClass(PANORAMA_ITEMS_CONTAINER_CLASS);
- this._$wrapper.append(this._$itemsContainer)
- },
- _render: function() {
- this._element().addClass(PANORAMA_CLASS);
- this.callBase();
- this._initBackgroundImage();
- this._itemsRenderStrategy.render()
- },
- _updatePositions: function(offset) {
- offset = offset || 0;
- this._updateBackgroundPosition(offset * this._calculateBackgroundStep());
- this._updateTitlePosition(offset * this._calculateTitleStep());
- this._itemsRenderStrategy.updatePositions(offset * this._elementWidth())
- },
- _updateBackgroundPosition: function(offset) {
- moveBackground(this._element(), this._calculateBackgroundPosition(this.option("selectedIndex")) + offset)
- },
- _updateTitlePosition: function(offset) {
- move(this._$title, this._calculateTitlePosition(this.option("selectedIndex")) + offset)
- },
- _animateRollback: function(currentIndex) {
- this._animateBackgroundMove(currentIndex);
- this._animateTitleMove(currentIndex);
- this._itemsRenderStrategy.animateRollback(currentIndex)
- },
- _animateBackgroundMove: function(toIndex) {
- return animation.backgroundMove(this._element(), this._calculateBackgroundPosition(toIndex))
- },
- _animateTitleMove: function(toIndex) {
- return animation.titleMove(this._$title, this._calculateTitlePosition(toIndex))
- },
- _animateComplete: function(newIndex, currentIndex) {
- var that = this,
- boundCross = this._itemsRenderStrategy.detectBoundsTransition(newIndex, currentIndex);
- var backgroundAnimation = this._performBackgroundAnimation(boundCross, newIndex);
- var titleAnimation = this._performTitleAnimation(boundCross, newIndex);
- var itemsAnimation = this._itemsRenderStrategy.animateComplete(boundCross, newIndex, currentIndex);
- $.when(backgroundAnimation, titleAnimation, itemsAnimation).done(function() {
- that._indexChangeOnAnimation = true;
- that.option("selectedIndex", newIndex);
- that._indexChangeOnAnimation = false
- })
- },
- _performBackgroundAnimation: function(boundCross, newIndex) {
- if (boundCross)
- return this._animateBackgroundBoundsTransition(boundCross, newIndex);
- return this._animateBackgroundMove(newIndex)
- },
- _animateBackgroundBoundsTransition: function(bound, newIndex) {
- var that = this,
- isLeft = bound === "left",
- afterAnimationPosition = this._calculateBackgroundPosition(newIndex),
- animationEndPositionShift = isLeft ^ this.option("rtlEnabled") ? -this._calculateBackgroundScaledWidth() : this._calculateBackgroundScaledWidth(),
- animationEndPosition = afterAnimationPosition + animationEndPositionShift;
- return animation.backgroundMove(this._element(), animationEndPosition, function() {
- moveBackground(that._element(), afterAnimationPosition)
- })
- },
- _performTitleAnimation: function(boundCross, newIndex) {
- if (boundCross)
- return this._animateTitleBoundsTransition(boundCross, newIndex);
- return this._animateTitleMove(newIndex)
- },
- _animateTitleBoundsTransition: function(bound, newIndex) {
- var that = this,
- $ghostTitle = this._$ghostTitle,
- ghostWidth = this._titleWidth(),
- panoramaWidth = this._elementWidth(),
- isLeft = bound === "left",
- rtl = this.option("rtlEnabled"),
- ghostTitleStartPosition = isLeft ^ rtl ? panoramaWidth : -ghostWidth,
- ghostTitleEndPosition = isLeft ^ rtl ? -(panoramaWidth + ghostWidth) : panoramaWidth;
- move($ghostTitle, ghostTitleStartPosition);
- this._toggleGhostTitle(true);
- this._swapGhostWithTitle();
- var ghostAnimation = animation.titleMove($ghostTitle, ghostTitleEndPosition, function() {
- that._toggleGhostTitle(false)
- });
- var titleAnimation = animation.titleMove(this._$title, this._calculateTitlePosition(newIndex));
- return $.when(ghostAnimation, titleAnimation)
- },
- _swapGhostWithTitle: function() {
- var $ghostTitle = this._$ghostTitle,
- $title = this._$title,
- lastTitlePosition = position($title);
- move($title, position($ghostTitle));
- move($ghostTitle, lastTitlePosition)
- },
- _calculateTitlePosition: function(atIndex) {
- var panoramaWidth = this._elementWidth(),
- titleWidth = this._titleWidth(),
- titleMargin = panoramaWidth * PANORAMA_TITLE_MARGIN_SCALE,
- titleStartPosition = this.option("rtlEnabled") ? panoramaWidth - titleMargin - titleWidth : titleMargin,
- titleStep = atIndex * this._calculateTitleStep() * this._getRTLSignCorrection();
- return titleStartPosition - titleStep
- },
- _calculateTitleStep: function() {
- var panoramaWidth = this._elementWidth(),
- titleWidth = this._titleWidth(),
- indexBoundary = this._indexBoundary() || 1;
- return Math.max((titleWidth - panoramaWidth) / indexBoundary, titleWidth / indexBoundary)
- },
- _calculateBackgroundPosition: function(atIndex) {
- var panoramaWidth = this._elementWidth(),
- backgroundScaledWidth = this._calculateBackgroundScaledWidth(),
- backgroundStartPosition = this.option("rtlEnabled") ? panoramaWidth - backgroundScaledWidth : 0,
- backgroundOffset = atIndex * this._calculateBackgroundStep() * this._getRTLSignCorrection();
- return backgroundStartPosition - backgroundOffset
- },
- _calculateBackgroundStep: function() {
- var itemWidth = this._itemWidth(),
- backgroundScaledWidth = this._calculateBackgroundScaledWidth();
- return Math.max((backgroundScaledWidth - itemWidth) / (this._indexBoundary() || 1), 0)
- },
- _calculateBackgroundScaledWidth: function() {
- return this._element().height() * this.option("backgroundImage.width") / (this.option("backgroundImage.height") || 1)
- },
- _initSwipeHandlers: function() {
- this._element().on(events.addNamespace("dxswipestart", this.NAME), {itemSizeFunc: $.proxy(this._elementWidth, this)}, $.proxy(this._swipeStartHandler, this)).on(events.addNamespace("dxswipe", this.NAME), $.proxy(this._swipeUpdateHandler, this)).on(events.addNamespace("dxswipeend", this.NAME), $.proxy(this._swipeEndHandler, this))
- },
- _swipeStartHandler: function(e) {
- this._stopAnimations();
- e.maxLeftOffset = 1;
- e.maxRightOffset = 1;
- if (DX.designMode || this.option("disabled") || this._indexBoundary() <= 1)
- e.cancel = true
- },
- _stopAnimations: function() {
- endAnimation([this._element(), this._$ghostTitle, this._$title]);
- endAnimation(this._itemsRenderStrategy.allItemElements())
- },
- _swipeUpdateHandler: function(e) {
- this._updatePositions(e.offset)
- },
- _swipeEndHandler: function(e) {
- var currentIndex = this.option("selectedIndex"),
- targetOffset = e.targetOffset * this._getRTLSignCorrection();
- if (targetOffset === 0)
- this._animateRollback(currentIndex);
- else
- this._animateComplete(this._normalizeIndex(currentIndex - targetOffset), currentIndex)
- },
- _renderSelectedIndex: function(current, previous) {
- if (!this._indexChangeOnAnimation)
- this._updatePositions()
- },
- _normalizeIndex: function(index) {
- var boundary = this._indexBoundary();
- if (index < 0)
- index = boundary + index;
- if (index >= boundary)
- index = index - boundary;
- return index
- },
- _indexBoundary: function() {
- return this.option("items").length
- },
- _visibilityChanged: function(visible) {
- if (visible)
- this._dimensionChanged()
- },
- _optionChanged: function(name, value, prevValue) {
- switch (name) {
- case"width":
- this.callBase.apply(this, arguments);
- this._dimensionChanged();
- break;
- case"backgroundImage":
- this._invalidate();
- break;
- case"title":
- this._updateTitle();
- break;
- case"items":
- this._initItemsRenderStrategy();
- this.callBase.apply(this, arguments);
- break;
- default:
- this.callBase.apply(this, arguments)
- }
- },
- _itemRenderDefault: function(item, index, $itemElement) {
- this.callBase(item, index, $itemElement);
- if (!item.header)
- return;
- var $itemHeader = $("<div>").addClass(PANORAMA_ITEM_HEADER_CLASS).text(item.header);
- $itemElement.prepend($itemHeader)
- }
- }));
- ui.dxPanorama.__internals = {animation: animation}
- })(jQuery, DevExpress);
- /*! Module widgets-mobile, file ui.slideout.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- events = ui.events,
- fx = DX.fx,
- utils = DX.utils,
- translator = DX.translator;
- var SLIDEOUT_CLASS = "dx-slideout",
- SLIDEOUT_WRAPPER_CLASS = "dx-slideout-wrapper",
- SLIDEOUT_ITEM_CONTAINER_CLASS = "dx-slideout-item-container",
- SLIDEOUT_MENU = "dx-slideout-menu",
- SLIDEOUT_SHIELD = "dx-slideout-shield",
- SLIDEOUT_ITEM_CLASS = "dx-slideout-item",
- SLIDEOUT_ITEM_DATA_KEY = "dxSlideoutItemData",
- INVISIBLE_STATE_CLASS = "dx-state-invisible",
- CONTENT_OFFSET = 45,
- ANIMATION_DURATION = 400;
- DX.registerComponent("dxSlideOut", ui.CollectionContainerWidget.inherit({
- _setDefaultOptions: function() {
- this.callBase();
- this.option({
- activeStateEnabled: false,
- menuItemRender: null,
- menuItemTemplate: "menuItem",
- swipeEnabled: true,
- menuVisible: false,
- menuGrouped: false,
- menuGroupTemplate: "group",
- menuGroupRender: null
- })
- },
- _itemClass: function() {
- return SLIDEOUT_ITEM_CLASS
- },
- _itemDataKey: function() {
- return SLIDEOUT_ITEM_DATA_KEY
- },
- _init: function() {
- this.callBase();
- this._deferredAnimate = undefined
- },
- _render: function() {
- this._renderWrapper();
- this._renderItemsContainer();
- this._renderShield();
- this._renderList();
- this._initSwipeHandlers();
- this._element().addClass(SLIDEOUT_CLASS);
- this.callBase();
- this._renderPosition(this.option("menuVisible"), false)
- },
- _renderWrapper: function() {
- this._wrapper = $("<div>").addClass(SLIDEOUT_WRAPPER_CLASS);
- this._element().append(this._wrapper)
- },
- _renderShield: function() {
- this._$shield = $("<div>").addClass(SLIDEOUT_SHIELD);
- this._$shield.appendTo(this._$container);
- this._$shield.on("dxclick", $.proxy(this.hideMenu, this));
- this._toggleShieldVisibility()
- },
- _dimensionChanged: function() {
- this._renderPosition(this.option("menuVisible"), false);
- this._clearListWidthCache()
- },
- _renderItemsContainer: function() {
- this._$container = $("<div>").addClass(SLIDEOUT_ITEM_CONTAINER_CLASS).appendTo(this._wrapper);
- this._$container.on("MSPointerDown", function(e){})
- },
- _selectedItemElement: function(index) {
- return this._itemElements().eq(0)
- },
- _renderContentImpl: function(template) {
- var items = this.option("items"),
- selectedIndex = this.option("selectedIndex");
- if (items.length && selectedIndex > -1) {
- var selectedItem = this._$list.dxList("instance").getItemByIndex(selectedIndex);
- this._renderItems([selectedItem])
- }
- },
- _renderList: function() {
- this._$list = $("<div>").addClass(SLIDEOUT_MENU).prependTo(this._wrapper);
- this._renderItemClickAction();
- var list = this._$list.dxList().dxList("instance");
- this._$list.dxList({
- _templates: this.option("_templates"),
- itemTemplateProperty: "menuTemplate",
- height: "100%",
- indicateLoading: false,
- itemClickAction: $.proxy(this._handleListItemClick, this),
- items: this.option("items"),
- dataSource: this.option("dataSource"),
- itemRender: this.option("menuItemRender"),
- itemTemplate: this._getTemplateByOption("menuItemTemplate"),
- grouped: this.option("menuGrouped"),
- groupTemplate: this.option("menuGroupTemplate"),
- groupRender: this.option("menuGroupRender")
- })
- },
- _handleListItemClick: function(e) {
- var selectedIndex = this._$list.find(".dx-list-item").index(e.itemElement);
- this.option("selectedIndex", selectedIndex);
- this._itemClickAction(e)
- },
- _handleItemClick: $.noop,
- _renderItemClickAction: function() {
- this._itemClickAction = this._createActionByOption("itemClickAction")
- },
- _renderItem: function(index, item, container) {
- this._$container.find("." + SLIDEOUT_ITEM_CLASS).remove();
- this.callBase(index, item, this._$container)
- },
- _renderSelectedIndex: function() {
- this._renderContent()
- },
- _initSwipeHandlers: function() {
- this._$container.dxSwipeable({
- elastic: false,
- itemSizeFunc: $.proxy(this._getListWidth, this),
- startAction: $.proxy(this.option("swipeEnabled") ? this._handleSwipeStart : function(e) {
- e.jQueryEvent.cancel = true
- }, this),
- updateAction: $.proxy(this._handleSwipeUpdate, this),
- endAction: $.proxy(this._handleSwipeEnd, this)
- })
- },
- _handleSwipeStart: function(e) {
- this._$shield.addClass(INVISIBLE_STATE_CLASS);
- fx.stop(this._$container);
- var menuVisible = this.option("menuVisible"),
- rtl = this.option("rtlEnabled");
- e.jQueryEvent.maxLeftOffset = rtl ? !menuVisible : menuVisible;
- e.jQueryEvent.maxRightOffset = rtl ? menuVisible : !menuVisible
- },
- _handleSwipeUpdate: function(e) {
- var offset = this.option("menuVisible") ? e.jQueryEvent.offset + 1 * this._getRTLSignCorrection() : e.jQueryEvent.offset;
- offset *= this._getRTLSignCorrection();
- this._renderPosition(offset, false)
- },
- _handleSwipeEnd: function(e) {
- var targetOffset = e.jQueryEvent.targetOffset * this._getRTLSignCorrection() + this.option("menuVisible"),
- menuVisible = targetOffset !== 0;
- if (this.option("menuVisible") === menuVisible)
- this._renderPosition(this.option("menuVisible"), true);
- else
- this.option("menuVisible", targetOffset !== 0)
- },
- _handleMenuButtonClick: function() {
- this.option("menuVisible", !this.option("menuVisible"))
- },
- _toggleMenuVisibility: function(visible, animate) {
- this.option("menuVisible", visible)
- },
- _renderPosition: function(offset, animate) {
- var pos = this._calculatePixelOffset(offset) * this._getRTLSignCorrection();
- if (animate) {
- this._$shield.addClass(INVISIBLE_STATE_CLASS);
- fx.animate(this._$container, {
- type: "slide",
- to: {left: pos},
- duration: ANIMATION_DURATION,
- complete: $.proxy(this._handleAnimationComplete, this)
- })
- }
- else
- translator.move(this._$container, {left: pos})
- },
- _calculatePixelOffset: function(offset) {
- var offset = offset || 0,
- maxOffset = this._getListWidth();
- return offset * maxOffset
- },
- _getListWidth: function() {
- if (!this._listWidth) {
- var listWidth = this._$list.width(),
- elementWidth = this._element().width() - CONTENT_OFFSET;
- this._listWidth = Math.min(elementWidth, listWidth)
- }
- return this._listWidth
- },
- _clearListWidthCache: function() {
- delete this._listWidth
- },
- _getRTLSignCorrection: function() {
- return this.option("rtlEnabled") ? -1 : 1
- },
- _changeMenuOption: function(name, value) {
- this._$list.dxList("instance").option(name, value);
- this._clearListWidthCache()
- },
- _visibilityChanged: function(visible) {
- if (visible)
- this._dimensionChanged()
- },
- _optionChanged: function(name, value, prevValue) {
- switch (name) {
- case"menuVisible":
- this._renderPosition(value, true);
- break;
- case"swipeEnabled":
- this._initSwipeHandlers();
- break;
- case"menuItemRender":
- this._changeMenuOption("itemRender", value);
- break;
- case"menuItemTemplate":
- this._changeMenuOption("itemTemplate", value);
- break;
- case"items":
- case"dataSource":
- this._changeMenuOption(name, value);
- break;
- case"menuGrouped":
- this._changeMenuOption("grouped", value);
- break;
- case"menuGroupRender":
- this._changeMenuOption("groupRender", value);
- break;
- case"menuGroupTemplate":
- this._changeMenuOption("groupTemplate", value);
- break;
- case"itemClickAction":
- this._renderItemClickAction();
- break;
- case"rtlEnabled":
- this.callBase.apply(this, arguments);
- this._renderPosition(this.option("menuVisible"), false);
- break;
- default:
- this.callBase(name, value, prevValue)
- }
- },
- _toggleShieldVisibility: function() {
- this._$shield.toggleClass(INVISIBLE_STATE_CLASS, !this.option("menuVisible"))
- },
- _handleAnimationComplete: function() {
- this._toggleShieldVisibility();
- if (this._deferredAnimate)
- this._deferredAnimate.resolveWith(this)
- },
- showMenu: function() {
- return this.toggleMenuVisibility(true)
- },
- hideMenu: function() {
- return this.toggleMenuVisibility(false)
- },
- toggleMenuVisibility: function(showing) {
- showing = showing === undefined ? !this.option("menuVisible") : showing;
- this._deferredAnimate = $.Deferred();
- this.option("menuVisible", showing);
- return this._deferredAnimate.promise()
- }
- }))
- })(jQuery, DevExpress);
- DevExpress.MOD_WIDGETS_MOBILE = true
- }
- if (!DevExpress.MOD_WIDGETS_WEB) {
- if (!DevExpress.MOD_WIDGETS_BASE)
- throw Error('Required module is not referenced: widgets-base');
- /*! Module widgets-web, file ui.pager.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- utils = DX.utils,
- events = ui.events,
- Class = DX.Class;
- var PAGES_LIMITER = 4,
- PAGER_CLASS = 'dx-pager',
- PAGER_PAGE_CLASS = 'dx-page',
- PAGER_PAGES_CLASS = 'dx-pages',
- PAGER_SELECTION_CLASS = 'dx-selection',
- PAGER_PAGE_SEPARATOR_CLASS = 'dx-separator',
- PAGER_PAGE_SIZES_CLASS = 'dx-page-sizes',
- PAGER_PAGE_SIZE_CLASS = 'dx-page-size';
- var Page = Class.inherit({
- ctor: function(value, index) {
- var that = this;
- that.index = index;
- that.element = $('<div />').text(value).addClass(PAGER_PAGE_CLASS)
- },
- value: function(value) {
- var that = this;
- if (utils.isDefined(value))
- that.element.text(value);
- else {
- var text = that.element.text();
- if (utils.isNumber(text))
- return parseInt(text);
- else
- return text
- }
- },
- select: function(value) {
- this.element.toggleClass(PAGER_SELECTION_CLASS, value)
- },
- render: function(rootElement, rtlEnabled) {
- rtlEnabled ? this.element.prependTo(rootElement) : this.element.appendTo(rootElement)
- }
- });
- DX.registerComponent("dxPager", DX.DOMComponent.inherit({
- NAMESPACE: ui,
- _setDefaultOptions: function() {
- this.callBase();
- this.option({
- visible: true,
- pageIndex: 1,
- maxPagesCount: 10,
- pagesCount: 10,
- pageSize: 5,
- showPageSizes: true,
- pageSizes: [5, 10],
- hasKnownLastPage: true,
- pageIndexChanged: $.noop,
- pageSizeChanged: $.noop
- })
- },
- _toggleVisibility: function(value) {
- var $element = this._element();
- if ($element)
- $element.css("display", value ? "" : "none")
- },
- _getPages: function(currentPage, count) {
- var pages = [],
- showMoreButton = !this.option("hasKnownLastPage"),
- firstValue,
- i;
- this._testPagesCount = count;
- this._testShowMoreButton = showMoreButton;
- if (count > 1 || showMoreButton)
- if (count <= this.option("maxPagesCount")) {
- for (i = 1; i <= count; i++)
- pages.push(new Page(i, i - 1));
- if (showMoreButton)
- pages.push(new Page('>', i - 1))
- }
- else {
- pages.push(new Page(1, 0));
- firstValue = currentPage ? currentPage.value() - currentPage.index : 1;
- for (i = 1; i <= PAGES_LIMITER; i++)
- pages.push(new Page(firstValue + i, i));
- pages.push(new Page(count, PAGES_LIMITER + 1));
- if (showMoreButton)
- pages.push(new Page('>', PAGES_LIMITER + 1))
- }
- return pages
- },
- _getPageByValue: function(value) {
- var that = this,
- page,
- i;
- for (i = 0; i < that._pages.length; i++) {
- page = that._pages[i];
- if (page.value() === value)
- return page
- }
- },
- _processSelectedPage: function(maxPagesCount, pageIndex, pagesCount) {
- var that = this,
- isPageIndexValid = false,
- selectedPageIndex;
- if (that._pages) {
- $.each(that._pages, function(key, page) {
- if (pageIndex === page.value())
- isPageIndexValid = true
- });
- if (!isPageIndexValid)
- that.selectedPage = null
- }
- if (utils.isDefined(that.selectedPage)) {
- if (pageIndex === pagesCount && pagesCount > maxPagesCount && that.selectedPage.index !== PAGES_LIMITER + 1)
- that.selectedPage.index = PAGES_LIMITER + 1
- }
- else if (pageIndex > PAGES_LIMITER && pageIndex < pagesCount) {
- selectedPageIndex = pagesCount - PAGES_LIMITER < pageIndex ? PAGES_LIMITER - (pagesCount - pageIndex) + 1 : 2;
- that.selectedPage = new Page(pageIndex, selectedPageIndex)
- }
- },
- _selectPageByValue: function(value) {
- var that = this,
- i,
- page = that._getPageByValue(value),
- pages = that._pages,
- pagesLength = pages.length,
- prevPage,
- nextPage,
- morePage;
- if (!utils.isDefined(page))
- return;
- prevPage = that._pages[page.index - 1];
- nextPage = that._pages[page.index + 1];
- if (nextPage && nextPage.value() === '>') {
- morePage = nextPage;
- nextPage = undefined;
- pagesLength--;
- pages.pop()
- }
- if (that.selectedPage)
- that.selectedPage.select(false);
- page.select(true);
- that.selectedPage = page;
- if (nextPage && nextPage.value() - value > 1)
- if (page.index !== 0) {
- prevPage.value(value + 1);
- that._pages.splice(page.index, 1);
- that._pages.splice(page.index - 1, 0, page);
- that._pages[page.index].index = page.index;
- page.index = page.index - 1;
- for (i = page.index - 1; i > 0; i--)
- that._pages[i].value(that._pages[i + 1].value() - 1)
- }
- else
- for (i = 0; i < pagesLength - 1; i++)
- that._pages[i].value(i + 1);
- if (prevPage && value - prevPage.value() > 1)
- if (page.index !== pagesLength - 1) {
- nextPage.value(value - 1);
- that._pages.splice(page.index, 1);
- that._pages.splice(page.index + 1, 0, page);
- that._pages[page.index].index = page.index;
- page.index = page.index + 1;
- for (i = page.index + 1; i < pagesLength - 1; i++)
- that._pages[i].value(that._pages[i - 1].value() + 1)
- }
- else
- for (i = 1; i <= pagesLength - 2; i++)
- that._pages[pagesLength - 1 - i].value(that._pages[pagesLength - 1].value() - i);
- if (morePage)
- pages.push(morePage)
- },
- _renderPagesChooser: function() {
- var that = this,
- page,
- pageIndexChanged = that.option("pageIndexChanged"),
- i,
- $element = that._element();
- if (!$element)
- return;
- that._clickPagesIndexAction = that._createAction(function(args) {
- var e = args.jQueryEvent,
- pageNumber = $(e.target).text(),
- pageIndex = pageNumber === '>' ? that.option("pagesCount") + 1 : Number(pageNumber);
- that._testPageIndex = pageIndex;
- that.option("pageIndex", pageIndex);
- pageIndexChanged(pageIndex)
- });
- if (utils.isDefined(that.pagesChooserElement))
- that.pagesChooserElement.empty();
- else
- that.pagesChooserElement = $('<div />').addClass(PAGER_PAGES_CLASS).on(events.addNamespace("dxclick", that.Name + "Pages"), '.' + PAGER_PAGE_CLASS, function(e) {
- that._clickPagesIndexAction({jQueryEvent: e})
- });
- if (that._pages.length === 0) {
- that.selectedPage = null;
- return
- }
- for (i = 0; i < that._pages.length; i++) {
- page = that._pages[i];
- page.render(that.pagesChooserElement, that.option('rtlEnabled'));
- if (that._pages[i + 1] && that._pages[i + 1].value() - page.value() > 1) {
- var $separator = $('<div>. . .</div>').addClass(PAGER_PAGE_SEPARATOR_CLASS).attr('style', '-webkit-user-select: none');
- that.option('rtlEnabled') ? $separator.prependTo(that.pagesChooserElement) : $separator.appendTo(that.pagesChooserElement)
- }
- }
- if (!utils.isDefined(that.pagesChooserElement[0].parentElement))
- that.pagesChooserElement.appendTo($element)
- },
- _renderPagesSizeChooser: function() {
- var that = this,
- i,
- pageSizeElement,
- currentPageSize = that.option("pageSize"),
- pageSizes = that.option("pageSizes"),
- showPageSizes = that.option("showPageSizes"),
- pageSizeValue,
- pagesSizesLength = pageSizes && pageSizes.length,
- $element = that._element();
- if (!$element)
- return;
- that._clickPagesSizeAction = that._createAction(function(args) {
- var e = args.jQueryEvent;
- pageSizeValue = parseInt($(e.target).text());
- that._testPageSizeIndex = pageSizeValue;
- that.option("pageSize", pageSizeValue)
- });
- if (utils.isDefined(that.pagesSizeChooserElement))
- that.pagesSizeChooserElement.empty();
- else
- that.pagesSizeChooserElement = $('<div />').addClass(PAGER_PAGE_SIZES_CLASS).on(events.addNamespace("dxclick", that.Name + "PageSize"), '.' + PAGER_PAGE_SIZE_CLASS, function(e) {
- that._clickPagesSizeAction({jQueryEvent: e})
- });
- if (!showPageSizes || !pagesSizesLength)
- return;
- that._testCurrentPageSize = currentPageSize;
- for (i = 0; i < pagesSizesLength; i++) {
- pageSizeElement = $('<div />').text(pageSizes[i]).addClass(PAGER_PAGE_SIZE_CLASS);
- if (currentPageSize === pageSizes[i])
- pageSizeElement.addClass(PAGER_SELECTION_CLASS);
- that.option('rtlEnabled') ? that.pagesSizeChooserElement.prepend(pageSizeElement) : that.pagesSizeChooserElement.append(pageSizeElement)
- }
- if (!utils.isDefined(that.pagesSizeChooserElement[0].parentElement))
- that.pagesSizeChooserElement.appendTo($element)
- },
- _render: function() {
- this._update();
- this._element().addClass(PAGER_CLASS);
- this._toggleVisibility(this.option("visible"));
- this._renderPagesSizeChooser();
- this._renderPagesChooser()
- },
- _update: function() {
- var pagesCount = this.option("pagesCount"),
- pageIndex = this.option("pageIndex");
- this._processSelectedPage(this.option("maxPagesCount"), pageIndex, pagesCount);
- this._pages = this._getPages(this.selectedPage, pagesCount);
- this._selectPageByValue(pageIndex)
- },
- _optionChanged: function(name, value) {
- switch (name) {
- case"visible":
- this._toggleVisibility(value);
- break;
- case"pageIndex":
- case"maxPagesCount":
- case"pagesCount":
- case"hasKnownLastPage":
- this._update();
- this._renderPagesChooser();
- break;
- case"pageSize":
- var pageSizeChanged = this.option("pageSizeChanged");
- if (pageSizeChanged)
- pageSizeChanged(value);
- case"pageSizes":
- this._renderPagesSizeChooser();
- break;
- default:
- this._invalidate()
- }
- },
- getHeight: function() {
- return this.option("visible") ? this._element().outerHeight() : 0
- }
- }));
- ui.dxPager.__internals = {
- PAGER_CLASS: PAGER_CLASS,
- PAGER_PAGE_CLASS: PAGER_PAGE_CLASS,
- PAGER_PAGES_CLASS: PAGER_PAGES_CLASS,
- PAGER_SELECTION_CLASS: PAGER_SELECTION_CLASS,
- PAGER_PAGE_SEPARATOR_CLASS: PAGER_PAGE_SEPARATOR_CLASS,
- PAGER_PAGE_SIZES_CLASS: PAGER_PAGE_SIZES_CLASS,
- PAGER_PAGE_SIZE_CLASS: PAGER_PAGE_SIZE_CLASS
- }
- })(jQuery, DevExpress);
- /*! Module widgets-web, file ui.colorPicker.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- events = ui.events,
- utils = DX.utils;
- var COLOR_PICKER_CLASS = "dx-color-picker",
- COLOR_PICKER_INPUT_CONTAINER_CLASS = "dx-color-picker-input-container",
- COLOR_PICKER_INPUT_CLASS = "dx-color-picker-input",
- COLOR_PICKER_COLOR_RESULT_PREVIEW = "dx-color-picker-color-result-preview",
- COLOR_PICKER_OVERLAY_CLASS = "dx-color-picker-overlay",
- COLOR_PICKER_OVERLAY_WITHOUT_ALPHA_CHANNEL_CLASS = "dx-color-picker-without-alpha-channel",
- COLOR_PICKER_CONTAINER_CLASS = "dx-color-picker-container",
- COLOR_PICKER_ROW_CLASS = "dx-color-picker-container-row",
- COLOR_PICKER_CELL_CLASS = "dx-color-picker-container-cell",
- COLOR_PICKER_PALETTE_CLASS = "dx-color-picker-palette",
- COLOR_PICKER_PALETTE_GRADIENT_CLASS = "dx-color-picker-palette-gradient",
- COLOR_PICKER_PALETTE_GRADIENT_WHITE_CLASS = "dx-white",
- COLOR_PICKER_PALETTE_GRADIENT_BLACK_CLASS = "dx-black",
- COLOR_PICKER_HUE_SCALE_CLASS = "dx-color-picker-hue-scale",
- COLOR_PICKER_HUE_SCALE_HANDLE_CLASS = "dx-color-picker-hue-scale-handle",
- COLOR_PICKER_HUE_SCALE_WRAPPER_CLASS = "dx-hue-scale-wrapper",
- COLOR_PICKER_CONTROLS_CONTAINER_CLASS = "dx-color-picker-controls-container",
- COLOR_PICKER_BUTTONS_CONTAINER_CLASS = "dx-color-picker-buttons-container",
- COLOR_PICKER_APPLY_BUTTON_CLASS = "dx-color-picker-apply-button",
- COLOR_PICKER_CANCEL_BUTTON_CLASS = "dx-color-picker-cancel-button",
- COLOR_PICKER_COLOR_CHOOSER_CLASS = "dx-color-picker-color-chooser",
- COLOR_PICKER_RED_LABEL_CLASS = "dx-color-picker-red-label",
- COLOR_PICKER_GREEN_LABEL_CLASS = "dx-color-picker-green-label",
- COLOR_PICKER_BLUE_LABEL_CLASS = "dx-color-picker-blue-label",
- COLOR_PICKER_HEX_LABEL_CLASS = "dx-color-picker-hex-label",
- COLOR_PICKER_RED_INPUT_CLASS = "dx-color-picker-red-input",
- COLOR_PICKER_GREEN_INPUT_CLASS = "dx-color-picker-green-input",
- COLOR_PICKER_BLUE_INPUT_CLASS = "dx-color-picker-blue-input",
- COLOR_PICKER_HEX_INPUT_CLASS = "dx-color-picker-hex-input",
- COLOR_PICKER_ALPHA_CHANNEL_SCALE_WRAPPER_CLASS = "dx-color-picker-alpha-scale-wrapper",
- COLOR_PICKER_ALPHA_CHANNEL_SCALE_CLASS = "dx-color-picker-alpha-scale",
- COLOR_PICKER_ALPHA_CHANNEL_INPUT_CLASS = "dx-color-picker-alpha-input",
- COLOR_PICKER_ALPHA_CHANNEL_LABEL_CLASS = "dx-color-picker-alpha-label",
- COLOR_PICKER_ALPHA_CHANNEL_HANDLE_CLASS = "dx-color-picker-alpha-handle",
- COLOR_PICKER_ALPHA_CHANNEL_CELL_CLASS = "dx-alpha-channel-cell",
- COLOR_PICKER_ALPHA_CHANNEL_BORDER_CLASS = "dx-alpha-channel-border",
- COLOR_PICKER_COLOR_PREVIEW_CONTAINER_CLASS = "dx-color-picker-color-preview-container",
- COLOR_PICKER_COLOR_PREVIEW_CONTAINER_INNER_CLASS = "dx-color-picker-color-preview-container-inner",
- COLOR_PICKER_COLOR_PREVIEW = "dx-color-preview",
- COLOR_PICKER_CURRENT_COLOR_PREVIEW = "dx-current-color",
- COLOR_PICKER_NEW_COLOR_PREVIEW = "dx-new-color";
- $.fn.colorPickerDrag = function(options) {
- return this.each(function(i, el) {
- var getCoordinatesFork = function() {
- var Xmax,
- Xmin,
- Ymax,
- Ymin;
- var deltaX = parentWidth - halfOfElWidth,
- deltaY = parentHeight - halfOfElHeight;
- if (options.enableStripHalfOfWidth) {
- Xmin = 0;
- Xmax = parentWidth
- }
- else {
- Xmin = halfOfElWidth;
- Xmax = deltaX
- }
- if (options.enableStripHalfOfHeight) {
- Ymin = 0;
- Ymax = parentHeight
- }
- else {
- Ymin = halfOfElHeight;
- Ymax = deltaY
- }
- return {
- x: {
- min: Xmin,
- max: Xmax
- },
- y: {
- min: Ymin,
- max: Ymax
- }
- }
- };
- var $base = $(el),
- $parent = $base.parent(),
- parentWidth = $parent.outerWidth(),
- parentHeight = $parent.outerHeight(),
- elHeight = $base.height(),
- elWidth = $base.width(),
- motionEnabled = false,
- halfOfElHeight = elHeight / 2,
- halfOfElWidth = elWidth / 2,
- coordinates = getCoordinatesFork();
- var defaultOptions = {
- enableVerticalMotion: true,
- enableHorizontalMotion: true,
- moveByClick: true,
- enableStripHalfOfWidth: false,
- enableStripHalfOfHeight: false,
- verticalMotionCallback: $.noop,
- horizontalMotionCallback: $.noop,
- _coordinatesUpdater: $.noop
- };
- options = $.extend(true, defaultOptions, options);
- var moveElement = function(event) {
- var x = options._coordinatesUpdater(event).x,
- y = options._coordinatesUpdater(event).y;
- changeElementPosition(x, y)
- };
- var changeElementPosition = function(x, y) {
- if (options.enableVerticalMotion) {
- if (y < coordinates.y.min)
- y = coordinates.y.min;
- if (y > coordinates.y.max)
- y = coordinates.y.max;
- $base.css("top", y - halfOfElHeight);
- options.verticalMotionCallback(y)
- }
- if (options.enableHorizontalMotion) {
- if (x < coordinates.x.min)
- x = coordinates.x.min;
- if (x > coordinates.x.max)
- x = coordinates.x.max;
- $base.css("right", "auto");
- $base.css("left", x - halfOfElWidth);
- options.horizontalMotionCallback(x)
- }
- };
- if (!options._coordinatesUpdater)
- options._coordinatesUpdater = function(event) {
- return {
- x: event.pageX - $parent.offset().left,
- y: event.pageY - $parent.offset().top
- }
- };
- $base.on(events.addNamespace("dxpointerdown", "dxColorPicker"), function() {
- motionEnabled = true
- });
- $("*").on(events.addNamespace("dxpointerup", "dxColorPicker"), function() {
- motionEnabled = false
- });
- $("body").on(events.addNamespace("dxpointermove", "dxColorPicker"), function(event) {
- if (motionEnabled) {
- event.preventDefault();
- event.stopPropagation();
- moveElement(event)
- }
- });
- if (options.moveByClick)
- $parent.on(events.addNamespace("dxpointerdown", "dxColorPicker"), function(event) {
- motionEnabled = true;
- moveElement(event)
- })
- })
- };
- var htmlCreator = {
- createElement: function(tagName, cssClass, $parent) {
- var el = document.createElement(tagName),
- $el = $(el);
- if (DX.utils.isArray(cssClass))
- cssClass = cssClass.join(" ");
- if (cssClass)
- $el.addClass(cssClass);
- if ($parent)
- return $el.appendTo($parent);
- else
- return $el
- },
- createHtmlRows: function(count) {
- var $rows = [];
- for (var i = 0; i < count; i++)
- $rows.push(this.createElement("div", COLOR_PICKER_ROW_CLASS));
- return $rows
- },
- createHtmlCellInsideRow: function(rowIndex, $rowParent, additionalClass) {
- var $row,
- $rows = $rowParent.find("." + COLOR_PICKER_ROW_CLASS);
- if (DX.utils.isNumber(rowIndex))
- $row = $rows.eq(rowIndex);
- else if (DX.utils.isString(rowIndex))
- $row = $rows[rowIndex]();
- var $cell = this.createElement("div", COLOR_PICKER_CELL_CLASS, $row);
- if (additionalClass)
- $cell.addClass(additionalClass);
- return $cell
- },
- createInputWithLabel: function(labelText, labelClass, inputClass) {
- return this.createElement("label", labelClass).text(labelText + ":").append(this.createElement("input", inputClass))
- }
- };
- var colorHelper = {makeCSSLinearGradient: function($el) {
- var color = this._currentColor,
- colorAsRgb = [color.r, color.g, color.b].join(","),
- colorAsHex = color.toHex().replace("#", "");
- var combineGradientString = function(colorAsRgb, colorAsHex) {
- var rtlEnabled = this.option("rtlEnabled"),
- startColor = "rgba(" + colorAsRgb + ", " + (rtlEnabled ? "1" : "0") + ")",
- finishColor = "rgba(" + colorAsRgb + ", " + (rtlEnabled ? "0" : "1") + ")",
- startColorIE = "'#" + (rtlEnabled ? "00" : "") + colorAsHex + "'",
- finishColorIE = "'#" + (rtlEnabled ? "" : "00") + colorAsHex + "'";
- return ["background-image: -webkit-linear-gradient(180deg, " + startColor + ", " + finishColor + ")", "background-image: -moz-linear-gradient(-90deg, " + startColor + ", " + finishColor + ")", "background-image: -ms-linear-gradient(-90deg, " + startColor + ", " + finishColor + ")", "background-image: -o-linear-gradient(-90deg, " + startColor + ", " + finishColor + ")", "background-image: linear-gradient(-90deg, " + startColor + ", " + finishColor + ")", "filter: progid:DXImageTransform.Microsoft.gradient(GradientType=1,startColorstr=" + startColorIE + ", endColorstr=" + finishColorIE + ")", "-ms-filter: progid:DXImageTransform.Microsoft.gradient(GradientType=1,startColorstr=" + startColorIE + ", endColorstr=" + finishColorIE + ")"].join(";")
- };
- $el.attr("style", combineGradientString.call(this, colorAsRgb, colorAsHex))
- }};
- DX.registerComponent("dxColorPicker", ui.dxDropDownEditor.inherit({
- _setDefaultOptions: function() {
- this.callBase();
- this.option({
- _dragCoordinatesUpdater: null,
- _standAlone: false,
- value: "#000000",
- editAlphaChannel: false,
- applyButtonText: Globalize.localize("OK"),
- cancelButtonText: Globalize.localize("Cancel")
- })
- },
- _setCurrentColor: function(value) {
- var newColor = new DX.Color(value);
- if (!newColor.colorIsInvalid) {
- this._currentColor = new DX.Color(value);
- this._alpha = this._currentColor.a
- }
- else
- this.option("value", this._currentColor.baseColor)
- },
- _initColorAndOpacity: function() {
- this._setCurrentColor(this.option("value"))
- },
- _init: function() {
- this.callBase();
- this._initColorAndOpacity()
- },
- _render: function() {
- this.callBase();
- this._element().addClass(COLOR_PICKER_CLASS);
- if (this.option("_standAlone")) {
- this._element().addClass("dx-standalone-colorpicker");
- this._element().find(".dx-dropdowneditor-button").trigger("dxclick")
- }
- },
- _optionChanged: function(name, value) {
- switch (name) {
- case"value":
- this._input().val(value);
- this._setCurrentColor(value);
- this._makeTransparentBackground(this._$colorResultPreview);
- this.callBase.apply(this, arguments);
- break;
- case"applyButtonText":
- this._$applyButton.dxButton("instance").option("text", value);
- break;
- case"cancelButtonText":
- this._$cancelButton.dxButton("instance").option("text", value);
- break;
- case"editAlphaChannel":
- if (this._$colorPickerContainer) {
- this._renderHtmlRows();
- this._toggleContainerClass();
- this._renderAlphaChannelElements()
- }
- break;
- default:
- this.callBase.apply(this, arguments)
- }
- },
- _handleValueChangeEvent: function(e) {
- if (this._dropDownVisible()) {
- this._setCurrentColor(this._input().val());
- this._refreshDropDown()
- }
- this.callBase(e)
- },
- _makeRgba: function() {
- return "rgba(" + [this._currentColor.r, this._currentColor.g, this._currentColor.b, this._alpha].join(", ") + ")"
- },
- _makeTransparentBackground: function($el) {
- if (DX.browser.msie && DX.browser.version === "8.0")
- $el.css({
- background: this._currentColor.toHex(),
- filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=" + this._alpha * 100 + ")"
- });
- else
- $el.css("backgroundColor", this._makeRgba())
- },
- _renderInput: function() {
- this._$colorPickerInputContainer = $("<div/>").addClass(COLOR_PICKER_INPUT_CONTAINER_CLASS);
- this._$colorResultPreview = htmlCreator.createElement("div", COLOR_PICKER_COLOR_RESULT_PREVIEW, this._$colorPickerInputContainer);
- this._makeTransparentBackground(this._$colorResultPreview);
- this.callBase(this._$colorPickerInputContainer);
- this._input().addClass(COLOR_PICKER_INPUT_CLASS)
- },
- _renderValue: function(formattedValue) {
- this.callBase(this.option("editAlphaChannel") ? this._makeRgba() : this.option("value"))
- },
- _closeOutsideDropDownHandler: function(e, ignoreContainerClicks) {
- this.callBase(e, true)
- },
- _hideOnBlur: function() {
- return false
- },
- _createDropDown: function() {
- var that = this;
- this.callBase({
- height: "",
- width: "",
- contentReadyAction: function() {
- that._createColorPickerContainer()
- }
- })
- },
- _showDropDown: function() {
- if (!this._dropDownVisible()) {
- this.callBase();
- this._refreshDropDown()
- }
- },
- _hideDropDown: function() {
- if (this._dropDownVisible()) {
- this._initColorAndOpacity();
- this.callBase()
- }
- },
- _calculateRowsCount: function() {
- var rowCount = this.option("editAlphaChannel") ? 3 : 2,
- $renderedRows = this._$colorPickerContainer.find("." + COLOR_PICKER_ROW_CLASS);
- if (this.option("editAlphaChannel") && $renderedRows.length === 2)
- rowCount = 1;
- if (!this.option("editAlphaChannel") && $renderedRows.length === 3)
- rowCount = 0;
- return rowCount
- },
- _renderHtmlRows: function() {
- var $renderedRows = this._$colorPickerContainer.find("." + COLOR_PICKER_ROW_CLASS),
- rowCount = this._calculateRowsCount($renderedRows);
- if (rowCount) {
- var $rows = htmlCreator.createHtmlRows(rowCount);
- if (rowCount === 1)
- this._$colorPickerContainer.find("." + COLOR_PICKER_ROW_CLASS).eq(0).after($rows);
- else
- this._$colorPickerContainer.append($rows)
- }
- else
- $renderedRows.eq(1).remove()
- },
- _toggleContainerClass: function() {
- this._$colorPickerContainer.toggleClass(COLOR_PICKER_OVERLAY_WITHOUT_ALPHA_CHANNEL_CLASS, !this.option("editAlphaChannel"))
- },
- _renderAlphaChannelElements: function() {
- if (this.option("editAlphaChannel")) {
- this._renderAlphaChannelScale();
- this._renderAlphaChannelInput()
- }
- },
- _createColorPickerContainer: function() {
- var $parent = this._dropDown.content();
- if (this.option("_standAlone")) {
- this._dropDown.hide();
- $parent = this._element()
- }
- else
- this._dropDown.content().addClass(COLOR_PICKER_OVERLAY_CLASS);
- this._$colorPickerContainer = htmlCreator.createElement("div", COLOR_PICKER_CONTAINER_CLASS, $parent);
- this._renderHtmlRows();
- this._toggleContainerClass();
- this._createPalette();
- this._renderHueScale();
- this._renderControlsContainer();
- this._renderControls();
- this._renderAlphaChannelElements();
- this._renderButtons()
- },
- _createPalette: function() {
- var $paletteCell = htmlCreator.createHtmlCellInsideRow("first", this._$colorPickerContainer, "dx-palette-cell"),
- $paletteGradientWhite = htmlCreator.createElement("div", [COLOR_PICKER_PALETTE_GRADIENT_CLASS, COLOR_PICKER_PALETTE_GRADIENT_WHITE_CLASS]),
- $paletteGradientBlack = htmlCreator.createElement("div", [COLOR_PICKER_PALETTE_GRADIENT_CLASS, COLOR_PICKER_PALETTE_GRADIENT_BLACK_CLASS]);
- this._$palette = htmlCreator.createElement("div", COLOR_PICKER_PALETTE_CLASS, $paletteCell).css("backgroundColor", this._currentColor.getPureColor().toHex());
- this._createColorChooser();
- this._$palette.append([$paletteGradientWhite, $paletteGradientBlack])
- },
- _updateColor: function(isHex) {
- var rgba,
- newColor;
- if (isHex)
- newColor = this._validateHex("#" + this._$hexInput.val());
- else {
- rgba = this._validateRgb();
- if (this._$alphaChannelInput) {
- rgba.push(this._$alphaChannelInput.val());
- newColor = "rgba(" + rgba.join(", ") + ")"
- }
- else
- newColor = "rgb(" + rgba.join(", ") + ")"
- }
- this._currentColor = new DX.Color(newColor);
- this._refreshDropDown()
- },
- _refreshDropDown: function() {
- this._placeHueMarker();
- this._placeColorChooser();
- this._updateColorParamsAndColorPreview();
- this._$palette.css("backgroundColor", this._currentColor.getPureColor().toHex());
- if (this._$alphaChannelHandle) {
- this._updateColorTransparence(this._currentColor.a);
- this._placeAlphaChannelHandle()
- }
- },
- _validateHex: function(hex) {
- return this._currentColor.isValidHex(hex) ? hex : this._currentColor.toHex()
- },
- _validateRgb: function() {
- var r = Number(this._$rgbInputs[0].val()),
- g = Number(this._$rgbInputs[1].val()),
- b = Number(this._$rgbInputs[2].val());
- if (!this._currentColor.isValidRGB(r, g, b)) {
- r = this._currentColor.r;
- g = this._currentColor.g;
- b = this._currentColor.b
- }
- return [r, g, b]
- },
- _placeHueMarker: function() {
- var hueScaleHeight = this._$hueScale.parent().outerHeight(),
- handleHeight = this._$hueScaleHandle.height();
- var top = hueScaleHeight - hueScaleHeight * this._currentColor.hsv.h / 360 - handleHeight / 2;
- if (hueScaleHeight < top + handleHeight)
- top = hueScaleHeight - handleHeight;
- if (top < 0)
- top = 0;
- this._$hueScaleHandle.css("top", Math.round(top))
- },
- _updateColorSaturation: function(value) {
- var hue = this._currentColor.hsv.h,
- saturation = Math.round(value * 100 / this._$palette.width()),
- value = this._currentColor.hsv.v;
- this._updateColorFromHsv(hue, saturation, value)
- },
- _updateColorValue: function(value) {
- var hue = this._currentColor.hsv.h,
- saturation = this._currentColor.hsv.s,
- value = 100 - Math.round(value * 100 / this._$palette.height());
- this._updateColorFromHsv(hue, saturation, value)
- },
- _updateColorHue: function(value) {
- var hue = 360 - Math.round((value + this._$hueScaleHandle.outerHeight() / 2) * 360 / this._$hueScale.height()),
- saturation = this._currentColor.hsv.s,
- value = this._currentColor.hsv.v;
- hue = hue < 0 ? 0 : hue;
- this._updateColorFromHsv(hue, saturation, value);
- this._$palette.css("backgroundColor", this._currentColor.getPureColor().toHex())
- },
- _updateColorTransparence: function(transparence) {
- this._$alphaChannelInput.val(transparence);
- this._alpha = transparence;
- this._makeTransparentBackground(this._$newColor)
- },
- _calculateColorTransparenceByScaleWidth: function(value) {
- var handleHalfWidth = this._$alphaChannelHandle.width() / 2,
- alphaScaleWidth = this._$alphaChannelScale.width(),
- rtlEnabled = this.option("rtlEnabled"),
- transparence = value / this._$alphaChannelScale.width();
- transparence = rtlEnabled ? transparence : 1 - transparence;
- if (handleHalfWidth === value)
- transparence = rtlEnabled ? 0 : 1;
- else if (value >= alphaScaleWidth - handleHalfWidth)
- transparence = rtlEnabled ? 1 : 0;
- else if (transparence < 1)
- transparence = transparence.toFixed(2);
- this._updateColorTransparence(transparence)
- },
- _updateColorFromHsv: function(hue, saturation, value) {
- this._currentColor = new DX.Color("hsv(" + [hue, saturation, value].join(",") + ")");
- this._updateColorParamsAndColorPreview()
- },
- _updateColorParamsAndColorPreview: function() {
- this._$hexInput.val(this._currentColor.toHex().replace("#", ""));
- this._$rgbInputs[0].val(this._currentColor.r);
- this._$rgbInputs[1].val(this._currentColor.g);
- this._$rgbInputs[2].val(this._currentColor.b);
- this._makeTransparentBackground(this._$newColor);
- if (this.option("editAlphaChannel"))
- colorHelper.makeCSSLinearGradient.call(this, this._$alphaChannelScale)
- },
- _createColorChooser: function() {
- this._$colorChooser = htmlCreator.createElement("div", COLOR_PICKER_COLOR_CHOOSER_CLASS, this._$palette).colorPickerDrag({
- verticalMotionCallback: $.proxy(this._updateColorValue, this),
- horizontalMotionCallback: $.proxy(this._updateColorSaturation, this),
- enableStripHalfOfWidth: true,
- enableStripHalfOfHeight: true,
- _coordinatesUpdater: this.option("_dragCoordinatesUpdater")
- });
- this._placeColorChooser()
- },
- _placeColorChooser: function() {
- var paletteHeight = this._$palette.height(),
- colorChooserPosition = {
- x: Math.round(this._$palette.width() * this._currentColor.hsv.s / 100 - this._$colorChooser.width() / 2),
- y: Math.round(paletteHeight - paletteHeight * this._currentColor.hsv.v / 100 - this._$colorChooser.height() / 2)
- };
- this._$colorChooser.css({
- left: colorChooserPosition.x,
- top: colorChooserPosition.y
- })
- },
- _renderHueScale: function() {
- var $hueScaleCell = htmlCreator.createHtmlCellInsideRow("first", this._$colorPickerContainer, "dx-hue-scale-cell");
- this._$hueScale = htmlCreator.createElement("div", COLOR_PICKER_HUE_SCALE_CLASS, $hueScaleCell);
- this._$hueScale.wrap("<div class=\"" + COLOR_PICKER_HUE_SCALE_WRAPPER_CLASS + "\"/>");
- this._renderHueScaleHandle()
- },
- _renderHueScaleHandle: function() {
- this._$hueScaleHandle = htmlCreator.createElement("div", COLOR_PICKER_HUE_SCALE_HANDLE_CLASS, this._$hueScale.closest("." + COLOR_PICKER_HUE_SCALE_WRAPPER_CLASS)).colorPickerDrag({
- enableHorizontalMotion: false,
- verticalMotionCallback: $.proxy(this._updateColorHue, this),
- _coordinatesUpdater: this.option("_dragCoordinatesUpdater")
- });
- this._placeHueMarker()
- },
- _renderControlsContainer: function() {
- var $controlsContainerCell = htmlCreator.createHtmlCellInsideRow("first", this._$colorPickerContainer);
- this._$controlsContainer = htmlCreator.createElement("div", COLOR_PICKER_CONTROLS_CONTAINER_CLASS, $controlsContainerCell)
- },
- _renderControls: function() {
- this._renderColorsPreview();
- this._renderRgbInputs();
- this._renderHexInput()
- },
- _renderButtons: function() {
- var $buttonContainerCell = htmlCreator.createHtmlCellInsideRow("last", this._$colorPickerContainer, "dx-buttons-cell");
- this._$buttonContainer = htmlCreator.createElement("div", COLOR_PICKER_BUTTONS_CONTAINER_CLASS, $buttonContainerCell);
- this._renderApplyButton();
- this._renderCancelButton()
- },
- _renderApplyButton: function() {
- this._$applyButton = htmlCreator.createElement("div", COLOR_PICKER_APPLY_BUTTON_CLASS, this._$buttonContainer).dxButton({
- text: this.option("applyButtonText"),
- clickAction: $.proxy(this._applyColor, this)
- })
- },
- _applyColor: function() {
- var colorValue = this.option("editAlphaChannel") ? this._makeRgba() : this._currentColor.toHex();
- this._input().val(colorValue);
- this._makeTransparentBackground(this._$colorResultPreview);
- this._makeTransparentBackground(this._$currentColor);
- this.option("value", colorValue);
- this._hideDropDown()
- },
- _cancelChanges: function() {
- if (!this.option("_standAlone"))
- this._hideDropDown();
- else {
- this._initColorAndOpacity();
- this._refreshDropDown()
- }
- },
- _renderCancelButton: function() {
- this._$cancelButton = htmlCreator.createElement("div", COLOR_PICKER_CANCEL_BUTTON_CLASS, this._$buttonContainer).dxButton({
- text: this.option("cancelButtonText"),
- clickAction: $.proxy(this._cancelChanges, this)
- })
- },
- _renderRgbInputs: function() {
- this._$rgbInputsWithLabels = [htmlCreator.createInputWithLabel("R", COLOR_PICKER_RED_LABEL_CLASS, COLOR_PICKER_RED_INPUT_CLASS), htmlCreator.createInputWithLabel("G", COLOR_PICKER_GREEN_LABEL_CLASS, COLOR_PICKER_GREEN_INPUT_CLASS), htmlCreator.createInputWithLabel("B", COLOR_PICKER_BLUE_LABEL_CLASS, COLOR_PICKER_BLUE_INPUT_CLASS)];
- this._$rgbInputs = [this._$rgbInputsWithLabels[0].find("input").val(this._currentColor.r).on("change", $.proxy(this._updateColor, this, false)), this._$rgbInputsWithLabels[1].find("input").val(this._currentColor.g).on("change", $.proxy(this._updateColor, this, false)), this._$rgbInputsWithLabels[2].find("input").val(this._currentColor.b).on("change", $.proxy(this._updateColor, this, false))];
- this._$controlsContainer.append(this._$rgbInputsWithLabels)
- },
- _renderHexInput: function() {
- var $hexInputWithLabel = htmlCreator.createInputWithLabel("#", COLOR_PICKER_HEX_LABEL_CLASS, COLOR_PICKER_HEX_INPUT_CLASS).appendTo(this._$controlsContainer);
- this._$hexInput = $hexInputWithLabel.find("input").val(this._currentColor.toHex().replace("#", "")).on("change", $.proxy(this._updateColor, this, true))
- },
- _renderColorsPreview: function() {
- var $colorsPreviewContainer = htmlCreator.createElement("div", COLOR_PICKER_COLOR_PREVIEW_CONTAINER_CLASS, this._$controlsContainer),
- $colorsPreviewContainerInner = htmlCreator.createElement("div", COLOR_PICKER_COLOR_PREVIEW_CONTAINER_INNER_CLASS, $colorsPreviewContainer);
- this._$currentColor = htmlCreator.createElement("div", [COLOR_PICKER_COLOR_PREVIEW, COLOR_PICKER_CURRENT_COLOR_PREVIEW]);
- this._$newColor = htmlCreator.createElement("div", [COLOR_PICKER_COLOR_PREVIEW, COLOR_PICKER_NEW_COLOR_PREVIEW]);
- this._makeTransparentBackground(this._$currentColor);
- this._makeTransparentBackground(this._$newColor);
- $colorsPreviewContainerInner.append([this._$currentColor, this._$newColor])
- },
- _renderAlphaChannelScale: function() {
- var $alphaChannelScaleCell = htmlCreator.createHtmlCellInsideRow(1, this._$colorPickerContainer, COLOR_PICKER_ALPHA_CHANNEL_CELL_CLASS),
- $alphaChannelBorder = htmlCreator.createElement("div", COLOR_PICKER_ALPHA_CHANNEL_BORDER_CLASS, $alphaChannelScaleCell),
- $alphaChannelScaleWrapper = htmlCreator.createElement("div", COLOR_PICKER_ALPHA_CHANNEL_SCALE_WRAPPER_CLASS, $alphaChannelBorder);
- this._$alphaChannelScale = htmlCreator.createElement("div", COLOR_PICKER_ALPHA_CHANNEL_SCALE_CLASS, $alphaChannelScaleWrapper);
- colorHelper.makeCSSLinearGradient.call(this, this._$alphaChannelScale);
- this._renderAlphaChannelHandle($alphaChannelScaleCell)
- },
- _renderAlphaChannelInput: function() {
- var that = this,
- $alphaChannelInputCell = htmlCreator.createHtmlCellInsideRow(1, this._$colorPickerContainer),
- $alphaChannelInputWithLabel = htmlCreator.createInputWithLabel("Alpha", COLOR_PICKER_ALPHA_CHANNEL_LABEL_CLASS, COLOR_PICKER_ALPHA_CHANNEL_INPUT_CLASS).appendTo($alphaChannelInputCell);
- this._$alphaChannelInput = $alphaChannelInputWithLabel.find("input").val(this._alpha).on("change", function() {
- var value = Number($(this).val());
- value = that._currentColor.isValidAlpha(value) ? value : that._alpha;
- that._updateColorTransparence(value);
- that._placeAlphaChannelHandle()
- })
- },
- _renderAlphaChannelHandle: function($parent) {
- this._$alphaChannelHandle = htmlCreator.createElement("div", COLOR_PICKER_ALPHA_CHANNEL_HANDLE_CLASS, $parent).colorPickerDrag({
- enableVerticalMotion: false,
- horizontalMotionCallback: $.proxy(this._calculateColorTransparenceByScaleWidth, this),
- _coordinatesUpdater: this.option("_dragCoordinatesUpdater")
- });
- this._placeAlphaChannelHandle()
- },
- _placeAlphaChannelHandle: function() {
- var alphaChannelScaleWidth = this._$alphaChannelScale.closest("." + COLOR_PICKER_ALPHA_CHANNEL_CELL_CLASS).outerWidth(),
- handleWidth = this._$alphaChannelHandle.width();
- var left = alphaChannelScaleWidth - alphaChannelScaleWidth * this._alpha - handleWidth / 2;
- if (left < 0)
- left = 0;
- if (alphaChannelScaleWidth < left + handleWidth)
- left = alphaChannelScaleWidth - handleWidth;
- this._$alphaChannelHandle.css(this.option("rtlEnabled") ? "right" : "left", left)
- }
- }))
- })(jQuery, DevExpress);
- /*! Module widgets-web, file ui.menuBase.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- utils = DX.utils,
- events = ui.events;
- var DX_MENU_CLASS = 'dx-menu',
- DX_MENU_ITEM_CLASS = DX_MENU_CLASS + '-item',
- DX_MENU_ITEM_HOVERED_CLASS = 'dx-state-hover',
- DX_MENU_ITEM_CAPTION_CLASS = DX_MENU_ITEM_CLASS + '-text',
- DX_MENU_ITEM_POPOUT_CLASS = DX_MENU_ITEM_CLASS + '-popout',
- DX_MENU_ITEM_POPOUT_CONTAINER_CLASS = DX_MENU_ITEM_POPOUT_CLASS + '-container',
- DX_MENU_ITEM_DISABLED_CLASS = DX_MENU_ITEM_CLASS + '-disabled',
- DX_MENU_ITEM_SELECTED_CLASS = DX_MENU_ITEM_CLASS + '-selected',
- DX_MENU_ITEM_WRAPPER_CLASS = DX_MENU_ITEM_CLASS + '-wrapper',
- DX_MENU_RTL_CLASS = DX_MENU_CLASS + '-rtl',
- DX_ICON_CLASS = 'dx-icon';
- var dxMenuBase = ui.CollectionContainerWidget.inherit({
- _itemRenderDefault: function(item, index, $itemElement) {
- var $itemContent,
- rtlEnabled;
- if (!utils.isDefined(item))
- return;
- if (item.visible !== undefined && !item.visible)
- $itemElement.hide();
- if (item.disabled)
- $itemElement.addClass(DX_MENU_ITEM_DISABLED_CLASS);
- rtlEnabled = !!this.option('rtlEnabled');
- if (rtlEnabled)
- $itemElement.addClass(DX_MENU_RTL_CLASS);
- $itemContent = $('<div>').addClass('dx-menu-item-content').appendTo($itemElement);
- this._renderImage(item, $itemContent);
- this._renderCaption(item, $itemContent);
- this._renderPopout(item, $itemContent)
- },
- _renderImage: function(item, $itemContent) {
- var $itemImage,
- $imageContainer;
- if (item.icon)
- $itemImage = $('<span>').addClass(DX_ICON_CLASS + "-" + item.icon).appendTo($itemContent);
- else if (item.iconSrc)
- $itemImage = $('<img>').attr('src', item.iconSrc).appendTo($itemContent);
- if ($itemImage)
- $itemImage.addClass(DX_ICON_CLASS)
- },
- _renderPopout: function(item, $itemContent) {
- var $popOutImage,
- $popOutContainer;
- if (this._hasChildren(item)) {
- $popOutContainer = $('<span>').addClass(DX_MENU_ITEM_POPOUT_CONTAINER_CLASS).appendTo($itemContent);
- $popOutImage = $('<div>').addClass(DX_MENU_ITEM_POPOUT_CLASS).appendTo($popOutContainer)
- }
- },
- _renderCaption: function(item, $itemContent) {
- var $itemCaption;
- $itemCaption = $('<span>').addClass(DX_MENU_ITEM_CAPTION_CLASS);
- if ($.isPlainObject(item)) {
- if (item.text)
- $itemCaption.text(item.text)
- }
- else
- $itemCaption.html(String(item));
- $itemContent.append($itemCaption)
- },
- _renderItemHotTrack: function($item, showHotTrack) {
- var $itemWrapper,
- menuItem;
- menuItem = $item.data(this._itemDataKey());
- if (menuItem == this.option('selectedItem') && showHotTrack)
- return;
- if (!!this.option('hoverStateEnabled')) {
- $itemWrapper = $item.parents('.' + DX_MENU_ITEM_WRAPPER_CLASS).eq(0);
- if ($itemWrapper.length)
- $itemWrapper.toggleClass(DX_MENU_ITEM_HOVERED_CLASS, showHotTrack)
- }
- },
- _itemDataKey: function() {
- return 'dxMenuItemDataKey'
- },
- _itemClass: function() {
- return DX_MENU_ITEM_CLASS
- },
- _itemWrapperSelector: function() {
- return '.' + DX_MENU_ITEM_WRAPPER_CLASS
- },
- _attachItemHoverEvents: function() {
- var itemSelector = this._itemWrapperSelector(),
- mouseEnterEventName,
- mouseLeaveEventName,
- itemMouseEnterAction = this._createAction($.proxy(function(e) {
- this._handleItemMouseEnter(e.jQueryEvent)
- }, this)),
- itemMouseLeaveAction = this._createAction($.proxy(function(e) {
- this._handleItemMouseLeave(e.jQueryEvent)
- }, this));
- mouseEnterEventName = events.addNamespace('mouseenter', this.NAME);
- mouseLeaveEventName = events.addNamespace('mouseleave', this.NAME);
- this._itemContainer().off(mouseEnterEventName, itemSelector).on(mouseEnterEventName, itemSelector, $.proxy(function(e) {
- itemMouseEnterAction({jQueryEvent: e})
- }, this));
- this._itemContainer().off(mouseLeaveEventName, itemSelector).on(mouseLeaveEventName, itemSelector, $.proxy(function(e) {
- itemMouseLeaveAction({jQueryEvent: e})
- }, this))
- },
- _handleItemMouseMove: function(eventArgs) {
- var that = this,
- $item = that._getItemElementByEventArgs(eventArgs);
- if (!that._itemX)
- that._itemX = 0;
- if (!that._itemY)
- that._itemY = 0;
- if (Math.abs(event.pageX - that._itemX) > 4 || Math.abs(event.pageY - that._itemY) > 4) {
- that._itemX = event.pageX;
- that._itemY = event.pageY;
- that._handleItemMouseMoveCore($item)
- }
- },
- _hasChildren: function(item) {
- return item.items && item.items.length > 0
- },
- _addCustomCssClass: function($element) {
- var cssClass = $.trim(this.option('cssClass'));
- if (cssClass)
- $element.addClass(cssClass)
- },
- _init: function() {
- var items = this.option('items');
- this.callBase();
- this.selectedItem = this.option('selectedItem');
- this.enableSelection = this.option('allowSelection');
- if (utils.isDefined(this.selectedItem) && this.selectedItem != null)
- return;
- this.selectedItem = this._getLastSelectedItem(items);
- if (this.selectedItem)
- this._setOptionInternal('selectedItem', this.selectedItem)
- },
- _setOptionInternal: function(name, value) {
- this._optionChangedInternalFlag = true;
- this.option(name, value);
- this._optionChangedInternalFlag = false
- },
- _getLastSelectedItem: function(items) {
- var that = this,
- selectedItem = null,
- nestedSelectedItem;
- $.each(items, function(_, item) {
- if (item) {
- if (item.selected && item.selectable)
- selectedItem = item;
- if (utils.isArray(item.items)) {
- nestedSelectedItem = that._getLastSelectedItem(item.items);
- if (nestedSelectedItem)
- selectedItem = nestedSelectedItem
- }
- }
- });
- return selectedItem
- },
- _updateSelectedItemOnClick: function($itemElement, itemData) {
- var prevSelItem = this.$selectedItemWrapper ? this.$selectedItemWrapper.children('.dx-menu-item').eq(0).data(this._itemDataKey()) : null,
- actionArgs = {
- selectedItem: itemData,
- previousSelectedItem: prevSelItem,
- itemElement: $itemElement,
- itemData: itemData
- },
- itemSelectAction = this._createActionByOption("itemSelectAction", actionArgs);
- if (this.option('allowSelectOnClick') && itemData.selectable) {
- if (this.$selectedItemWrapper) {
- this.$selectedItemWrapper.removeClass(DX_MENU_ITEM_SELECTED_CLASS);
- if (this.$selectedItemWrapper.children('.dx-menu-item').eq(0).data(this._itemDataKey()))
- this.$selectedItemWrapper.children('.dx-menu-item').eq(0).data(this._itemDataKey()).selected = false
- }
- this._setOptionInternal('selectedItem', null);
- this.$selectedItemWrapper = $itemElement.parents('.dx-menu-item-wrapper').eq(0);
- this.$selectedItemWrapper.addClass(DX_MENU_ITEM_SELECTED_CLASS);
- this._setOptionInternal('selectedItem', itemData);
- itemData.selected = true;
- itemSelectAction(actionArgs)
- }
- },
- _handleItemClick: function(e) {
- var itemClickActionHandler = this._createAction($.proxy(this._updateOverlayVisibilityOnClick, this));
- this._handleItemJQueryEvent(e, "itemClickAction", {}, {afterExecute: $.proxy(itemClickActionHandler, this)})
- },
- _getItemElementByEventArgs: function(eventArgs) {
- return $(eventArgs.currentTarget).children(this._itemSelector()).first()
- }
- });
- ui.dxMenuBase = dxMenuBase
- })(jQuery, DevExpress);
- /*! Module widgets-web, file ui.contextMenu.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- utils = DX.utils,
- events = ui.events,
- fx = DX.fx,
- DXMENU = 'dxContextMenu';
- var DX_MENU_CLASS = 'dx-menu',
- DX_MENU_ITEM_CLASS = DX_MENU_CLASS + '-item',
- DX_MENU_ITEM_POPOUT_CLASS = DX_MENU_ITEM_CLASS + '-popout',
- DX_MENU_ITEM_SELECTED_CLASS = DX_MENU_ITEM_CLASS + '-selected',
- DX_MENU_ITEM_HOVERED_CLASS = 'dx-state-hover',
- DX_MENU_PHONE_CLASS = 'dx-menu-phone-overlay',
- DX_MENU_ITEMS_CONTAINER_CLASS = DX_MENU_CLASS + '-items-container',
- DX_MENU_ITEM_WRAPPER_CLASS = DX_MENU_ITEM_CLASS + '-wrapper',
- DX_SUBMENU_CLASS = 'dx-submenu',
- DX_SUBMENU_LEVEL_ID = 'dxSubMenuLevel',
- DX_CONTEXT_MENU_CLASS = 'dx-context-menu',
- DX_WIDGET_CLASS = 'dx-widget',
- DX_MENU_SEPARATOR_CLASS = DX_MENU_CLASS + '-separator',
- DX_CONTEXT_MENU_CONTENT_DELIMITER_CLASS = DX_CONTEXT_MENU_CLASS + '-content-delimiter';
- DX.registerComponent("dxContextMenu", ui.dxMenuBase.inherit({
- _deprecatedOptions: {
- direction: {
- since: "14.1",
- message: "Use the 'submenuDirection' option instead."
- },
- allowSelectItem: {
- since: "14.1",
- message: "Use the 'allowSelection' option instead."
- }
- },
- _optionAliases: {
- direction: "submenuDirection",
- allowSelectItem: "allowSelection"
- },
- _setDefaultOptions: function() {
- this.callBase();
- this.option({
- items: [],
- showSubmenuMode: 'onHover',
- cssClass: '',
- invokeOnlyFromCode: false,
- position: {
- at: 'top left',
- my: 'top left'
- },
- hoverStateEnabled: true,
- allowSelection: true,
- allowSelectItem: true,
- allowSelectOnClick: true,
- selectedItem: null,
- itemSelectAction: null,
- animation: {
- show: {
- type: "fade",
- from: 0,
- to: 1,
- duration: 100
- },
- hide: {
- type: 'fade',
- from: 1,
- to: 0,
- duration: 100
- }
- },
- showingAction: null,
- shownAction: null,
- hidingAction: null,
- hiddenAction: null,
- positioningAction: null,
- submenuDirection: 'auto',
- direction: 'auto',
- visible: false,
- target: window
- })
- },
- _optionsByReference: function() {
- return $.extend(this.callBase(), {
- animation: true,
- position: true,
- selectedItem: true
- })
- },
- _itemContainer: function() {
- return this._overlay.content()
- },
- _clean: function() {
- if (this._overlay) {
- this._overlay._element().remove();
- this._overlay = null
- }
- this._target.off(events.addNamespace('dxhold', this.NAME));
- this._target.off(events.addNamespace('contextmenu', this.NAME))
- },
- _optionChanged: function(name, value) {
- if (this._optionChangedInternalFlag)
- return;
- switch (name) {
- case'visible':
- this._toggleVisibility(value);
- break;
- case'disable':
- break;
- case'invokeOnlyFromCode':
- break;
- case'items':
- if (this._overlay.option('visible'))
- this._overlay.toggle(false);
- this.selectedItem = this._getLastSelectedItem(value);
- this._setOptionInternal('selectedItem', this.selectedItem);
- this.callBase.apply(this, arguments);
- break;
- case'selectedItem':
- this.selectedItem = value;
- break;
- default:
- if (this._overlay.option('visible'))
- this._overlay.toggle(false);
- this.callBase.apply(this, arguments)
- }
- },
- _toggleVisibility: function(value) {
- value ? this.show() : this.hide()
- },
- _render: function() {
- this._target = $(this.option('target'));
- this.option('position');
- this.callBase()
- },
- _renderContentImpl: function() {
- this._renderContextMenuOverlay();
- this._renderAdditionGraphicsElements();
- this._attachItemHoverEvents();
- this._attachShowContextMenuEvents();
- this._addCustomCssClass(this._element());
- this.callBase()
- },
- _renderDimensions: function(){},
- _renderContextMenuOverlay: function() {
- var $overlayElement,
- $overlayContent,
- overlayOptions = this._getOverlayOptions();
- $overlayElement = $('<div>').appendTo(this._$element);
- $overlayElement.dxOverlay(overlayOptions);
- this._overlay = $overlayElement.dxOverlay('instance');
- $overlayContent = this._overlay.content();
- $overlayContent.addClass(DX_CONTEXT_MENU_CLASS).addClass(DX_WIDGET_CLASS);
- this._addCustomCssClass($overlayContent);
- this._addPlatformDependentClass($overlayContent);
- if (this.option('visible'))
- this.show()
- },
- _addPlatformDependentClass: function($element) {
- if (DX.devices.current().phone)
- $element.addClass(DX_MENU_PHONE_CLASS)
- },
- _renderAdditionGraphicsElements: function() {
- if (this.option('showAdditionalElements')) {
- this.$contentDelimiter = $('<div>').appendTo(this._itemContainer());
- this.$contentDelimiter.addClass(DX_CONTEXT_MENU_CONTENT_DELIMITER_CLASS);
- this.$contentDelimiter.css('position', 'absolute').css('display', 'none').css('z-index', '2000')
- }
- },
- _attachShowContextMenuEvents: function() {
- var that = this,
- holdEventName = events.addNamespace('dxhold', this.NAME),
- rightClickEventName = events.addNamespace('contextmenu', this.NAME),
- holdAction = this._createAction($.proxy(function(e) {
- if (!that.option('invokeOnlyFromCode'))
- if (e.jQueryEvent.originalEvent && e.jQueryEvent.originalEvent.pointerType !== 'mouse')
- that.show(e.jQueryEvent)
- }, this)),
- contextMenuAction = this._createAction($.proxy(function(e) {
- if (!that.option('invokeOnlyFromCode'))
- if (that.show(e.jQueryEvent)) {
- e.jQueryEvent.preventDefault();
- if (e.jQueryEvent.originalEvent)
- e.jQueryEvent.originalEvent.returnValue = false
- }
- }, this));
- this._target.off(holdEventName).on(holdEventName, $.proxy(function(e) {
- holdAction({jQueryEvent: e})
- }, this)).off(rightClickEventName).on(rightClickEventName, $.proxy(function(e) {
- contextMenuAction({jQueryEvent: e})
- }, this))
- },
- _renderItems: function(items) {
- var FIRST_SUBMENU_LEVEL = 1;
- this._renderSubMenu(items, this._itemContainer(), FIRST_SUBMENU_LEVEL)
- },
- _renderSubMenu: function(items, $holder, subMenuLevel) {
- var that = this,
- $subMenu,
- $itemsContainer,
- $itemWrapper,
- $item;
- if (items.length) {
- $subMenu = $('<div>').appendTo($holder);
- $subMenu.addClass(DX_SUBMENU_CLASS);
- $subMenu.data(DX_SUBMENU_LEVEL_ID, subMenuLevel);
- $subMenu.css('display', subMenuLevel === 1 ? 'block' : 'none');
- $itemsContainer = $('<ul>').appendTo($subMenu);
- $itemsContainer.addClass(DX_MENU_ITEMS_CONTAINER_CLASS);
- if (subMenuLevel === 1) {
- if (that.option('width'))
- $itemsContainer.css('min-width', that.option('width'));
- if (that.option('height'))
- $itemsContainer.css('min-height', that.option('height'))
- }
- $.each(items, function(index, item) {
- that._renderSeparator(item, index, $itemsContainer);
- $itemWrapper = $('<li>').appendTo($itemsContainer);
- $itemWrapper.addClass(DX_MENU_ITEM_WRAPPER_CLASS);
- $item = that._renderItem(index, item, $itemWrapper);
- if (that.option('allowSelection') && item === that.option('selectedItem')) {
- $itemWrapper.addClass(DX_MENU_ITEM_SELECTED_CLASS);
- that.$selectedItemWrapper = $itemWrapper
- }
- if (that._hasChildren(item))
- that._renderSubMenu(item.items, $item, ++subMenuLevel)
- })
- }
- },
- _renderSeparator: function(item, index, $itemsContainer) {
- var $separator;
- if (item.beginGroup && index > 0) {
- $separator = $('<li>').appendTo($itemsContainer);
- $separator.addClass(DX_MENU_SEPARATOR_CLASS)
- }
- },
- _showAdditionalGraphicsElements: function() {
- var $subMenu = this._itemContainer().children('.dx-submenu').eq(0),
- $rootItem = this.option('position').of,
- positionAt = this.option('position').at,
- positionMy = this.option('position').my,
- position = {of: $subMenu};
- if (this.$contentDelimiter) {
- this.$contentDelimiter.css('display', 'block');
- if (positionAt === 'left bottom' && positionMy === 'left top' || positionAt === 'right bottom' && positionMy === 'right top') {
- this.$contentDelimiter.width($rootItem.width() < $subMenu.width() ? $rootItem.width() - 2 : $subMenu.width() - 2);
- if (this._itemContainer().offset().top > $rootItem.offset().top) {
- this.$contentDelimiter.height(2);
- if (Math.round(this._itemContainer().offset().left) < Math.round($rootItem.offset().left)) {
- position.offset = '-1 -1';
- position.at = 'right top';
- position.my = 'right top'
- }
- else {
- position.offset = '1 -1';
- position.at = 'left top';
- position.my = 'left top'
- }
- }
- else {
- this.$contentDelimiter.height(3);
- if (Math.round(this._itemContainer().offset().left) < Math.round($rootItem.offset().left)) {
- position.offset = '-1 2';
- position.at = 'right bottom';
- position.my = 'right bottom'
- }
- else {
- position.offset = '1 2';
- position.at = 'left bottom';
- position.my = 'left bottom'
- }
- }
- }
- else {
- this.$contentDelimiter.width(2);
- this.$contentDelimiter.height($rootItem.height() < $subMenu.height() ? $rootItem.height() - 2 : $subMenu.height() - 2);
- if (this._itemContainer().offset().top < $rootItem.offset().top) {
- position.offset = positionAt === 'right top' ? '-1 -1' : '1 -1';
- position.at = positionAt === 'right top' ? 'left bottom' : 'right bottom';
- position.my = position.at
- }
- else {
- position.offset = positionAt === 'right top' ? '-1 1' : '1 1';
- position.at = positionMy;
- position.my = positionMy
- }
- }
- DX.position(this.$contentDelimiter, position)
- }
- },
- _getOverlayOptions: function() {
- var that = this,
- overlayAnimation = this.option('animation'),
- overlayOptions = {
- animation: overlayAnimation,
- closeOnOutsideClick: $.proxy(that._closeOnOutsideClickHandler, that),
- closeOnTargetScroll: true,
- deferRendering: false,
- disabled: this.option('disabled'),
- position: {
- at: this.option('position').at,
- my: this.option('position').my,
- of: this._target
- },
- shading: false,
- showTitle: false,
- height: 'auto',
- width: 'auto',
- rtlEnabled: this.option('rtlEnabled'),
- showingAction: $.proxy(that._overlayShowingActionHandler, that),
- shownAction: $.proxy(that._overlayShownActionHandler, that),
- hidingAction: $.proxy(that._overlayHidingActionHandler, that),
- hiddenAction: $.proxy(that._overlayHiddenActionHandler, that),
- positionedAction: $.proxy(that._overlayPositionedActionHandler, that)
- };
- return overlayOptions
- },
- _removeHoverClass: function() {
- var that = this,
- hovered_items = that._overlay._$container.find('.dx-state-hover');
- $.each(hovered_items, function(_, item) {
- $(item).removeClass(DX_MENU_ITEM_HOVERED_CLASS)
- })
- },
- _searchActiveItem: function(target) {
- return $(target).closest('.dx-menu-item').get(0)
- },
- _closeOnOutsideClickHandler: function(e) {
- var that = this,
- hovered_items = that._overlay._$container.find('.dx-state-hover'),
- clickedItem = undefined,
- sameUL = false,
- shownSubMenus = $.extend([], that._shownSubMenus),
- $subMenuElements,
- context;
- if (e.target === document) {
- this._removeHoverClass();
- return true
- }
- clickedItem = this._searchActiveItem(e.target);
- if (clickedItem !== undefined) {
- $.each(hovered_items, function(_, item) {
- if (clickedItem.parentElement.parentElement === item.parentElement)
- sameUL = true;
- if (sameUL && clickedItem.parentElement !== item)
- $(item).removeClass(DX_MENU_ITEM_HOVERED_CLASS)
- });
- if (this.option('showSubmenuMode') === 'onclick') {
- $subMenuElements = $(clickedItem).find('.dx-submenu');
- if ($subMenuElements.length > 0)
- $.each(shownSubMenus, function(_, $subMenu) {
- context = that._searchActiveItem($subMenu.context).parentElement;
- if (context.parentElement === $(clickedItem)[0].parentElement.parentElement && context !== $(clickedItem)[0].parentElement)
- that._hideChildrenSubMenus($subMenu)
- })
- }
- return false
- }
- else {
- this._removeHoverClass();
- return true
- }
- },
- _overlayShowingActionHandler: function(arg) {
- var action = this._createActionByOption('showingAction', {});
- action(arg)
- },
- _overlayShownActionHandler: function(arg) {
- var action = this._createActionByOption('shownAction', {});
- action(arg)
- },
- _overlayHidingActionHandler: function(arg) {
- var action = this._createActionByOption('hidingAction', {});
- action(arg);
- this._hideAllShownSubMenus()
- },
- _overlayHiddenActionHandler: function(arg) {
- var action = this._createActionByOption('hiddenAction', {});
- action(arg);
- this._setOptionInternal('visible', false)
- },
- _overlayPositionedActionHandler: function() {
- this._showAdditionalGraphicsElements()
- },
- _handleItemMouseEnter: function(eventArgs) {
- var that = this,
- mouseMoveEventName = events.addNamespace('mousemove', that.NAME),
- $itemElement = that._getItemElementByEventArgs(eventArgs),
- $subMenuElement = $itemElement.children('.dx-submenu'),
- showSubmenuMode = that.option('showSubmenuMode'),
- shownSubMenus = $.extend([], that._shownSubMenus),
- itemElement,
- itemWrapper,
- $itemWrapper = $itemElement.parents('.' + DX_MENU_ITEM_WRAPPER_CLASS).eq(0),
- hovered_items,
- sameOverlay;
- $.each(shownSubMenus, function(_, $subMenu) {
- itemElement = that._getItemElementByEventArgs(eventArgs);
- itemWrapper = $($subMenu.context);
- sameOverlay = false;
- if ($subMenu.context.parentElement === itemElement[0].parentElement.parentElement && $subMenu.context !== itemElement[0].parentElement) {
- hovered_items = that._overlay._$container.find('.dx-state-hover');
- $.each(hovered_items, function(_, item) {
- if (item.parentElement === itemWrapper.context.parentElement)
- sameOverlay = true;
- if (sameOverlay && item.parentElement !== itemWrapper.context.parentElement)
- $(item).removeClass(DX_MENU_ITEM_HOVERED_CLASS)
- });
- that._hideChildrenSubMenus($subMenu);
- itemWrapper.removeClass(DX_MENU_ITEM_HOVERED_CLASS)
- }
- });
- if ($itemElement.data(this._itemDataKey()).disabled)
- return;
- that._renderItemHotTrack($itemElement, true);
- if (this.option('showSubmenuMode') !== 'onclick')
- if ($subMenuElement.length > 0) {
- that._showSubMenuGroup($subMenuElement, $itemElement);
- $itemWrapper.addClass(DX_MENU_ITEM_HOVERED_CLASS);
- if (showSubmenuMode && showSubmenuMode.toLowerCase() === 'onhoverstay')
- $itemElement.off(mouseMoveEventName).on(mouseMoveEventName, function(e) {
- that._handleItemMouseMove(e)
- })
- }
- },
- _handleItemMouseLeave: function(eventArgs) {
- var that = this,
- $itemElement = that._getItemElementByEventArgs(eventArgs),
- $subMenuElement = $itemElement.children('.dx-submenu');
- if ($itemElement.data(this._itemDataKey()).disabled)
- return;
- if (!$subMenuElement.is(':visible'))
- that._renderItemHotTrack($itemElement, false)
- },
- _handleItemMouseMoveCore: function($item) {
- var $subMenuElement = $item.children('.dx-submenu');
- this._showSubMenuGroup($subMenuElement, $item)
- },
- _hideSubMenuGroup: function($subMenu) {
- var that = this;
- if (this._isSubMenuVisible($subMenu))
- that._hideSubMenuCore($subMenu)
- },
- _showSubMenuGroup: function($subMenu, $itemElement, forceRestartTimer) {
- var that = this;
- if (forceRestartTimer || !this._isSubMenuVisible($subMenu))
- that._showSubMenuCore($subMenu, that._getSubMenuPosition($itemElement))
- },
- _getSubMenuPosition: function($rootItem) {
- var isVerticalMenu,
- submenuDirection,
- rtlEnabled,
- position,
- $rootItemWrapper;
- rtlEnabled = !!this.option('rtlEnabled');
- submenuDirection = this.option('submenuDirection').toLowerCase();
- $rootItemWrapper = $rootItem.parent('.dx-menu-item-wrapper');
- position = {
- collision: 'flip',
- of: $rootItemWrapper,
- offset: {
- h: 0,
- v: -1
- }
- };
- switch (submenuDirection) {
- case'left':
- position.at = 'left top';
- position.my = 'right top';
- break;
- case'right':
- position.at = 'right top';
- position.my = 'left top';
- break;
- default:
- if (rtlEnabled) {
- position.at = 'left top';
- position.my = 'right top'
- }
- else {
- position.at = 'right top';
- position.my = 'left top'
- }
- break
- }
- return position
- },
- _isSubMenuVisible: function($subMenu) {
- return $subMenu.css('display') !== 'none'
- },
- _animate: function($container, options) {
- fx.animate($container, options)
- },
- _stopAnimate: function($container) {
- fx.stop($container, true)
- },
- _showSubMenuCore: function($subMenu, position) {
- var animation = this.option('animation') ? this.option('animation').show : {};
- if (this._overlay && this._overlay.option('visible')) {
- if (!utils.isDefined(this._shownSubMenus))
- this._shownSubMenus = [];
- if ($.inArray($subMenu, this._shownSubMenus))
- this._shownSubMenus.push($subMenu);
- $subMenu.css('display', 'block');
- DevExpress.position($subMenu, position);
- this._stopAnimate($subMenu);
- this._animate($subMenu, animation)
- }
- },
- _hideSubMenuCore: function($subMenu) {
- var index = $.inArray($subMenu, this._shownSubMenus),
- animation = this.option('animation') ? this.option('animation').hide : {};
- if (index >= 0)
- this._shownSubMenus.splice(index, 1);
- this._stopAnimate($subMenu);
- this._animate($subMenu, animation.hide);
- $subMenu.css('display', 'none')
- },
- _updateOverlayVisibilityOnClick: function(actionArgs) {
- var $itemElement,
- $subMenuElement;
- if (actionArgs.args.length && actionArgs.args[0]) {
- actionArgs.args[0].jQueryEvent.stopPropagation();
- $itemElement = actionArgs.args[0].itemElement;
- $subMenuElement = $itemElement.children('.dx-submenu');
- if ($itemElement.context === $subMenuElement.context && $subMenuElement.is(":visible"))
- return;
- if (!$itemElement.data(this._itemDataKey()) || $itemElement.data(this._itemDataKey()).disabled)
- return;
- this._updateSelectedItemOnClick($itemElement, actionArgs.args[0].itemData);
- if ($subMenuElement.length === 0) {
- var $prevSubMenu = $($itemElement.parents('.dx-submenu')[0]);
- this._hideChildrenSubMenus($prevSubMenu);
- if (!actionArgs.canceled && this._overlay && this._overlay.option('visible'))
- this.option('visible', false)
- }
- else {
- if (this._shownSubMenus && this._shownSubMenus.length > 0)
- if (this._shownSubMenus[0].is($subMenuElement) || this._shownSubMenus[0].has($subMenuElement).length === 1)
- this._hideChildrenSubMenus($subMenuElement);
- else
- this._hideAllShownSubMenus();
- this._showSubMenuGroup($subMenuElement, $itemElement)
- }
- }
- },
- _hideChildrenSubMenus: function($curSubMenu) {
- var that = this,
- shownSubMenus = $.extend([], that._shownSubMenus);
- $.each(shownSubMenus, function(_, $subMenu) {
- if ($curSubMenu.is($subMenu) || $curSubMenu.has($subMenu).length)
- that._hideSubMenuCore($subMenu)
- })
- },
- _hideAllShownSubMenus: function() {
- var that = this,
- shownSubMenus = $.extend([], that._shownSubMenus);
- $.each(shownSubMenus, function(_, $subMenu) {
- that._hideSubMenuCore($subMenu)
- })
- },
- show: function(jqueryEvent) {
- var position = this.option('position'),
- actionArgs,
- positioningAction;
- if (jqueryEvent && jqueryEvent.preventDefault)
- position = {
- at: 'top left',
- my: 'top left',
- of: jqueryEvent
- };
- if (!position.of)
- position.of = this._target;
- actionArgs = {
- position: position,
- jQueryEvent: jqueryEvent
- };
- positioningAction = this._createActionByOption('positioningAction', actionArgs);
- positioningAction(actionArgs);
- if (!actionArgs.canceled && this._overlay) {
- if (position) {
- this._overlay.option('position', null);
- this._overlay.option('position', position)
- }
- this._overlay.toggle(true);
- this._setOptionInternal('visible', true)
- }
- return this.option('visible')
- },
- hide: function() {
- if (this._overlay) {
- this._overlay.toggle(false);
- this._setOptionInternal('visible', false)
- }
- }
- }))
- })(jQuery, DevExpress);
- /*! Module widgets-web, file ui.menu.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- utils = DX.utils,
- events = ui.events,
- fx = DX.fx,
- DIV = '<div />',
- UL = '<ul />',
- DXMENU = 'dxMenu',
- DURATION = 50;
- var DX_MENU_CLASS = 'dx-menu',
- DX_MENU_VERTICAL_CLASS = DX_MENU_CLASS + '-vertical',
- DX_MENU_HORIZONTAL_CLASS = DX_MENU_CLASS + '-horizontal',
- DX_MENU_ITEM_CLASS = DX_MENU_CLASS + '-item',
- DX_MENU_ITEM_SELECTED_CLASS = DX_MENU_ITEM_CLASS + '-selected',
- DX_MENU_ITEMS_CONTAINER_CLASS = DX_MENU_CLASS + '-items-container',
- DX_MENU_ITEM_WITH_SUBMENU_CLASS = DX_MENU_ITEM_CLASS + '-with-submenu',
- DX_MENU_ITEM_WRAPPER_CLASS = DX_MENU_ITEM_CLASS + '-wrapper',
- DX_CONTEXT_MENU_CLASS = 'dx-context-menu',
- DX_MENU_SEPARATOR_CLASS = DX_MENU_CLASS + '-separator',
- DX_CONTEXT_MENU_CONTAINER_BORDER_CLASS = DX_CONTEXT_MENU_CLASS + '-container-border';
- DX.registerComponent("dxMenu", ui.dxMenuBase.inherit({
- _deprecatedOptions: {
- firstSubMenuDirection: {
- since: "14.1",
- message: "Use the 'submenuDirection' option instead."
- },
- showPopupMode: {
- since: "14.1",
- message: "Use the 'showFirstSubmenuMode' option instead."
- },
- allowSelectItem: {
- since: "14.1",
- message: "Use the 'allowSelection' option instead."
- }
- },
- _optionAliases: {
- firstSubMenuDirection: "submenuDirection",
- showPopupMode: "showFirstSubmenuMode",
- allowSelectItem: "allowSelection"
- },
- _setDefaultOptions: function() {
- this.callBase();
- this.option({
- orientation: 'horizontal',
- submenuDirection: 'auto',
- firstSubMenuDirection: 'auto',
- showFirstSubmenuMode: 'onclick',
- showPopupMode: 'onclick',
- showSubmenuMode: 'auto',
- items: [],
- hoverStateEnabled: true,
- allowSelection: true,
- allowSelectItem: true,
- allowSelectOnClick: true,
- selectedItem: null,
- cssClass: '',
- animation: {
- show: {
- type: "fade",
- from: 0,
- to: 1,
- duration: 100
- },
- hide: {
- type: 'fade',
- from: 1,
- to: 0,
- duration: 100
- }
- },
- submenuShowingAction: null,
- submenuShownAction: null,
- submenuHidingAction: null,
- submenuHiddenAction: null,
- itemSelectAction: null
- })
- },
- _optionsByReference: function() {
- return $.extend(this.callBase(), {
- animation: true,
- selectedItem: true
- })
- },
- _render: function() {
- this.callBase();
- this._element().addClass(DX_MENU_CLASS);
- this._addCustomCssClass(this._element());
- this._attachItemHoverEvents()
- },
- _renderItems: function(items) {
- var that = this,
- isVerticalMenu,
- $rootGroup,
- $itemsContainer,
- $itemWrapper,
- $item,
- $popupMenu,
- $separator;
- if (items.length) {
- isVerticalMenu = that.option('orientation') === 'vertical';
- $rootGroup = $('<div>').appendTo(that._$element);
- $rootGroup.addClass(isVerticalMenu ? DX_MENU_VERTICAL_CLASS : DX_MENU_HORIZONTAL_CLASS);
- $itemsContainer = $('<ul>').appendTo($rootGroup);
- $itemsContainer.addClass(DX_MENU_ITEMS_CONTAINER_CLASS);
- $itemsContainer.css('min-height', this._getValueHeight($rootGroup));
- $.each(items, function(index, item) {
- that._renderSeparator(item, index, $itemsContainer);
- $itemWrapper = $('<li>').appendTo($itemsContainer);
- $itemWrapper.addClass(DX_MENU_ITEM_WRAPPER_CLASS);
- $item = that._renderItem(index, item, $itemWrapper);
- that._renderSelectedItem(item, $itemWrapper);
- that._renderChildrenItems(item, $item)
- })
- }
- },
- _renderSeparator: function(item, index, $itemsContainer) {
- var $separator;
- if (item.beginGroup && index > 0) {
- $separator = $('<li>').appendTo($itemsContainer);
- $separator.addClass(DX_MENU_SEPARATOR_CLASS)
- }
- },
- _renderSelectedItem: function(item, $itemWrapper) {
- if (this.option('allowSelection'))
- if (item === this.option("selectedItem")) {
- $itemWrapper.addClass(DX_MENU_ITEM_SELECTED_CLASS);
- this.$selectedItemWrapper = $itemWrapper
- }
- },
- _renderChildrenItems: function(item, $item) {
- if (this._hasChildren(item)) {
- this._createPopupMenu(item.items, $item, this.option("selectedItem")).appendTo($item);
- this._renderBorderElement($item)
- }
- },
- _renderBorderElement: function($item) {
- var $border = $('<div>').appendTo($item);
- $border.addClass(DX_CONTEXT_MENU_CONTAINER_BORDER_CLASS);
- $border.css('display', 'none')
- },
- _getValueHeight: function($root) {
- var $div = $("<div>").html("Jj").css({
- width: "auto",
- position: "fixed",
- top: "-3000px",
- left: "-3000px"
- }).appendTo($root),
- height = $div.height();
- $div.remove();
- return height
- },
- _handleItemMouseEnter: function(eventArg) {
- var that = this,
- DX_MENU_HOVERSTAY_TIMEOUT = 300,
- mouseMoveEventName,
- $item,
- popupMenu,
- showFirstSubmenuMode,
- isHoverStayMode;
- $item = that._getItemElementByEventArgs(eventArg);
- if ($item.data(this._itemDataKey()).disabled)
- return;
- that._renderItemHotTrack($item, true);
- popupMenu = that._getPopupMenuByRootElement($item);
- showFirstSubmenuMode = that.option('showFirstSubmenuMode').toLowerCase();
- if (showFirstSubmenuMode !== 'onclick' && popupMenu) {
- clearTimeout(that._hidePopupMenuTimer);
- clearTimeout(that._showPopupMenuTimer);
- isHoverStayMode = that.option('showFirstSubmenuMode') !== 'onhover';
- if (isHoverStayMode && that.visiblePopupMenu == popupMenu && !popupMenu._overlay.option('visible')) {
- mouseMoveEventName = events.addNamespace('mousemove', that.NAME);
- $item.off(mouseMoveEventName).on(mouseMoveEventName, $.proxy(that._handleItemMouseMove, that));
- that._showPopupMenuTimer = setTimeout(function() {
- that._showPopupMenu(popupMenu, $item)
- }, DX_MENU_HOVERSTAY_TIMEOUT)
- }
- else
- that._showPopupMenu(popupMenu, $item)
- }
- },
- _handleItemMouseLeave: function(eventArg) {
- var that = this,
- DX_MENU_HOVER_TIMEOUT = 50,
- DX_MENU_HOVERSTAY_TIMEOUT = 300,
- $item,
- popupMenu,
- showFirstSubmenuMode,
- timeout;
- showFirstSubmenuMode = that.option('showFirstSubmenuMode').toLowerCase();
- timeout = that.option('showFirstSubmenuMode') !== 'onhover' ? DX_MENU_HOVERSTAY_TIMEOUT : DX_MENU_HOVER_TIMEOUT;
- $item = that._getItemElementByEventArgs(eventArg);
- if ($item.data(this._itemDataKey()).disabled)
- return;
- that._renderItemHotTrack($item, false);
- if (showFirstSubmenuMode !== 'onclick') {
- clearTimeout(that._showPopupMenuTimer);
- clearTimeout(that._hidePopupMenuTimer);
- that._hidePopupMenuTimer = setTimeout(function() {
- popupMenu = that._getPopupMenuByRootElement($item);
- that._hidePopupMenu(popupMenu);
- if (that.visiblePopupMenu == popupMenu)
- that.visiblePopupMenu = null
- }, timeout)
- }
- },
- _handleItemMouseMoveCore: function($item) {
- var that = this,
- DX_MENU_HOVERSTAY_TIMEOUT = 300,
- popupMenu;
- if (that._showPopupMenuTimer) {
- clearTimeout(that._hidePopupMenuTimer);
- clearTimeout(that._showPopupMenuTimer);
- popupMenu = that._getPopupMenuByRootElement($item),
- that._showPopupMenuTimer = setTimeout(function() {
- that._showPopupMenu(popupMenu, $item)
- }, DX_MENU_HOVERSTAY_TIMEOUT)
- }
- },
- _updateOverlayVisibilityOnClick: function(actionArgs) {
- var that = this,
- $item,
- popupMenu;
- if (actionArgs.args.length && actionArgs.args[0]) {
- actionArgs.args[0].jQueryEvent.stopPropagation();
- $item = actionArgs.args[0].itemElement;
- if ($item.data(this._itemDataKey()).disabled)
- return;
- popupMenu = that._getPopupMenuByRootElement($item);
- this._updateSelectedItemOnClick($item, actionArgs.args[0].itemData);
- if (popupMenu)
- if (popupMenu._overlay.option('visible')) {
- if (that.option('showFirstSubmenuMode') === 'onclick')
- that._hidePopupMenu(popupMenu)
- }
- else
- that._showPopupMenu(popupMenu, $item)
- }
- },
- _createPopupMenu: function(items, $rootItem, nestedSelectedItem) {
- var that = this,
- popupMenu,
- $popupMenuContainer = $('<div>'),
- $popupMenuTarget = $('<div>'),
- $popupMenuOverlayContent,
- popupMenuMouseEnterName,
- popupMenuMouseLeaveName;
- popupMenuMouseEnterName = events.addNamespace('mouseenter', that.NAME + '_popupMenu');
- popupMenuMouseLeaveName = events.addNamespace('mouseleave', that.NAME + '_popupMenu');
- $popupMenuContainer.dxContextMenu({
- _templates: this.option("_templates"),
- target: $popupMenuTarget,
- items: items,
- position: that._getPopupMenuPosition($rootItem),
- showAdditionalElements: true,
- selectedItem: nestedSelectedItem,
- cssClass: this.option('cssClass'),
- animation: this.option('animation'),
- rtlEnabled: this.option('rtlEnabled'),
- disabled: this.option('disabled'),
- showSubmenuMode: this.option('showSubmenuMode') === 'auto' ? this.option('showFirstSubmenuMode') : this.option('showSubmenuMode'),
- itemSelectAction: $.proxy(this._nestedItemSelectActionHandler, this),
- itemClickAction: $.proxy(this._nestedItemClickActionHandler, this),
- showingAction: $.proxy(this._contextMenuShowingActionHandler, this, $rootItem, popupMenu),
- shownAction: $.proxy(this._contextMenuShownActionHandler, this, $rootItem, popupMenu),
- hidingAction: $.proxy(this._contextMenuHidingActionHandler, this, $rootItem, popupMenu),
- hiddenAction: $.proxy(this._contextMenuHiddenActionHandler, this, $rootItem, popupMenu)
- });
- $popupMenuContainer.addClass(DX_CONTEXT_MENU_CLASS);
- popupMenu = $popupMenuContainer.dxContextMenu('instance');
- $popupMenuOverlayContent = popupMenu._overlay.content();
- $popupMenuOverlayContent.off(popupMenuMouseEnterName).on(popupMenuMouseEnterName, null, $.proxy(this._handlePopupMenuMouseEnter, this, $rootItem));
- $popupMenuOverlayContent.off(popupMenuMouseLeaveName).on(popupMenuMouseLeaveName, null, $.proxy(this._handlePopupMenuMouseLeave, this, $rootItem));
- return $popupMenuContainer
- },
- _getPopupMenuPosition: function($rootItem) {
- var isVerticalMenu,
- submenuDirection,
- rtlEnabled,
- popupMenuPosition;
- rtlEnabled = !!this.option('rtlEnabled');
- isVerticalMenu = this.option('orientation').toLowerCase() == 'vertical';
- submenuDirection = this.option('submenuDirection').toLowerCase();
- popupMenuPosition = {
- collision: 'flip',
- of: $rootItem
- };
- switch (submenuDirection) {
- case'leftOrTop':
- popupMenuPosition.at = isVerticalMenu ? 'left top' : 'left top';
- popupMenuPosition.my = isVerticalMenu ? 'right top' : 'left bottom';
- break;
- case'rightOrBottom':
- popupMenuPosition.at = isVerticalMenu ? 'right top' : 'left bottom';
- popupMenuPosition.my = isVerticalMenu ? 'left top' : 'left top';
- break;
- case'auto':
- default:
- if (isVerticalMenu) {
- popupMenuPosition.at = rtlEnabled ? 'left top' : 'right top';
- popupMenuPosition.my = rtlEnabled ? 'right top' : 'left top'
- }
- else {
- popupMenuPosition.at = rtlEnabled ? 'right bottom' : 'left bottom';
- popupMenuPosition.my = rtlEnabled ? 'right top' : 'left top'
- }
- break
- }
- return popupMenuPosition
- },
- _nestedItemSelectActionHandler: function(arg) {
- this._updateSelectedItemOnClick(arg.itemElement, arg.itemData)
- },
- _nestedItemClickActionHandler: function(arg) {
- var action = this._createActionByOption('itemClickAction', {});
- action(arg)
- },
- _contextMenuShowingActionHandler: function($rootItem, popupMenu) {
- var action,
- $borderElt,
- animation;
- action = this._createActionByOption('submenuShowingAction', {});
- action({
- rootItem: $rootItem,
- popupMenu: popupMenu
- });
- $borderElt = $rootItem.children('.' + DX_CONTEXT_MENU_CONTAINER_BORDER_CLASS);
- if (this._options.width !== undefined)
- if (this._options.rtlEnabled)
- $borderElt.width(this._$element.width() - $rootItem.position().right);
- else
- $borderElt.width(this._$element.width() - $rootItem.position().left);
- $borderElt.css('display', 'block');
- DX.fx.stop($borderElt, true);
- animation = this.option('animation') ? this.option('animation').show : {};
- DX.fx.animate($borderElt, animation);
- $rootItem.addClass(DX_MENU_ITEM_WITH_SUBMENU_CLASS)
- },
- _contextMenuShownActionHandler: function($rootItem, popupMenu) {
- var action = this._createActionByOption('submenuShownAction', {});
- action({
- rootItem: $rootItem,
- popupMenu: popupMenu
- })
- },
- _contextMenuHidingActionHandler: function($rootItem, popupMenu) {
- var action,
- $borderElt,
- animation;
- action = this._createActionByOption('submenuHidingAction', {});
- action({
- rootItem: $rootItem,
- popupMenu: popupMenu
- });
- $borderElt = $rootItem.children('.' + DX_CONTEXT_MENU_CONTAINER_BORDER_CLASS);
- animation = this.option('animation') ? this.option('animation').hide : {};
- DX.fx.animate($borderElt, animation);
- $borderElt.css('display', 'none');
- $rootItem.removeClass(DX_MENU_ITEM_WITH_SUBMENU_CLASS)
- },
- _contextMenuHiddenActionHandler: function($rootItem, popupMenu) {
- var action = this._createActionByOption('submenuHiddenAction', {});
- action({
- rootItem: $rootItem,
- popupMenu: popupMenu
- })
- },
- _handlePopupMenuMouseEnter: function($rootItem) {
- this._hoveredPopupMenuContainer = $rootItem
- },
- _handlePopupMenuMouseLeave: function($rootItem) {
- var that = this,
- popupMenu,
- HOVER_TIMEOUT = 50;
- setTimeout(function() {
- if (!that._hoveredPopupMenuContainer || !that._hoveredPopupMenuContainer.is(that._hoveredRootItem)) {
- popupMenu = that._getPopupMenuByRootElement($rootItem);
- if (popupMenu)
- popupMenu.hide()
- }
- that._hoveredPopupMenuContainer = null
- }, HOVER_TIMEOUT)
- },
- _showPopupMenu: function(popupMenu, $popupMenuContainer) {
- if (utils.isDefined(this.visiblePopupMenu) && this.visiblePopupMenu !== popupMenu)
- this.visiblePopupMenu.hide();
- this._renderItemHotTrack($popupMenuContainer, false);
- popupMenu.show();
- this.visiblePopupMenu = popupMenu;
- this._hoveredRootItem = $popupMenuContainer
- },
- _hidePopupMenu: function(popupMenu) {
- if (!this._hoveredRootItem || !this._hoveredRootItem.is(this._hoveredPopupMenuContainer))
- if (popupMenu)
- popupMenu.hide();
- this._hoveredRootItem = null
- },
- _optionChanged: function(name, value) {
- if (this._optionChangedInternalFlag)
- return;
- if (this.visiblePopupMenu)
- this.visiblePopupMenu.hide();
- switch (name) {
- case'items':
- this.selectedItem = this._getLastSelectedItem(value);
- this._setOptionInternal('selectedItem', this.selectedItem);
- this.callBase.apply(this, arguments);
- break;
- case'selectedItem':
- this.selectedItem = value;
- break;
- default:
- this.callBase.apply(this, arguments)
- }
- },
- _getPopupMenuByRootElement: function($rootItem) {
- var popupMenu = null,
- $popupMenu;
- if ($rootItem) {
- $popupMenu = $rootItem.children('.dx-context-menu');
- if ($popupMenu.length > 0)
- popupMenu = $popupMenu.dxContextMenu('instance')
- }
- return popupMenu
- },
- _containNode: function(hierarchy, node) {
- var that = this,
- nestedResult = false,
- result = false;
- $.each(hierarchy, function(_, curNode) {
- if (curNode == node)
- result = true;
- if (curNode.items) {
- nestedResult = that._containNode(curNode.items, node);
- nestedResult ? result = nestedResult : result
- }
- });
- return result
- }
- }));
- ui.dxMenu.__internals = {MENU_AMIMATION_DURATION: DURATION}
- })(jQuery, DevExpress);
- /*! Module widgets-web, file ui.dataGrid.js */
- (function($, DX) {
- var ui = DX.ui,
- utils = DX.utils;
- var DATAGRID_ROW_SELECTOR = ".dx-row";
- var ModuleItem = DX.Class.inherit({
- ctor: function(component) {
- var that = this;
- that.component = component;
- that.disposing = component.disposing;
- that._actions = {};
- $.each(this.callbackNames() || [], function(index, name) {
- var flags = that.callbackFlags(name);
- that[this] = $.Callbacks(flags)
- })
- },
- callbackNames: function(){},
- callbackFlags: function(name){},
- publicMethods: function(){},
- init: function(){},
- option: function() {
- return this.component.option.apply(this.component, arguments)
- },
- optionChanged: function(name, value, prevValue){},
- getController: function(name) {
- return this.component._controllers[name]
- },
- getView: function(name) {
- return this.component._views[name]
- },
- createAction: function(actionName, config) {
- var action;
- if (utils.isFunction(actionName)) {
- action = this.component._createAction($.proxy(actionName, this), config);
- return function(e) {
- action({jQueryEvent: e})
- }
- }
- else
- this._actions[actionName] = this.option(actionName) ? this.component._createActionByOption(actionName, config) : null
- },
- executeAction: function(actionName, options) {
- var action = this._actions[actionName];
- return action && action(options)
- },
- dispose: function() {
- var that = this;
- $.each(that.callbackNames() || [], function() {
- that[this].empty()
- })
- }
- });
- var Controller = ModuleItem;
- var ViewController = Controller;
- var View = ViewController.inherit({
- _element: function() {
- return this._$element
- },
- _renderCore: function(options){},
- _afterRender: function($root){},
- _parentElement: function() {
- return this._$parent
- },
- ctor: function(component) {
- this.callBase(component);
- this.renderCompleted = $.Callbacks();
- this.resizeCompleted = $.Callbacks()
- },
- isVisible: function() {
- return true
- },
- getTemplate: function(name) {
- return this.component._getTemplate(name)
- },
- render: function($parent, options) {
- var $element = this._$element,
- isVisible = this.isVisible();
- this._$parent = $parent;
- if (!$element)
- $element = this._$element = $('<div />').appendTo($parent);
- $element.toggle(isVisible);
- if (isVisible) {
- this._renderCore(options);
- this._afterRender($parent);
- this.renderCompleted.fire()
- }
- },
- resize: function() {
- this.isResizing = true;
- this.resizeCompleted.fire();
- this.isResizing = false
- },
- focus: function() {
- this._element().focus()
- }
- });
- var processModules = function(that, modules) {
- var controllerTypes = {},
- viewTypes = {};
- that._controllers = {};
- that._views = {};
- $.each(modules, function() {
- var controllers = this.controllers,
- moduleName = this.name,
- views = this.views;
- controllers && $.each(controllers, function(name, type) {
- if (controllerTypes[name])
- throw'Module "' + moduleName + '". Controller "' + name + '" is already registered';
- else if (!(type && type.subclassOf && type.subclassOf(Controller))) {
- type.subclassOf(Controller);
- throw'Module "' + moduleName + '". Controller "' + name + '" must be inheritor of DevExpress.ui.dataGrid.Controller';
- }
- controllerTypes[name] = type
- });
- views && $.each(views, function(name, type) {
- if (viewTypes[name])
- throw'Module "' + moduleName + '". View "' + name + '" is already registered';
- else if (!(type && type.subclassOf && type.subclassOf(View)))
- throw'Module "' + moduleName + '". View "' + name + '" must be inheritor of DevExpress.ui.dataGrid.View';
- viewTypes[name] = type
- })
- });
- $.each(modules, function() {
- var extenders = this.extenders;
- if (extenders) {
- extenders.controllers && $.each(extenders.controllers, function(name, extender) {
- if (controllerTypes[name])
- controllerTypes[name] = controllerTypes[name].inherit(extender)
- });
- extenders.views && $.each(extenders.views, function(name, extender) {
- if (viewTypes[name])
- viewTypes[name] = viewTypes[name].inherit(extender)
- })
- }
- });
- var registerPublicMethods = function(that, name, moduleItem) {
- var publicMethods = moduleItem.publicMethods();
- if (publicMethods)
- $.each(publicMethods, function(index, methodName) {
- if (moduleItem[methodName])
- if (!that[methodName])
- that[methodName] = function() {
- return moduleItem[methodName].apply(moduleItem, arguments)
- };
- else
- throw'Public method "' + methodName + '" is already registered';
- else
- throw'Public method "' + name + '.' + methodName + '" is not exists';
- })
- };
- $.each(controllerTypes, function(name, controllerType) {
- var controller = new controllerType(that);
- controller.name = name;
- registerPublicMethods(that, name, controller);
- that._controllers[name] = controller
- });
- $.each(viewTypes, function(name, viewType) {
- var view = new viewType(that);
- view.name = name;
- registerPublicMethods(that, name, view);
- that._views[name] = view
- })
- };
- var dataGrid = ui.dataGrid = {
- __internals: {},
- modules: [],
- View: View,
- ViewController: ViewController,
- Controller: Controller,
- registerModule: function(name, module) {
- var modules = this.modules,
- i;
- for (i = 0; i < modules.length; i++)
- if (modules[i].name === name)
- return;
- module.name = name;
- modules.push(module)
- },
- unregisterModule: function(name) {
- this.modules = $.grep(this.modules, function(module) {
- return module.name !== name
- })
- },
- processModules: processModules
- };
- DX.registerComponent("dxDataGrid", ui.Widget.inherit(function() {
- return {
- _activeStateUnit: DATAGRID_ROW_SELECTOR,
- _deprecatedOptions: {"editing.texts.recoverRow": {
- since: "14.1",
- message: "Use the 'undeleteRow' option instead."
- }},
- _optionAliases: {"editing.texts.recoverRow": "editing.texts.undeleteRow"},
- _setDefaultOptions: function() {
- var that = this;
- that.callBase();
- $.each(dataGrid.modules, function() {
- if ($.isFunction(this.defaultOptions))
- that.option(this.defaultOptions())
- })
- },
- _defaultOptionsRules: function() {
- return this.callBase().slice(0).concat([{
- device: [{platform: "ios"}, {platform: "ios7"}],
- options: {showRowLines: true}
- }, {
- device: function() {
- return DevExpress.browser.webkit
- },
- options: {loadPanel: {animation: {show: {
- easing: 'cubic-bezier(1, 0, 1, 0)',
- duration: 500,
- from: {opacity: 0},
- to: {opacity: 1}
- }}}}
- }, {
- device: function() {
- return DX.devices.real().ios
- },
- options: {loadingTimeout: 30}
- }])
- },
- _init: function() {
- var that = this;
- that.callBase();
- processModules(that, dataGrid.modules);
- $.each(that._controllers, function() {
- this.init()
- });
- $.each(that._views, function() {
- this.init()
- });
- that._gridView = that._views['gridView']
- },
- _clean: $.noop,
- _optionChanged: function(name, value, prevValue) {
- var that = this;
- that.callBase(name, value, prevValue);
- $.each(that._controllers, function() {
- this.optionChanged(name, value, prevValue)
- });
- $.each(that._views, function() {
- this.optionChanged(name, value, prevValue)
- })
- },
- _dimensionChanged: function() {
- this.resize()
- },
- _visibilityChanged: function() {
- this.resize()
- },
- _renderContentImpl: function() {
- var that = this;
- that._gridView.render(that._element())
- },
- _renderContent: function() {
- this._renderContentImpl()
- },
- _getTemplate: function(templateName) {
- var template,
- templateClass,
- $template;
- if (!this.option("_templates")[templateName]) {
- $template = $(templateName);
- if ($template.length === 1) {
- templateClass = this._templateProvider.getTemplateClass();
- this.option("_templates")[templateName] = new templateClass($template)
- }
- }
- return this.callBase(templateName)
- },
- _dispose: function() {
- var that = this;
- that.callBase();
- $.each(that._controllers, function() {
- this.dispose()
- });
- $.each(that._views, function() {
- this.dispose()
- })
- },
- beginUpdate: function() {
- var that = this;
- that.callBase();
- if (that._controllers)
- $.each(that._controllers, function() {
- this.beginUpdate && this.beginUpdate()
- });
- if (that._views)
- $.each(that._views, function() {
- this.beginUpdate && this.beginUpdate()
- })
- },
- endUpdate: function() {
- var that = this;
- if (that._controllers)
- $.each(that._controllers, function() {
- this.endUpdate && this.endUpdate()
- });
- if (that._views)
- $.each(that._views, function() {
- this.endUpdate && this.endUpdate()
- });
- that.callBase()
- },
- getController: function(name) {
- return this._controllers[name]
- },
- getView: function(name) {
- return this._views[name]
- },
- resize: function() {
- this._gridView.resize()
- }
- }
- }()))
- })(jQuery, DevExpress);
- /*! Module widgets-web, file ui.dataGrid.groupingHelperBase.js */
- (function($, DX) {
- var normalizeSortingInfo = DX.data.utils.normalizeSortingInfo;
- DX.ui.dataGrid.GroupingHelperBase = DX.Class.inherit(function() {
- var findGroupInfoByKey = function(groupsInfo, key) {
- var i;
- for (i = 0; i < groupsInfo.length; i++)
- if (DX.data.utils.keysEqual(null, groupsInfo[i].key, key))
- return groupsInfo[i]
- };
- var getGroupInfoIndexByOffset = function(groupsInfo, offset) {
- var index;
- for (index = 0; index < groupsInfo.length; index++)
- if (groupsInfo[index].offset > offset)
- break;
- return index
- };
- var updateGroupInfoOffsets = function(groupsInfo) {
- var groupInfo,
- index,
- newIndex;
- for (index = 0; index < groupsInfo.length; index++) {
- groupInfo = groupsInfo[index];
- if (groupInfo.data && groupInfo.data.offset !== groupInfo.offset) {
- groupsInfo.splice(index, 1);
- groupInfo.offset = groupInfo.data.offset;
- newIndex = getGroupInfoIndexByOffset(groupsInfo, groupInfo.offset);
- groupsInfo.splice(newIndex, 0, groupInfo);
- if (newIndex > index)
- index--
- }
- }
- };
- var cleanGroupsInfo = function(groupsInfo, groupIndex, groupsCount) {
- var i;
- for (i = 0; i < groupsInfo.length; i++)
- if (groupIndex + 1 >= groupsCount)
- groupsInfo[i].children = [];
- else
- cleanGroupsInfo(groupsInfo[i].children, groupIndex + 1, groupsCount)
- };
- return {
- ctor: function(dataSource) {
- this._dataSource = dataSource;
- this.reset()
- },
- reset: function() {
- this._groupsInfo = [];
- this._totalCountCorrection = 0
- },
- totalItemsCount: function() {
- var that = this,
- totalCount = that._dataSource.totalCount();
- return totalCount > 0 ? totalCount + that._totalCountCorrection : 0
- },
- itemsCount: function() {
- return this._itemsCount || 0
- },
- mergeLoadedData: function(datas, groupDataOptions) {
- var data = this.mergeLoadedDataCore(datas, groupDataOptions);
- this._itemsCount = this.calculateItemsCount(data);
- return data
- },
- updateTotalItemsCount: function(totalCountCorrection) {
- this._totalCountCorrection = totalCountCorrection || 0
- },
- _isGroupItemCountable: function(item) {
- return !this._isVirtualPaging() || !item.isContinuation
- },
- _isVirtualPaging: function() {
- var dataSource = this._dataSource,
- dataSourceOptions = dataSource && dataSource._options,
- scrollingMode = dataSourceOptions && dataSourceOptions.scrolling && dataSourceOptions.scrolling.mode;
- return scrollingMode === 'virtual' || scrollingMode === 'infinite'
- },
- updateItemsCount: function(data, groupsCount) {
- function calculateItemsCount(that, items, groupsCount) {
- var i,
- result = 0;
- if (items)
- if (!groupsCount)
- result = items.length;
- else
- for (i = 0; i < items.length; i++) {
- if (that._isGroupItemCountable(items[i]))
- result++;
- result += calculateItemsCount(that, items[i].items, groupsCount - 1)
- }
- return result
- }
- this._itemsCount = calculateItemsCount(this, data, groupsCount)
- },
- foreachGroups: function(callback, childrenAtFirst) {
- var that = this;
- function foreachGroupsCore(groupsInfo, callback, childrenAtFirst, parents) {
- var i,
- callbackResult,
- callbackResults = [];
- function executeCallback(callback, data, parents, callbackResults) {
- var callbackResult = data && callback(data, parents);
- callbackResults.push(callbackResult);
- return callbackResult
- }
- for (i = 0; i < groupsInfo.length; i++) {
- parents.push(groupsInfo[i].data);
- if (!childrenAtFirst && executeCallback(callback, groupsInfo[i].data, parents, callbackResults) === false)
- return false;
- if (!groupsInfo[i].data || groupsInfo[i].data.isExpanded) {
- callbackResult = foreachGroupsCore(groupsInfo[i].children, callback, childrenAtFirst, parents);
- callbackResults.push(callbackResult);
- if (callbackResult === false)
- return false
- }
- if (childrenAtFirst && executeCallback(callback, groupsInfo[i].data, parents, callbackResults) === false)
- return false;
- parents.pop()
- }
- return $.when.apply($, callbackResults).always(function() {
- updateGroupInfoOffsets(groupsInfo)
- })
- }
- return foreachGroupsCore(that._groupsInfo, callback, childrenAtFirst, [])
- },
- findGroupInfo: function(path) {
- var that = this,
- i,
- pathIndex,
- groupInfo,
- groupsInfo = that._groupsInfo;
- for (pathIndex = 0; groupsInfo && pathIndex < path.length; pathIndex++) {
- groupInfo = findGroupInfoByKey(groupsInfo, path[pathIndex]);
- groupsInfo = groupInfo && groupInfo.children
- }
- return groupInfo && groupInfo.data
- },
- addGroupInfo: function(groupInfoData) {
- var that = this,
- index,
- groupInfo,
- path = groupInfoData.path,
- pathIndex,
- groupsInfo = that._groupsInfo;
- for (pathIndex = 0; pathIndex < path.length; pathIndex++) {
- groupInfo = findGroupInfoByKey(groupsInfo, path[pathIndex]);
- if (!groupInfo) {
- groupInfo = {
- key: path[pathIndex],
- offset: groupInfoData.offset,
- children: []
- };
- index = getGroupInfoIndexByOffset(groupsInfo, groupInfoData.offset);
- groupsInfo.splice(index, 0, groupInfo)
- }
- if (pathIndex === path.length - 1) {
- groupInfo.data = groupInfoData;
- updateGroupInfoOffsets(groupsInfo)
- }
- groupsInfo = groupInfo.children
- }
- },
- allowCollapseAll: function() {
- return true
- },
- collapseAll: function(groupIndex) {
- if (!this.allowCollapseAll()) {
- DX.utils.logger.error("The collapseAll method cannot be called when using a remote data source");
- return false
- }
- return this._collapseExpandAll(groupIndex, false)
- },
- expandAll: function(groupIndex) {
- return this._collapseExpandAll(groupIndex, true)
- },
- _collapseExpandAll: function(groupIndex, isExpand) {
- var that = this,
- dataSource = that._dataSource,
- group = dataSource.group(),
- groups = normalizeSortingInfo(group || []),
- i;
- if (groups.length) {
- for (i = 0; i < groups.length; i++)
- if (groupIndex === undefined || groupIndex === i)
- groups[i].isExpanded = isExpand;
- else if (group && group[i])
- groups[i].isExpanded = group[i].isExpanded;
- dataSource.group(groups);
- that.foreachGroups(function(groupInfo, parents) {
- if (groupIndex === undefined || groupIndex === parents.length - 1)
- groupInfo.isExpanded = isExpand
- });
- that.updateItemsCount()
- }
- return true
- },
- processLoadOptions: function(storeLoadOptions) {
- this._group = storeLoadOptions.group
- },
- refresh: function(storeLoadOptions) {
- var that = this,
- groupIndex,
- oldGroups = normalizeSortingInfo(that._group || []),
- groups = normalizeSortingInfo(storeLoadOptions.group || []),
- groupsCount = Math.min(oldGroups.length, groups.length);
- that._group = storeLoadOptions.group;
- for (groupIndex = 0; groupIndex < groupsCount; groupIndex++)
- if (oldGroups[groupIndex].selector !== groups[groupIndex].selector) {
- groupsCount = groupIndex;
- break
- }
- if (!groupsCount)
- that.reset();
- else
- cleanGroupsInfo(that._groupsInfo, 0, groupsCount)
- }
- }
- }())
- })(jQuery, DevExpress);
- /*! Module widgets-web, file ui.dataGrid.groupingHelper.js */
- (function($, DX) {
- var utils = DX.utils,
- normalizeSortingInfo = DX.data.utils.normalizeSortingInfo,
- keysEqual = DX.data.utils.keysEqual;
- var loadTotalCount = function(store, options) {
- var d = $.Deferred(),
- loadOptions = $.extend({
- skip: 0,
- take: 0,
- requireTotalCount: true
- }, options);
- store.load(loadOptions).done(function(data, extra) {
- if (extra && isFinite(extra.totalCount))
- d.resolve(extra.totalCount);
- else
- store.totalCount(options).done($.proxy(d.resolve, d)).fail($.proxy(d.reject, d))
- }).fail($.proxy(d.reject, d));
- return d
- };
- DX.ui.dataGrid.GroupingHelper = DX.ui.dataGrid.GroupingHelperBase.inherit(function() {
- var foreachCollapsedGroups = function(that, callback) {
- return that.foreachGroups(function(groupInfo) {
- if (!groupInfo.isExpanded)
- return callback(groupInfo)
- })
- };
- var correctSkipLoadOption = function(that, skip) {
- var skipCorrection = 0,
- resultSkip = skip || 0;
- if (skip) {
- foreachCollapsedGroups(that, function(groupInfo) {
- if (groupInfo.offset - skipCorrection >= skip)
- return false;
- skipCorrection += groupInfo.count - 1
- });
- resultSkip += skipCorrection
- }
- return resultSkip
- };
- var processGroupItems = function(that, items, path, offset, skipFirstItem, take) {
- var i,
- item,
- offsetInfo,
- removeLastItemsCount = 0,
- needRemoveFirstItem = false;
- for (i = 0; i < items.length; i++) {
- item = items[i];
- if (item.items !== undefined) {
- path.push(item.key);
- var groupInfo = that.findGroupInfo(path);
- if (groupInfo && !groupInfo.isExpanded) {
- item.items = null;
- offset += groupInfo.count;
- take--;
- if (take < 0)
- removeLastItemsCount++;
- if (skipFirstItem)
- needRemoveFirstItem = true
- }
- else if (item.items) {
- offsetInfo = processGroupItems(that, item.items, path, offset, skipFirstItem, take);
- if (skipFirstItem)
- if (offsetInfo.offset - offset > 1)
- item.isContinuation = true;
- else
- needRemoveFirstItem = true;
- offset = offsetInfo.offset;
- take = offsetInfo.take;
- if (take < 0)
- if (item.items.length)
- item.isContinuationOnNextPage = true;
- else
- removeLastItemsCount++
- }
- path.pop()
- }
- else {
- if (skipFirstItem)
- needRemoveFirstItem = true;
- offset++;
- take--;
- if (take < 0)
- removeLastItemsCount++
- }
- skipFirstItem = false
- }
- if (needRemoveFirstItem)
- items.splice(0, 1);
- if (removeLastItemsCount)
- items.splice(-removeLastItemsCount, removeLastItemsCount);
- return {
- offset: offset,
- take: take
- }
- };
- var pathEquals = function(path1, path2) {
- var i;
- if (path1.length !== path2.length)
- return false;
- for (i = 0; i < path1.length; i++)
- if (!keysEqual(null, path1[i], path2[i]))
- return false;
- return true
- };
- var updateGroupOffsets = function(that, items, path, offset, additionalGroupInfo) {
- var i,
- item,
- groupsInfo = that._groupsInfo;
- for (i = 0; i < items.length; i++) {
- item = items[i];
- if (item.items !== undefined) {
- path.push(item.key);
- if (additionalGroupInfo && pathEquals(additionalGroupInfo.path, path))
- additionalGroupInfo.offset = offset;
- var groupInfo = that.findGroupInfo(path);
- if (groupInfo && !groupInfo.isExpanded) {
- groupInfo.offset = offset;
- offset += groupInfo.count
- }
- else
- offset = updateGroupOffsets(that, item.items, path, offset, additionalGroupInfo);
- path.pop()
- }
- else
- offset++
- }
- return offset
- };
- var removeGroupLoadOption = function(storeLoadOptions) {
- if (storeLoadOptions.group) {
- storeLoadOptions.sort = normalizeSortingInfo(storeLoadOptions.group || []).concat(normalizeSortingInfo(storeLoadOptions.sort || []));
- delete storeLoadOptions.group
- }
- };
- var createGroupFilter = function(path, storeLoadOptions) {
- var groups = normalizeSortingInfo(storeLoadOptions.group || []),
- i,
- filter = [];
- for (i = 0; i < path.length; i++)
- filter.push([groups[i].selector, '=', path[i]]);
- if (storeLoadOptions.filter)
- filter.push(storeLoadOptions.filter);
- return filter
- };
- var createOffsetFilter = function(path, storeLoadOptions) {
- var groups = normalizeSortingInfo(storeLoadOptions.group || []),
- i,
- j,
- filterElement,
- filter = [];
- for (i = 0; i < path.length; i++) {
- filterElement = [];
- for (j = 0; j <= i; j++)
- filterElement.push([groups[j].selector, i === j ? groups[j].desc ? '>' : '<' : '=', path[j]]);
- if (filter.length)
- filter.push('or');
- filter.push(filterElement)
- }
- if (storeLoadOptions.filter)
- filter.push(storeLoadOptions.filter);
- return filter
- };
- return {
- processLoadOptions: function(storeLoadOptions) {
- var that = this,
- currentTake,
- loadOptions,
- collapsedPaths = [],
- collapsedPathsByLoads = [],
- skipFirstItem = false,
- take,
- offset,
- group = storeLoadOptions.group,
- groupLoadOptions = [];
- that.callBase(storeLoadOptions);
- removeGroupLoadOption(storeLoadOptions);
- loadOptions = $.extend({}, storeLoadOptions);
- loadOptions.skip = correctSkipLoadOption(that, storeLoadOptions.skip);
- if (loadOptions.skip && loadOptions.take && group) {
- loadOptions.skip--;
- loadOptions.take++;
- skipFirstItem = true
- }
- if (loadOptions.take && group) {
- take = loadOptions.take;
- loadOptions.take++
- }
- offset = loadOptions.skip || 0;
- if (loadOptions.take) {
- foreachCollapsedGroups(that, function(groupInfo) {
- if (groupInfo.offset >= loadOptions.skip + loadOptions.take)
- return false;
- else if (groupInfo.offset >= loadOptions.skip && groupInfo.count) {
- currentTake = groupInfo.offset - loadOptions.skip;
- if (currentTake > 0) {
- groupLoadOptions.push($.extend({}, loadOptions, {
- skip: loadOptions.skip,
- take: currentTake
- }));
- loadOptions.take -= currentTake;
- collapsedPathsByLoads.push(collapsedPaths);
- collapsedPaths = []
- }
- loadOptions.skip = groupInfo.offset + groupInfo.count;
- loadOptions.take--;
- collapsedPaths.push(groupInfo.path)
- }
- });
- if (!groupLoadOptions.length || loadOptions.take > 0)
- groupLoadOptions.push(loadOptions);
- if (collapsedPaths.length)
- collapsedPathsByLoads.push(collapsedPaths)
- }
- else
- groupLoadOptions.push(loadOptions);
- return {
- loads: groupLoadOptions,
- data: {
- collapsedPathsByLoads: collapsedPathsByLoads,
- offset: offset,
- skipFirstItem: skipFirstItem,
- take: take,
- group: group
- }
- }
- },
- updateTotalItemsCount: function() {
- var itemsCountCorrection = 0;
- foreachCollapsedGroups(this, function(groupInfo) {
- if (groupInfo.count)
- itemsCountCorrection -= groupInfo.count - 1
- });
- this.callBase(itemsCountCorrection)
- },
- changeGroupExpand: function(path) {
- var that = this,
- dataSource = that._dataSource,
- basePageIndex = dataSource.basePageIndex && dataSource.basePageIndex() || dataSource.pageIndex(),
- offset = correctSkipLoadOption(that, basePageIndex * dataSource.pageSize()),
- groupCountQuery;
- groupCountQuery = loadTotalCount(dataSource.store(), {filter: createGroupFilter(path, {
- filter: dataSource.filter(),
- group: dataSource.group()
- })});
- return $.when(groupCountQuery).done(function(count) {
- var groupInfo;
- count = parseInt(count.length ? count[0] : count);
- groupInfo = that.findGroupInfo(path);
- if (groupInfo) {
- updateGroupOffsets(that, dataSource.items(), [], offset);
- groupInfo.isExpanded = !groupInfo.isExpanded;
- groupInfo.count = count
- }
- else {
- groupInfo = {
- offset: -1,
- count: count,
- path: path,
- isExpanded: false
- };
- updateGroupOffsets(that, dataSource.items(), [], offset, groupInfo);
- if (groupInfo.offset >= 0)
- that.addGroupInfo(groupInfo)
- }
- that.updateTotalItemsCount()
- }).fail($.proxy(dataSource.loadError.fire, dataSource.loadError))
- },
- mergeLoadedData: function(datas, groupDataOptions) {
- var that = this,
- data = [],
- i,
- pathIndex,
- query,
- collapsedPathsByLoads = groupDataOptions.collapsedPathsByLoads,
- collapsedPaths,
- groups = normalizeSortingInfo(groupDataOptions.group || []),
- groupsCount = groups.length,
- loadsCount = Math.max(datas.length, collapsedPathsByLoads.length);
- function createCollapsedGroupItem(path) {
- var result = {},
- i,
- item;
- for (i = 0; i < path.length; i++) {
- if (!item)
- item = result;
- else {
- item.items.push({});
- item = item.items[0]
- }
- item.key = path[i];
- item.items = []
- }
- return result
- }
- function appendData(data, appendingData) {
- var index = 0;
- if (appendingData) {
- if (data.length && appendingData.length && keysEqual(null, data[data.length - 1].key, appendingData[0].key)) {
- appendData(data[data.length - 1].items, appendingData[0].items);
- index = 1
- }
- while (index < appendingData.length) {
- data.push(appendingData[index]);
- index++
- }
- }
- }
- for (i = 0; i < loadsCount; i++) {
- collapsedPaths = collapsedPathsByLoads[i];
- if (collapsedPaths && collapsedPaths.length)
- for (pathIndex = 0; pathIndex < collapsedPaths.length; pathIndex++)
- appendData(data, [createCollapsedGroupItem(collapsedPaths[pathIndex])]);
- if (datas[i]) {
- query = DX.data.query(datas[i]);
- DX.data.utils.multiLevelGroup(query, groups).enumerate().done(function(groupedData) {
- appendData(data, groupedData)
- })
- }
- }
- processGroupItems(that, data, [], groupDataOptions.offset, groupDataOptions.skipFirstItem, groupDataOptions.take);
- that.updateItemsCount(data, groupsCount);
- return data
- },
- allowCollapseAll: function() {
- return false
- },
- refresh: function(storeLoadOptions) {
- var that = this,
- store = that._dataSource.store();
- that.callBase(storeLoadOptions);
- return foreachCollapsedGroups(that, function(groupInfo) {
- var groupCountQuery = loadTotalCount(store, {filter: createGroupFilter(groupInfo.path, storeLoadOptions)}),
- groupOffsetQuery = loadTotalCount(store, {filter: createOffsetFilter(groupInfo.path, storeLoadOptions)});
- return $.when(groupOffsetQuery, groupCountQuery).done(function(offset, count) {
- offset = parseInt(offset.length ? offset[0] : offset);
- count = parseInt(count.length ? count[0] : count);
- groupInfo.offset = offset;
- if (groupInfo.count !== count) {
- groupInfo.count = count;
- that.updateTotalItemsCount()
- }
- }).fail($.proxy(that._dataSource.loadError.fire, that._dataSource.loadError))
- })
- }
- }
- }());
- $.extend(DX.ui.dataGrid.__internals, {loadTotalCount: loadTotalCount})
- })(jQuery, DevExpress);
- /*! Module widgets-web, file ui.dataGrid.groupingHelperWithNativeGrouping.js */
- (function($, DX) {
- var utils = DX.utils,
- normalizeSortingInfo = DX.data.utils.normalizeSortingInfo,
- keysEqual = DX.data.utils.keysEqual;
- DX.ui.dataGrid.GroupingHelperWithNativeGrouping = DX.ui.dataGrid.GroupingHelperBase.inherit(function() {
- var foreachExpandedGroups = function(that, callback) {
- return that.foreachGroups(function(groupInfo, parents) {
- if (groupInfo.isExpanded)
- return callback(groupInfo, parents)
- }, true)
- };
- var processGroupItems = function(that, items, path, groupsCount) {
- var i,
- item;
- if (!groupsCount)
- return;
- for (i = 0; i < items.length; i++) {
- item = items[i];
- if (item.items !== undefined) {
- path.push(item.key);
- var groupInfo = that.findGroupInfo(path);
- if (!groupInfo || !groupInfo.isExpanded)
- item.items = null;
- else
- processGroupItems(that, item.items, path, groupsCount - 1);
- path.pop()
- }
- }
- };
- var hasExpandedGroup = function(that, group) {
- var hasExpandedGroup = false,
- i,
- groupsCount = normalizeSortingInfo(group || []).length;
- for (i = 0; i < groupsCount; i++)
- if (that._isGroupExpanded(i))
- hasExpandedGroup = true;
- return hasExpandedGroup
- };
- var updateGroupInfos = function(that, items, groupsCount, offset) {
- updateGroupInfosCore(that, items, 0, groupsCount, [], offset)
- };
- var updateGroupInfosCore = function(that, items, groupIndex, groupsCount, path, offset) {
- var item,
- i,
- groupInfo;
- if (groupIndex >= groupsCount)
- return;
- for (i = 0; i < items.length; i++) {
- item = items[i];
- if (item) {
- path.push(item.key);
- groupInfo = that.findGroupInfo(path);
- if (!groupInfo)
- that.addGroupInfo({
- isExpanded: that._isGroupExpanded(groupIndex),
- path: path.slice(0),
- offset: offset + i,
- count: item.items.length
- });
- else {
- groupInfo.count = item.items.length;
- groupInfo.offset = offset + i
- }
- updateGroupInfosCore(that, item.items, groupIndex + 1, groupsCount, path, 0);
- path.pop()
- }
- }
- };
- var isGroupExpanded = function(groups, groupIndex) {
- return groups && groups.length && groups[groupIndex] && !!groups[groupIndex].isExpanded
- };
- var getTotalOffset = function(groupInfos, pageSize, offset) {
- var groupIndex,
- prevOffset = 0,
- groupSize,
- totalOffset = offset;
- for (groupIndex = 0; groupIndex < groupInfos.length; groupIndex++) {
- groupSize = groupInfos[groupIndex].offset + 1;
- if (groupIndex > 0) {
- groupSize += groupInfos[groupIndex - 1].childrenTotalCount;
- if (pageSize)
- groupSize += getContinuationGroupCount(totalOffset, pageSize, groupSize, groupIndex - 1) * groupIndex
- }
- totalOffset += groupSize
- }
- return totalOffset
- };
- var getContinuationGroupCount = function(groupOffset, pageSize, groupSize, groupIndex) {
- groupIndex = groupIndex || 0;
- if (pageSize > 1 && groupSize > 0) {
- var pageOffset = groupOffset - Math.floor(groupOffset / pageSize) * pageSize || pageSize;
- pageOffset += groupSize - groupIndex - 2;
- if (pageOffset < 0)
- pageOffset += pageSize;
- return Math.floor(pageOffset / (pageSize - groupIndex - 1))
- }
- return 0
- };
- DX.ui.dataGrid.getContinuationGroupCount = getContinuationGroupCount;
- return {
- updateTotalItemsCount: function() {
- var totalItemsCount = 0,
- pageSize = this._dataSource.pageSize(),
- isVirtualPaging = this._isVirtualPaging();
- foreachExpandedGroups(this, function(groupInfo, parents) {
- groupInfo.childrenTotalCount = 0
- });
- foreachExpandedGroups(this, function(groupInfo, parents) {
- var totalOffset = getTotalOffset(parents, isVirtualPaging ? 0 : pageSize, totalItemsCount),
- count = groupInfo.count + groupInfo.childrenTotalCount,
- i;
- if (!isVirtualPaging)
- count += getContinuationGroupCount(totalOffset, pageSize, count, parents.length - 1);
- if (parents[parents.length - 2])
- parents[parents.length - 2].childrenTotalCount += count;
- else
- totalItemsCount += count
- });
- this.callBase(totalItemsCount)
- },
- _isGroupExpanded: function(groupIndex) {
- var groups = this._dataSource.group();
- return isGroupExpanded(groups, groupIndex)
- },
- processLoadOptions: function(storeLoadOptions, isExpandedGroupsLoaded) {
- var that = this,
- dataSource = this._dataSource,
- isVirtualPaging = that._isVirtualPaging(),
- pageSize = dataSource.pageSize(),
- groups = normalizeSortingInfo(storeLoadOptions.group || []),
- skips = [],
- takes = [],
- skipChildrenTotalCount = 0,
- childrenTotalCount = 0,
- loadOptions = $.extend({}, storeLoadOptions);
- that.callBase(storeLoadOptions);
- if (hasExpandedGroup(that, groups) && !isExpandedGroupsLoaded) {
- delete loadOptions.skip;
- delete loadOptions.take
- }
- else if (loadOptions.take) {
- foreachExpandedGroups(this, function(groupInfo) {
- groupInfo.childrenTotalCount = 0;
- groupInfo.skipChildrenTotalCount = 0
- });
- foreachExpandedGroups(that, function(groupInfo, parents) {
- var skip,
- take,
- takeCorrection = 0,
- parentTakeCorrection = 0,
- totalOffset = getTotalOffset(parents, isVirtualPaging ? 0 : pageSize, childrenTotalCount),
- continuationGroupCount = 0,
- skipContinuationGroupCount = 0,
- groupInfoCount = groupInfo.count + groupInfo.childrenTotalCount,
- childrenGroupInfoCount = groupInfoCount;
- if (totalOffset <= loadOptions.skip + loadOptions.take && groupInfoCount) {
- skip = loadOptions.skip - totalOffset;
- take = loadOptions.take;
- if (!isVirtualPaging) {
- continuationGroupCount = getContinuationGroupCount(totalOffset, pageSize, groupInfoCount, parents.length - 1);
- groupInfoCount += continuationGroupCount * parents.length;
- childrenGroupInfoCount += continuationGroupCount;
- if (pageSize && skip >= 0) {
- takeCorrection = parents.length;
- parentTakeCorrection = parents.length - 1;
- skipContinuationGroupCount = Math.floor(skip / pageSize)
- }
- }
- if (skip >= 0) {
- if (totalOffset + groupInfoCount > loadOptions.skip)
- skips.unshift(skip - skipContinuationGroupCount * takeCorrection - groupInfo.skipChildrenTotalCount);
- if (totalOffset + groupInfoCount >= loadOptions.skip + take)
- takes.unshift(take - takeCorrection - groupInfo.childrenTotalCount + groupInfo.skipChildrenTotalCount)
- }
- else if (totalOffset + groupInfoCount >= loadOptions.skip + take)
- takes.unshift(take + skip - groupInfo.childrenTotalCount)
- }
- if (totalOffset <= loadOptions.skip)
- if (parents[parents.length - 2])
- parents[parents.length - 2].skipChildrenTotalCount += Math.min(childrenGroupInfoCount, skip + 1 - skipContinuationGroupCount * parentTakeCorrection);
- else
- skipChildrenTotalCount += Math.min(childrenGroupInfoCount, skip + 1);
- if (totalOffset <= loadOptions.skip + take) {
- groupInfoCount = Math.min(childrenGroupInfoCount, skip + take - (skipContinuationGroupCount + 1) * parentTakeCorrection);
- if (parents[parents.length - 2])
- parents[parents.length - 2].childrenTotalCount += groupInfoCount;
- else
- childrenTotalCount += groupInfoCount
- }
- });
- loadOptions.skip -= skipChildrenTotalCount;
- loadOptions.take -= childrenTotalCount - skipChildrenTotalCount
- }
- return {
- loads: [loadOptions],
- data: {
- skip: loadOptions.skip,
- take: loadOptions.take,
- skips: skips,
- takes: takes,
- storeLoadOptions: storeLoadOptions
- }
- }
- },
- changeGroupExpand: function(path) {
- var that = this,
- groupInfo = that.findGroupInfo(path);
- if (groupInfo) {
- groupInfo.isExpanded = !groupInfo.isExpanded;
- that.updateTotalItemsCount();
- return $.Deferred().resolve()
- }
- return $.Deferred().reject()
- },
- mergeLoadedData: function(datas, groupDataOptions) {
- var that = this,
- data = datas[0],
- group = normalizeSortingInfo(groupDataOptions.storeLoadOptions.group || []),
- groupsCount = group.length,
- skips,
- takes,
- i,
- item,
- items;
- updateGroupInfos(that, data, groupsCount, groupDataOptions.skip || 0);
- that.updateTotalItemsCount();
- if (hasExpandedGroup(that, group)) {
- groupDataOptions = that.processLoadOptions(groupDataOptions.storeLoadOptions, true).data;
- if (groupDataOptions.skip)
- data = data.slice(groupDataOptions.skip);
- if (groupDataOptions.take)
- data = data.slice(0, groupDataOptions.take)
- }
- skips = groupDataOptions.skips;
- takes = groupDataOptions.takes;
- items = data;
- for (i = 0; items && i < groupsCount; i++) {
- item = items[0];
- items = item && item.items;
- if (items && skips[i] !== undefined) {
- item.isContinuation = true;
- items = items.slice(skips[i]);
- item.items = items
- }
- }
- items = data;
- for (i = 0; items && i < groupsCount; i++) {
- item = items[items.length - 1];
- items = item && item.items;
- if (items && takes[i] !== undefined && items.length > takes[i]) {
- item.isContinuationOnNextPage = true;
- items = items.slice(0, takes[i]);
- item.items = items
- }
- }
- processGroupItems(that, data, [], groupsCount);
- that.updateItemsCount(data, groupsCount);
- return data
- },
- refresh: function(storeLoadOptions) {
- var that = this,
- oldGroups = normalizeSortingInfo(that._group || []),
- groups = normalizeSortingInfo(storeLoadOptions.group || []),
- groupIndex;
- for (groupIndex = 0; groupIndex < oldGroups.length; groupIndex++)
- if (isGroupExpanded(that._group, groupIndex) !== isGroupExpanded(storeLoadOptions.group, groupIndex)) {
- that.reset();
- return
- }
- that.callBase(storeLoadOptions);
- that.foreachGroups(function(groupInfo) {
- groupInfo.count = 0
- });
- if (groups.length)
- return that._dataSource.store().load(storeLoadOptions).done(function(data) {
- updateGroupInfos(that, data, groups.length, 0)
- }).fail($.proxy(that._dataSource.loadError.fire, that._dataSource.loadError))
- }
- }
- }())
- })(jQuery, DevExpress);
- /*! Module widgets-web, file ui.dataGrid.scrollingDataSourceWrapper.js */
- (function($, DX) {
- var dataGrid = DX.ui.dataGrid,
- utils = DX.utils;
- dataGrid.ScrollingDataSourceWrapper = DX.Class.inherit(function() {
- var getPreloadPageCount = function(that) {
- var scrolling = that._options.scrolling;
- return scrolling && scrolling.preloadEnabled ? 2 : 1
- };
- var isVirtualMode = function(that) {
- return that._options.scrolling && that._options.scrolling.mode === 'virtual'
- };
- var isAppendMode = function(that) {
- return that._options.scrolling && that._options.scrolling.mode === 'infinite'
- };
- var getBasePageIndex = function(that) {
- return that._cache[0] ? that._cache[0].pageIndex : -1
- };
- var updateLoading = function(that) {
- var basePageIndex = getBasePageIndex(that),
- pagesCount = that._cache.length;
- if (isVirtualMode(that))
- if (basePageIndex < 0 || that._viewportItemIndex >= 0 && (basePageIndex * that.pageSize() > that._viewportItemIndex || basePageIndex * that.pageSize() + that.itemsCount() < that._viewportItemIndex + that._viewportSize) && that._dataSource.isLoading()) {
- if (!that._isLoading) {
- that._isLoading = true;
- that.loadingChanged.fire(true)
- }
- }
- else if (that._isLoading) {
- that._isLoading = false;
- that.loadingChanged.fire(false)
- }
- };
- return {
- ctor: function(options) {
- var that = this,
- dataSource = new dataGrid.DataSource(options, that);
- that._dataSource = dataSource;
- that.loadError = dataSource.loadError;
- that.changed = $.Callbacks();
- that.loadingChanged = $.Callbacks();
- that._isLoading = true;
- that._pageIndex = dataSource.pageIndex();
- that._lastPageIndex = that._pageIndex;
- that._viewportSize = 0;
- that._viewportItemIndex = -1;
- that._userPageSize = options.pageSize;
- that._items = [];
- that._isLoaded = true;
- dataSource.loadingChanged.add(function(isLoading) {
- if (!isVirtualMode(that)) {
- that._isLoading = isLoading;
- that.loadingChanged.fire(isLoading)
- }
- });
- var processChanged = function(that, changeType, isDelayChanged) {
- var dataSource = that._dataSource,
- items = dataSource.items();
- if (changeType === 'append')
- that._items.push.apply(that._items, items);
- else if (changeType === 'prepend')
- that._items.unshift.apply(that._items, items);
- else
- that._items = items;
- updateLoading(that);
- that._lastPageIndex = that.pageIndex();
- that._isDelayChanged = isDelayChanged;
- if (!isDelayChanged)
- that.changed.fire(changeType && {
- changeType: changeType,
- items: items
- })
- };
- var processDelayChanged = function(that) {
- if (that._isDelayChanged) {
- that._isDelayChanged = false;
- that.changed.fire()
- }
- };
- dataSource.changed.add(function() {
- var basePageIndex,
- lastCacheLength = that._cache.length,
- changeType,
- cacheItem;
- if (isVirtualMode(that)) {
- basePageIndex = getBasePageIndex(that);
- if (basePageIndex >= 0)
- if (basePageIndex + that._cache.length === dataSource.pageIndex());
- else if (basePageIndex - 1 === dataSource.pageIndex());
- else
- that._cache = [];
- cacheItem = {
- pageIndex: dataSource.pageIndex(),
- itemsCount: dataSource.itemsCount()
- };
- processDelayChanged(that);
- if (basePageIndex === dataSource.pageIndex() + 1) {
- changeType = 'prepend';
- that._cache.unshift(cacheItem)
- }
- else {
- changeType = 'append';
- that._cache.push(cacheItem)
- }
- processChanged(that, that._cache.length > 1 ? changeType : undefined, lastCacheLength === 0);
- that.load().done(function() {
- processDelayChanged(that)
- })
- }
- else
- processChanged(that, isAppendMode(that) && dataSource.pageIndex() !== 0 ? 'append' : undefined)
- });
- $.each(dataSource, function(memberName, member) {
- if (!that[memberName] && $.isFunction(member))
- that[memberName] = function() {
- return this._dataSource[memberName].apply(this._dataSource, arguments)
- }
- });
- that._cache = [];
- that._options = options
- },
- items: function() {
- return this._items
- },
- itemsCount: function() {
- var itemsCount = 0;
- if (isVirtualMode(this))
- $.each(this._cache, function() {
- itemsCount += this.itemsCount
- });
- else
- itemsCount = this._dataSource.itemsCount();
- return itemsCount
- },
- virtualItemsCount: function() {
- var that = this,
- pageIndex,
- itemsCount = 0,
- i,
- beginItemsCount,
- endItemsCount;
- if (isVirtualMode(that)) {
- pageIndex = getBasePageIndex(that);
- if (pageIndex < 0)
- pageIndex = 0;
- beginItemsCount = pageIndex * that.pageSize();
- itemsCount = that._cache.length * that.pageSize();
- endItemsCount = Math.max(0, that.totalItemsCount() - itemsCount - beginItemsCount);
- return {
- begin: beginItemsCount,
- end: endItemsCount
- }
- }
- },
- setViewportItemIndex: function(itemIndex) {
- var that = this,
- pageSize = that.pageSize(),
- dataSource = that._dataSource,
- pagesCount = that.pagesCount(),
- virtualMode = isVirtualMode(that),
- appendMode = isAppendMode(that),
- totalItemsCount = that.totalItemsCount(),
- lastPageSize,
- needLoad = that._viewportItemIndex < 0,
- maxPageIndex,
- newPageIndex;
- that._viewportItemIndex = itemIndex;
- if (pageSize && (virtualMode || appendMode)) {
- if (that._viewportSize && itemIndex + that._viewportSize >= totalItemsCount) {
- if (that.hasKnownLastPage()) {
- newPageIndex = pagesCount - 1;
- lastPageSize = totalItemsCount % pageSize;
- if (newPageIndex > 0 && lastPageSize > 0 && lastPageSize < pageSize / 2)
- newPageIndex--
- }
- else if (that.pageIndex() < pagesCount)
- newPageIndex = pagesCount
- }
- else {
- newPageIndex = Math.floor(itemIndex / pageSize);
- maxPageIndex = pagesCount - 1;
- newPageIndex = Math.max(newPageIndex, 0);
- newPageIndex = Math.min(newPageIndex, maxPageIndex)
- }
- if (that.pageIndex() !== newPageIndex || needLoad) {
- that.pageIndex(newPageIndex);
- that.load()
- }
- }
- },
- setViewportSize: function(size) {
- var that = this,
- pageSize;
- if (that._viewportSize !== size) {
- that._viewportSize = size;
- if ((isVirtualMode(that) || isAppendMode(that)) && !that._userPageSize) {
- pageSize = Math.ceil(size / 5) * 10;
- if (pageSize !== that.pageSize()) {
- that.pageSize(pageSize);
- that.reload()
- }
- }
- }
- },
- pageIndex: function(pageIndex) {
- if (isVirtualMode(this) || isAppendMode(this)) {
- if (pageIndex !== undefined)
- this._pageIndex = pageIndex;
- return this._pageIndex
- }
- else
- return this._dataSource.pageIndex(pageIndex)
- },
- basePageIndex: function() {
- var basePageIndex = getBasePageIndex(this);
- return basePageIndex > 0 ? basePageIndex : 0
- },
- load: function() {
- var basePageIndex = getBasePageIndex(this),
- pageIndexForLoad = -1,
- dataSource = this._dataSource,
- result;
- var loadCore = function(that, pageIndex) {
- var dataSource = that._dataSource;
- if (pageIndex === that.pageIndex() || !dataSource.isLoading() && pageIndex < dataSource.pagesCount() || !dataSource.hasKnownLastPage() && pageIndex === dataSource.pagesCount()) {
- dataSource.pageIndex(pageIndex);
- return dataSource.load()
- }
- };
- if (isVirtualMode(this)) {
- if (basePageIndex < 0 || !this._cache[this._pageIndex - basePageIndex])
- pageIndexForLoad = this._pageIndex;
- if (basePageIndex >= 0 && pageIndexForLoad < 0 && this._viewportItemIndex >= 0 && basePageIndex + this._cache.length <= this._pageIndex + getPreloadPageCount(this))
- pageIndexForLoad = basePageIndex + this._cache.length;
- if (pageIndexForLoad >= 0)
- result = loadCore(this, pageIndexForLoad);
- updateLoading(this)
- }
- else if (isAppendMode(this)) {
- if (!dataSource.isLoaded() || this.pageIndex() === dataSource.pagesCount()) {
- dataSource.pageIndex(this.pageIndex());
- result = dataSource.load()
- }
- }
- else
- result = dataSource.load();
- if (!result && this._lastPageIndex !== this.pageIndex())
- this.changed.fire({changeType: 'pageIndex'});
- return result || $.Deferred().resolve()
- },
- isLoading: function() {
- return this._isLoading
- },
- isLoaded: function() {
- return this._dataSource.isLoaded() && this._isLoaded
- },
- changeGroupExpand: function(path) {
- this._cache = [];
- updateLoading(this);
- this._dataSource.changeGroupExpand(path)
- },
- reload: function() {
- var that = this,
- dataSource = that._dataSource;
- that._cache = [];
- that._isLoaded = false;
- updateLoading(that);
- that._isLoaded = true;
- if (isAppendMode(that)) {
- that.pageIndex(0);
- dataSource.pageIndex(0)
- }
- else
- dataSource.pageIndex(that.pageIndex());
- return dataSource.reload()
- }
- }
- }())
- })(jQuery, DevExpress);
- /*! Module widgets-web, file ui.dataGrid.dataSource.js */
- (function($, DX) {
- var dataGrid = DX.ui.dataGrid;
- dataGrid.DataSource = DX.data.DataSource.inherit(function() {
- var hasGrouping = function(that) {
- return !!that._storeLoadOptions.group
- };
- return {
- ctor: function(options, dataSourceWrapper) {
- var that = this;
- that.callBase(options);
- that._pageIndex = options.pageIndex || 0;
- that._asyncLoadEnabled = !!options.asyncLoadEnabled;
- that._loadingTimeout = options.loadingTimeout;
- if (options.useNativeGrouping === 'auto')
- options.useNativeGrouping = that.store() instanceof DX.data.ArrayStore;
- that._groupingHelper = options.useNativeGrouping ? new dataGrid.GroupingHelperWithNativeGrouping(dataSourceWrapper || that) : new dataGrid.GroupingHelper(dataSourceWrapper || that);
- that._hasLastPage = false;
- that._currentTotalCount = 0;
- that._options = options;
- that.map(that._mapFunc)
- },
- map: function(mapFunc) {
- var that = this,
- i,
- store = that.store();
- if (mapFunc)
- if (store instanceof DX.data.ArrayStore) {
- for (i = 0; i < store._array.length; i++)
- store._array[i] = mapFunc(store._array[i]);
- delete that._mapFunc
- }
- else
- that._mapFunc = mapFunc;
- else
- return that._mapFunc
- },
- pageSize: function(value) {
- if (value === undefined)
- return this._paginate ? this._pageSize : 0;
- this._pageSize = value || 20
- },
- totalCount: function() {
- return parseInt(this._currentTotalCount || this._totalCount)
- },
- totalItemsCount: function() {
- var that = this;
- return hasGrouping(that) && that._storeLoadOptions.requireTotalCount ? that._groupingHelper.totalItemsCount() : that.totalCount()
- },
- itemsCount: function() {
- var that = this;
- return hasGrouping(that) ? that._groupingHelper.itemsCount() : that.items().length
- },
- collapseAll: function(groupIndex) {
- return this._groupingHelper.collapseAll(groupIndex)
- },
- expandAll: function(groupIndex) {
- return this._groupingHelper.expandAll(groupIndex)
- },
- pagesCount: function() {
- var that = this,
- count = that.totalItemsCount(),
- pageSize = that.pageSize();
- if (pageSize && count > 0)
- return Math.max(1, Math.ceil(count / pageSize));
- return 1
- },
- _reloadCore: function() {
- var that = this,
- prop,
- userData = that._userData;
- for (prop in userData)
- if (userData.hasOwnProperty(prop))
- delete userData[prop];
- that._isLastPage = !that._paginate;
- that._currentTotalCount = 0;
- that._totalCount = -1;
- that._hasLastPage = that._isLastPage;
- that._isLoaded = false;
- return that.load()
- },
- reload: function() {
- var that = this,
- d = $.Deferred();
- if (that.isLoading()) {
- var loadingChangedHandler = function() {
- that.loadingChanged.remove(loadingChangedHandler);
- setTimeout(function() {
- that.reload().done(d.resolve).fail(d.reject)
- })
- };
- that.loadingChanged.add(loadingChangedHandler)
- }
- else
- $.when(that._groupingHelper.refresh(that._createStoreLoadOptions())).always(function() {
- that._reloadCore().done(d.resolve).fail(d.reject)
- });
- return d
- },
- hasKnownLastPage: function() {
- return this._hasLastPage || this._totalCount >= 0
- },
- changeGroupExpand: function(path) {
- var that = this,
- groupingHelper = that._groupingHelper;
- if (hasGrouping(that)) {
- that._changeLoadingCount(1);
- groupingHelper.changeGroupExpand(path).always(function() {
- that._changeLoadingCount(-1)
- }).done(function() {
- that.load()
- })
- }
- else
- that.load()
- },
- _createLoadQueue: function() {
- return DX.createQueue(true)
- },
- _scheduleChangedCallbacks: function(deferred) {
- var that = this,
- pageIndex = that.pageIndex();
- that._lastLoadDeferred = deferred;
- deferred.done(function() {
- var currentTotalCount,
- itemsCount = that.itemsCount();
- that._isLastPage = !itemsCount || !that._paginate || that._pageSize && itemsCount < that._pageSize;
- if (that.isLastPage())
- that._hasLastPage = true;
- if (that._totalCount >= 0) {
- if (that._pageIndex >= that.pagesCount()) {
- that.pageIndex(that.pagesCount() - 1);
- that.load()
- }
- }
- else {
- currentTotalCount = that.pageIndex() * that.pageSize() + itemsCount;
- that._currentTotalCount = Math.max(that._currentTotalCount, currentTotalCount);
- if (itemsCount === 0 && that.pageIndex() >= that.pagesCount()) {
- that.pageIndex(that.pagesCount() - 1);
- that.load()
- }
- }
- if (pageIndex === that.pageIndex() && !that.isLoading())
- that.changed.fire()
- })
- },
- _loadFromStore: function(storeLoadOptions, pendingDeferred) {
- var that = this;
- var loadTaskCore = function() {
- var i,
- groupOptions,
- groupLoadOptions,
- groupingHelper = that._groupingHelper,
- loads = [],
- datas = [];
- if (that._disposed)
- return;
- if (hasGrouping(that)) {
- groupOptions = groupingHelper.processLoadOptions(storeLoadOptions);
- groupLoadOptions = groupOptions.loads;
- for (i = 0; i < groupLoadOptions.length; i++) {
- loads.push(that.store().load(groupLoadOptions[i]));
- (function(index) {
- loads[index].done(function(data) {
- datas[index] = data
- })
- })(i)
- }
- }
- else
- loads.push(that.store().load(storeLoadOptions));
- $.when.apply($, loads).done(function(data, extra) {
- if (that._disposed)
- return;
- if (hasGrouping(that)) {
- if (datas.length > 1)
- extra = undefined;
- data = groupingHelper.mergeLoadedData(datas, groupOptions.data)
- }
- extra = extra || {totalCount: that._totalCount >= 0 ? that._totalCount : undefined};
- that._processStoreLoadResult(data, extra, storeLoadOptions, pendingDeferred)
- }).fail($.proxy(pendingDeferred.reject, pendingDeferred))
- };
- if (that._asyncLoadEnabled)
- window.setTimeout(loadTaskCore, that._loadingTimeout);
- else
- loadTaskCore()
- }
- }
- }())
- })(jQuery, DevExpress);
- /*! Module widgets-web, file ui.dataGrid.stateStoring.js */
- (function($, DX) {
- var ui = DX.ui,
- utils = DX.utils,
- dataGrid = ui.dataGrid;
- dataGrid.StateStoringController = dataGrid.ViewController.inherit(function() {
- var getStorage = function(options) {
- var storage = options.type === 'sessionStorage' ? sessionStorage : localStorage;
- if (!storage)
- throw new Error("State storing can not be provided due to the restrictions of your browser.");
- return storage
- };
- var getUniqueStorageKey = function(options) {
- return 'dx_datagrid_' + (utils.isDefined(options.storageKey) ? options.storageKey : 'storage')
- };
- var dateReviver = function(key, value) {
- var date;
- if (typeof value === 'string') {
- date = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value);
- if (date)
- return new Date(Date.UTC(+date[1], +date[2] - 1, +date[3], +date[4], +date[5], +date[6]))
- }
- return value
- };
- var processLoadState = function(that, state) {
- var allowedPageSizes = state.allowedPageSizes,
- searchText = state.searchText,
- selectedRowKeys = state.selectedRowKeys,
- columnsController = that.getController('columns'),
- selectionController = that.getController('selection'),
- dataController = that.getController('data'),
- pagerView = that.getView('pagerView');
- if (columnsController) {
- columnsController.setUserState(state.columns);
- columnsController.columnsChanged.add(function() {
- that.state({columns: columnsController.getUserState()});
- that.save()
- })
- }
- if (selectedRowKeys)
- that.option('selectedRowKeys', selectedRowKeys);
- if (selectionController)
- selectionController.selectionChanged.add(function(keys) {
- that.state({selectedRowKeys: keys});
- that.save()
- });
- if (dataController) {
- if (allowedPageSizes && that.option('pager.allowedPageSizes') === 'auto' && allowedPageSizes)
- that.option('pager').allowedPageSizes = allowedPageSizes;
- if (searchText)
- dataController.searchByText(searchText);
- dataController.changed.add(function() {
- that.state({
- searchText: dataController.getSearchText(),
- pageIndex: dataController.pageIndex(),
- pageSize: dataController.pageSize(),
- allowedPageSizes: pagerView.getPageSizes()
- });
- that.save()
- })
- }
- };
- return {
- _loadState: function() {
- var options = this.option('stateStoring');
- if (options.type === 'custom')
- return options.customLoad && options.customLoad();
- try {
- return JSON.parse(getStorage(options).getItem(getUniqueStorageKey(options)), dateReviver)
- }
- catch(e) {
- DX.utils.logger.error(e.message)
- }
- },
- _saveState: function(state) {
- var options = this.option('stateStoring');
- if (options.type === 'custom') {
- options.customSave && options.customSave(state);
- return
- }
- try {
- getStorage(options).setItem(getUniqueStorageKey(options), JSON.stringify(state))
- }
- catch(e) {}
- },
- publicMethods: function() {
- return ['state']
- },
- isEnabled: function() {
- var stateStoringOptions = this.option('stateStoring');
- return stateStoringOptions && stateStoringOptions.enabled
- },
- init: function() {
- var that = this;
- that._state = {};
- that._isLoaded = false;
- that._isLoading = false
- },
- isLoaded: function() {
- return this._isLoaded
- },
- isLoading: function() {
- return this._isLoading
- },
- load: function() {
- var that = this,
- loadResult;
- that._isLoading = true;
- loadResult = that._loadState();
- if (!loadResult || !$.isFunction(loadResult.done))
- loadResult = $.Deferred().resolve(loadResult);
- loadResult.done(function(state) {
- that._isLoaded = true;
- that._isLoading = false;
- that._state = state || {};
- processLoadState(that, that._state)
- });
- return loadResult
- },
- state: function(state) {
- var that = this;
- if (state === undefined)
- return that._state;
- else
- $.extend(that._state, state)
- },
- save: function() {
- var that = this;
- clearTimeout(that._savingTimeoutID);
- that._savingTimeoutID = setTimeout(function() {
- that._saveState(that.state())
- }, that.option('stateStoring.savingTimeout'))
- },
- dispose: function() {
- clearTimeout(this._savingTimeoutID)
- }
- }
- }());
- dataGrid.registerModule('stateStoring', {
- defaultOptions: function() {
- return {stateStoring: {
- enabled: false,
- storageKey: null,
- type: 'localStorage',
- customLoad: null,
- customSave: null,
- savingTimeout: 2000
- }}
- },
- controllers: {stateStoring: ui.dataGrid.StateStoringController},
- extenders: {controllers: {
- columns: {getVisibleColumns: function() {
- var visibleColumns = this.callBase();
- return this.getController('stateStoring').isLoading() ? [] : visibleColumns
- }},
- data: {
- _refreshDataSource: function() {
- var that = this,
- callBase = that.callBase,
- stateStoringController = that.getController('stateStoring');
- if (stateStoringController.isEnabled() && !stateStoringController.isLoaded())
- stateStoringController.load().done(function() {
- callBase.call(that)
- });
- else
- callBase.call(that)
- },
- isLoading: function() {
- var that = this,
- stateStoringController = that.getController('stateStoring');
- return this.callBase() || stateStoringController.isLoading()
- },
- _dataSourceOptions: function() {
- var that = this,
- result = that.callBase(),
- stateStoringController = that.getController('stateStoring'),
- userState;
- if (stateStoringController.isEnabled()) {
- userState = stateStoringController.state();
- if (userState.pageIndex !== undefined)
- result.pageIndex = userState.pageIndex;
- if (userState.pageSize !== undefined)
- result.pageSize = userState.pageSize
- }
- return result
- }
- }
- }}
- })
- })(jQuery, DevExpress);
- /*! Module widgets-web, file ui.dataGrid.columnsController.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- dataGrid = ui.dataGrid,
- utils = DX.utils,
- dataUtils = DX.data.utils,
- normalizeSortingInfo = dataUtils.normalizeSortingInfo,
- isDefined = utils.isDefined;
- var USER_STATE_FIELD_NAMES = ['initialIndex', 'dataField', 'width', 'visible', 'sortOrder', 'sortIndex', 'groupIndex', 'filterValue', 'selectedFilterOperation'];
- var GUID_REGEX = /^(\{{0,1}([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12}\}{0,1})$/;
- dataGrid.checkChanges = function(changes, changeNames) {
- var changesWithChangeNamesCount = 0,
- i;
- for (i = 0; i < changeNames.length; i++)
- if (changes[changeNames[i]])
- changesWithChangeNamesCount++;
- return changes.length && changes.length === changesWithChangeNamesCount
- };
- var ColumnsController = dataGrid.Controller.inherit(function() {
- var DEFAULT_COLUMN_OPTIONS = {visible: true},
- DATATYPE_OPERATIONS = {
- number: ['=', '<>', '<', '>', '<=', '>='],
- date: ['=', '<>', '<', '>', '<=', '>='],
- string: ['contains', 'notcontains', 'startswith', 'endswith', '=', '<>']
- },
- FIXED_COLUMN_OPTIONS = {
- allowResizing: false,
- allowGrouping: false,
- allowReordering: false,
- allowSorting: false,
- allowHiding: false
- };
- var GROUP_COLUMN_WIDTH = 30;
- var GROUP_LOCATION = 'group',
- COLUMN_CHOOSER_LOCATION = 'columnChooser';
- var convertNameToCaption = function(name) {
- var captionList = [],
- i,
- char,
- isPrevCharNewWord = false,
- isNewWord = false;
- for (i = 0; i < name.length; i++) {
- char = name.charAt(i);
- isNewWord = char === char.toUpperCase() || char in ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
- if (char === '_' || char === '.') {
- char = ' ';
- isNewWord = true
- }
- else if (i === 0) {
- char = char.toUpperCase();
- isNewWord = true
- }
- else if (!isPrevCharNewWord && isNewWord)
- if (captionList.length > 0)
- captionList.push(' ');
- captionList.push(char);
- isPrevCharNewWord = isNewWord
- }
- return captionList.join('')
- };
- var createColumn = function(that, columnOptions) {
- var commonColumnOptions,
- calculatedColumnOptions;
- if (columnOptions) {
- if (utils.isString(columnOptions))
- columnOptions = {dataField: columnOptions};
- commonColumnOptions = that.getCommonSettings();
- calculatedColumnOptions = that._createCalculatedColumnOptions(columnOptions);
- return $.extend(true, {}, DEFAULT_COLUMN_OPTIONS, commonColumnOptions, calculatedColumnOptions, columnOptions)
- }
- };
- var createColumnsFromOptions = function(that, columnsOptions) {
- var result = [];
- if (columnsOptions)
- $.each(columnsOptions, function(index, value) {
- var column = createColumn(that, value);
- if (column) {
- if (column.initialIndex === undefined)
- column.initialIndex = index;
- result.push(column)
- }
- });
- return result
- };
- var getValueDataType = function(value) {
- var dataType = $.type(value);
- if (dataType === 'string') {
- if (utils.isNumber(value))
- dataType = 'number';
- else if (GUID_REGEX.test(value))
- dataType = 'guid'
- }
- else if (dataType !== 'boolean' && dataType !== 'number' && dataType !== 'date')
- dataType = undefined;
- return dataType
- };
- var getAlignmentByDataType = function(dataType, isRTL) {
- switch (dataType) {
- case'number':
- return 'right';
- case'boolean':
- return 'center';
- case'date':
- return 'left';
- default:
- return isRTL ? 'right' : 'left'
- }
- };
- var getFormatByDataType = function(dataType) {
- switch (dataType) {
- case"date":
- return "shortDate"
- }
- };
- var getCustomizeTextByDataType = function(dataType) {
- if (dataType === 'boolean')
- return function(e) {
- if (e.value === true)
- return this.trueText || 'true';
- else if (e.value === false)
- return this.falseText || 'false';
- else
- return e.valueText || ''
- }
- };
- var createColumnsFromDataSource = function(that, dataSource) {
- var firstItems = getFirstItems(dataSource),
- fieldName,
- processedFields = {},
- i,
- initialIndex = 0,
- result = [];
- for (i = 0; i < firstItems.length; i++)
- firstItems[i] && $.each(firstItems[i], function(fieldName) {
- processedFields[fieldName] = true
- });
- $.each(processedFields, function(fieldName) {
- if (fieldName.indexOf('__') !== 0) {
- var column = createColumn(that, fieldName);
- column.initialIndex = initialIndex++;
- result.push(column)
- }
- });
- return result
- };
- var equalSortParameters = function(sortParameters1, sortParameters2) {
- var i;
- if ($.isArray(sortParameters1) && $.isArray(sortParameters2)) {
- if (sortParameters1.length !== sortParameters2.length)
- return false;
- else
- for (i = 0; i < sortParameters1.length; i++)
- if (sortParameters1[i].selector !== sortParameters2[i].selector || sortParameters1[i].desc !== sortParameters2[i].desc || !sortParameters1[i].isExpanded !== !sortParameters2[i].isExpanded)
- return false;
- return true
- }
- else
- return (!sortParameters1 || !sortParameters1.length) === (!sortParameters2 || !sortParameters2.length)
- };
- var getFirstItems = function(dataSource) {
- var groupsCount,
- items = [];
- var getFirstItemsCore = function(items, groupsCount) {
- var i,
- childItems;
- if (!items || !groupsCount)
- return items;
- for (i = 0; i < items.length; i++) {
- childItems = getFirstItemsCore(items[i].items, groupsCount - 1);
- if (childItems && childItems.length)
- return childItems
- }
- };
- if (dataSource && dataSource.items().length > 0) {
- groupsCount = normalizeSortingInfo(dataSource.group() || []).length;
- items = getFirstItemsCore(dataSource.items(), groupsCount) || []
- }
- return items
- };
- var updateColumnIndexes = function(that) {
- $.each(that._columns, function(index, column) {
- column.index = index
- })
- };
- var updateColumnParameterIndexes = function(that, indexParameterName, currentColumn) {
- var indexedSortColumns = [],
- parameterIndex = 0;
- $.each(that._columns, function(index, column) {
- var index = column[indexParameterName];
- if (isDefined(index)) {
- if (!indexedSortColumns[index])
- indexedSortColumns[index] = [];
- if (column === currentColumn)
- indexedSortColumns[index].unshift(column);
- else
- indexedSortColumns[index].push(column);
- delete column[indexParameterName]
- }
- });
- $.each(indexedSortColumns, function(index, sortColumns) {
- if (sortColumns)
- $.each(sortColumns, function() {
- this[indexParameterName] = parameterIndex++
- })
- });
- return parameterIndex
- };
- var updateColumnGroupIndexes = function(that, currentColumn) {
- var indexPropertyName = 'groupIndex',
- groupIndex = updateColumnParameterIndexes(that, indexPropertyName, currentColumn);
- $.each(that._columns, function(index, column) {
- if (!isDefined(column[indexPropertyName]) && column.grouped)
- column[indexPropertyName] = groupIndex++;
- delete column.grouped
- })
- };
- var updateColumnSortIndexes = function(that, currentColumn) {
- $.each(that._columns, function(index, column) {
- if (isDefined(column.sortIndex) && !isSortOrderValid(column.sortOrder))
- delete column.sortIndex
- });
- var sortIndex = updateColumnParameterIndexes(that, 'sortIndex', currentColumn);
- $.each(that._columns, function(index, column) {
- if (!isDefined(column.sortIndex) && !isDefined(column.groupIndex) && isSortOrderValid(column.sortOrder))
- column.sortIndex = sortIndex++
- })
- };
- var parseDate = function(value) {
- var parsedDate;
- if (!utils.isDate(value))
- if (utils.isNumber(value))
- value = new Date(value);
- else {
- parsedDate = Date.parse(value);
- if (parsedDate)
- value = new Date(parsedDate)
- }
- return value
- };
- var applyColumnTypesToDataSource = function(that, dataSource) {
- var i,
- columns = that._columns,
- firstItem = getFirstItems(dataSource)[0],
- fieldName,
- userMapFunc,
- columnTypesMapFunc,
- columnTypesWithUserMapFunc,
- groupsCount,
- dateFieldNames = [],
- numberFieldNames = [];
- if (dataSource && dataSource.map) {
- for (i = 0; i < columns.length; i++) {
- fieldName = columns[i].dataField;
- if (fieldName)
- switch (columns[i].dataType) {
- case"date":
- if (!firstItem || !utils.isDate(firstItem[fieldName]))
- dateFieldNames.push(fieldName);
- break;
- case"number":
- if (!firstItem || utils.isString(firstItem[fieldName]))
- numberFieldNames.push(fieldName);
- break
- }
- }
- var convertValue = function(item, fieldNames, groupsCount, parseFunc) {
- if (!groupsCount || !utils.isDefined(item.items))
- for (var i = 0; i < fieldNames.length; i++) {
- var fieldValue = item[fieldNames[i]];
- if (fieldValue)
- item[fieldNames[i]] = parseFunc(fieldValue)
- }
- else
- $.each(item.items, function(index, item) {
- convertValue(item, fieldNames, groupsCount - 1, parseFunc)
- })
- };
- if (dateFieldNames.length > 0 || numberFieldNames.length > 0) {
- userMapFunc = dataSource.map();
- columnTypesMapFunc = function(item) {
- var groupsCount;
- if (item) {
- groupsCount = normalizeSortingInfo(dataSource.group() || []).length;
- convertValue(item, dateFieldNames, groupsCount, parseDate);
- convertValue(item, numberFieldNames, groupsCount, Number)
- }
- return item
- };
- columnTypesWithUserMapFunc = function(item) {
- item = userMapFunc ? userMapFunc(item) : item;
- return columnTypesMapFunc(item)
- };
- dataSource.map(columnTypesWithUserMapFunc);
- if (!dataSource.map()) {
- dataSource.store().inserting.remove(that._insertingHandler);
- that._insertingHandler = function(values) {
- columnTypesWithUserMapFunc(values)
- };
- dataSource.store().inserting.add(that._insertingHandler)
- }
- else
- $.each(dataSource.items(), function() {
- columnTypesMapFunc(this)
- });
- return dataSource.load()
- }
- }
- };
- var getColumnIndexByVisibleIndex = function(that, visibleIndex, location) {
- var columns = location === GROUP_LOCATION ? that.getGroupColumns() : location === COLUMN_CHOOSER_LOCATION ? that.getHiddenColumns() : that.getVisibleColumns(),
- column = columns[visibleIndex];
- return column && isDefined(column.index) ? column.index : -1
- };
- var moveColumnToGroup = function(that, column, groupIndex) {
- var groupColumns = that.getGroupColumns(),
- i;
- if (groupIndex >= 0) {
- for (i = 0; i < groupColumns.length; i++)
- if (groupColumns[i].groupIndex >= groupIndex)
- groupColumns[i].groupIndex++
- }
- else {
- groupIndex = 0;
- for (i = 0; i < groupColumns.length; i++)
- groupIndex = Math.max(groupIndex, groupColumns[i].groupIndex + 1)
- }
- column.groupIndex = groupIndex
- };
- var applyUserState = function(that) {
- var columnsUserState = that._columnsUserState,
- columns = that._columns,
- resultColumns = [],
- columnsByInitialIndex = [],
- column,
- i;
- if (columnsUserState) {
- if (columns.length !== columnsUserState.length)
- return;
- for (i = 0; i < columns.length; i++)
- columnsByInitialIndex[columns[i].initialIndex] = columns[i];
- for (i = 0; i < columnsUserState.length; i++) {
- column = columnsByInitialIndex[columnsUserState[i].initialIndex];
- if (column && columnsUserState[i].dataField === column.dataField) {
- column = $.extend({}, column);
- $.each(USER_STATE_FIELD_NAMES, function(index, value) {
- column[value] = columnsUserState[i][value]
- });
- resultColumns.push(column)
- }
- else
- return
- }
- that._columns = resultColumns
- }
- };
- var updateIndexes = function(that, column) {
- updateColumnIndexes(that);
- updateColumnGroupIndexes(that, column);
- updateColumnSortIndexes(that, column)
- };
- var updateColumnChanges = function(that, changeType, optionName, column) {
- var columnChanges = that._columnChanges || {
- optionNames: {length: 0},
- changeTypes: {length: 0},
- columnIndex: column && column.initialIndex,
- column: column
- };
- var changeTypes = columnChanges.changeTypes;
- if (changeType && !changeTypes[changeType]) {
- changeTypes[changeType] = true;
- changeTypes.length++
- }
- var optionNames = columnChanges.optionNames;
- if (optionName && !optionNames[optionName]) {
- optionNames[optionName] = true;
- optionNames.length++
- }
- if (column === undefined || column !== columnChanges.column) {
- delete columnChanges.column;
- delete columnChanges.columnIndex
- }
- that._columnChanges = columnChanges;
- that._visibleColumns = undefined
- };
- var fireColumnsChanged = function(that, changeType) {
- if (changeType)
- updateColumnChanges(that, changeType);
- if (!that._updateLockCount && that._columnChanges) {
- that.columnsChanged.fire(that._columnChanges);
- that._columnChanges = undefined
- }
- };
- var columnOptionCore = function(that, column, optionName, value) {
- var optionGetter = dataUtils.compileGetter(optionName),
- changeType;
- if (arguments.length === 3)
- return optionGetter(column, {functionsAsIs: true});
- if (optionGetter(column, {functionsAsIs: true}) !== value) {
- if (optionName === 'groupIndex')
- changeType = 'grouping';
- else if (optionName === 'sortIndex' || optionName === 'sortOrder')
- changeType = 'sorting';
- else
- changeType = 'columns';
- dataUtils.compileSetter(optionName)(column, value, {functionsAsIs: true});
- updateColumnChanges(that, changeType, optionName, column)
- }
- };
- var isSortOrderValid = function(sortOrder) {
- return sortOrder === 'asc' || sortOrder === 'desc'
- };
- return {
- init: function() {
- var that = this,
- columns = that.option('columns');
- that._columns = columns ? createColumnsFromOptions(that, columns) : [];
- that._updateLockCount = that._updateLockCount || 0;
- that._isColumnsFromOptions = !!columns;
- if (that._isColumnsFromOptions)
- applyUserState(that);
- else
- that._columns = that._columnsUserState || that._columns;
- if (that._dataSourceApplied)
- that.applyDataSource(that._dataSource, true);
- else
- updateIndexes(that)
- },
- callbackNames: function() {
- return ['columnsChanged']
- },
- optionChanged: function(name, value, prevValue) {
- switch (name) {
- case'columns':
- case'commonColumnSettings':
- case'columnAutoWidth':
- case'allowColumnResizing':
- case'allowColumnReordering':
- case'grouping':
- case'groupPanel':
- case'regenerateColumnsByVisibleItems':
- case'customizeColumns':
- case'editing':
- case'rtlEnabled':
- this._columnsUserState = this.getUserState();
- this.init();
- break
- }
- },
- publicMethods: function() {
- return ['addColumn', 'columnOption', 'columnCount']
- },
- applyDataSource: function(dataSource, forceApplying) {
- var that = this,
- isDataSourceLoaded = dataSource && dataSource.isLoaded(),
- applyingComplete;
- that._dataSource = dataSource;
- if (!that._dataSourceApplied || that._dataSourceColumnsCount === 0 || forceApplying || that.option('regenerateColumnsByVisibleItems'))
- if (isDataSourceLoaded) {
- if (!that._isColumnsFromOptions) {
- that._columns = createColumnsFromDataSource(that, dataSource);
- that._dataSourceColumnsCount = that._columns.length;
- applyUserState(that)
- }
- return that.updateColumns(dataSource)
- }
- },
- reset: function() {
- this._dataSourceApplied = false;
- this._dataSourceColumnsCount = undefined
- },
- isInitialized: function() {
- return !!this._columns.length
- },
- isDataSourceApplied: function() {
- return this._dataSourceApplied
- },
- beginUpdate: function() {
- this._updateLockCount++
- },
- endUpdate: function() {
- var that = this;
- that._updateLockCount--;
- if (!that._updateLockCount)
- fireColumnsChanged(that)
- },
- getCommonSettings: function() {
- var commonColumnSettings = this.option('commonColumnSettings') || {},
- groupingOptions = this.option('grouping') || {},
- groupPanelOptions = this.option('groupPanel') || {};
- return $.extend({
- allowResizing: this.option('allowColumnResizing'),
- allowReordering: this.option('allowColumnReordering'),
- autoExpandGroup: groupingOptions.autoExpandAll,
- allowCollapsing: groupingOptions.allowCollapsing,
- allowGrouping: groupPanelOptions.allowColumnDragging && groupPanelOptions.visible
- }, commonColumnSettings)
- },
- isColumnOptionUsed: function(optionName) {
- for (var i = 0; i < this._columns.length; i++)
- if (this._columns[i][optionName])
- return true
- },
- getColumns: function() {
- return $.extend(true, [], this._columns)
- },
- getGroupColumns: function() {
- var result = [];
- $.each(this._columns, function() {
- var column = this;
- if (isDefined(column.groupIndex))
- result[column.groupIndex] = column
- });
- return result
- },
- getVisibleColumns: function() {
- var visibleColumns = $.map(this.getGroupColumns(), function(column) {
- return $.extend({}, column, {width: GROUP_COLUMN_WIDTH}, FIXED_COLUMN_OPTIONS)
- });
- var notGroupedColumnsCount = 0;
- $.each(this._columns, function() {
- var column = this;
- if (column.visible && !isDefined(column.groupIndex)) {
- column = $.extend(true, {}, column);
- visibleColumns.push(column);
- notGroupedColumnsCount++
- }
- });
- if (!notGroupedColumnsCount && this._columns.length)
- visibleColumns.push({command: 'empty'});
- return visibleColumns
- },
- getHiddenColumns: function() {
- var result = [];
- $.each(this._columns, function(_, column) {
- if (!column.visible)
- result.push(column)
- });
- return result
- },
- allowMoveColumn: function(fromVisibleIndex, toVisibleIndex, sourceLocation, targetLocation) {
- var that = this,
- columnIndex = getColumnIndexByVisibleIndex(that, fromVisibleIndex, sourceLocation),
- sourceColumn = that._columns[columnIndex];
- if (sourceColumn && (sourceColumn.allowReordering || sourceColumn.allowGrouping || sourceColumn.allowHiding)) {
- if (sourceLocation === targetLocation) {
- if (sourceLocation === COLUMN_CHOOSER_LOCATION)
- return false;
- return fromVisibleIndex !== toVisibleIndex && fromVisibleIndex + 1 !== toVisibleIndex
- }
- else if (sourceLocation === GROUP_LOCATION && targetLocation !== COLUMN_CHOOSER_LOCATION || targetLocation === GROUP_LOCATION)
- return sourceColumn && sourceColumn.allowGrouping;
- else if (sourceLocation === COLUMN_CHOOSER_LOCATION || targetLocation === COLUMN_CHOOSER_LOCATION)
- return sourceColumn && sourceColumn.allowHiding;
- return true
- }
- return false
- },
- moveColumn: function(fromVisibleIndex, toVisibleIndex, sourceLocation, targetLocation) {
- var that = this,
- fromIndex,
- toIndex,
- targetGroupIndex,
- isGroupMoving = sourceLocation === GROUP_LOCATION || targetLocation === GROUP_LOCATION,
- column;
- fromIndex = getColumnIndexByVisibleIndex(that, fromVisibleIndex, sourceLocation);
- toIndex = getColumnIndexByVisibleIndex(that, toVisibleIndex, targetLocation);
- if (fromIndex >= 0) {
- column = that._columns[fromIndex];
- targetGroupIndex = toIndex >= 0 ? that._columns[toIndex].groupIndex : -1;
- if (isDefined(column.groupIndex)) {
- if (targetGroupIndex > column.groupIndex)
- targetGroupIndex--;
- delete column.groupIndex;
- delete column.sortOrder;
- updateColumnGroupIndexes(that)
- }
- if (targetLocation === GROUP_LOCATION)
- moveColumnToGroup(that, column, targetGroupIndex);
- else if (toVisibleIndex >= 0) {
- that._columns.splice(fromIndex, 1);
- if (toIndex < 0)
- that._columns.push(column);
- else {
- var spliceIndex = toIndex > fromIndex ? toIndex - 1 : toIndex;
- that._columns.splice(spliceIndex, 0, column)
- }
- updateColumnIndexes(that)
- }
- column.visible = targetLocation !== COLUMN_CHOOSER_LOCATION;
- fireColumnsChanged(that, isGroupMoving ? 'grouping' : 'columns')
- }
- },
- changeSortOrder: function(columnIndex, sortOrder) {
- var that = this,
- sortingOptions = that.option('sorting'),
- sortingMode = sortingOptions && sortingOptions.mode,
- needResetSorting = sortingMode === 'single' || !sortOrder,
- allowSorting = sortingMode === 'single' || sortingMode === 'multiple',
- column = that._columns[columnIndex],
- nextSortOrder = function(column) {
- if (sortOrder === "ctrl") {
- delete column.sortOrder;
- delete column.sortIndex
- }
- else if (isDefined(column.groupIndex) || isDefined(column.sortIndex))
- column.sortOrder = column.sortOrder === 'desc' ? 'asc' : 'desc';
- else
- column.sortOrder = 'asc'
- },
- isSortingChanged = false;
- if (allowSorting && column && column.allowSorting) {
- if (needResetSorting && !isDefined(column.groupIndex))
- $.each(that._columns, function(index) {
- if (index !== columnIndex && this.sortOrder && !isDefined(this.groupIndex)) {
- delete this.sortOrder;
- delete this.sortIndex;
- isSortingChanged = true
- }
- });
- if (isSortOrderValid(sortOrder)) {
- if (column.sortOrder !== sortOrder) {
- column.sortOrder = sortOrder;
- isSortingChanged = true
- }
- }
- else if (sortOrder === 'none') {
- if (column.sortOrder) {
- delete column.sortIndex;
- delete column.sortOrder;
- isSortingChanged = true
- }
- }
- else {
- nextSortOrder(column);
- isSortingChanged = true
- }
- }
- if (isSortingChanged) {
- updateColumnSortIndexes(that);
- fireColumnsChanged(that, 'sorting')
- }
- },
- getSortDataSourceParameters: function() {
- var that = this,
- sortColumns = [],
- sort = [];
- $.each(that._columns, function() {
- if ((this.dataField || this.calculateCellValue) && this.visible && isDefined(this.sortIndex) && !isDefined(this.groupIndex))
- sortColumns[this.sortIndex] = this
- });
- $.each(sortColumns, function() {
- var sortOrder = this && this.sortOrder;
- if (isSortOrderValid(sortOrder))
- sort.push({
- selector: this.dataField || this.calculateCellValue,
- desc: this.sortOrder === 'desc'
- })
- });
- return sort.length > 0 ? sort : null
- },
- getGroupDataSourceParameters: function() {
- var group = [];
- $.each(this.getGroupColumns(), function() {
- var selector = this.dataField || this.calculateCellValue;
- if (selector)
- group.push({
- selector: selector,
- desc: this.sortOrder === 'desc',
- isExpanded: !!this.autoExpandGroup
- })
- });
- return group.length > 0 ? group : null
- },
- refresh: function(updateNewLookupsOnly) {
- var deferreds = [];
- $.each(this._columns, function() {
- var lookup = this.lookup;
- if (lookup) {
- if (updateNewLookupsOnly && lookup.valueMap)
- return;
- if (lookup.update)
- deferreds.push(lookup.update())
- }
- });
- return $.when.apply($, deferreds)
- },
- _updateColumnDataTypes: function(dataSource) {
- var firstItems = getFirstItems(dataSource),
- rtlEnabled = this.option("rtlEnabled");
- $.each(this._columns, function(index, column) {
- var i,
- value,
- dataType,
- lookup = column.lookup;
- if (column.dataField && firstItems.length)
- for (i = 0; (!column.dataType || lookup && !lookup.dataType) && i < firstItems.length; i++) {
- value = column.calculateCellValue(firstItems[i]);
- column.dataType = getValueDataType(value);
- if (lookup)
- lookup.dataType = getValueDataType(lookup.calculateCellValue(value))
- }
- dataType = lookup ? lookup.dataType : column.dataType;
- if (dataType) {
- column.alignment = column.alignment || getAlignmentByDataType(dataType, rtlEnabled);
- column.format = column.format || getFormatByDataType(dataType);
- column.customizeText = column.customizeText || getCustomizeTextByDataType(dataType);
- if (!isDefined(column.filterOperations))
- column.filterOperations = !lookup && DATATYPE_OPERATIONS[dataType] || [];
- column.defaultFilterOperation = column.filterOperations && column.filterOperations[0] || '=';
- column.defaultSelectedFilterOperation = column.selectedFilterOperation
- }
- })
- },
- updateColumns: function(dataSource) {
- var that = this,
- customizeColumns = that.option('customizeColumns'),
- sortParameters,
- groupParameters;
- that.updateSortingGrouping(dataSource);
- if (!dataSource || dataSource.isLoaded()) {
- sortParameters = dataSource ? dataSource.sort() || [] : that.getSortDataSourceParameters();
- groupParameters = dataSource ? dataSource.group() || [] : that.getGroupDataSourceParameters();
- if (customizeColumns) {
- customizeColumns(that._columns);
- that._columns = createColumnsFromOptions(that, that._columns)
- }
- updateIndexes(that);
- that._updateColumnDataTypes(dataSource);
- return $.when(that.refresh(true), applyColumnTypesToDataSource(that, dataSource)).always(function() {
- if (dataSource) {
- that._updateColumnDataTypes(dataSource);
- that._dataSourceApplied = true
- }
- if (!equalSortParameters(sortParameters, that.getSortDataSourceParameters()))
- updateColumnChanges(that, 'sorting');
- else if (!equalSortParameters(groupParameters, that.getGroupDataSourceParameters()))
- updateColumnChanges(that, 'grouping');
- else
- updateColumnChanges(that, 'columns');
- fireColumnsChanged(that)
- })
- }
- },
- updateSortingGrouping: function(dataSource) {
- var that = this,
- sortParameters,
- groupParameters,
- columnsGroupParameters,
- columnsSortParameters,
- updateSortGroupParameterIndexes = function(columns, sortParameters, indexParameterName) {
- var i;
- $.each(columns, function(index, column) {
- if (column.dataField) {
- delete column[indexParameterName];
- if (sortParameters && sortParameters.length)
- for (i = 0; i < sortParameters.length; i++)
- if (sortParameters[i].selector === column.dataField) {
- column.sortOrder = column.sortOrder || (sortParameters[i].desc ? 'desc' : 'asc');
- column[indexParameterName] = i;
- break
- }
- }
- })
- };
- if (dataSource) {
- sortParameters = normalizeSortingInfo(dataSource.sort() || []);
- groupParameters = normalizeSortingInfo(dataSource.group() || []);
- columnsGroupParameters = that.getGroupDataSourceParameters();
- columnsSortParameters = that.getSortDataSourceParameters();
- if (!that._columns.length) {
- $.each(groupParameters, function(index, group) {
- that._columns.push(group.selector)
- });
- $.each(sortParameters, function(index, sort) {
- that._columns.push(sort.selector)
- });
- that._columns = createColumnsFromOptions(that, that._columns)
- }
- if (!columnsGroupParameters && !equalSortParameters(groupParameters, columnsGroupParameters)) {
- that.__groupingUpdated = true;
- updateSortGroupParameterIndexes(that._columns, groupParameters, 'groupIndex')
- }
- if (!columnsSortParameters && !equalSortParameters(sortParameters, columnsSortParameters)) {
- that.__sortingUpdated = true;
- updateSortGroupParameterIndexes(that._columns, sortParameters, 'sortIndex')
- }
- }
- },
- columnCount: function() {
- return this._columns.length
- },
- columnOption: function(identificator, option, value) {
- var that = this,
- i,
- columns = that._columns,
- column;
- for (i = 0; i < columns.length; i++)
- if (columns[i].initialIndex === identificator || columns[i].dataField === identificator || columns[i].caption === identificator) {
- column = columns[i];
- break
- }
- if (column) {
- if (arguments.length === 1)
- return $.extend({}, column);
- if (utils.isString(option))
- if (arguments.length === 2)
- return columnOptionCore(that, column, option);
- else
- columnOptionCore(that, column, option, value);
- else if (utils.isObject(option))
- $.each(option, function(optionName, value) {
- columnOptionCore(that, column, optionName, value)
- });
- updateIndexes(that, column);
- fireColumnsChanged(that)
- }
- },
- getVisibleIndex: function(initialIndex) {
- var i,
- visibleColumns = this.getVisibleColumns();
- for (i = 0; i < visibleColumns.length; i++)
- if (visibleColumns[i].initialIndex === initialIndex)
- return i;
- return -1
- },
- addColumn: function(options) {
- var that = this;
- that._columns.push(createColumn(that, options));
- that.updateColumns()
- },
- getUserState: function() {
- var columns = this._columns,
- result = [],
- i;
- for (i = 0; i < columns.length; i++) {
- result[i] = {};
- $.each(USER_STATE_FIELD_NAMES, function(index, value) {
- if (columns[i][value] !== undefined)
- result[i][value] = columns[i][value]
- })
- }
- return result
- },
- setUserState: function(state) {
- this._columnsUserState = state;
- this.init()
- },
- _createCalculatedColumnOptions: function(columnOptions) {
- var calculatedColumnOptions = {};
- if (columnOptions.dataField) {
- calculatedColumnOptions = {
- caption: convertNameToCaption(columnOptions.dataField),
- calculateCellValue: dataUtils.compileGetter(columnOptions.dataField),
- validate: function(value) {
- if (typeof value === 'string')
- return !value || !this.parseValue || this.parseValue(value) !== undefined;
- return true
- },
- parseValue: function(text) {
- var column = this,
- result,
- parsedValue;
- if (column.dataType === 'number') {
- if (utils.isString(text)) {
- parsedValue = Globalize.parseFloat(text);
- if (utils.isNumber(parsedValue))
- result = parsedValue
- }
- else if (utils.isDefined(text))
- result = Number(text)
- }
- else if (column.dataType === 'boolean') {
- if (text === column.trueText)
- result = true;
- else if (text === column.falseText)
- result = false
- }
- else if (column.dataType === 'date') {
- parsedValue = Globalize.parseDate(text);
- if (parsedValue)
- result = parsedValue
- }
- else if (column.dataType === 'guid') {
- if (GUID_REGEX.test(text))
- result = text
- }
- else
- result = text;
- return result
- }
- };
- if (columnOptions.lookup)
- calculatedColumnOptions.lookup = {
- calculateCellValue: function(value) {
- return this.valueMap && this.valueMap[value]
- },
- updateValueMap: function() {
- var calculateValue,
- calculateDisplayValue,
- item,
- i;
- this.valueMap = {};
- if (this.items) {
- calculateValue = dataUtils.compileGetter(this.valueExpr);
- calculateDisplayValue = dataUtils.compileGetter(this.displayExpr);
- for (i = 0; i < this.items.length; i++) {
- item = this.items[i];
- this.valueMap[calculateValue(item)] = calculateDisplayValue(item)
- }
- }
- },
- update: function() {
- var that = this,
- dataSource = that.dataSource;
- if (dataSource)
- if (utils.isObject(dataSource) || utils.isArray(dataSource)) {
- dataSource = new DX.data.DataSource($.extend(true, {
- paginate: false,
- _preferSync: true
- }, dataUtils.normalizeDataSourceOptions(dataSource)));
- return dataSource.load().done(function(data) {
- that.items = data;
- that.updateValueMap && that.updateValueMap()
- })
- }
- else
- DX.utils.logger.error("Unexpected type of data source is provided for a lookup column. For the list of supported types, see http://js.devexpress.com/Documentation/ApiReference/UI_Widgets/dxDataGrid/Configuration/columns/lookup#dataSource");
- else
- that.updateValueMap && that.updateValueMap()
- }
- }
- }
- else
- $.extend(true, calculatedColumnOptions, {calculateCellValue: function() {
- return null
- }});
- calculatedColumnOptions.resizedCallbacks = $.Callbacks();
- if (columnOptions.resized)
- calculatedColumnOptions.resizedCallbacks.add($.proxy(columnOptions.resized, columnOptions));
- return calculatedColumnOptions
- }
- }
- }());
- ui.dataGrid.ColumnsController = ColumnsController;
- dataGrid.registerModule('columns', {
- defaultOptions: function() {
- return {
- commonColumnSettings: {
- allowFiltering: true,
- allowHiding: true,
- allowSorting: true,
- allowEditing: true,
- encodeHtml: true,
- trueText: Globalize.localize("dxDataGrid-trueText"),
- falseText: Globalize.localize("dxDataGrid-falseText")
- },
- grouping: {
- autoExpandAll: true,
- allowCollapsing: true,
- groupContinuesMessage: Globalize.localize("dxDataGrid-groupContinuesMessage"),
- groupContinuedMessage: Globalize.localize("dxDataGrid-groupContinuedMessage")
- },
- allowColumnReordering: false,
- allowColumnResizing: false,
- columns: undefined,
- regenerateColumnsByVisibleItems: false,
- sorting: {
- mode: 'single',
- ascendingText: Globalize.localize("dxDataGrid-sortingAscendingText"),
- descendingText: Globalize.localize("dxDataGrid-sortingDescendingText"),
- clearText: Globalize.localize("dxDataGrid-sortingClearText")
- },
- customizeColumns: null
- }
- },
- controllers: {columns: ColumnsController}
- })
- })(jQuery, DevExpress);
- /*! Module widgets-web, file ui.dataGrid.selection.js */
- (function($, DX) {
- var dataGrid = DX.ui.dataGrid,
- events = DX.ui.events,
- utils = DX.utils;
- var DATAGRID_EDITOR_CELL_CLASS = "dx-editor-cell",
- DATAGRID_ROW_SELECTION_CLASS = "dx-selection",
- DATAGRID_SELECT_CHECKBOX_CLASS = "dx-select-checkbox",
- LONG_TAP_TIME = 500,
- MAX_EQUAL_KEYS_LEVEL = 3;
- $.extend(dataGrid.__internals, {DATAGRID_ROW_SELECTION_CLASS: DATAGRID_ROW_SELECTION_CLASS});
- var SHOW_CHECKBOXES_MODE = 'selection.showCheckBoxesInMultipleMode';
- dataGrid.equalKeys = function(key1, key2, level) {
- var propertyName,
- i;
- level = level || 0;
- if (level < MAX_EQUAL_KEYS_LEVEL)
- if (utils.isObject(key1) && utils.isObject(key2)) {
- for (propertyName in key1)
- if (key1.hasOwnProperty(propertyName) && !dataGrid.equalKeys(key1[propertyName], key2[propertyName], level + 1))
- return false;
- for (propertyName in key2)
- if (!(propertyName in key1))
- return false;
- return true
- }
- else if (utils.isArray(key1) && utils.isArray(key2)) {
- if (key1.length !== key2.length)
- return false;
- for (i = 0; i < key1.length; i++)
- if (!dataGrid.equalKeys(key1[i], key2[i], level + 1))
- return false;
- return true
- }
- else if (utils.isDate(key1) && utils.isDate(key2))
- return key1.getTime() === key2.getTime();
- else
- return key1 === key2;
- return true
- };
- dataGrid.SelectionController = dataGrid.Controller.inherit(function() {
- var SELECTION_MODE = 'selection.mode';
- var isSelectable = function(selectionMode) {
- return selectionMode === 'single' || selectionMode === 'multiple'
- };
- var indexOfSelectedItemKey = function(that, key, isSelectAll) {
- var index,
- selectedItemKeys = isSelectAll ? that._unselectedItemKeys : that._selectedItemKeys;
- if (utils.isObject(key)) {
- for (index = 0; index < selectedItemKeys.length; index++)
- if (equalKeys(selectedItemKeys[index], key))
- return index;
- return -1
- }
- else
- return $.inArray(key, selectedItemKeys)
- };
- var addSelectedItem = function(that, itemData) {
- var key = that.getController('data').keyOf(itemData),
- keyIndex;
- if (indexOfSelectedItemKey(that, key) === -1) {
- that._selectedItemKeys.push(key);
- that._addedItemKeys.push(key);
- that._selectedItems.push(itemData)
- }
- if (that._isSelectAll) {
- keyIndex = indexOfSelectedItemKey(that, key, true);
- that._unselectedItemKeys.splice(keyIndex, 1)
- }
- };
- var removeSelectedItem = function(that, key) {
- var keyIndex = indexOfSelectedItemKey(that, key);
- if (keyIndex >= 0) {
- that._selectedItemKeys.splice(keyIndex, 1);
- that._removedItemKeys.push(key);
- that._selectedItems.splice(keyIndex, 1);
- if (that._isSelectAll && indexOfSelectedItemKey(that, key, true) === -1)
- that._unselectedItemKeys.push(key)
- }
- };
- var clearSelectedItems = function(that) {
- setSelectedItems(that, [], [])
- };
- var setSelectedItems = function(that, keys, items, isSelectAll) {
- var i,
- oldSelectedItemKeys = that._selectedItemKeys;
- that._selectedItemKeys = keys;
- that._selectedItems = items;
- that._unselectedItemKeys = [];
- that._isSelectAll = !!isSelectAll;
- for (i = 0; i < oldSelectedItemKeys.length; i++)
- if ($.inArray(oldSelectedItemKeys[i], keys) === -1)
- that._removedItemKeys.push(oldSelectedItemKeys[i]);
- for (i = 0; i < keys.length; i++)
- if ($.inArray(keys[i], oldSelectedItemKeys) === -1)
- that._addedItemKeys.push(keys[i])
- };
- var equalKeys = dataGrid.equalKeys;
- var resetItemSelectionWhenShiftKeyPressed = function(that) {
- delete that._shiftFocusedItemIndex
- };
- var isDataItem = function(row) {
- return row && row.rowType === "data"
- };
- var changeItemSelectionWhenShiftKeyPressed = function(that, itemIndex, items) {
- var isSelectedItemsChanged = false,
- itemIndexStep,
- index,
- dataController = that.getController('data'),
- isFocusedItemSelected = items[that._focusedItemIndex] && that.isSelectedItem(dataController.keyOf(items[that._focusedItemIndex].data));
- var addRemoveSelectedItem = function(that, data, isRemove) {
- if (isRemove)
- removeSelectedItem(that, dataController.keyOf(data));
- else
- addSelectedItem(that, data)
- };
- if (!utils.isDefined(that._shiftFocusedItemIndex))
- that._shiftFocusedItemIndex = that._focusedItemIndex;
- if (that._shiftFocusedItemIndex !== that._focusedItemIndex) {
- itemIndexStep = that._focusedItemIndex < that._shiftFocusedItemIndex ? 1 : -1;
- for (index = that._focusedItemIndex; index !== that._shiftFocusedItemIndex; index += itemIndexStep)
- if (isDataItem(items[index])) {
- addRemoveSelectedItem(that, items[index].data, true);
- isSelectedItemsChanged = true
- }
- }
- if (itemIndex !== that._shiftFocusedItemIndex) {
- itemIndexStep = itemIndex < that._shiftFocusedItemIndex ? 1 : -1;
- for (index = itemIndex; index !== that._shiftFocusedItemIndex; index += itemIndexStep)
- if (isDataItem(items[index])) {
- addRemoveSelectedItem(that, items[index].data, false);
- isSelectedItemsChanged = true
- }
- }
- if (isDataItem(items[that._focusedItemIndex]) && !isFocusedItemSelected) {
- addRemoveSelectedItem(that, items[that._focusedItemIndex].data, false);
- isSelectedItemsChanged = true
- }
- return isSelectedItemsChanged
- };
- var createSelectedItemsFilterCriteria = function(dataSource, selectedItemKeys, isSelectAll) {
- var keyCriteria,
- i,
- key = dataSource && dataSource.key(),
- criteria = [];
- if (dataSource)
- if (key)
- $.each(selectedItemKeys, function(index, keyValue) {
- if (criteria.length > 0)
- criteria.push(isSelectAll ? 'and' : 'or');
- if ($.isArray(key)) {
- keyCriteria = [];
- for (i = 0; i < key.length; i++) {
- if (i > 0)
- keyCriteria.push(isSelectAll ? 'or' : 'and');
- keyCriteria.push([key[i], isSelectAll ? '<>' : '=', keyValue[key[i]]])
- }
- criteria.push(keyCriteria)
- }
- else
- criteria.push([key, isSelectAll ? '<>' : '=', keyValue])
- });
- else
- criteria = function(item) {
- var i;
- for (i = 0; i < selectedItemKeys.length; i++)
- if (equalKeys(selectedItemKeys[i], item))
- return !isSelectAll;
- return isSelectAll
- };
- if (criteria.length > 0 || $.isFunction(criteria))
- return criteria
- };
- var updateSelectedItems = function(that) {
- var changedItemIndexes = [],
- dataController = that.getController('data'),
- addedItemKeys,
- removedItemKeys;
- if (dataController) {
- $.each(dataController.items(), function(index, row) {
- var key = dataController.keyOf(row.data);
- if (isDataItem(row) && row.isSelected !== that.isSelectedItem(key))
- changedItemIndexes.push(index)
- });
- if (that.option(SHOW_CHECKBOXES_MODE) === 'onClick')
- if (that._selectedItemKeys.length > 1)
- that.startSelectionWithCheckboxes();
- else if (that._selectedItemKeys.length === 0 && changedItemIndexes.length)
- that.stopSelectionWithCheckboxes();
- if (changedItemIndexes.length)
- dataController.updateItems({
- changeType: 'updateSelection',
- itemIndexes: changedItemIndexes
- });
- addedItemKeys = that._addedItemKeys;
- removedItemKeys = that._removedItemKeys;
- if (addedItemKeys.length || removedItemKeys.length) {
- that._selectedItemsInternalChange = true;
- that.option("selectedRowKeys", that._selectedItemKeys.slice(0));
- that._selectedItemsInternalChange = false;
- that.selectionChanged.fire(that._selectedItemKeys);
- that.executeAction("selectionChanged", {
- selectedRowsData: that._selectedItems,
- selectedRowKeys: that._selectedItemKeys,
- currentSelectedRowKeys: addedItemKeys,
- currentDeselectedRowKeys: removedItemKeys
- })
- }
- that._addedItemKeys = [];
- that._removedItemKeys = []
- }
- };
- return {
- init: function() {
- var that = this;
- that._isSelectionWithCheckboxes = false;
- that._focusedItemIndex = -1;
- that._selectedItemKeys = [];
- that._unselectedItemKeys = [];
- that._selectedItems = [];
- that._addedItemKeys = [];
- that._removedItemKeys = [];
- that._isSelectAll = false;
- that.createAction("selectionChanged")
- },
- callbackNames: function() {
- return ['selectionChanged']
- },
- optionChanged: function(name, value, prevValue) {
- switch (name) {
- case"selection":
- this.init();
- this.getController('columns').updateColumns();
- break;
- case"selectedRowKeys":
- if (utils.isArray(value) && !this._selectedItemsInternalChange)
- this.selectRows(value);
- break;
- case"selectionChanged":
- this.createAction("selectionChanged");
- break
- }
- },
- publicMethods: function() {
- return ['selectRows', 'selectRowsByIndexes', 'getSelectedRowKeys', 'getSelectedRowsData', 'clearSelection', 'selectAll', 'startSelectionWithCheckboxes', 'stopSelectionWithCheckboxes']
- },
- isSelectedItem: function(key) {
- var index = indexOfSelectedItemKey(this, key);
- return index !== -1
- },
- isSelectColumnVisible: function() {
- var showCheckboxesMode = this.option(SHOW_CHECKBOXES_MODE);
- return this.option(SELECTION_MODE) === 'multiple' && (showCheckboxesMode === 'always' || showCheckboxesMode === 'onClick' || this._isSelectionWithCheckboxes)
- },
- isSelectAll: function() {
- return this._isSelectAll && !this._unselectedItemKeys.length
- },
- selectAll: function() {
- if (this.option(SHOW_CHECKBOXES_MODE) === 'onClick')
- this.startSelectionWithCheckboxes();
- return this.selectedItemKeys([], true)
- },
- clearSelection: function() {
- this.selectedItemKeys([])
- },
- refresh: function() {
- var that = this,
- result;
- if (that.isSelectAll())
- result = that.selectAll();
- else
- result = that.selectedItemKeys(that.option("selectedRowKeys") || []);
- return result.done(function(selectedRows) {
- updateSelectedItems(that)
- })
- },
- selectedItemKeys: function(value, isSelectAll) {
- var that = this,
- keys,
- criteria,
- isFunctionCriteria,
- deferred,
- dataController = that.getController('data'),
- dataSource = dataController.dataSource(),
- store = dataSource && dataSource.store(),
- dataSourceFilter,
- filter;
- if (utils.isDefined(value)) {
- if (store) {
- keys = $.isArray(value) ? $.extend(true, [], value) : [value];
- that._isSelectAll = isSelectAll;
- if (keys.length || isSelectAll) {
- criteria = createSelectedItemsFilterCriteria(dataSource, keys, isSelectAll);
- isFunctionCriteria = $.isFunction(criteria);
- if (criteria || isSelectAll) {
- dataSourceFilter = dataSource.filter();
- if (criteria && !isFunctionCriteria && dataSourceFilter) {
- filter = [];
- filter.push(criteria);
- filter.push(dataSourceFilter)
- }
- else if (dataSourceFilter)
- filter = dataSourceFilter;
- else if (criteria && !isFunctionCriteria)
- filter = criteria;
- deferred = $.Deferred();
- dataController.setSelectionLoading(true);
- store.load({filter: filter}).done(function(items) {
- new DX.data.ArrayStore(items).load({filter: criteria}).done(function(items) {
- deferred.resolve(items)
- })
- }).fail($.proxy(deferred.reject, deferred)).always(function() {
- dataController.setSelectionLoading(false)
- })
- }
- }
- }
- deferred = deferred || $.Deferred().resolve([]);
- deferred.done(function(items) {
- var i,
- key,
- keys = [];
- if (store && items.length > 0)
- for (i = 0; i < items.length; i++) {
- key = store.keyOf(items[i]);
- keys.push(key)
- }
- setSelectedItems(that, keys, items, isSelectAll);
- updateSelectedItems(that)
- });
- return deferred
- }
- else
- return that._selectedItemKeys
- },
- getSelectedRowKeys: function() {
- return this.selectedItemKeys()
- },
- selectRows: function(keys) {
- return this.selectedItemKeys(keys)
- },
- selectRowsByIndexes: function(indexes) {
- var items = this.getController('data').items(),
- i,
- keys = [];
- if (!utils.isArray(indexes))
- indexes = Array.prototype.slice.call(arguments, 0);
- $.each(indexes, function() {
- var item = items[this];
- if (item && item.rowType === 'data')
- keys.push(item.key)
- });
- return this.selectRows(keys)
- },
- getSelectedRowsData: function() {
- return this._selectedItems
- },
- changeItemSelection: function(itemIndex, keys) {
- var that = this,
- dataController = that.getController('data'),
- items = dataController.items(),
- item = items[itemIndex],
- itemData = item && item.data,
- selectionMode = that.option(SELECTION_MODE),
- isSelectedItemsChanged,
- isSelected,
- itemKey;
- if (isSelectable(selectionMode) && isDataItem(item)) {
- itemKey = dataController.keyOf(itemData);
- keys = keys || {};
- if (that.isSelectionWithCheckboxes())
- keys.control = true;
- if (keys.shift && selectionMode === 'multiple' && that._focusedItemIndex >= 0)
- isSelectedItemsChanged = changeItemSelectionWhenShiftKeyPressed(that, itemIndex, items);
- else if (keys.control) {
- resetItemSelectionWhenShiftKeyPressed(that);
- isSelected = that.isSelectedItem(itemKey);
- if (selectionMode === 'single')
- clearSelectedItems(that);
- if (isSelected)
- removeSelectedItem(that, itemKey);
- else
- addSelectedItem(that, itemData);
- isSelectedItemsChanged = true
- }
- else {
- resetItemSelectionWhenShiftKeyPressed(that);
- if (that._selectedItemKeys.length !== 1 || !equalKeys(that._selectedItemKeys[0], itemKey)) {
- setSelectedItems(that, [itemKey], [itemData]);
- isSelectedItemsChanged = true
- }
- }
- if (isSelectedItemsChanged) {
- that._focusedItemIndex = itemIndex;
- updateSelectedItems(that);
- return true
- }
- }
- return false
- },
- focusedItemIndex: function(itemIndex) {
- var that = this;
- if (utils.isDefined(itemIndex))
- that._focusedItemIndex = itemIndex;
- else
- return that._focusedItemIndex
- },
- isSelectionWithCheckboxes: function() {
- var selectionMode = this.option(SELECTION_MODE),
- showCheckboxesMode = this.option(SHOW_CHECKBOXES_MODE);
- return selectionMode === 'multiple' && (showCheckboxesMode === 'always' || this._isSelectionWithCheckboxes)
- },
- startSelectionWithCheckboxes: function() {
- var that = this,
- isSelectColumnVisible = that.isSelectColumnVisible();
- if (that.option(SELECTION_MODE) === 'multiple' && !that.isSelectionWithCheckboxes()) {
- that._isSelectionWithCheckboxes = true;
- if (isSelectColumnVisible !== that.isSelectColumnVisible())
- that.getController('columns').updateColumns();
- else if (that.option(SHOW_CHECKBOXES_MODE) === 'onClick')
- updateSelectedItems(that);
- return true
- }
- return false
- },
- stopSelectionWithCheckboxes: function() {
- var that = this,
- isSelectColumnVisible = that.isSelectColumnVisible();
- if (that._isSelectionWithCheckboxes) {
- that._isSelectionWithCheckboxes = false;
- if (isSelectColumnVisible !== that.isSelectColumnVisible())
- that.getController('columns').updateColumns();
- return true
- }
- return false
- }
- }
- }());
- dataGrid.registerModule('selection', {
- defaultOptions: function() {
- return {
- selection: {
- mode: 'none',
- showCheckBoxesInMultipleMode: 'onClick',
- allowSelectAll: true
- },
- selectionChanged: null,
- selectedRowKeys: []
- }
- },
- controllers: {selection: dataGrid.SelectionController},
- extenders: {
- controllers: {
- data: {
- setDataSource: function(dataSource) {
- this.callBase(dataSource);
- this.getController('selection').refresh()
- },
- setSelectionLoading: function(isLoading) {
- this._isSelectionLoading = isLoading;
- this._fireLoadingChanged()
- },
- isLoading: function() {
- var isLoading = this.callBase();
- return isLoading || !!this._isSelectionLoading
- },
- pageIndex: function(value) {
- var that = this,
- dataSource = that._dataSource;
- if (dataSource && value && dataSource.pageIndex() !== value)
- that.getController('selection').focusedItemIndex(-1);
- return that.callBase(value)
- },
- _processDataItem: function() {
- var that = this,
- selectionController = that.getController('selection'),
- hasSelectColumn = selectionController.isSelectColumnVisible(),
- dataItem = this.callBase.apply(this, arguments);
- dataItem.isSelected = selectionController.isSelectedItem(dataItem.key);
- if (hasSelectColumn && dataItem.values)
- dataItem.values[0] = dataItem.isSelected;
- return dataItem
- },
- refresh: function() {
- this.callBase.apply(this, arguments);
- this.getController('selection').refresh()
- }
- },
- columns: {getVisibleColumns: function() {
- var that = this,
- selectionController = that.getController('selection'),
- columns = that.callBase();
- columns = $.grep(columns, function(column) {
- return column.command !== 'select'
- });
- if (selectionController.isSelectColumnVisible() && columns.length)
- columns.unshift({
- visible: true,
- command: 'select',
- dataType: 'boolean',
- alignment: 'center',
- width: 70
- });
- return columns
- }}
- },
- views: {
- columnHeadersView: {
- _renderCore: function(options) {
- var that = this;
- that.getController('selection').selectionChanged.remove(that._selectionChangedHandler);
- that.callBase(options)
- },
- _renderHeaderContent: function(rootElement, column, columnIndex) {
- var that = this,
- groupElement,
- selectionController = that.getController('selection');
- var getSelectAllValue = function(selectionController) {
- if (selectionController.isSelectAll() || selectionController.getSelectedRowKeys().length === 0)
- return selectionController.isSelectAll()
- };
- if (column.command === 'select') {
- rootElement.addClass(DATAGRID_EDITOR_CELL_CLASS);
- groupElement = $('<div />').appendTo(rootElement);
- that.getController('editorFactory').createEditor(groupElement, $.extend({}, column, {
- parentType: "headerRow",
- value: getSelectAllValue(selectionController),
- setValue: function(value, e) {
- if (e.jQueryEvent && getSelectAllValue(selectionController) !== value) {
- if (e.previousValue === undefined || e.previousValue) {
- selectionController.clearSelection();
- e.component.option('value', false)
- }
- if (e.previousValue === false)
- if (that.option("selection.allowSelectAll"))
- selectionController.selectAll();
- else
- e.component.option('value', false);
- e.jQueryEvent.preventDefault()
- }
- }
- }));
- rootElement.on('dxclick', that.createAction(function(e) {
- var event = e.jQueryEvent;
- if (!$(event.target).closest('.dx-checkbox').length)
- $(event.currentTarget).children().trigger('dxclick');
- event.preventDefault()
- }));
- that._selectionChangedHandler = function() {
- groupElement.dxCheckBox('instance').option('value', getSelectAllValue(selectionController))
- };
- selectionController.selectionChanged.add(that._selectionChangedHandler)
- }
- else
- that.callBase(rootElement, column, columnIndex)
- }
- },
- rowsView: {
- _getDefaultTemplate: function(column) {
- var that = this,
- groupElement;
- if (column.command === 'select')
- return function(container, options) {
- container.addClass(DATAGRID_EDITOR_CELL_CLASS);
- container.on('dxclick', that.createAction(function(e) {
- var selectionController = that.getController('selection'),
- event = e.jQueryEvent,
- rowIndex = that.getRowIndex($(event.currentTarget).closest('.dx-row'));
- if (rowIndex >= 0) {
- selectionController.startSelectionWithCheckboxes();
- selectionController.changeItemSelection(rowIndex, {shift: event.shiftKey})
- }
- }));
- groupElement = $('<div />').addClass(DATAGRID_SELECT_CHECKBOX_CLASS).appendTo(container);
- that.getController('editorFactory').createEditor(groupElement, $.extend({}, column, {
- parentType: "dataRow",
- value: options.value
- }))
- };
- else
- return that.callBase(column)
- },
- _update: function(change) {
- var that = this;
- if (change.changeType === 'updateSelection') {
- if (that._tableElement.length > 0)
- $.each(change.itemIndexes || [], function(_, index) {
- var $row,
- isSelected;
- if (change.items[index]) {
- $row = that._getRowElements().eq(index);
- isSelected = !!change.items[index].isSelected;
- $row.toggleClass(DATAGRID_ROW_SELECTION_CLASS, isSelected);
- $row.find('.dx-checkbox').dxCheckBox('option', 'value', isSelected)
- }
- });
- that._updateCheckboxesClass()
- }
- else
- that.callBase(change)
- },
- _createTable: function() {
- var that = this,
- $table = that.callBase();
- return $table.on(events.addNamespace('dxpointerdown', "dxDataGridRowsView"), that.createAction(function(e) {
- that._isTouchEvent = events.isTouchEvent(e.jQueryEvent)
- })).on(events.addNamespace('dxhold', "dxDataGridRowsView"), {timeout: that.option("selection.longTapTime") || LONG_TAP_TIME}, that.createAction(function(e) {
- var selectionController = that.getController('selection'),
- event = e.jQueryEvent;
- if (that.option(SHOW_CHECKBOXES_MODE) === 'onLongTap')
- if (selectionController.isSelectionWithCheckboxes())
- selectionController.stopSelectionWithCheckboxes();
- else
- selectionController.startSelectionWithCheckboxes();
- if (that.option(SHOW_CHECKBOXES_MODE) === 'onClick')
- $(event.target).closest('.dx-row').find(DATAGRID_SELECT_CHECKBOX_CLASS).parent().trigger('dxclick')
- })).on('mousedown selectstart', that.createAction(function(e) {
- var event = e.jQueryEvent;
- if (event.shiftKey)
- event.preventDefault()
- }))
- },
- _createRow: function(rowOptions) {
- var $row = this.callBase(rowOptions);
- rowOptions && $row.toggleClass(DATAGRID_ROW_SELECTION_CLASS, !!rowOptions.isSelected);
- return $row
- },
- _rowClick: function(rowIndex, event) {
- var that = this;
- that.getController('selection').changeItemSelection(rowIndex, {
- control: event.ctrlKey,
- shift: event.shiftKey
- });
- that.callBase(rowIndex, event)
- },
- _renderCore: function(change) {
- this.callBase(change);
- this._updateCheckboxesClass()
- },
- _updateCheckboxesClass: function() {
- var selectionController = this.getController('selection');
- this._element().toggleClass('dx-select-checkboxes-hidden', selectionController.isSelectColumnVisible() && !selectionController.isSelectionWithCheckboxes())
- }
- }
- }
- }
- })
- })(jQuery, DevExpress);
- /*! Module widgets-web, file ui.dataGrid.editorFactory.js */
- (function($, DX) {
- var dataGrid = DX.ui.dataGrid,
- addNamespace = DX.ui.events.addNamespace;
- var FILTERING_TIMEOUT = 700,
- DATAGRID_CHECKBOX_SIZE_CLASS = "dx-datagrid-checkbox-size",
- DATAGRID_MODULE_NAMESPACE = 'dxDataGridEditorFactory',
- DATAGRID_UPDATE_FOCUS_EVENTS = addNamespace('focusin dxpointerdown dxclick', DATAGRID_MODULE_NAMESPACE),
- ENTER_KEY = 13,
- TAB_KEY = 9,
- DATAGRID_FOCUS_OVERLAY_CLASS = 'dx-datagrid-focus-overlay',
- DATAGRID_FOCUSED_ELEMENT_CLASS = 'dx-focused',
- DATAGRID_CONTENT_CLASS = 'dx-datagrid-content';
- dataGrid.EditorFactoryController = dataGrid.Controller.inherit(function() {
- var createCalendarPicker = function($container, options) {
- $container.dxDateBox({
- value: options.value,
- useCalendar: true,
- customOverlayCssClass: 'dx-datagrid',
- formatString: DX.utils.isString(options.format) && DX.DateTimeFormat[options.format.toLowerCase()] || options.format,
- formatWidthCalculator: null,
- rtlEnabled: options.rtlEnabled,
- disabled: options.disabled
- });
- $container.dxDateBox('instance').optionChanged.add(function(optionName, value) {
- if (optionName === 'value')
- options.setValue(value)
- })
- };
- var createTextBox = function($container, options) {
- var toString = function(value) {
- return DX.utils.isDefined(value) ? value.toString() : ''
- },
- isFilterRow = options.parentType === 'filterRow',
- isSearchPanel = options.parentType === 'searchPanel';
- $container.dxTextBox({
- placeholder: options.placeholder,
- width: options.width,
- value: toString(options.value),
- valueChangeAction: function(e) {
- var updateValue = function(e, isTimeout) {
- var parsedValue;
- if (!options.validate || options.validate(e.value)) {
- parsedValue = options.parseValue ? options.parseValue(e.value) : e.value;
- options.setValue(parsedValue !== undefined ? parsedValue : null, e)
- }
- else if (!isTimeout)
- e.component.option('value', toString(e.previousValue))
- };
- window.clearTimeout($container._valueChangeTimeoutID);
- if (e.jQueryEvent && e.jQueryEvent.type === "keyup")
- $container._valueChangeTimeoutID = window.setTimeout(function() {
- updateValue(e, true)
- }, FILTERING_TIMEOUT);
- else if (e.jQueryEvent && e.jQueryEvent.type === 'keydown') {
- if (e.jQueryEvent.which === ENTER_KEY || e.jQueryEvent.which === TAB_KEY)
- updateValue(e)
- }
- else
- updateValue(e)
- },
- mode: isSearchPanel ? 'search' : 'text',
- valueChangeEvent: 'change keydown' + (isFilterRow ? ' keyup' : '') + (isSearchPanel ? ' keyup search' : ''),
- rtlEnabled: options.rtlEnabled,
- disabled: options.disabled
- })
- };
- var createBooleanEditor = function($container, options) {
- if (options.parentType === 'filterRow')
- createSelectBox($container, $.extend({lookup: {
- displayExpr: function(data) {
- if (data === true)
- return options.trueText || 'true';
- else if (data === false)
- return options.falseText || 'false'
- },
- items: [true, false],
- rtlEnabled: options.rtlEnabled,
- disabled: options.disabled
- }}, options));
- else
- createCheckBox($container, options)
- };
- var createSelectBox = function($container, options) {
- var lookup = options.lookup,
- items,
- displayGetter,
- isFilterRow = options.parentType === 'filterRow';
- if (lookup) {
- items = lookup.items;
- displayGetter = DX.data.utils.compileGetter(lookup.displayExpr);
- if (isFilterRow && items) {
- items = items.slice(0);
- items.unshift(null)
- }
- $container.dxSelectBox({
- value: options.value || null,
- valueExpr: options.lookup.valueExpr,
- showClearButton: lookup.allowClearing && !isFilterRow,
- displayExpr: function(data) {
- if (data === null)
- return options.showAllText;
- return displayGetter(data)
- },
- items: items,
- valueChangeAction: function(e) {
- options.setValue(e.value, e)
- },
- rtlEnabled: options.rtlEnabled,
- disabled: options.disabled
- })
- }
- };
- var createCheckBox = function($container, options) {
- $container.addClass(DATAGRID_CHECKBOX_SIZE_CLASS).dxCheckBox({
- value: options.value,
- valueChangeAction: function(e) {
- options.setValue && options.setValue(e.value, e)
- },
- rtlEnabled: options.rtlEnabled
- })
- };
- return {
- _updateFocusCore: function() {
- var $focus = this._$focusedElement,
- $dataGridElement = this.component && this.component._element();
- if ($dataGridElement) {
- $focus = $dataGridElement.find('[tabindex]:focus, input:focus');
- if ($focus.length) {
- $focus = $focus.closest('.dx-editor-cell > *, .dx-row > td');
- if ($focus.length) {
- this.focus($focus);
- return
- }
- }
- }
- this.loseFocus()
- },
- _updateFocus: function(e) {
- var that = this,
- isFocusOverlay = e.jQueryEvent && $(e.jQueryEvent.target).hasClass(DATAGRID_FOCUS_OVERLAY_CLASS);
- that._isFocusOverlay = that._isFocusOverlay || isFocusOverlay;
- clearTimeout(that._updateFocusTimeoutID);
- that._updateFocusTimeoutID = setTimeout(function() {
- delete that._updateFocusTimeoutID;
- if (!that._isFocusOverlay)
- that._updateFocusCore();
- that._isFocusOverlay = false
- })
- },
- callbackNames: function() {
- return ["focused"]
- },
- focus: function($element) {
- var that = this;
- if ($element === undefined)
- return that._$focusedElement;
- else if ($element)
- setTimeout(function() {
- var $focusOverlay = that._$focusOverlay = that._$focusOverlay || $('<div>').addClass(DATAGRID_FOCUS_OVERLAY_CLASS);
- var align = !parseInt($element.css('border-left-width')) && parseInt($element.css('border-right-width')) ? "right bottom" : "left top";
- $focusOverlay.show();
- $focusOverlay.css('visibility', 'hidden');
- $focusOverlay.appendTo($element.closest('.' + DATAGRID_CONTENT_CLASS));
- $focusOverlay.outerWidth($element.outerWidth() + 1);
- $focusOverlay.outerHeight($element.outerHeight() + 1);
- DX.position($focusOverlay, {
- my: align,
- at: align,
- of: $element
- });
- $focusOverlay.css('visibility', 'visible');
- that._$focusedElement && that._$focusedElement.removeClass(DATAGRID_FOCUSED_ELEMENT_CLASS);
- $element.addClass(DATAGRID_FOCUSED_ELEMENT_CLASS);
- that._$focusedElement = $element;
- that.focused.fire($element)
- })
- },
- loseFocus: function() {
- this._$focusedElement && this._$focusedElement.removeClass(DATAGRID_FOCUSED_ELEMENT_CLASS);
- this._$focusedElement = null;
- this._$focusOverlay && this._$focusOverlay.hide()
- },
- init: function() {
- var that = this,
- $container = that.component && that.component._element();
- $(document).on(DATAGRID_UPDATE_FOCUS_EVENTS, this.createAction($.proxy(this._updateFocus, this)));
- $container && $container.on('dxclick', '.' + DATAGRID_FOCUS_OVERLAY_CLASS, function(e) {
- var $focusOverlay = $(e.target),
- element;
- $focusOverlay.hide();
- element = document.elementFromPoint(e.pageX, e.pageY);
- $focusOverlay.show();
- $(element).trigger('dxclick');
- that._$focusedElement && that._$focusedElement.find('input').focus()
- })
- },
- dispose: function() {
- $(document).off(DATAGRID_UPDATE_FOCUS_EVENTS)
- },
- createEditor: function($container, options) {
- var editorPreparing = this.option('editorPreparing'),
- editorPrepared = this.option('editorPrepared');
- options.rtlEnabled = this.option('rtlEnabled');
- options.disabled = this.option("disabled");
- options.cancel = false;
- editorPreparing && editorPreparing($container, options);
- if (options.cancel)
- return;
- if (options.lookup)
- createSelectBox($container, options);
- else
- switch (options.dataType) {
- case'date':
- createCalendarPicker($container, options);
- break;
- case'boolean':
- createBooleanEditor($container, options);
- break;
- default:
- createTextBox($container, options);
- break
- }
- editorPrepared && editorPrepared($container, options)
- }
- }
- }());
- $.extend(dataGrid.__internals, {DATAGRID_FOCUSED_ELEMENT_CLASS: DATAGRID_FOCUSED_ELEMENT_CLASS});
- dataGrid.registerModule('editorFactory', {
- defaultOptions: function() {
- return {}
- },
- controllers: {editorFactory: dataGrid.EditorFactoryController}
- })
- })(jQuery, DevExpress);
- /*! Module widgets-web, file ui.dataGrid.columnChooserModule.js */
- (function($, DX) {
- var ui = DX.ui,
- utils = DX.utils,
- dataGrid = ui.dataGrid;
- var DATAGRID_COLUMN_CHOOSER_CLASS = 'dx-datagrid-column-chooser',
- DATAGRID_COLUMN_CHOOSER_BUTTON_CLASS = 'dx-datagrid-column-chooser-button',
- DATAGRID_COLUMN_CHOOSER_ICON_NAME = 'column-chooser',
- DATAGRID_COLUMN_CHOOSER_ITEM_CLASS = "dx-column-chooser-item",
- DATAGRID_COLUMN_CHOOSER_MESSAGE_CLASS = "dx-column-chooser-message",
- DATAGRID_HEADERS_ACTION_CLASS = "dx-datagrid-action-cursor";
- dataGrid.ColumnChooserView = dataGrid.View.inherit({
- _updateItems: function() {
- var hiddenColumns = this._columnsController.getHiddenColumns(),
- columnChooserOptions = this.option("columnChooser"),
- $content = this._popupContainer.content();
- $content.dxScrollable(dataGrid.createScrollableOptions(this));
- this._renderColumnChooserItems($content, hiddenColumns);
- if (!hiddenColumns.length)
- $('<span />').addClass(DATAGRID_COLUMN_CHOOSER_MESSAGE_CLASS).text(columnChooserOptions ? columnChooserOptions.emptyPanelText : "").appendTo($content.dxScrollable("instance").content())
- },
- _initializePopupContainer: function() {
- var that = this,
- $element = this._element().addClass(DATAGRID_COLUMN_CHOOSER_CLASS),
- columnChooserOptions = this.option("columnChooser"),
- theme = DevExpress.ui.themes.current(),
- isGenericTheme = theme && theme.indexOf("generic") > -1;
- if (!utils.isDefined(this._popupContainer)) {
- this._popupContainer = $element.dxPopup({
- visible: false,
- shading: false,
- closeButton: isGenericTheme,
- cancelButton: !isGenericTheme,
- width: columnChooserOptions.width,
- height: columnChooserOptions.height,
- title: columnChooserOptions.title,
- targetContainer: this._element().parent(),
- rtlEnabled: this.option('rtlEnabled')
- }).data('dxPopup');
- this._popupContainer.optionChanged.add(function(optionName) {
- if (optionName === "visible")
- that.renderCompleted.fire()
- })
- }
- },
- _renderCore: function() {
- if (this.option("columnChooser.enabled"))
- this._initializePopupContainer();
- if (this._popupContainer)
- this._updateItems()
- },
- _renderColumnChooserItems: function($container, hiddenColumns) {
- var dxScrollable = $container.dxScrollable("instance"),
- $scrollableContainer = dxScrollable.content(),
- $item;
- $scrollableContainer.empty();
- $.each(hiddenColumns, function(index, hiddenColumn) {
- $item = $('<div />').addClass(hiddenColumn.cssClass).addClass(DATAGRID_COLUMN_CHOOSER_ITEM_CLASS).toggleClass(DATAGRID_HEADERS_ACTION_CLASS, hiddenColumn.allowHiding).text(hiddenColumn.caption).appendTo($scrollableContainer)
- });
- dxScrollable.update()
- },
- init: function() {
- var that = this;
- that._columnsController = that.getController('columns');
- that._columnsController.columnsChanged.add(function(e) {
- if (!dataGrid.checkChanges(e.optionNames, ['width']))
- that.render()
- })
- },
- renderShowColumnChooserButton: function(rootElement) {
- var that = this,
- columnChooserOptions = that.option("columnChooser") || {},
- $showColumnChooserButton = rootElement.find("." + DATAGRID_COLUMN_CHOOSER_BUTTON_CLASS);
- if (columnChooserOptions.enabled)
- if (!$showColumnChooserButton.length)
- $('<div />').addClass(DATAGRID_COLUMN_CHOOSER_BUTTON_CLASS).appendTo(rootElement).dxButton({
- icon: DATAGRID_COLUMN_CHOOSER_ICON_NAME,
- clickAction: function(e) {
- that._popupContainer.toggle(!that._popupContainer.option('visible'))
- }
- });
- else
- $showColumnChooserButton.show();
- else
- $showColumnChooserButton.hide()
- },
- getColumnElements: function() {
- var $content = this._popupContainer && this._popupContainer.content();
- return $content && $content.find('.' + DATAGRID_COLUMN_CHOOSER_ITEM_CLASS)
- },
- getName: function() {
- return 'columnChooser'
- },
- getColumns: function() {
- return this._columnsController.getHiddenColumns()
- },
- allowDragging: function(column) {
- var popupContainer = this._popupContainer;
- return popupContainer && popupContainer.option("visible") && column && column.allowHiding
- },
- getBoundingRect: function() {
- var that = this,
- container = that._popupContainer && that._popupContainer._container(),
- offset;
- if (container && container.is(':visible')) {
- offset = container.offset();
- return {
- left: offset.left,
- top: offset.top,
- right: offset.left + container.outerWidth(),
- bottom: offset.top + container.outerHeight()
- }
- }
- return null
- },
- showColumnChooser: function() {
- this._isPopupContainerShown = true;
- if (!this._popupContainer) {
- this._initializePopupContainer();
- this.render()
- }
- this._popupContainer.show()
- },
- hideColumnChooser: function() {
- if (this._popupContainer) {
- this._popupContainer.hide();
- this._isPopupContainerShown = false
- }
- },
- publicMethods: function() {
- return ['showColumnChooser', 'hideColumnChooser']
- }
- });
- $.extend(dataGrid.__internals, {
- DATAGRID_COLUMN_CHOOSER_CLASS: DATAGRID_COLUMN_CHOOSER_CLASS,
- DATAGRID_COLUMN_CHOOSER_ITEM_CLASS: DATAGRID_COLUMN_CHOOSER_ITEM_CLASS,
- DATAGRID_COLUMN_CHOOSER_BUTTON_CLASS: DATAGRID_COLUMN_CHOOSER_BUTTON_CLASS,
- DATAGRID_COLUMN_CHOOSER_MESSAGE_CLASS: DATAGRID_COLUMN_CHOOSER_MESSAGE_CLASS
- });
- dataGrid.registerModule('columnChooser', {
- defaultOptions: function() {
- return {columnChooser: {
- enabled: false,
- width: 250,
- height: 260,
- title: Globalize.localize("dxDataGrid-columnChooserTitle"),
- emptyPanelText: Globalize.localize("dxDataGrid-columnChooserEmptyText")
- }}
- },
- views: {columnChooserView: dataGrid.ColumnChooserView},
- extenders: {views: {headerPanel: {
- _renderShowColumnChooserButton: function() {
- this.getView('columnChooserView').renderShowColumnChooserButton(this._element())
- },
- _renderCore: function() {
- this.callBase();
- this._renderShowColumnChooserButton()
- },
- optionChanged: function(name, value, prevValue) {
- this.callBase(name, value, prevValue);
- switch (name) {
- case'columnChooser':
- this._renderShowColumnChooserButton();
- break
- }
- },
- isVisible: function() {
- var that = this,
- columnChooserOptions = that.getView('columnChooserView').option('columnChooser');
- return that.callBase() || columnChooserOptions && columnChooserOptions.enabled
- }
- }}}
- })
- })(jQuery, DevExpress);
- /*! Module widgets-web, file ui.dataGrid.editing.js */
- (function($, DX) {
- var dataGrid = DX.ui.dataGrid,
- events = DX.ui.events,
- addNamespace = events.addNamespace,
- utils = DX.utils;
- var DATAGRID_LINK_CLASS = "dx-link",
- DATAGRID_EDITOR_CELL_CLASS = "dx-editor-cell",
- DATAGRID_ROW_SELECTED = "dx-selection",
- DATAGRID_EDIT_ROW = "dx-edit-row",
- DATAGRID_EDIT_BUTTON_CLASS = "dx-edit-button",
- DATAGRID_INSERT_INDEX = "__DX_INSERT_INDEX__",
- DATAGRID_ROW_REMOVED = "dx-row-removed",
- DATAGRID_ROW_INSERTED = "dx-row-inserted",
- DATAGRID_ROW_MODIFIED = "dx-row-modified",
- DATAGRID_CELL_MODIFIED = "dx-cell-modified",
- DATAGRID_CELL_HIGHLIGHT_OUTLINE = "dx-highlight-outline",
- DATAGRID_EDITING_NAMESPACE = "dxDataGridEditing",
- DATAGRID_FOCUS_OVERLAY_CLASS = "dx-datagrid-focus-overlay",
- DATAGRID_EDIT_MODE_BATCH = "batch",
- DATAGRID_EDIT_MODE_ROW = "row";
- $.extend(dataGrid.__internals, {
- DATAGRID_LINK_CLASS: DATAGRID_LINK_CLASS,
- DATAGRID_EDITOR_CELL_CLASS: DATAGRID_EDITOR_CELL_CLASS,
- DATAGRID_EDIT_ROW: DATAGRID_EDIT_ROW,
- DATAGRID_EDIT_BUTTON_CLASS: DATAGRID_EDIT_BUTTON_CLASS
- });
- var getEditMode = function(that) {
- var editing = that.option('editing.editMode');
- if (editing === DATAGRID_EDIT_MODE_BATCH)
- return editing;
- return DATAGRID_EDIT_MODE_ROW
- };
- var getEditIndex = function(key, editDataArray) {
- var index = -1;
- $.each(editDataArray, function(i, editData) {
- if (key && key[DATAGRID_INSERT_INDEX] && key === editData.key || dataGrid.equalKeys(key, editData.key)) {
- index = i;
- return false
- }
- });
- return index
- };
- dataGrid.EditingController = dataGrid.ViewController.inherit(function() {
- var getDataController = function(that) {
- return that.getController('data')
- };
- var getDefaultEditor = function(that) {
- return function(container, options) {
- var $editor = $('<div/>').appendTo(container);
- that.getController('editorFactory').createEditor($editor, $.extend({}, options.column, {
- value: options.value,
- setValue: options.setValue,
- parentType: 'dataRow',
- width: null
- }))
- }
- };
- return {
- init: function() {
- var that = this;
- that._insertIndex = 1;
- that._editRowIndex = -1;
- that._editData = [];
- that._editColumnIndex = -1;
- that._columnsController = that.getController("columns");
- if (!that._saveEditorHandler) {
- that._saveEditorHandler = that.createAction(function(e) {
- var event = e.jQueryEvent,
- visibleColumns,
- isEditorPopup,
- isFocusOverlay,
- $targetCell,
- allowEditing,
- isDataRow;
- if (getEditMode(that) === DATAGRID_EDIT_MODE_BATCH && that.isEditing() && !that._editCellInProgress) {
- isEditorPopup = $(event.target).closest('.dx-overlay-wrapper').length;
- isFocusOverlay = $(event.target).hasClass(DATAGRID_FOCUS_OVERLAY_CLASS);
- isDataRow = $(event.target).closest('.dx-data-row').length;
- visibleColumns = that._columnsController.getVisibleColumns();
- $targetCell = $(event.target).closest('td');
- allowEditing = $targetCell.length && visibleColumns[$targetCell[0].cellIndex].allowEditing;
- if ((!isDataRow || isDataRow && !allowEditing) && !isEditorPopup && !isFocusOverlay)
- that.closeEditCell()
- }
- });
- $(document).on('dxclick', that._saveEditorHandler)
- }
- that._updateEditButtons()
- },
- getEditMode: function() {
- return getEditMode(this)
- },
- hasChanges: function() {
- return this._editData.length
- },
- dispose: function() {
- this.callBase();
- $(document).off('dxclick', this._saveEditorHandler)
- },
- optionChanged: function(name, value, prevValue){},
- publicMethods: function() {
- return ['insertRow', 'editRow', 'editCell', 'closeEditCell', 'removeRow', 'saveEditData', 'recoverRow', 'undeleteRow', 'cancelEditData']
- },
- refresh: function() {
- if (getEditMode(this) === DATAGRID_EDIT_MODE_BATCH) {
- this._editRowIndex = -1;
- this._editColumnIndex = -1
- }
- else
- this.init()
- },
- isEditing: function() {
- return this._editRowIndex > -1
- },
- isEditRow: function(rowIndex) {
- return this._editRowIndex === rowIndex && this._editColumnIndex === -1
- },
- isEditCell: function(rowIndex, columnIndex) {
- return this._editRowIndex === rowIndex && this._editColumnIndex === columnIndex
- },
- processItems: function(items) {
- var that = this,
- editData = that._editData,
- i,
- key;
- that.update();
- for (i = 0; i < editData.length; i++) {
- key = editData[i].key;
- if (key && key[DATAGRID_INSERT_INDEX] && key.pageIndex === that._pageIndex)
- items.splice(key.rowIndex, 0, key)
- }
- return items
- },
- processDataItem: function(item, columns, generateDataValues) {
- var that = this,
- editIndex,
- data,
- key = item.data[DATAGRID_INSERT_INDEX] ? item.data : item.key;
- editIndex = getEditIndex(key, that._editData);
- if (editIndex >= 0) {
- data = that._editData[editIndex].data;
- if (key && key[DATAGRID_INSERT_INDEX]) {
- item.inserted = true;
- item.key = key;
- item.data = data
- }
- else if (data) {
- item.modified = true;
- item.data = $.extend(true, {}, item.data, data);
- item.modifiedValues = generateDataValues(data, columns)
- }
- else
- item.removed = true
- }
- },
- insertRow: function() {
- var that = this,
- dataController = getDataController(that),
- rowsView = that.getView('rowsView'),
- initNewRow = that.option("initNewRow"),
- param = {data: {}},
- insertKey = {
- pageIndex: dataController.pageIndex(),
- rowIndex: rowsView ? rowsView.getTopVisibleItemIndex() : 0
- };
- that.refresh();
- if (getEditMode(that) === DATAGRID_EDIT_MODE_ROW)
- that._editRowIndex = insertKey.rowIndex;
- initNewRow && initNewRow(param);
- insertKey[DATAGRID_INSERT_INDEX] = that._insertIndex++;
- that._editData.push({
- key: insertKey,
- data: param.data
- });
- dataController.updateItems()
- },
- editRow: function(rowIndex) {
- var that = this,
- dataController = getDataController(that),
- item = dataController.items()[rowIndex],
- editingStart = that.option("editingStart"),
- params = {
- data: item.data,
- key: item.key,
- cancel: false
- };
- if (!item.inserted)
- params.key = item.key;
- editingStart && editingStart(params);
- if (params.cancel)
- return;
- that.init();
- that._editRowIndex = rowIndex;
- that._pageIndex = dataController.pageIndex();
- dataController.updateItems()
- },
- editCell: function (rowIndex, columnIndex) {
- if (rowIndex < 0) return false // hcLee 2015 07 15
- var that = this,
- rowsView = that.getView("rowsView"),
- dataController = getDataController(that),
- item = dataController.items()[rowIndex],
- editingStart = that.option("editingStart"),
- params = {
- data: item.data,
- cancel: false,
- column: that._columnsController.getVisibleColumns()[columnIndex]
- };
- if (item && item.rowType === 'data' && !item.removed && getEditMode(that) === DATAGRID_EDIT_MODE_BATCH) {
- if (!item.inserted)
- params.key = item.key;
- editingStart && editingStart(params);
- if (params.cancel)
- return;
- that._editRowIndex = rowIndex;
- that._editColumnIndex = columnIndex;
- that._pageIndex = dataController.pageIndex();
- that._editCellInProgress = true;
- dataController.updateItems();
- setTimeout(function() {
- that._editCellInProgress = false;
- rowsView._focusEditor()
- });
- return true
- }
- return false
- },
- removeRow: function(rowIndex) {
- var that = this,
- editingOptions = that.option("editing"),
- editingTexts = editingOptions && editingOptions.texts,
- confirmDeleteTitle = editingTexts && editingTexts.confirmDeleteTitle,
- isBatchMode = editingOptions && editingOptions.editMode === DATAGRID_EDIT_MODE_BATCH,
- confirmDeleteMessage = editingTexts && editingTexts.confirmDeleteMessage,
- dataController = getDataController(that),
- removeByKey,
- item = dataController.items()[rowIndex],
- key = item && item.key;
- if (item) {
- removeByKey = function(key) {
- that.refresh();
- var editIndex = getEditIndex(key, that._editData);
- if (editIndex >= 0)
- if (key && key[DATAGRID_INSERT_INDEX])
- that._editData.splice(editIndex, 1);
- else
- that._editData[editIndex].data = null;
- else
- that._editData.push({
- key: key,
- oldData: item.data
- });
- if (isBatchMode)
- dataController.updateItems();
- else
- that.saveEditData()
- };
- if (isBatchMode || !confirmDeleteMessage)
- removeByKey(key);
- else
- DX.ui.dialog.confirm(confirmDeleteMessage, confirmDeleteTitle).done(function(confirmResult) {
- if (confirmResult)
- removeByKey(key)
- })
- }
- },
- recoverRow: function(rowIndex) {
- DX.utils.logger.warn("'recoverRow' method is deprecated since 14.1. Use the 'undeleteRow' method instead.");
- return this.undeleteRow(rowIndex)
- },
- undeleteRow: function(rowIndex) {
- var that = this,
- dataController = getDataController(that),
- item = dataController.items()[rowIndex],
- key = item && item.key;
- if (item) {
- var editIndex = getEditIndex(key, that._editData);
- if (editIndex >= 0) {
- that._editData.splice(editIndex, 1);
- dataController.updateItems()
- }
- }
- },
- saveEditData: function() {
- var that = this;
- that._editRowIndex = -1;
- that._editColumnIndex = -1;
- that._saveEditData()
- },
- _saveEditData: function() {
- var that = this,
- dataController = getDataController(that),
- store = dataController.store(),
- item,
- key,
- rowInserting = that.option("rowInserting"),
- rowInserted = that.option("rowInserted"),
- rowUpdating = that.option("rowUpdating"),
- rowUpdated = that.option("rowUpdated"),
- rowRemoving = that.option("rowRemoving"),
- rowRemoved = that.option("rowRemoved"),
- processedKeys = [],
- deferreds = [],
- editData = $.extend({}, that._editData);
- var removeEditData = function(that, keys) {
- $.each(keys, function(index, key) {
- var editIndex = getEditIndex(key, that._editData);
- if (editIndex >= 0)
- that._editData.splice(editIndex, 1)
- })
- };
- if (that._editData.length) {
- $.each(that._editData, function(_, editData) {
- var data = editData.data,
- oldData = editData.oldData,
- key = editData.key,
- deferred,
- params;
- if (!data) {
- params = {
- data: oldData,
- key: key,
- cancel: false
- };
- rowRemoving && rowRemoving(params);
- if (params.cancel)
- return;
- deferred = store.remove(key)
- }
- else if (key && key[DATAGRID_INSERT_INDEX]) {
- params = {
- data: data,
- cancel: false
- };
- rowInserting && rowInserting(params);
- if (params.cancel)
- return;
- deferred = store.insert(data)
- }
- else {
- params = {
- newData: $.extend({}, oldData, data),
- oldData: oldData,
- key: key,
- cancel: false
- };
- rowUpdating && rowUpdating(params);
- if (params.cancel)
- return;
- deferred = store.update(key, data)
- }
- deferred.done($.proxy(processedKeys.push, processedKeys, key));
- deferreds.push(deferred)
- });
- if (deferreds.length)
- $.when.apply($, deferreds).always(function(e) {
- var isError = e && e.name === "Error";
- if (!isError)
- removeEditData(that, processedKeys);
- $.when(dataController.refresh()).always(function() {
- $.each(editData, function(_, itemData) {
- var data = itemData.data,
- key = itemData.key,
- params = {
- key: key,
- data: data
- };
- if (isError)
- params.error = e;
- if (!data)
- rowRemoved && rowRemoved($.extend({}, params, {data: itemData.oldData}));
- else if (key && key[DATAGRID_INSERT_INDEX])
- rowInserted && rowInserted(params);
- else
- rowUpdated && rowUpdated(params)
- })
- });
- if (isError)
- dataController.dataErrorOccurred.fire(e)
- })
- }
- else
- dataController.updateItems()
- },
- _updateEditButtons: function() {
- var that = this,
- saveChangesButton = that._saveChangesButton,
- cancelChangesButton = that._cancelChangesButton,
- hasChanges = that.hasChanges();
- if (saveChangesButton)
- saveChangesButton.option('disabled', !hasChanges);
- if (cancelChangesButton)
- cancelChangesButton.option('disabled', !hasChanges)
- },
- cancelEditData: function() {
- var that = this,
- dataController = getDataController(that);
- that.init();
- dataController.updateItems()
- },
- closeEditCell: function() {
- var that = this,
- dataController = getDataController(that);
- setTimeout(function() {
- that._editRowIndex = -1;
- that._editColumnIndex = -1;
- dataController.updateItems()
- })
- },
- update: function() {
- var that = this,
- dataController = getDataController(that);
- if (that._pageIndex !== dataController.pageIndex()) {
- that.refresh();
- that._pageIndex = dataController.pageIndex()
- }
- that._updateEditButtons()
- },
- updateFieldValue: function(options) {
- var that = this,
- rowKey = options.key,
- dataField = options.column.dataField,
- value = options.column.serializeValue ? options.column.serializeValue(options.value) : options.value,
- editDataIndex;
- if (rowKey !== undefined) {
- editDataIndex = getEditIndex(rowKey, that._editData);
- if (editDataIndex < 0) {
- editDataIndex = that._editData.length;
- that._editData.push({
- data: {},
- key: rowKey,
- oldData: options.data
- })
- }
- if (that._editData[editDataIndex])
- that._editData[editDataIndex].data[dataField] = value;
- that._updateEditButtons()
- }
- },
- getColumnTemplate: function(options) {
- var that = this,
- column = options.column,
- template,
- isRowMode,
- editingOptions,
- editingTexts;
- if (column.allowEditing && column.dataField && !column.command && that._editRowIndex === options.rowIndex && (that._editColumnIndex < 0 || that._editColumnIndex === options.columnIndex) && options.rowType === 'data') {
- options.setValue = function(value) {
- options.value = value;
- that.updateFieldValue(options)
- };
- template = column.editCellTemplate || getDefaultEditor(that)
- }
- else if (column.command === 'edit')
- template = function(container, options) {
- var createLink = function(container, text, methodName, options) {
- var $link = $('<a />').addClass(DATAGRID_LINK_CLASS).text(text).on(addNamespace('dxclick', DATAGRID_EDITING_NAMESPACE), that.createAction(function() {
- setTimeout(function() {
- that[methodName](options.rowIndex)
- })
- }));
- options.rtlEnabled ? container.prepend($link, " ") : container.append($link, " ")
- };
- isRowMode = getEditMode(that) === DATAGRID_EDIT_MODE_ROW;
- container.css('text-align', 'center');
- options.rtlEnabled = that.option('rtlEnabled');
- editingOptions = that.option("editing") || {};
- editingTexts = editingOptions.texts || {};
- if (that._editRowIndex === options.rowIndex && isRowMode) {
- createLink(container, editingTexts.saveRowChanges, 'saveEditData', options);
- createLink(container, editingTexts.cancelRowChanges, 'cancelEditData', options)
- }
- else {
- if (editingOptions.editEnabled && isRowMode)
- createLink(container, editingTexts.editRow, 'editRow', options);
- if (editingOptions.removeEnabled)
- if (options.row.removed)
- createLink(container, editingTexts.undeleteRow, 'undeleteRow', options);
- else
- createLink(container, editingTexts.deleteRow, 'removeRow', options)
- }
- };
- return template
- },
- renderEditButtons: function(rootElement) {
- var that = this,
- insertButton = rootElement.find('.' + DATAGRID_EDIT_BUTTON_CLASS),
- editingOptions = that.option("editing") || {};
- var createEditButton = function(rootElement, className, methodName) {
- return $('<div />').addClass(DATAGRID_EDIT_BUTTON_CLASS).addClass("dx-datagrid-" + className + "-button").appendTo(rootElement).dxButton({
- icon: "edit-button-" + className,
- clickAction: $.proxy(that, methodName)
- }).dxButton('instance')
- };
- if (insertButton.length)
- insertButton.remove();
- if ((editingOptions.editEnabled || editingOptions.insertEnabled || editingOptions.removeEnabled) && getEditMode(that) === DATAGRID_EDIT_MODE_BATCH) {
- that._cancelChangesButton = createEditButton(rootElement, "cancel", 'cancelEditData');
- that._saveChangesButton = createEditButton(rootElement, "save", 'saveEditData');
- that._updateEditButtons()
- }
- if (editingOptions.insertEnabled)
- createEditButton(rootElement, "addrow", 'insertRow')
- }
- }
- }());
- dataGrid.registerModule('editing', {
- defaultOptions: function() {
- return {editing: {
- editMode: 'row',
- insertEnabled: false,
- editEnabled: false,
- removeEnabled: false,
- texts: {
- editRow: Globalize.localize("dxDataGrid-editingEditRow"),
- saveRowChanges: Globalize.localize("dxDataGrid-editingSaveRowChanges"),
- cancelRowChanges: Globalize.localize("dxDataGrid-editingCancelRowChanges"),
- deleteRow: Globalize.localize("dxDataGrid-editingDeleteRow"),
- recoverRow: Globalize.localize("dxDataGrid-editingUndeleteRow"),
- undeleteRow: Globalize.localize("dxDataGrid-editingUndeleteRow"),
- confirmDeleteMessage: Globalize.localize("dxDataGrid-editingConfirmDeleteMessage"),
- confirmDeleteTitle: Globalize.localize("dxDataGrid-editingConfirmDeleteTitle")
- }
- }}
- },
- controllers: {editing: dataGrid.EditingController},
- extenders: {
- controllers: {
- data: {
- init: function() {
- this._editingController = this.getController('editing');
- this.callBase()
- },
- reload: function() {
- this._editingController.refresh();
- return this.callBase()
- },
- _processItems: function(items) {
- items = this._editingController.processItems(items);
- return this.callBase(items)
- },
- _processDataItem: function(dataItem, columns) {
- this._editingController.processDataItem(dataItem, columns, this._generateDataValues);
- return this.callBase(dataItem, columns)
- }
- },
- columns: {getVisibleColumns: function() {
- var that = this,
- editing = that.option('editing'),
- columns = that.callBase();
- columns = $.grep(columns, function(column) {
- return column.command !== 'edit'
- });
- if (editing && ((editing.editEnabled || editing.insertEnabled) && getEditMode(that) === DATAGRID_EDIT_MODE_ROW || editing.removeEnabled) && columns.length)
- columns.push({
- visible: true,
- command: 'edit',
- width: 100
- });
- return columns
- }}
- },
- views: {
- rowsView: {
- _getColumnTemplate: function(options) {
- var that = this,
- template = that.getController('editing').getColumnTemplate(options);
- return template || that.callBase(options)
- },
- _createRow: function(options) {
- var $row = this.callBase(options),
- editingController,
- isEditRow,
- isRowRemoved,
- isRowInserted,
- isRowModified;
- if (options) {
- editingController = this.getController('editing');
- isEditRow = editingController.isEditRow(options.rowIndex);
- isRowRemoved = !!options.removed;
- isRowInserted = !!options.inserted;
- isRowModified = !!options.modified;
- if (getEditMode(this) === DATAGRID_EDIT_MODE_BATCH)
- $row.toggleClass(DATAGRID_ROW_REMOVED, isRowRemoved);
- else
- $row.toggleClass(DATAGRID_EDIT_ROW, isEditRow);
- $row.toggleClass(DATAGRID_ROW_INSERTED, isRowInserted);
- $row.toggleClass(DATAGRID_ROW_MODIFIED, isRowModified);
- if (isEditRow || isRowInserted || isRowRemoved || isRowModified)
- $row.removeClass(DATAGRID_ROW_SELECTED)
- }
- return $row
- },
- _rowClick: function(rowIndex, event) {
- var that = this,
- editingController = that.getController('editing'),
- editing = that.option('editing'),
- $targetCell = $(event.target).closest('td'),
- cellIndex = $targetCell.length ? $targetCell[0].cellIndex : -1,
- column = that._columnsController.getVisibleColumns()[cellIndex],
- isEditCell = cellIndex >= 0 && editing && editing.editEnabled && column && column.allowEditing && editingController.editCell(rowIndex, cellIndex);
- if (!isEditCell && !editingController.isEditRow(rowIndex))
- that.callBase(rowIndex, event)
- },
- _cellPrepared: function($cell, parameters) {
- var modifiedValues = parameters.row && (parameters.row.inserted ? parameters.row.values : parameters.row.modifiedValues),
- columnIndex = parameters.columnIndex,
- alignment = parameters.column.alignment,
- editingController = this.getController('editing'),
- $contents;
- parameters.isEditing = editingController.isEditCell(parameters.rowIndex, columnIndex) || editingController.isEditRow(parameters.rowIndex) && parameters.column.allowEditing;
- if (parameters.isEditing) {
- $cell.addClass(DATAGRID_EDITOR_CELL_CLASS);
- if (alignment)
- $cell.find('input').first().css('text-align', alignment)
- }
- if (modifiedValues && parameters.column && parameters.column.allowEditing && modifiedValues[columnIndex] !== undefined)
- if (!parameters.isEditing) {
- $cell.addClass(DATAGRID_CELL_MODIFIED);
- $contents = $cell.contents();
- $("<div>").addClass(DATAGRID_CELL_HIGHLIGHT_OUTLINE).append(!$contents.length || $contents.length === 1 && !$contents.eq(0).text().length ? " " : $contents).appendTo($cell)
- }
- this.callBase.apply(this, arguments)
- },
- _update: function(change) {
- this.callBase(change);
- if (change.changeType === 'updateSelection')
- this._element().find('.' + DATAGRID_EDIT_ROW).removeClass(DATAGRID_ROW_SELECTED)
- },
- _focusEditor: function() {
- this._tableElement.find('input').first().focus()
- }
- },
- headerPanel: {
- _renderCore: function() {
- this.callBase();
- this.getController('editing').renderEditButtons(this._element())
- },
- isVisible: function() {
- var that = this,
- editingOptions = that.getController('editing').option('editing');
- return that.callBase() || editingOptions && (editingOptions.insertEnabled || (editingOptions.editEnabled || editingOptions.removeEnabled) && editingOptions.editMode === DATAGRID_EDIT_MODE_BATCH)
- }
- }
- }
- }
- });
- $.extend(dataGrid.__internals, {
- DATAGRID_CELL_MODIFIED: DATAGRID_CELL_MODIFIED,
- DATAGRID_ROW_REMOVED: DATAGRID_ROW_REMOVED,
- DATAGRID_ROW_INSERTED: DATAGRID_ROW_INSERTED,
- DATAGRID_ROW_MODIFIED: DATAGRID_ROW_MODIFIED,
- DATAGRID_CELL_HIGHLIGHT_OUTLINE: DATAGRID_CELL_HIGHLIGHT_OUTLINE,
- DATAGRID_FOCUS_OVERLAY_CLASS: DATAGRID_FOCUS_OVERLAY_CLASS
- })
- })(jQuery, DevExpress);
- /*! Module widgets-web, file ui.dataGrid.dataController.js */
- (function($, DX) {
- var ui = DX.ui,
- dataGrid = ui.dataGrid,
- utils = DX.utils;
- dataGrid.DataController = dataGrid.Controller.inherit({}).include(ui.DataHelperMixin).inherit(function() {
- var processGroupItems = function(that, items, groupsCount) {
- var scrollingMode = that.option('scrolling.mode'),
- collectedItems = [],
- collectItemsCore = function(items, collectedItems, groupIndex, groupsCount, path, collectContinuationItems) {
- var i,
- isExpanded,
- item;
- if (groupIndex >= groupsCount)
- collectedItems.push.apply(collectedItems, items);
- else
- for (i = 0; i < items.length; i++) {
- item = items[i];
- if (item.items !== undefined) {
- path.push(item.key);
- isExpanded = !!item.items;
- if (collectContinuationItems || !item.isContinuation)
- collectedItems.push({
- rowType: 'group',
- groupIndex: groupIndex,
- data: item,
- isExpanded: isExpanded,
- values: path.slice(0)
- });
- if (isExpanded)
- collectItemsCore(item.items, collectedItems, groupIndex + 1, groupsCount, path, collectContinuationItems);
- path.pop()
- }
- else
- collectedItems.push(item)
- }
- };
- collectItemsCore(items, collectedItems, 0, groupsCount, [], scrollingMode !== 'virtual' && scrollingMode !== 'infinite');
- return collectedItems
- };
- return {
- init: function() {
- var that = this;
- that._items = [];
- that._columnsController = that.getController('columns');
- that._columnsChangedHandler = function(e) {
- var changeTypes = e.changeTypes,
- optionNames = e.optionNames;
- var updateItemsHandler = function() {
- that._columnsController.columnsChanged.remove(updateItemsHandler);
- that.updateItems()
- };
- if (changeTypes.sorting || changeTypes.grouping) {
- if (that._dataSource) {
- that._dataSource.group(that._columnsController.getGroupDataSourceParameters());
- that._dataSource.sort(that._columnsController.getSortDataSourceParameters());
- that.reload()
- }
- }
- else if (changeTypes.columns) {
- if (optionNames.filterValue || optionNames.selectedFilterOperation)
- if (!e.column || utils.isDefined(e.column.filterValue) || !optionNames.selectedFilterOperation || optionNames.filterValue)
- that._applyFilter();
- if (!that._needApplyFilter && !dataGrid.checkChanges(optionNames, ['width', 'filterValue', 'selectedFilterOperation']))
- that._columnsController.columnsChanged.add(updateItemsHandler)
- }
- };
- that._gridDataSourceChangedHandler = function(e) {
- var dataSource = that._dataSource;
- if (dataSource && !that._isDataSourceApplying) {
- that._isDataSourceApplying = true;
- $.when(that._columnsController.applyDataSource(dataSource)).done(function() {
- that._isDataSourceApplying = false;
- var additionalFilter = that._calculateAdditionalFilter(),
- needApplyFilter = that._needApplyFilter;
- that._needApplyFilter = false;
- if (needApplyFilter && additionalFilter && additionalFilter.length)
- that._applyFilter();
- else
- that.updateItems(e)
- });
- that._needApplyFilter = !that._columnsController.isDataSourceApplied()
- }
- };
- that._columnsController.columnsChanged.add(that._columnsChangedHandler);
- that._loadingChangedHandler = function(isLoading) {
- that._isLoading = isLoading;
- that._fireLoadingChanged()
- };
- that._loadErrorHandler = function(e) {
- that.dataErrorOccurred.fire(e)
- };
- that._viewportSize = 20;
- that._isLoading = false;
- that._isCustomLoading = false;
- that._refreshDataSource();
- that.createAction('dataErrorOccurred', {excludeValidators: ['gesture']});
- that.dataErrorOccurred.add(function(e) {
- return that.executeAction('dataErrorOccurred', e)
- })
- },
- callbackNames: function() {
- return ['changed', 'loadingChanged', 'dataErrorOccurred']
- },
- callbackFlags: function(name) {
- if (name === 'dataErrorOccurred')
- return 'stopOnFalse'
- },
- publicMethods: function() {
- return ['beginCustomLoading', 'endCustomLoading', 'refresh', 'filter', 'clearFilter', 'keyOf', 'byKey', 'getDataByKeys', 'collapseAll', 'expandAll', 'pageIndex', 'pageSize', 'pageCount', 'totalCount', '_disposeDataSource']
- },
- optionChanged: function(name, value, prevValue) {
- var that = this;
- switch (name) {
- case'dataSource':
- case'grouping':
- case'scrolling':
- case'rtlEnabled':
- case'paging':
- case'columns':
- that._columnsController.reset();
- that._refreshDataSource();
- break;
- case'dataErrorOccurred':
- that.createAction('dataErrorOccurred');
- break
- }
- },
- _dataSourceType: function() {
- var scrolling = this.option('scrolling');
- if (scrolling && (scrolling.mode === 'virtual' || scrolling.mode === 'infinite'))
- return dataGrid.ScrollingDataSourceWrapper;
- else
- return dataGrid.DataSource
- },
- _dataSourceOptions: function() {
- var that = this,
- paging = that.option('paging'),
- scrolling = that.option('scrolling'),
- virtualMode = !!(scrolling && scrolling.mode === 'virtual'),
- appendMode = !!(scrolling && scrolling.mode === 'infinite');
- return {
- paginate: paging && paging.enabled || virtualMode || appendMode,
- loadingTimeout: that.option('loadingTimeout'),
- asyncLoadEnabled: true,
- pageIndex: paging && paging.pageIndex,
- pageSize: paging && paging.pageSize,
- requireTotalCount: !appendMode,
- useNativeGrouping: 'auto',
- scrolling: scrolling
- }
- },
- _initDataSource: function() {
- var columnsController = this._columnsController,
- sort,
- group,
- dataSource;
- if (this.option("dataSource") instanceof DX.data.DataSource) {
- DX.utils.logger.error("The dataSource option cannot take the DevExpress.data.DataSource instance directly. Assign a DataSource configuration object (see http://js.devexpress.com/Documentation/ApiReference/Data_Library/DataSource/Configuration) or a simple array instead.");
- return
- }
- this.callBase();
- dataSource = this._dataSource;
- if (dataSource) {
- columnsController.updateSortingGrouping(dataSource);
- sort = columnsController.getSortDataSourceParameters();
- if (sort)
- dataSource.sort(sort);
- group = columnsController.getGroupDataSourceParameters();
- if (group)
- dataSource.group(group);
- this.setDataSource(dataSource)
- }
- },
- _processItems: function(items) {
- var that = this,
- visibleColumns = that._columnsController.getVisibleColumns(),
- groupColumns = that._columnsController.getGroupColumns(),
- result = [],
- dataIndex = 0;
- if (items.length > 0 && that._columnsController.isInitialized()) {
- if (groupColumns.length > 0)
- items = processGroupItems(that, items, groupColumns.length);
- $.each(items, function(index, item) {
- if (utils.isDefined(item)) {
- if (utils.isDefined(item.groupIndex))
- dataIndex = 0;
- else {
- item = that._generateDataItem(item);
- item = that._processDataItem(item, visibleColumns);
- item.dataIndex = dataIndex++
- }
- result.push(item)
- }
- })
- }
- return result
- },
- _generateDataItem: function(data) {
- return {
- rowType: 'data',
- data: data,
- key: this.keyOf(data)
- }
- },
- _processDataItem: function(dataItem, visibleColumns) {
- dataItem.values = this._generateDataValues(dataItem.data, visibleColumns);
- return dataItem
- },
- _generateDataValues: function(data, columns) {
- var values = [];
- $.each(columns, function() {
- var value = null;
- if (utils.isDefined(this.groupIndex))
- value = null;
- else if (this.calculateCellValue)
- value = this.calculateCellValue(data);
- else if (this.dataField)
- value = data[this.dataField];
- values.push(value)
- });
- return values
- },
- _updateItemsCore: function(change) {
- var that = this,
- items,
- dataSource = that._dataSource,
- changes = [],
- changeType = change.changeType;
- if (dataSource) {
- items = change.items || dataSource.items();
- items = that._processItems(items.slice(0));
- change.items = items;
- change.changeType = changeType || 'refresh';
- switch (changeType) {
- case'prepend':
- that._items.unshift.apply(that._items, items);
- break;
- case'append':
- that._items.push.apply(that._items, items);
- break;
- default:
- that._items = items;
- break
- }
- }
- },
- updateItems: function(change) {
- var that = this;
- change = change || {};
- if (that._dataSource && that._columnsController.isDataSourceApplied()) {
- that._updateItemsCore(change);
- that.changed.fire(change)
- }
- },
- changeGroupExpand: function(path) {
- this._dataSource && this._dataSource.changeGroupExpand(path)
- },
- getGroupPathByRowIndex: function(rowIndex) {
- var item = this.items()[rowIndex];
- if (item && item.rowType === 'group')
- return item.values
- },
- isLoading: function() {
- return this._isLoading || this._isCustomLoading
- },
- _fireLoadingChanged: function(messageText) {
- this.loadingChanged.fire(this.isLoading(), messageText)
- },
- _calculateAdditionalFilter: function() {
- return null
- },
- _applyFilter: function() {
- var that = this,
- dataSource = that._dataSource,
- additionalFilter,
- filter = that._filter;
- if (dataSource) {
- additionalFilter = that._calculateAdditionalFilter();
- if (additionalFilter)
- if (filter)
- filter = [additionalFilter, 'and', filter];
- else
- filter = additionalFilter;
- dataSource.filter(filter && filter.length ? filter : null);
- dataSource.pageIndex(0);
- return that.reload()
- }
- },
- filter: function(filterExpr) {
- this._filter = arguments.length > 1 ? Array.prototype.slice.call(arguments, 0) : filterExpr;
- this._applyFilter()
- },
- clearFilter: function() {
- this._filter = null;
- this._applyFilter()
- },
- setDataSource: function(dataSource) {
- var that = this;
- if (that._dataSource) {
- that._dataSource.changed.remove(that._gridDataSourceChangedHandler);
- that._dataSource.loadingChanged.remove(that._loadingChangedHandler);
- that._dataSource.loadError.remove(that._loadErrorHandler)
- }
- that._dataSource = dataSource;
- if (dataSource) {
- that._isLoading = !dataSource.isLoaded();
- that._filter = dataSource.filter();
- dataSource.changed.add(that._gridDataSourceChangedHandler);
- dataSource.loadingChanged.add(that._loadingChangedHandler);
- dataSource.loadError.add(that._loadErrorHandler);
- that._needApplyFilter = true;
- if (dataSource.isLoaded())
- that._gridDataSourceChangedHandler()
- }
- },
- items: function() {
- return this._items
- },
- virtualItemsCount: function() {
- var dataSource = this._dataSource;
- return dataSource && dataSource.virtualItemsCount && dataSource.virtualItemsCount()
- },
- setViewportSize: function(size) {
- var dataSource = this._dataSource;
- return dataSource && dataSource.setViewportSize && dataSource.setViewportSize(size)
- },
- setViewportItemIndex: function(itemIndex) {
- var dataSource = this._dataSource;
- dataSource && dataSource.setViewportItemIndex && dataSource.setViewportItemIndex(itemIndex)
- },
- collapseAll: function(groupIndex) {
- var dataSource = this._dataSource;
- if (dataSource && dataSource.collapseAll(groupIndex)) {
- dataSource.pageIndex(0);
- dataSource.reload()
- }
- },
- expandAll: function(groupIndex) {
- var dataSource = this._dataSource;
- if (dataSource && dataSource.expandAll(groupIndex)) {
- dataSource.pageIndex(0);
- dataSource.reload()
- }
- },
- totalItemsCount: function() {
- return this._dataSource ? this._dataSource.totalItemsCount() : 0
- },
- hasKnownLastPage: function() {
- return this._dataSource ? this._dataSource.hasKnownLastPage() : true
- },
- isLoaded: function() {
- return this._dataSource ? this._dataSource.isLoaded() : false
- },
- totalCount: function() {
- return this._dataSource ? this._dataSource.totalCount() : 0
- },
- pageCount: function() {
- return this._dataSource ? this._dataSource.pagesCount() : 1
- },
- dataSource: function() {
- return this._dataSource
- },
- store: function() {
- var dataSource = this._dataSource;
- return dataSource && dataSource.store()
- },
- keyOf: function(data) {
- var store = this.store();
- return store && store.keyOf(data)
- },
- byKey: function(key) {
- var store = this.store(),
- result;
- if (!store)
- return;
- $.each(this._items, function(_, item) {
- if (item.key === key) {
- result = $.Deferred().resolve(item.data);
- return false
- }
- });
- return result || store.byKey(key)
- },
- getDataByKeys: function(rowKeys) {
- var that = this,
- result = $.Deferred(),
- deferreds = [],
- data = [];
- $.each(rowKeys, function(index, key) {
- deferreds.push(that.byKey(key).done(function(keyData) {
- data[index] = keyData
- }))
- });
- $.when.apply($, deferreds).always(function() {
- result.resolve(data)
- });
- return result
- },
- pageIndex: function(value) {
- var that = this,
- dataSource = that._dataSource;
- if (dataSource) {
- if (value !== undefined)
- if (dataSource.pageIndex() !== value) {
- dataSource.pageIndex(value);
- return dataSource.load()
- }
- return dataSource.pageIndex()
- }
- return 0
- },
- pageSize: function(value) {
- var that = this,
- dataSource = that._dataSource;
- if (value === undefined)
- return dataSource ? dataSource.pageSize() : 0;
- if (dataSource) {
- dataSource.pageIndex(0);
- dataSource.pageSize(value);
- return dataSource.reload()
- }
- },
- beginCustomLoading: function(messageText) {
- this._isCustomLoading = true;
- this._fireLoadingChanged(messageText)
- },
- endCustomLoading: function() {
- this._isCustomLoading = false;
- this._fireLoadingChanged()
- },
- refresh: function() {
- var that = this,
- d = $.Deferred();
- $.when(this._columnsController.refresh()).always(function() {
- $.when(that.reload()).done(d.resolve).fail(d.reject)
- });
- return d
- },
- reload: function() {
- var dataSource = this._dataSource;
- return dataSource && dataSource.reload()
- },
- dispose: function() {
- var that = this,
- dataSource = that._dataSource;
- that.callBase();
- if (dataSource) {
- dataSource.changed.remove(that._gridDataSourceChangedHandler);
- dataSource.loadingChanged.remove(that._loadingChangedHandler)
- }
- }
- }
- }());
- dataGrid.registerModule('data', {
- defaultOptions: function() {
- return {
- dataSource: null,
- dataErrorOccurred: null
- }
- },
- controllers: {data: ui.dataGrid.DataController}
- })
- })(jQuery, DevExpress);
- /*! Module widgets-web, file ui.dataGrid.columnsView.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- utils = DX.utils,
- dataGrid = ui.dataGrid;
- var DATAGRID_SORT_CLASS = "dx-sort",
- DATAGRID_SORTUP_CLASS = "dx-sort-up",
- DATAGRID_SORTDOWN_CLASS = "dx-sort-down",
- DATAGRID_SORT_ALIGNMENT_CLASS = "dx-sort-alignment-",
- DATAGRID_CELL_CONTENT_CLASS = "dx-datagrid-text-content",
- DATAGRID_TABLE_CONTENT_CLASS = "dx-datagrid-table-content",
- DATAGRID_ROW_CLASS = "dx-row",
- DATAGRID_GROUP_ROW_CLASS = "dx-group-row",
- DATAGRID_TABLE_CLASS = "dx-datagrid-table";
- dataGrid.ColumnsView = dataGrid.View.inherit({
- _applySorting: function(rootElement, column, showColumnLines) {
- var $span,
- columnAlignment;
- function getAlignment(columnAlignment) {
- return columnAlignment === 'right' ? 'left' : 'right'
- }
- rootElement.find('.' + DATAGRID_SORT_CLASS).remove();
- if (utils.isDefined(column.sortOrder)) {
- if (column.alignment === 'center') {
- var align = this.option('rtlEnabled') ? 'right' : 'left';
- $('<span />').addClass(DATAGRID_SORT_CLASS).css('float', align).prependTo(rootElement)
- }
- columnAlignment = column.alignment || 'left';
- $span = $('<span />').addClass(DATAGRID_SORT_CLASS).css('float', showColumnLines ? getAlignment(column.alignment) : columnAlignment).toggleClass(DATAGRID_SORTUP_CLASS, column.sortOrder === 'asc').toggleClass(DATAGRID_SORTDOWN_CLASS, column.sortOrder === 'desc');
- if (this.option("showColumnLines"))
- $span.prependTo(rootElement);
- else
- $span.addClass(DATAGRID_SORT_ALIGNMENT_CLASS + columnAlignment).appendTo(rootElement)
- }
- },
- _updateSortIndicatorPositions: function(rootElement) {
- if (!rootElement)
- return;
- var sortIndicators = rootElement.find('.' + DATAGRID_SORT_CLASS);
- $.each(sortIndicators, function() {
- var $sortIndicator = $(this),
- $sortIndicatorContainer = $sortIndicator.parent(),
- $textContent = $sortIndicatorContainer.find('.' + DATAGRID_CELL_CONTENT_CLASS);
- $sortIndicator.height($textContent.height() || $sortIndicatorContainer.height())
- })
- },
- _createRow: function() {
- return $("<tr />").addClass(DATAGRID_ROW_CLASS)
- },
- _createTable: function() {
- return $('<table />').toggleClass(DATAGRID_TABLE_CLASS, !this.option('columnAutoWidth'))
- },
- init: function() {
- var that = this;
- that._columnsController = that.getController('columns')
- },
- getColumnWidths: function() {
- var that = this,
- cells,
- result = [],
- width,
- clientRect;
- if (that._tableElement) {
- cells = that._tableElement.find('tr').filter(':not(.' + DATAGRID_GROUP_ROW_CLASS + ')').first().find('td');
- $.each(cells, function(index, item) {
- if (item.getBoundingClientRect) {
- clientRect = item.getBoundingClientRect();
- width = Math.floor(clientRect.right - clientRect.left)
- }
- else
- width = $(item).outerWidth(true);
- result.push(width)
- })
- }
- return result
- },
- setColumnWidths: function(widths) {
- this._setColumnWidthsCore(this._tableElement, widths)
- },
- _setColumnWidthsCore: function(tableElements, widths) {
- var colgroupElement,
- i,
- columnIndex;
- if (!tableElements)
- return;
- for (i = 0; i < tableElements.length; i++) {
- tableElements.eq(i).addClass(DATAGRID_TABLE_CLASS);
- if (widths) {
- this._columnWidths = widths;
- colgroupElement = tableElements.eq(i).find('colgroup').first();
- colgroupElement.empty();
- for (columnIndex = 0; columnIndex < widths.length; columnIndex++)
- $('<col />').width(widths[columnIndex] || 'auto').appendTo(colgroupElement)
- }
- }
- },
- resetColumnWidths: function() {
- var that = this,
- tableElement,
- visibleColumns = that._columnsController.getVisibleColumns(),
- i,
- widths = [],
- $elementWithFocus,
- elementWithFocus,
- selectionStart,
- selectionEnd;
- for (i = 0; i < visibleColumns.length; i++)
- widths.push(visibleColumns[i].width);
- that.setColumnWidths(widths);
- if (that._tableElement) {
- $elementWithFocus = that._tableElement.find(':focus');
- elementWithFocus = $elementWithFocus.get(0);
- if (elementWithFocus) {
- selectionStart = elementWithFocus.selectionStart;
- selectionEnd = elementWithFocus.selectionEnd
- }
- tableElement = that._createTable();
- tableElement.append(that._tableElement.children());
- tableElement.toggleClass(DATAGRID_TABLE_CONTENT_CLASS, that._tableElement.hasClass(DATAGRID_TABLE_CONTENT_CLASS));
- tableElement.attr('style', that._tableElement.attr('style'));
- that._tableElement.replaceWith(tableElement);
- that._tableElement = tableElement;
- if (elementWithFocus && elementWithFocus.setSelectionRange)
- elementWithFocus.setSelectionRange(selectionStart, selectionEnd);
- $elementWithFocus.focus()
- }
- },
- getColumnElements: function(){},
- getColumns: function(){},
- getCell: function(columnIndex, rowIndex) {
- var row;
- if (this._tableElement && this._tableElement.length === 1) {
- row = this._tableElement[0].rows[rowIndex];
- return row ? $(row.cells[columnIndex]) : null
- }
- },
- getRowsCount: function() {
- if (this._tableElement && this._tableElement.length === 1)
- return this._tableElement[0].rows.length;
- return 0
- },
- getBoundingRect: function(){},
- getName: function(){}
- });
- $.extend(dataGrid.__internals, {
- DATAGRID_SORT_CLASS: DATAGRID_SORT_CLASS,
- DATAGRID_SORTUP_CLASS: DATAGRID_SORTUP_CLASS,
- DATAGRID_SORTDOWN_CLASS: DATAGRID_SORTDOWN_CLASS,
- DATAGRID_SORT_ALIGNMENT_CLASS: DATAGRID_SORT_ALIGNMENT_CLASS,
- DATAGRID_CELL_CONTENT_CLASS: DATAGRID_CELL_CONTENT_CLASS,
- DATAGRID_ROW_CLASS: DATAGRID_ROW_CLASS,
- DATAGRID_GROUP_ROW_CLASS: DATAGRID_GROUP_ROW_CLASS,
- DATAGRID_TABLE_CLASS: DATAGRID_TABLE_CLASS
- })
- })(jQuery, DevExpress);
- /*! Module widgets-web, file ui.dataGrid.columnHeadersView.js */
- (function($, DX) {
- var ui = DX.ui,
- events = ui.events,
- utils = DX.utils,
- dataGrid = ui.dataGrid;
- var DATAGRID_CELL_CONTENT_CLASS = "dx-datagrid-text-content",
- DATAGRID_HEADERS_ACTION_CLASS = "dx-datagrid-action-cursor",
- DATAGRID_HEADERS_CONTAINER_CLASS = "dx-datagrid-headers-container",
- DATAGRID_HEADERS_CLASS = "dx-datagrid-headers",
- DATAGRID_HEADER_ROW_CLASS = "dx-header-row",
- DATAGRID_NOWRAP_CLASS = "dx-datagrid-nowrap",
- DATAGRID_GROUP_SPACE_CLASS = "dx-datagrid-group-space",
- DATAGRID_CONTENT_CLASS = "dx-datagrid-content",
- DATAGRID_COLUMN_LINES_CLASS = "dx-column-lines",
- DATAGRID_CONTEXT_MENU_SORT_ASC_ICON = "context-menu-sort-asc",
- DATAGRID_CONTEXT_MENU_SORT_DESC_ICON = "context-menu-sort-desc",
- DATAGRID_CONTEXT_MENU_SORT_NONE_ICON = "context-menu-sort-none",
- DATAGRID_SORT_CLASS = "dx-sort",
- COLUMN_HEADERS_VIEW_NAMESPACE = 'dxDataGridColumnHeadersView';
- dataGrid.ColumnHeadersView = dataGrid.ColumnsView.inherit({
- _renderHeaderContent: function($cell, column, columnIndex) {
- var that = this,
- $group = $('<div />'),
- headerCellTemplate = column.headerCellTemplate;
- if (column.command === "empty" || column.command === "edit")
- $cell.html(' ');
- else if (!utils.isDefined(column.groupIndex)) {
- that._applySorting($cell, column, that.option('showColumnLines'));
- var $content = $('<div />').addClass(DATAGRID_CELL_CONTENT_CLASS);
- if (that.option("showColumnLines"))
- $content.appendTo($cell);
- else
- $content.css("float", column.alignment || 'left').prependTo($cell);
- var templateOptions = {
- column: column,
- columnIndex: columnIndex
- };
- if ($.isFunction(headerCellTemplate))
- headerCellTemplate($content, templateOptions);
- else if (utils.isString(headerCellTemplate)) {
- headerCellTemplate = that.getTemplate(headerCellTemplate);
- if (headerCellTemplate)
- headerCellTemplate.render($content, templateOptions)
- }
- else
- $content.text(column.caption)
- }
- else
- $cell.addClass(DATAGRID_GROUP_SPACE_CLASS)
- },
- _renderHeader: function(rootElement, column, columnIndex) {
- var that = this,
- sorting = that.option('sorting'),
- sortingMode = sorting && sorting.mode,
- cellElement;
- cellElement = $('<td />').css('text-align', column.alignment || 'left').toggleClass(column.cssClass, !utils.isDefined(column.groupIndex));
- that._renderHeaderContent(cellElement, column, columnIndex);
- if (((sortingMode === 'single' || sortingMode === 'multiple') && column.allowSorting || column.allowReordering || column.allowHiding) && !utils.isDefined(column.groupIndex))
- cellElement.addClass(DATAGRID_HEADERS_ACTION_CLASS);
- cellElement.appendTo(rootElement)
- },
- _renderCore: function() {
- var that = this,
- $container = that._element(),
- columns = that._columnsController.getVisibleColumns(),
- scrollLeft = that._scrollLeft,
- columnsLength = columns.length,
- i,
- $row;
- that._tableElement = that._createTable().attr('style', '-webkit-user-select: none').append(dataGrid.createColGroup(columns));
- if (that.option('showColumnHeaders')) {
- $row = that._createRow().addClass(DATAGRID_HEADER_ROW_CLASS).toggleClass(DATAGRID_COLUMN_LINES_CLASS, that.option('showColumnLines'));
- $row.on(events.addNamespace("dxclick", COLUMN_HEADERS_VIEW_NAMESPACE), 'td', that.createAction(function(e) {
- var keyName = null,
- event = e.jQueryEvent;
- event.stopPropagation();
- setTimeout(function() {
- var column = columns[event.currentTarget.cellIndex];
- if (event.shiftKey)
- keyName = "shift";
- else if (event.ctrlKey)
- keyName = "ctrl";
- if (column && !utils.isDefined(column.groupIndex))
- that._columnsController.changeSortOrder(column.index, keyName)
- })
- }));
- for (i = 0; i < columnsLength; i++)
- that._renderHeader($row, columns[i], i);
- that._tableElement.append($row)
- }
- $container.addClass(DATAGRID_HEADERS_CLASS).addClass(DATAGRID_CONTENT_CLASS).toggleClass(DATAGRID_NOWRAP_CLASS, !!that.option("columnAutoWidth") || !that.option("wordWrapEnabled")).empty();
- $('<div/>').addClass(DATAGRID_HEADERS_CONTAINER_CLASS).append(that._tableElement).appendTo($container);
- that._scrollLeft = 0;
- that.scrollOffset(scrollLeft)
- },
- setColumnWidths: function(widths) {
- var that = this,
- scrollLeft = that._scrollLeft;
- that.callBase(widths);
- that._scrollLeft = 0;
- that.scrollOffset(scrollLeft)
- },
- _afterRender: function($root) {
- var that = this;
- if (!$root)
- that.setColumnWidths(that._columnWidths && that._columnWidths.length === that._columnsController.getVisibleColumns().length ? that._columnWidths : null);
- that._updateSortIndicatorPositions(that._element());
- that.processSizeChanged()
- },
- _updateSortIndicatorPositions: function(element) {
- var that = this,
- columns = that.getColumnElements();
- that.callBase(element);
- if (!that.option('showColumnLines') && columns) {
- var i;
- for (i = 0; i < columns.length; i++) {
- var $cell = $(columns[i]);
- that._setColumnTextWidth($cell, $cell.outerWidth())
- }
- }
- },
- _updateSortIndicators: function() {
- var that = this,
- columns = that._columnsController.getVisibleColumns(),
- $element = that._element(),
- $cells = $element.find('.' + DATAGRID_HEADER_ROW_CLASS + ' > td'),
- i;
- for (i = 0; i < columns.length; i++)
- if (!utils.isDefined(columns[i].groupIndex))
- that._applySorting($cells.eq(i), columns[i], that.option('showColumnLines'));
- that._updateSortIndicatorPositions($element)
- },
- _processColumnsChanged: function(e) {
- var visibleColumnIndex;
- if (dataGrid.checkChanges(e.changeTypes, ['sorting'])) {
- this._updateSortIndicators();
- return
- }
- if (dataGrid.checkChanges(e.optionNames, ['width'])) {
- visibleColumnIndex = this._columnsController.getVisibleIndex(e.columnIndex);
- if (visibleColumnIndex !== -1) {
- this._tableElement.find('col').eq(visibleColumnIndex).css('width', e.column.width);
- this._updateSortIndicatorPositions(this._element());
- if (!this.option('showColumnLines'))
- this._setColumnTextWidth($(this._tableElement.find('.' + DATAGRID_HEADER_ROW_CLASS + ' td')[visibleColumnIndex]), e.column.width)
- }
- if (this._columnWidths)
- this._columnWidths[visibleColumnIndex] = e.column.width;
- return
- }
- this.render()
- },
- _setColumnTextWidth: function($column, columnWidth) {
- var $sortElement = $column.find("." + DATAGRID_SORT_CLASS),
- indicatorOuterWidth = $sortElement.outerWidth(),
- columnPaddings = $column.outerWidth() - $column.width(),
- columnContentIndent = indicatorOuterWidth + columnPaddings;
- $column.find("." + DATAGRID_CELL_CONTENT_CLASS).css("max-width", columnWidth - columnContentIndent)
- },
- _isElementVisible: function(elementOptions) {
- return elementOptions && elementOptions.visible
- },
- processSizeChanged: function() {
- var that = this,
- $element = that._element();
- if (!utils.isDefined(that._headersHeight) || that._headersHeight !== $element.height()) {
- that._headersHeight = $element.height();
- that.sizeChanged.fire()
- }
- },
- getHeaderElement: function(index) {
- var columnElements = this.getColumnElements();
- return columnElements && columnElements.eq(index)
- },
- getColumnElements: function() {
- var that = this,
- columnElements;
- if (that._tableElement) {
- columnElements = that._tableElement.find('.' + DATAGRID_HEADER_ROW_CLASS).find('td');
- if (columnElements.length)
- return columnElements
- }
- return null
- },
- allowDragging: function(column, draggingPanels) {
- var i,
- result = false,
- columns = this.getColumns(),
- draggableColumnCount = 0,
- allowDrag = function(column) {
- return column.allowReordering || column.allowGrouping || column.allowHiding
- };
- for (i = 0; i < columns.length; i++)
- if (allowDrag(columns[i]))
- draggableColumnCount++;
- if (draggableColumnCount <= 1)
- return false;
- else if (!draggingPanels)
- return (this.option("allowColumnReordering") || this._columnsController.isColumnOptionUsed("allowReordering")) && column && column.allowReordering;
- for (i = 0; i < draggingPanels.length; i++)
- if (draggingPanels[i].allowDragging(column))
- return true;
- return false
- },
- getColumns: function() {
- return this._columnsController.getVisibleColumns()
- },
- getBoundingRect: function() {
- var that = this,
- offset;
- if (that._tableElement.length > 0 && that._tableElement[0].rows.length > 0 && that._tableElement[0].rows[0].cells.length > 0) {
- offset = that._tableElement.offset();
- return {top: offset.top}
- }
- return null
- },
- getName: function() {
- return 'headers'
- },
- getHeadersLength: function() {
- var that = this;
- if (that._tableElement.length > 0 && that._tableElement[0].rows.length > 0)
- return that._tableElement[0].rows[0].cells.length;
- return 0
- },
- tableElement: function() {
- return this._tableElement
- },
- init: function() {
- var that = this,
- dataController = that.getController('data');
- that.callBase();
- that._columnsController.columnsChanged.add(function(e) {
- var dataControllerChangedHandler = function() {
- dataController.changed.remove(dataControllerChangedHandler);
- that._processColumnsChanged(e)
- };
- if (e.changeTypes.grouping)
- dataController.changed.add(dataControllerChangedHandler);
- else
- that._processColumnsChanged(e)
- });
- that._scrollerWidth = 0;
- that.sizeChanged = $.Callbacks()
- },
- isVisible: function() {
- return this.option('showColumnHeaders')
- },
- scrollOffset: function(pos) {
- var that = this,
- $element = that._element(),
- $scrollContainer = $element && $element.find('.' + DATAGRID_HEADERS_CONTAINER_CLASS);
- if (pos === undefined)
- return $scrollContainer && $scrollContainer.scrollLeft();
- else if (that._scrollLeft !== pos) {
- that._scrollLeft = pos;
- $scrollContainer && $scrollContainer.scrollLeft(pos)
- }
- },
- setScrollerSpacing: function(width) {
- var that = this,
- $element = that._element(),
- rtlEnabled = that.option("rtlEnabled");
- that._scrollerWidth = width;
- $element && $element.css(rtlEnabled ? {paddingLeft: width} : {paddingRight: width})
- },
- optionChanged: function(name, value, prevValue) {
- var that = this;
- switch (name) {
- case'showColumnHeaders':
- case'wordWrapEnabled':
- case'showColumnLines':
- that.render();
- break
- }
- },
- resize: function() {
- this.callBase();
- this._updateSortIndicatorPositions(this._element())
- },
- getHeight: function() {
- var that = this,
- $element = that._element();
- return $element ? $element.height() : 0
- },
- getContextMenuItems: function($targetElement) {
- var that = this,
- $cell,
- column,
- itemClickAction,
- sortingOptions;
- if ($targetElement.closest("." + DATAGRID_HEADER_ROW_CLASS).length) {
- $cell = $targetElement.closest("td");
- column = $cell.length && that.getColumns()[$cell[0].cellIndex];
- sortingOptions = that.option("sorting");
- if (sortingOptions && sortingOptions.mode !== "none" && column && column.allowSorting) {
- itemClickAction = function(params) {
- setTimeout(function() {
- that._columnsController.changeSortOrder(column.index, params.itemData.value)
- })
- };
- return [{
- text: sortingOptions.ascendingText,
- value: "asc",
- icon: DATAGRID_CONTEXT_MENU_SORT_ASC_ICON,
- itemClickAction: itemClickAction
- }, {
- text: sortingOptions.descendingText,
- value: "desc",
- icon: DATAGRID_CONTEXT_MENU_SORT_DESC_ICON,
- itemClickAction: itemClickAction
- }, {
- text: sortingOptions.clearText,
- value: "none",
- icon: DATAGRID_CONTEXT_MENU_SORT_NONE_ICON,
- itemClickAction: itemClickAction
- }]
- }
- }
- return []
- }
- });
- $.extend(dataGrid.__internals, {
- DATAGRID_CELL_CONTENT_CLASS: DATAGRID_CELL_CONTENT_CLASS,
- DATAGRID_HEADERS_ACTION_CLASS: DATAGRID_HEADERS_ACTION_CLASS,
- DATAGRID_HEADERS_CONTAINER_CLASS: DATAGRID_HEADERS_CONTAINER_CLASS,
- DATAGRID_HEADERS_CLASS: DATAGRID_HEADERS_CLASS,
- DATAGRID_HEADER_ROW_CLASS: DATAGRID_HEADER_ROW_CLASS,
- DATAGRID_NOWRAP_CLASS: DATAGRID_NOWRAP_CLASS
- });
- dataGrid.registerModule('columnHeaders', {
- defaultOptions: function() {
- return {showColumnHeaders: true}
- },
- views: {columnHeadersView: dataGrid.ColumnHeadersView}
- })
- })(jQuery, DevExpress);
- /*! Module widgets-web, file ui.dataGrid.filterRow.js */
- (function($, DX) {
- var ui = DX.ui,
- events = ui.events,
- utils = DX.utils,
- dataGrid = ui.dataGrid;
- var OPERATION_ICONS = {
- '=': 'filter-operation-equals',
- '<>': 'filter-operation-not-equals',
- '<': 'filter-operation-less',
- '<=': 'filter-operation-less-equal',
- '>': 'filter-operation-greater',
- '>=': 'filter-operation-greater-equal',
- 'default': 'filter-operation-default',
- notcontains: 'filter-operation-not-contains',
- contains: 'filter-operation-contains',
- startswith: 'filter-operation-starts-with',
- endswith: 'filter-operation-ends-with'
- };
- var DATAGRID_FILTER_ROW_CLASS = "dx-datagrid-filter-row",
- DATAGRID_MENU_CLASS = "dx-menu",
- DATAGRID_MENU_IMAGE_CLASS = 'dx-menu-image',
- DATAGRID_CELL_CONTENT_CLASS = "dx-datagrid-text-content",
- DATAGRID_GROUP_SPACE_CLASS = "dx-datagrid-group-space",
- DATAGRID_EDITOR_WITH_MENU_CLASS = "dx-editor-with-menu",
- DATAGRID_EDITOR_CONTAINER_CLASS = "dx-editor-container",
- DATAGRID_COLUMN_LINES_CLASS = "dx-column-lines",
- DATAGRID_EDITOR_CELL_CLASS = "dx-editor-cell";
- var ColumnHeadersViewFilterRowExtender = {
- _processColumnsChanged: function(e) {
- var that = this,
- visibleIndex,
- textBox,
- column,
- $menu;
- if (dataGrid.checkChanges(e.optionNames, ['filterValue']))
- return;
- if (dataGrid.checkChanges(e.optionNames, ['selectedFilterOperation'])) {
- visibleIndex = that.getController('columns').getVisibleIndex(e.columnIndex);
- column = e.column;
- if (visibleIndex >= 0) {
- $menu = that._element().find('.' + DATAGRID_FILTER_ROW_CLASS).children().eq(visibleIndex).find('.' + DATAGRID_MENU_CLASS);
- if ($menu.length) {
- that._updateFilterOperationChooser($menu, column);
- textBox = $menu.prev().children().data('dxTextBox');
- if (textBox)
- textBox.option('value', column.filterValue)
- }
- }
- }
- else
- that.callBase(e)
- },
- isFilterRowVisible: function() {
- return this._isElementVisible(this.option('filterRow'))
- },
- isVisible: function() {
- return this.callBase() || this.isFilterRowVisible()
- },
- _renderCore: function() {
- this.callBase();
- var that = this,
- columns = that._columnsController.getVisibleColumns(),
- i,
- rowElement;
- if (that.isFilterRowVisible()) {
- rowElement = that._createRow().appendTo(that._tableElement);
- rowElement.addClass(DATAGRID_FILTER_ROW_CLASS).toggleClass(DATAGRID_COLUMN_LINES_CLASS, that.option('showColumnLines'));
- for (i = 0; i < columns.length; i++)
- that._renderFilterRowCell(rowElement, columns[i])
- }
- },
- _updateFilterOperationChooser: function($menu, column) {
- var that = this;
- $menu.dxMenu({
- highlightActiveItem: true,
- cssClass: 'dx-datagrid dx-widget',
- showFirstSubmenuMode: 'onhover',
- items: [{
- disabled: column.filterOperations && column.filterOperations.length === 0,
- icon: OPERATION_ICONS[column.selectedFilterOperation || "default"],
- items: that._getFilterOperationMenuItems(column)
- }],
- itemClickAction: function(properties) {
- var selectedFilterOperation = properties.itemData.name;
- if (properties.itemData.items)
- return;
- if (selectedFilterOperation)
- that._columnsController.columnOption(column.initialIndex, 'selectedFilterOperation', selectedFilterOperation);
- else
- that._columnsController.columnOption(column.initialIndex, {
- selectedFilterOperation: column.defaultSelectedFilterOperation || null,
- filterValue: null
- })
- },
- rtlEnabled: that.option('rtlEnabled')
- })
- },
- _renderFilterOperationChooser: function($container, column) {
- var that = this,
- $menu;
- if (that.option("filterRow.showOperationChooser")) {
- $container.addClass(DATAGRID_EDITOR_WITH_MENU_CLASS);
- $menu = $('<div />').appendTo($container);
- that._updateFilterOperationChooser($menu, column)
- }
- },
- _getFilterOperationMenuItems: function(column) {
- var that = this,
- result = [{}],
- filterRowOptions = that.option("filterRow"),
- operationDescriptions = filterRowOptions && filterRowOptions.operationDescriptions || {};
- if (column.filterOperations && column.filterOperations.length) {
- result = $.map(column.filterOperations, function(value) {
- return {
- name: value,
- selectable: true,
- selected: (column.selectedFilterOperation || column.defaultFilterOperation) === value,
- text: operationDescriptions[value],
- icon: OPERATION_ICONS[value]
- }
- });
- result.push({
- name: null,
- text: filterRowOptions && filterRowOptions.resetOperationText,
- allowSelectOnclick: false,
- icon: OPERATION_ICONS['default']
- })
- }
- return result
- },
- _renderFilterRowCell: function(rootElement, column) {
- var that = this,
- $cell = $('<td />').toggleClass(column.cssClass, !utils.isDefined(column.groupIndex)).appendTo(rootElement),
- columnsController = that._columnsController,
- $container,
- $editorContainer,
- $editor;
- var updateFilterValue = function(that, column, value) {
- var filterOptions,
- filterText = value;
- if (value === '')
- value = undefined;
- if (!utils.isDefined(column.filterValue) && !utils.isDefined(value))
- return;
- column.filterValue = value;
- columnsController.columnOption(column.initialIndex, 'filterValue', value)
- };
- if (column.command === 'empty')
- $cell.html(' ');
- else if (utils.isDefined(column.groupIndex))
- $cell.addClass(DATAGRID_GROUP_SPACE_CLASS);
- else if (column.allowFiltering) {
- $cell.addClass(DATAGRID_EDITOR_CELL_CLASS);
- $container = $('<div />').appendTo($cell);
- $editorContainer = $('<div />').addClass(DATAGRID_EDITOR_CONTAINER_CLASS).appendTo($container);
- $editor = $('<div />').appendTo($editorContainer);
- that.getController('editorFactory').createEditor($editor, $.extend({}, column, {
- value: columnsController.isDataSourceApplied() ? column.filterValue : undefined,
- setValue: function(value) {
- updateFilterValue(that, column, value)
- },
- parentType: "filterRow",
- showAllText: that.option('filterRow.showAllText'),
- width: null
- }));
- if (column.alignment)
- $cell.find('input').first().css('text-align', column.alignment);
- if (column.filterOperations && column.filterOperations.length)
- that._renderFilterOperationChooser($container, column)
- }
- },
- optionChanged: function(name, value, prevValue) {
- var that = this;
- switch (name) {
- case'filterRow':
- case'showColumnLines':
- case'disabled':
- that.render();
- break;
- default:
- that.callBase(name);
- break
- }
- }
- };
- var DataControllerFilterRowExtender = {_calculateAdditionalFilter: function() {
- var that = this,
- filter = that.callBase(),
- i,
- filters = [],
- resultFilter = [],
- columns = that._columnsController.getVisibleColumns();
- $.each(columns, function() {
- var filterOptions,
- filter;
- if (this.allowFiltering && this.calculateFilterExpression && utils.isDefined(this.filterValue)) {
- filter = this.calculateFilterExpression(this.filterValue, this.selectedFilterOperation || this.defaultFilterOperation);
- if (filter)
- filters.push(filter)
- }
- });
- if (filters.length) {
- if (filter && filter.length)
- filters.unshift(filter);
- for (i = 0; i < filters.length; i++) {
- if (i > 0)
- resultFilter.push('and');
- resultFilter.push(filters[i])
- }
- }
- else
- resultFilter = filter;
- return resultFilter && resultFilter.length ? resultFilter : null
- }};
- var ColumnsControllerFilterRowExtender = {_createCalculatedColumnOptions: function(columnOptions) {
- var calculatedColumnOptions = this.callBase(columnOptions);
- if (columnOptions.dataField)
- $.extend(calculatedColumnOptions, {
- calculateFilterExpression: function(value, selectedFilterOperation) {
- var column = this,
- dataField = column.dataField,
- filter = null;
- if (utils.isDefined(value))
- if (column.dataType === 'string' && !column.lookup)
- filter = [dataField, selectedFilterOperation || 'contains', value];
- else if (column.dataType === 'date') {
- if (utils.isDate(value)) {
- var dateStart = new Date(value.getFullYear(), value.getMonth(), value.getDate()),
- dateEnd = new Date(value.getFullYear(), value.getMonth(), value.getDate() + 1);
- switch (selectedFilterOperation) {
- case'<':
- return [dataField, '<', dateStart];
- case'<=':
- return [dataField, '<', dateEnd];
- case'>':
- return [dataField, '>=', dateEnd];
- case'>=':
- return [dataField, '>=', dateStart];
- case'<>':
- return [[dataField, '<', dateStart], 'or', [dataField, '>=', dateEnd]];
- default:
- return [[dataField, '>=', dateStart], 'and', [dataField, '<', dateEnd]]
- }
- }
- }
- else
- filter = [dataField, selectedFilterOperation || '=', value];
- return filter
- },
- allowFiltering: true
- });
- else
- $.extend(calculatedColumnOptions, {allowFiltering: !!columnOptions.calculateFilterExpression});
- return calculatedColumnOptions
- }};
- dataGrid.registerModule('filterRow', {
- defaultOptions: function() {
- return {filterRow: {
- visible: false,
- showOperationChooser: true,
- showAllText: Globalize.localize("dxDataGrid-filterRowShowAllText"),
- resetOperationText: Globalize.localize("dxDataGrid-filterRowResetOperationText"),
- operationDescriptions: {
- '=': Globalize.localize("dxDataGrid-filterRowOperationEquals"),
- '<>': Globalize.localize("dxDataGrid-filterRowOperationNotEquals"),
- '<': Globalize.localize("dxDataGrid-filterRowOperationLess"),
- '<=': Globalize.localize("dxDataGrid-filterRowOperationLessOrEquals"),
- '>': Globalize.localize("dxDataGrid-filterRowOperationGreater"),
- '>=': Globalize.localize("dxDataGrid-filterRowOperationGreaterOrEquals"),
- startswith: Globalize.localize("dxDataGrid-filterRowOperationStartsWith"),
- contains: Globalize.localize("dxDataGrid-filterRowOperationContains"),
- notcontains: Globalize.localize("dxDataGrid-filterRowOperationNotContains"),
- endswith: Globalize.localize("dxDataGrid-filterRowOperationEndsWith")
- }
- }}
- },
- extenders: {
- controllers: {
- data: DataControllerFilterRowExtender,
- columns: ColumnsControllerFilterRowExtender
- },
- views: {columnHeadersView: ColumnHeadersViewFilterRowExtender}
- }
- });
- $.extend(dataGrid.__internals, {
- DATAGRID_FILTER_ROW_CLASS: DATAGRID_FILTER_ROW_CLASS,
- DATAGRID_MENU_CLASS: DATAGRID_MENU_CLASS,
- DATAGRID_MENU_IMAGE_CLASS: DATAGRID_MENU_IMAGE_CLASS,
- DATAGRID_CELL_CONTENT_CLASS: DATAGRID_CELL_CONTENT_CLASS,
- DATAGRID_EDITOR_WITH_MENU_CLASS: DATAGRID_EDITOR_WITH_MENU_CLASS,
- DATAGRID_EDITOR_CONTAINER_CLASS: DATAGRID_EDITOR_CONTAINER_CLASS
- });
- dataGrid.ColumnHeadersViewFilterRowExtender = ColumnHeadersViewFilterRowExtender;
- dataGrid.DataControllerFilterRowExtender = DataControllerFilterRowExtender
- })(jQuery, DevExpress);
- /*! Module widgets-web, file ui.dataGrid.headerPanel.js */
- (function($, DX) {
- var ui = DX.ui,
- events = ui.events,
- dataGrid = ui.dataGrid;
- var DATAGRID_HEADER_PANEL_CLASS = "dx-datagrid-header-panel",
- DATAGRID_GROUP_PANEL_CLASS = "dx-datagrid-group-panel",
- DATAGRID_GROUP_PANEL_MESSAGE_CLASS = "dx-group-panel-message",
- DATAGRID_GROUP_PANEL_ITEM_CLASS = "dx-group-panel-item",
- DATAGRID_HEADERS_ACTION_CLASS = "dx-datagrid-action-cursor";
- dataGrid.HeaderPanel = dataGrid.ColumnsView.inherit({
- _renderGroupPanel: function() {
- var that = this,
- $element = that._element(),
- groupPanelOptions = that.option("groupPanel"),
- $groupPanel,
- groupColumns = that.getController('columns').getGroupColumns();
- $groupPanel = $element.find('.' + DATAGRID_GROUP_PANEL_CLASS);
- if (groupPanelOptions && groupPanelOptions.visible) {
- if (!$groupPanel.length)
- $groupPanel = $('<div />').addClass(DATAGRID_GROUP_PANEL_CLASS).prependTo($element);
- else
- $groupPanel.show();
- that._renderGroupPanelItems($groupPanel, groupColumns);
- if (groupPanelOptions.allowColumnDragging && !groupColumns.length)
- $('<div />').addClass(DATAGRID_GROUP_PANEL_MESSAGE_CLASS).text(groupPanelOptions.emptyPanelText).appendTo($groupPanel)
- }
- else
- $groupPanel.hide()
- },
- _renderGroupPanelItems: function($groupPanel, groupColumns) {
- var that = this,
- $item;
- $groupPanel.empty();
- $.each(groupColumns, function(index, groupColumn) {
- $item = $('<div />').addClass(groupColumn.cssClass).addClass(DATAGRID_GROUP_PANEL_ITEM_CLASS).toggleClass(DATAGRID_HEADERS_ACTION_CLASS, groupColumn.allowSorting || groupColumn.allowReordering).appendTo($groupPanel).text(groupColumn.caption).on(events.addNamespace("dxclick", "dxDataGridHeaderPanel"), that.createAction(function(e) {
- setTimeout(function() {
- that.getController('columns').changeSortOrder(groupColumn.index)
- })
- }));
- that._applySorting($item, {
- alignment: 'left',
- sortOrder: groupColumn.sortOrder === 'desc' ? 'desc' : 'asc'
- }, true)
- });
- that._updateSortIndicatorPositions($groupPanel)
- },
- _renderCore: function() {
- var that = this;
- that._element().addClass(DATAGRID_HEADER_PANEL_CLASS);
- that._renderGroupPanel()
- },
- getHeaderPanel: function() {
- return this._element()
- },
- allowDragging: function(column) {
- var groupPanelOptions = this.option("groupPanel");
- return groupPanelOptions && groupPanelOptions.visible && groupPanelOptions.allowColumnDragging && column && column.allowGrouping
- },
- getColumnElements: function() {
- var $element = this._element();
- return $element && $element.find('.' + DATAGRID_GROUP_PANEL_ITEM_CLASS)
- },
- getColumns: function() {
- return this.getController('columns').getGroupColumns()
- },
- getBoundingRect: function() {
- var that = this,
- $element = that._element(),
- offset;
- if ($element && $element.find('.' + DATAGRID_GROUP_PANEL_CLASS).length) {
- offset = $element.offset();
- return {
- top: offset.top,
- bottom: offset.top + $element.height()
- }
- }
- return null
- },
- getName: function() {
- return 'group'
- },
- init: function() {
- var that = this;
- that.callBase();
- that.getController('columns').columnsChanged.add(function(e) {
- if (!dataGrid.checkChanges(e.optionNames, ['width']))
- that.render()
- })
- },
- isVisible: function() {
- var groupPanelOptions = this.option('groupPanel');
- return groupPanelOptions && groupPanelOptions.visible
- },
- getHeight: function() {
- var $element = this._element();
- return $element ? $element.outerHeight(true) : 0
- },
- optionChanged: function(name, value, prevValue) {
- var that = this;
- switch (name) {
- case'searchPanel':
- that._renderSearchPanel();
- break;
- case'groupPanel':
- that._renderGroupPanel();
- break;
- case'disabled':
- that.render();
- break
- }
- },
- resize: function() {
- var that = this,
- $element = that._element(),
- $groupPanel = $element && $element.find('.' + DATAGRID_GROUP_PANEL_CLASS),
- groupPanelOptions = that.option('groupPanel');
- that.callBase();
- that._updateSortIndicatorPositions($groupPanel)
- }
- });
- $.extend(dataGrid.__internals, {
- DATAGRID_HEADER_PANEL_CLASS: DATAGRID_HEADER_PANEL_CLASS,
- DATAGRID_GROUP_PANEL_CLASS: DATAGRID_GROUP_PANEL_CLASS,
- DATAGRID_GROUP_PANEL_MESSAGE_CLASS: DATAGRID_GROUP_PANEL_MESSAGE_CLASS,
- DATAGRID_GROUP_PANEL_ITEM_CLASS: DATAGRID_GROUP_PANEL_ITEM_CLASS,
- DATAGRID_HEADERS_ACTION_CLASS: DATAGRID_HEADERS_ACTION_CLASS
- });
- dataGrid.registerModule('headerPanel', {
- defaultOptions: function() {
- return {groupPanel: {
- visible: false,
- emptyPanelText: Globalize.localize("dxDataGrid-groupPanelEmptyText"),
- allowColumnDragging: true
- }}
- },
- views: {headerPanel: dataGrid.HeaderPanel}
- })
- })(jQuery, DevExpress);
- /*! Module widgets-web, file ui.dataGrid.search.js */
- (function($, DX) {
- var ui = DX.ui,
- events = ui.events,
- utils = DX.utils,
- dataGrid = ui.dataGrid;
- var DATAGRID_SEARCH_PANEL_CLASS = "dx-datagrid-search-panel",
- MARGIN_RIGHT = 10;
- dataGrid.registerModule('search', {
- defaultOptions: function() {
- return {searchPanel: {
- visible: false,
- width: 160,
- placeholder: Globalize.localize("dxDataGrid-searchPanelPlaceholder"),
- highlightSearchText: true
- }}
- },
- extenders: {
- controllers: {data: function() {
- var calculateSearchFilter = function(that, text) {
- var i,
- column,
- columns = that._columnsController.getColumns(),
- filter,
- filterValue,
- lookup,
- searchFilter = [];
- if (!text)
- return null;
- for (i = 0; i < columns.length; i++) {
- filter = null;
- column = columns[i];
- if (column.allowFiltering && column.calculateFilterExpression) {
- lookup = column.lookup;
- if (lookup && lookup.items) {
- filterValue = column.parseValue.call(lookup, text);
- DX.data.query(lookup.items).filter(column.calculateFilterExpression.call({
- dataField: lookup.displayExpr,
- dataType: lookup.dataType
- }, filterValue)).enumerate().done(function(items) {
- var i,
- valueGetter = DX.data.utils.compileGetter(lookup.valueExpr),
- value;
- for (i = 0; i < items.length; i++) {
- if (searchFilter.length > 0)
- searchFilter.push('or');
- value = valueGetter(items[i]);
- searchFilter.push(column.calculateFilterExpression(value))
- }
- })
- }
- else {
- filterValue = column.parseValue ? column.parseValue(text) : text;
- if (filterValue !== undefined) {
- filter = column.calculateFilterExpression(filterValue);
- if (filter) {
- if (searchFilter.length > 0)
- searchFilter.push('or');
- searchFilter.push(filter)
- }
- }
- }
- }
- }
- return searchFilter
- };
- return {
- publicMethods: function() {
- return this.callBase().concat(['searchByText'])
- },
- _calculateAdditionalFilter: function() {
- var that = this,
- filter = that.callBase(),
- searchFilter = calculateSearchFilter(that, that._searchText);
- if (searchFilter)
- if (filter)
- filter = [filter, 'and', searchFilter];
- else
- filter = searchFilter;
- return filter
- },
- searchByText: function(text) {
- var that = this;
- if (that._searchText !== text) {
- that._searchText = text;
- that._applyFilter()
- }
- },
- getSearchText: function() {
- return this._searchText || ''
- }
- }
- }()},
- views: {headerPanel: function() {
- var getSearchPanelOptions = function(that) {
- return that.option('searchPanel')
- };
- return {
- _renderSearchPanel: function() {
- var that = this,
- $element = that._element(),
- dataController = that.getController('data'),
- searchPanelOptions = getSearchPanelOptions(that);
- if (searchPanelOptions && searchPanelOptions.visible) {
- if (!that._$searchPanel)
- that._$searchPanel = $('<div/>').addClass(DATAGRID_SEARCH_PANEL_CLASS).prependTo($element);
- else
- that._$searchPanel.show();
- that.getController('editorFactory').createEditor(that._$searchPanel, {
- width: searchPanelOptions.width,
- placeholder: searchPanelOptions.placeholder,
- parentType: "searchPanel",
- value: dataController.getSearchText(),
- setValue: function(value) {
- dataController.searchByText(value)
- }
- });
- that.resize()
- }
- else
- that._$searchPanel && that._$searchPanel.hide()
- },
- _renderCore: function() {
- this.callBase();
- this._renderSearchPanel()
- },
- focus: function() {
- var textBox = this._$searchPanel.dxTextBox("instance");
- if (textBox)
- textBox.focus()
- },
- isVisible: function() {
- var searchPanelOptions = getSearchPanelOptions(this);
- return this.callBase() || searchPanelOptions && searchPanelOptions.visible
- }
- }
- }()}
- }
- });
- dataGrid.__internals = $.extend({}, dataGrid.__internals, {DATAGRID_SEARCH_PANEL_CLASS: DATAGRID_SEARCH_PANEL_CLASS})
- })(jQuery, DevExpress);
- /*! Module widgets-web, file ui.dataGrid.rowsView.js */
- (function($, DX) {
- var ui = DX.ui,
- utils = DX.utils,
- dataGrid = ui.dataGrid;
- var DATAGRID_CELL_CONTENT_CLASS = "dx-datagrid-text-content",
- DATAGRID_GROUP_ROW_CLASS = "dx-group-row",
- DATAGRID_SEARCH_TEXT_CLASS = "dx-datagrid-search-text",
- DATAGRID_ROWS_VIEW_CLASS = "dx-datagrid-rowsview",
- DATAGRID_TABLE_CONTENT_CLASS = "dx-datagrid-table-content",
- DATAGRID_TABLE_CLASS = "dx-datagrid-table",
- DATAGRID_ROW_CLASS = "dx-row",
- DATAGRID_DATA_ROW_CLASS = "dx-data-row",
- DATAGRID_FREESPACE_CLASS = "dx-freespace-row",
- DATAGRID_BOTTOM_LOAD_PANEL_CLASS = "dx-datagrid-bottom-load-panel",
- DATAGRID_NODATA_TEXT_CLASS = "dx-datagrid-nodata",
- DATAGRID_GROUP_SPACE_CLASS = "dx-datagrid-group-space",
- DATAGRID_GROUP_OPENED_CLASS = "dx-datagrid-group-opened",
- DATAGRID_GROUP_CLOSED_CLASS = "dx-datagrid-group-closed",
- DATAGRID_CONTENT_CLASS = "dx-datagrid-content",
- DATAGRID_NOWRAP_CLASS = "dx-datagrid-nowrap",
- DATAGRID_ROW_LINES_CLASS = "dx-row-lines",
- DATAGRID_COLUMN_LINES_CLASS = "dx-column-lines",
- DATAGRID_ROW_ALTERNATION_CLASS = 'dx-row-alt',
- DATAGRID_EDITOR_CELL_CLASS = "dx-editor-cell",
- PIXELS_LIMIT = 250000,
- DATAGRID_LOADPANEL_HIDE_TIMEOUT = 200;
- var formatValue = function(value, options) {
- var formatObject = {
- value: value,
- valueText: DX.formatHelper.format(value, options.format, options.precision) || ''
- };
- return options.customizeText ? options.customizeText.call(options, formatObject) : formatObject.valueText
- };
- var appendElementTemplate = {render: function(container, element) {
- container.append(element)
- }};
- var createScrollableOptions = function(that) {
- var useNativeScrolling = that.option("scrolling.useNativeScrolling");
- var options = {
- direction: "both",
- rtlEnabled: that.option("rtlEnabled") || DX.rtlEnabled,
- disabled: that.option("disabled"),
- bounceEnabled: false,
- useKeyboard: false
- };
- if (useNativeScrolling === undefined)
- useNativeScrolling = true;
- if (useNativeScrolling !== 'auto') {
- options.useNative = !!useNativeScrolling;
- options.useSimulatedScrollbar = !useNativeScrolling
- }
- return options
- };
- dataGrid.createScrollableOptions = createScrollableOptions;
- dataGrid.RowsView = dataGrid.ColumnsView.inherit({
- _getDefaultTemplate: function(column) {
- var that = this;
- switch (column.command) {
- case"group":
- return function(container, options) {
- if (!utils.isDefined(options.value) || options.data && options.data.isContinuation)
- container.addClass(DATAGRID_GROUP_SPACE_CLASS);
- else
- container.addClass(options.value ? DATAGRID_GROUP_OPENED_CLASS : DATAGRID_GROUP_CLOSED_CLASS).on('dxclick', that.createAction(function() {
- that._dataController.changeGroupExpand(options.values)
- }))
- };
- case"empty":
- return function(container) {
- container.html(' ')
- };
- default:
- return function(container, options) {
- var isDataTextEmpty = !options.text && options.rowType === "data",
- text = isDataTextEmpty ? " " : options.text;
- if (column.encodeHtml && !isDataTextEmpty)
- container.text(text);
- else
- container.html(text)
- }
- }
- },
- _getDefaultGroupTemplate: function() {
- var that = this;
- return function(container, options) {
- var data = options.data,
- text = options.column.caption + ": " + options.text;
- if (data)
- if (options.groupContinuedMessage && options.groupContinuesMessage)
- text += ' (' + options.groupContinuedMessage + '. ' + options.groupContinuesMessage + ')';
- else if (options.groupContinuesMessage)
- text += ' (' + options.groupContinuesMessage + ')';
- else if (options.groupContinuedMessage)
- text += ' (' + options.groupContinuedMessage + ')';
- container.css('text-align', that.option('rtlEnabled') ? 'right' : 'left').text(text)
- }
- },
- _update: function(change){},
- _createRow: function(rowOptions) {
- var $row = this.callBase(),
- isGroup,
- isDataRow;
- if (rowOptions) {
- isGroup = rowOptions.rowType === 'group';
- isDataRow = rowOptions.rowType === 'data';
- $row.toggleClass(DATAGRID_DATA_ROW_CLASS, isDataRow).toggleClass(DATAGRID_ROW_ALTERNATION_CLASS, isDataRow && rowOptions.dataIndex % 2 === 1 && this.option('rowAlternationEnabled')).toggleClass(DATAGRID_ROW_LINES_CLASS, isDataRow && this.option('showRowLines')).toggleClass(DATAGRID_COLUMN_LINES_CLASS, this.option('showColumnLines')).toggleClass(DATAGRID_GROUP_ROW_CLASS, isGroup)
- }
- return $row
- },
- _highlightSearchText: function(cellElement, isEquals) {
- var that = this,
- $parent,
- searchHTML,
- searchText = that._dataController.getSearchText();
- if (searchText && that.option("searchPanel.highlightSearchText")) {
- searchHTML = $('<div>').text(searchText).html();
- $parent = cellElement.parent();
- if (!$parent.length)
- $parent = $('<div>').append(cellElement);
- $.each($parent.find(":dxicontains('" + searchText + "')"), function(index, element) {
- $.each($(element).contents(), function(index, content) {
- if (content.nodeType !== 3)
- return;
- var highlightSearchTextInTextNode = function($content, searchText) {
- var $searchTextSpan = $('<span />').addClass(DATAGRID_SEARCH_TEXT_CLASS),
- text = $content.text(),
- index = text.toLowerCase().indexOf(searchText.toLowerCase());
- if (index >= 0) {
- if ($content[0].textContent)
- $content[0].textContent = text.substr(0, index);
- else
- $content[0].nodeValue = text.substr(0, index);
- $content.after($searchTextSpan.text(text.substr(index, searchText.length)));
- $content = $(document.createTextNode(text.substr(index + searchText.length))).insertAfter($searchTextSpan);
- return highlightSearchTextInTextNode($content, searchText)
- }
- };
- if (isEquals) {
- if ($(content).text().toLowerCase() === searchText.toLowerCase())
- $(this).replaceWith($('<span />').addClass(DATAGRID_SEARCH_TEXT_CLASS).text($(content).text()))
- }
- else
- highlightSearchTextInTextNode($(content), searchText)
- })
- })
- }
- },
- _renderTemplate: function(container, template, options) {
- var that = this;
- if ($.isFunction(template)) {
- template(container, options);
- return true
- }
- else if (utils.isString(template)) {
- if (!that._templatesCache[template])
- that._templatesCache[template] = that.getTemplate(template);
- template = that._templatesCache[template];
- if (template)
- if (template.allowRenderToDetachedContainer) {
- template.render(container, options);
- return true
- }
- else
- that._delayedTemplates.push({
- template: template,
- container: container,
- options: options
- })
- }
- return false
- },
- _getColumnTemplate: function(options) {
- var that = this,
- column = options.column,
- template;
- if (column.groupIndex !== undefined)
- template = column.groupCellTemplate || that._getDefaultGroupTemplate();
- else
- template = column.cellTemplate || that._getDefaultTemplate(column);
- return template
- },
- _updateCell: function($cell, parameters) {
- var that = this,
- column = parameters.column,
- isEquals = column.dataType !== "string";
- if (column.allowFiltering)
- that._highlightSearchText($cell, isEquals);
- if (parameters.rowType === "data" && column.groupIndex === undefined)
- that._cellPrepared($cell, parameters)
- },
- _createCell: function(value, item, rowIndex, column, columnIndex) {
- var that = this,
- template,
- groupingOptions = that.option('grouping'),
- scrollingMode = this.option('scrolling.mode'),
- data = item && item.data,
- displayValue = column.lookup ? column.lookup.calculateCellValue(value) : value,
- $cell = $('<td />').addClass(column.cssClass),
- parameters = {
- value: value,
- displayValue: displayValue,
- row: item,
- key: item && item.key,
- data: data,
- rowType: item && item.rowType,
- values: item && item.values,
- text: formatValue(displayValue, column),
- rowIndex: rowIndex,
- columnIndex: columnIndex,
- column: column,
- resized: column.resizedCallbacks
- };
- if (utils.isDefined(column.groupIndex) && scrollingMode !== 'virtual' && scrollingMode !== 'infinite') {
- parameters.groupContinuesMessage = data && data.isContinuationOnNextPage && groupingOptions && groupingOptions.groupContinuesMessage;
- parameters.groupContinuedMessage = data && data.isContinuation && groupingOptions && groupingOptions.groupContinuedMessage
- }
- template = that._getColumnTemplate(parameters);
- if (that._renderTemplate($cell, template, parameters))
- that._updateCell($cell, parameters);
- return $cell
- },
- _cellPrepared: function($cell, options) {
- var that = this,
- cellPrepared = that.option("cellPrepared"),
- alignment = options.column.alignment,
- extendOptions = function(event) {
- return {
- cellElement: $(event.target).closest('td'),
- jQueryEvent: event,
- eventType: event.type
- }
- };
- if (alignment)
- $cell[0].style.textAlign = alignment;
- if (that.option("cellClick"))
- $cell.on("dxclick", function(e) {
- that.executeAction("cellClick", $.extend({}, options, extendOptions(e)))
- });
- if (that.option("cellHoverChanged")) {
- $cell.on("mouseover", function(e) {
- that.executeAction("cellHoverChanged", $.extend({}, options, extendOptions(e)))
- });
- $cell.on("mouseout", function(e) {
- that.executeAction("cellHoverChanged", $.extend({}, options, extendOptions(e)))
- })
- }
- if (utils.isFunction(cellPrepared))
- cellPrepared($cell, options)
- },
- _rowPrepared: function($row, options) {
- var that = this,
- rowPrepared = that.option("rowPrepared");
- if (utils.isFunction(rowPrepared))
- rowPrepared($row, options)
- },
- _renderScrollable: function($table) {
- var that = this,
- $element = that._element();
- if (!utils.isDefined(that._tableElement)) {
- that._tableElement = $table;
- if (!$element.children().length)
- $element.append('<div />');
- that._renderLoadPanel($element);
- that._renderScrollableCore($element);
- that._subscribeToWindowScrollEvents($element)
- }
- },
- _renderScrollableCore: function($element) {
- var that = this,
- dxScrollableOptions = createScrollableOptions(that);
- var scrollHandler = function(e) {
- var $content = that._findContentElement();
- if (that._hasHeight && that._rowHeight) {
- that._scrollTop = e.scrollOffset.top;
- that._dataController.setViewportItemIndex(that._scrollTop / that._rowHeight)
- }
- that.scrollOffsetChanged.fire(e.scrollOffset)
- };
- dxScrollableOptions.scrollAction = scrollHandler;
- dxScrollableOptions.stopAction = scrollHandler;
- $element.dxScrollable(dxScrollableOptions);
- that._scrollable = $element.data('dxScrollable');
- that._scrollableContainer = that._scrollable._$container
- },
- _renderLoadPanel: function($element) {
- var that = this,
- loadPanelOptions;
- if ($element.dxLoadPanel) {
- loadPanelOptions = that.option("loadPanel");
- if (loadPanelOptions && loadPanelOptions.enabled) {
- loadPanelOptions = $.extend({
- shading: false,
- message: loadPanelOptions.text,
- position: {of: $element},
- targetContainer: $element
- }, loadPanelOptions);
- if (that._loadPanel)
- that._loadPanel.option(loadPanelOptions);
- else
- that._loadPanel = $('<div />').appendTo($element.parent()).dxLoadPanel(loadPanelOptions).dxLoadPanel('instance')
- }
- else {
- that._loadPanel && that._loadPanel._element().remove();
- that._loadPanel = null
- }
- }
- },
- _subscribeToWindowScrollEvents: function($element) {
- var that = this,
- disposing = that.disposing,
- $componentContainer = that.component._element(),
- $scrollElement;
- if (!$componentContainer)
- return;
- if (!that._windowScrollEvents) {
- that._windowScrollEvents = true;
- var createWindowScrollHandler = function($scrollElement, oldHandler) {
- var handler = function(e) {
- var contentOffset,
- scrollTop = $scrollElement.scrollTop();
- if (!that._hasHeight && that._rowHeight) {
- scrollTop -= $element.offset().top;
- scrollTop = scrollTop > 0 ? scrollTop : 0;
- that._scrollTop = scrollTop;
- that._dataController.setViewportItemIndex(scrollTop / that._rowHeight)
- }
- };
- if (oldHandler)
- return function(e) {
- handler(e);
- oldHandler(e)
- };
- return handler
- };
- var subscribeToScrollEvents = function($scrollElement) {
- var dxScrollable = $scrollElement.data("dxScrollable"),
- scrollHandler,
- oldScrollHandler;
- if (dxScrollable) {
- oldScrollHandler = dxScrollable.option('scrollAction');
- scrollHandler = createWindowScrollHandler($scrollElement, oldScrollHandler);
- dxScrollable.option('scrollAction', scrollHandler);
- disposing && disposing.add(function() {
- if (dxScrollable.option('scrollAction') === scrollHandler)
- dxScrollable.option('scrollAction', oldScrollHandler)
- })
- }
- else if ($scrollElement.is(document) || $scrollElement.css("overflow-y") === "auto") {
- if ($scrollElement.is(document))
- $scrollElement = $(window);
- scrollHandler = createWindowScrollHandler($scrollElement);
- $scrollElement.on('scroll', scrollHandler);
- disposing && disposing.add(function() {
- $scrollElement.off('scroll', scrollHandler)
- })
- }
- };
- for ($scrollElement = that.component._element().parent(); $scrollElement.length; $scrollElement = $scrollElement.parent())
- subscribeToScrollEvents($scrollElement)
- }
- },
- _renderContent: function(contentElement, tableElement) {
- var that = this,
- contentElement,
- contentHeight,
- virtualItemsCount = that._dataController.virtualItemsCount();
- that._tableElement = tableElement;
- contentElement.addClass(DATAGRID_CONTENT_CLASS);
- if (virtualItemsCount) {
- tableElement.addClass(DATAGRID_TABLE_CONTENT_CLASS);
- if (!contentElement.children().length)
- contentElement.append(tableElement);
- else
- contentElement.children().first().replaceWith(tableElement);
- if (contentElement.children().length === 1) {
- contentElement.append(that._createTable());
- that._contentHeight = 0
- }
- }
- else
- contentElement.replaceWith($('<div>').addClass(DATAGRID_CONTENT_CLASS).append(tableElement));
- return contentElement
- },
- _updateContentPosition: function() {
- var that = this,
- contentElement,
- contentHeight,
- rowHeight = that._rowHeight || 20,
- virtualItemsCount = that._dataController.virtualItemsCount();
- if (virtualItemsCount) {
- contentElement = that._findContentElement();
- DX.translator.move(contentElement.children().first(), {top: Math.floor(virtualItemsCount.begin * rowHeight)});
- contentHeight = (virtualItemsCount.begin + virtualItemsCount.end) * rowHeight + contentElement.children().first().outerHeight();
- if (that._contentHeight !== contentHeight || contentHeight === 0) {
- that._contentHeight = contentHeight;
- that._updateContainerHeight(contentElement.children().eq(1), contentHeight)
- }
- }
- },
- setColumnWidths: function(widths) {
- this._setColumnWidthsCore(this._findContentElement().children(), widths)
- },
- _updateContent: function(tableElement, changeType) {
- var that = this,
- contentElement = that._findContentElement(),
- rowHeight = that._rowHeight || 20,
- contentTable,
- virtualItemsCount = that._dataController.virtualItemsCount();
- that.setColumnWidths();
- if (changeType === 'append' || changeType === 'prepend') {
- contentTable = contentElement.children().first();
- tableElement.find('tr')[changeType === 'append' ? 'appendTo' : 'prependTo'](contentTable)
- }
- else
- that._renderContent(contentElement, tableElement);
- that._updateBottomLoading()
- },
- _renderFreeSpaceRow: function(tableElement, columns) {
- var that = this,
- i,
- freeSpaceRowElement = that._createRow().hide(),
- column;
- freeSpaceRowElement.addClass(DATAGRID_FREESPACE_CLASS).toggleClass(DATAGRID_COLUMN_LINES_CLASS, that.option('showColumnLines'));
- for (i = 0; i < columns.length; i++) {
- column = {
- command: utils.isDefined(columns[i].groupIndex) ? 'group' : '',
- cssClass: utils.isDefined(columns[i].cssClass) ? columns[i].cssClass : ''
- };
- freeSpaceRowElement.append(that._createCell(null, null, null, column))
- }
- that._appendRow(tableElement, freeSpaceRowElement);
- that._freeSpaceRowElement = freeSpaceRowElement
- },
- _updateRowHeight: function() {
- var that = this,
- tableHeight,
- $element = that._element(),
- itemsCount = that._dataController.items().length,
- lastRowHight = that._rowHeight,
- viewportHeight;
- if ($element && itemsCount > 0 && (!lastRowHight || that.option('scrolling.mode') === 'infinite')) {
- tableHeight = that._tableElement.outerHeight();
- if (that._freeSpaceRowElement && that._freeSpaceRowElement.is(':visible'))
- tableHeight -= that._freeSpaceRowElement.outerHeight();
- that._rowHeight = tableHeight / itemsCount;
- if (!lastRowHight && that._rowHeight) {
- that._updateContentPosition();
- viewportHeight = that._hasHeight ? $element.outerHeight() : $(window).outerHeight();
- that._dataController.setViewportSize(Math.round(viewportHeight / that._rowHeight))
- }
- }
- },
- _updateContainerHeight: function(container, height) {
- var that = this,
- columns = that._columnsController.getVisibleColumns(),
- html = container.find('colgroup').prop('outerHTML') || dataGrid.createColGroup(columns).prop('outerHTML'),
- freeSpaceCellsHtml = '',
- i,
- columnLinesClass = that.option('showColumnLines') ? DATAGRID_COLUMN_LINES_CLASS : '',
- createFreeSpaceRowHtml = function(height) {
- return '<tr style="height:' + height + 'px;" class="' + DATAGRID_FREESPACE_CLASS + ' ' + DATAGRID_ROW_CLASS + ' ' + columnLinesClass + '" >' + freeSpaceCellsHtml + '</tr>'
- };
- for (i = 0; i < columns.length; i++)
- freeSpaceCellsHtml += utils.isDefined(columns[i].groupIndex) ? '<td class="' + DATAGRID_GROUP_SPACE_CLASS + '"/>' : '<td />';
- while (height > PIXELS_LIMIT) {
- html += createFreeSpaceRowHtml(PIXELS_LIMIT);
- height -= PIXELS_LIMIT
- }
- html += createFreeSpaceRowHtml(height);
- container.addClass(DATAGRID_TABLE_CLASS);
- container.html(html)
- },
- _findContentElement: function() {
- var $element = this._element(),
- $scrollableContent;
- if ($element) {
- $scrollableContent = $element.find('.dx-scrollable-content');
- if (!$scrollableContent)
- $scrollableContent = $element;
- return $scrollableContent.children().first()
- }
- },
- _findBottomLoadPanel: function() {
- var $bottomLoadPanel = this._element().find('.' + DATAGRID_BOTTOM_LOAD_PANEL_CLASS);
- if ($bottomLoadPanel.length)
- return $bottomLoadPanel
- },
- _getRowElements: function() {
- return this._element().find('.dx-row:not(.' + DATAGRID_FREESPACE_CLASS + ')')
- },
- _updateBottomLoading: function() {
- var that = this,
- scrollingOptions = that.option("scrolling"),
- virtualMode = scrollingOptions && scrollingOptions.mode === 'virtual',
- appendMode = scrollingOptions && scrollingOptions.mode === 'infinite',
- showBottomLoading = !that._dataController.hasKnownLastPage() && that._dataController.isLoaded() && (virtualMode || appendMode),
- bottomLoadPanelElement = that._findBottomLoadPanel();
- if (showBottomLoading) {
- bottomLoadPanelElement = bottomLoadPanelElement || $('<div />').addClass(DATAGRID_BOTTOM_LOAD_PANEL_CLASS).append($('<div />').dxLoadIndicator());
- bottomLoadPanelElement.appendTo(that._findContentElement());
- bottomLoadPanelElement.show()
- }
- else if (bottomLoadPanelElement)
- bottomLoadPanelElement.hide()
- },
- _appendRow: function(tableElement, rowElement) {
- var that = this;
- if (that.option("rowTemplate") && that._delayedTemplates.length && rowElement)
- that._delayedTemplates.push({
- container: tableElement,
- template: appendElementTemplate,
- options: rowElement
- });
- else
- tableElement.append(rowElement)
- },
- _updateNoDataText: function() {
- var noDataElement = this._element().find('.' + DATAGRID_NODATA_TEXT_CLASS),
- isVisible = !this._dataController.items().length,
- isLoading = this._dataController.isLoading(),
- rtlEnabled = this.option("rtlEnabled"),
- noDataElementCSSConfig = {};
- if (!noDataElement.length)
- noDataElement = $('<span>').addClass(DATAGRID_NODATA_TEXT_CLASS).hide().appendTo(this._element());
- noDataElement.text(this.option("noDataText"));
- noDataElementCSSConfig = {
- marginTop: -Math.floor(noDataElement.height() / 2),
- marginRight: rtlEnabled ? -Math.floor(noDataElement.width() / 2) : 0,
- marginLeft: rtlEnabled ? 0 : -Math.floor(noDataElement.width() / 2)
- };
- noDataElement.css(noDataElementCSSConfig);
- if (isVisible && !isLoading)
- noDataElement.show();
- else
- noDataElement.hide()
- },
- _createTable: function() {
- var that = this;
- return that.callBase().on("dxclick", '.dx-row', that.createAction(function(args) {
- var e = args.jQueryEvent;
- if (!$(e.target).closest('.' + DATAGRID_EDITOR_CELL_CLASS).length && !$(e.target).closest('a').length) {
- that._rowClick(that.getRowIndex(e.currentTarget), e);
- e.preventDefault()
- }
- }))
- },
- _rowClick: function(rowIndex, event) {
- var item = this._dataController.items()[rowIndex] || {};
- this.executeAction("rowClick", $.extend({
- rowIndex: rowIndex,
- columns: this._columnsController.getVisibleColumns(),
- jQueryEvent: event,
- rowElement: $(event.target).closest(".dx-row"),
- evaluate: function(expr) {
- var getter = DX.data.utils.compileGetter(expr);
- return getter(item.data)
- }
- }, item))
- },
- _renderTable: function(items) {
- var that = this,
- itemsLength = items.length,
- item,
- $row,
- $groupCell,
- values,
- columnsLength,
- i,
- j,
- groupEmptyCellsCount,
- $cells = [],
- columnsCountBeforeGroups = 0,
- columns = that._columnsController.getVisibleColumns(),
- rowTemplate = that.option("rowTemplate"),
- scrollingMode = that.option("scrolling.mode"),
- $table = that._createTable();
- $table.append(dataGrid.createColGroup(columns));
- for (i = 0; i < columns.length; i++)
- if (columns[i].groupIndex !== undefined) {
- columnsCountBeforeGroups = i;
- break
- }
- for (i = 0; i < itemsLength; i++) {
- item = items[i];
- item.rowIndex = i;
- $cells = [];
- if (item.groupIndex !== undefined) {
- $row = that._createRow(item);
- groupEmptyCellsCount = item.groupIndex + columnsCountBeforeGroups;
- for (j = 0; j < groupEmptyCellsCount; j++)
- $cells.push(that._createCell(null, item, i, {command: 'group'}));
- if (columns[groupEmptyCellsCount].allowCollapsing && scrollingMode !== "infinite")
- $cells.push(that._createCell(!!item.isExpanded, item, i, {command: 'group'}));
- else
- $cells.push(that._createCell(null, item, i, {command: 'group'}));
- $groupCell = that._createCell(item.values[item.groupIndex], item, i, columns[groupEmptyCellsCount]);
- $groupCell.attr('colspan', columns.length - groupEmptyCellsCount - 1);
- $cells.push($groupCell)
- }
- else if (rowTemplate)
- that._renderTemplate($table, rowTemplate, $.extend({columns: columns}, item));
- else {
- values = item.values;
- columnsLength = columns.length;
- $row = that._createRow(item);
- for (j = 0; j < columnsLength; j++)
- $cells.push(that._createCell(values[j], item, i, utils.isDefined(columns[j].groupIndex) ? {command: 'group'} : columns[j], j))
- }
- if ($cells.length)
- $row.append($cells);
- if ($row)
- that._rowPrepared($row, $.extend({columns: columns}, item));
- that._appendRow($table, $row)
- }
- if (rowTemplate)
- that._highlightSearchText($table);
- that._renderFreeSpaceRow($table, columns);
- return $table
- },
- _renderCore: function(change) {
- var that = this,
- items = change && change.items || that._dataController.items(),
- changeType = change && change.changeType,
- $element = that._element(),
- $root = $element.parent();
- $element.addClass(DATAGRID_ROWS_VIEW_CLASS).toggleClass(DATAGRID_NOWRAP_CLASS, !that.option("wordWrapEnabled"));
- var $table = that._renderTable(items);
- that._renderScrollable($table);
- that._updateContent($table, changeType);
- if (!$root || $root.parent().length)
- that.renderDelayedTemplates();
- that._updateContentPosition();
- that._lastColumnWidths = null
- },
- getRowIndex: function($row) {
- return this._getRowElements().index($row)
- },
- getRow: function(index) {
- var rows = this._getRowElements();
- if (rows.length > index)
- return $(rows[index])
- },
- getCell: function(columnIndex, rowIndex) {
- var rows = this._getRowElements(),
- cells;
- if (rows.length > 0 && rowIndex >= 0) {
- rowIndex = rowIndex < rows.length ? rowIndex : rows.length - 1;
- cells = rows[rowIndex].cells;
- if (cells && cells.length > 0)
- return $(cells[cells.length > columnIndex ? columnIndex : cells.length - 1])
- }
- },
- getTableFromCell: function($cell) {
- return $cell.closest("." + DATAGRID_ROWS_VIEW_CLASS + " ." + DATAGRID_TABLE_CLASS)
- },
- updateFreeSpaceRowHeight: function() {
- var that = this,
- elementHeight,
- contentElement = that._findContentElement(),
- contentHeight = 0,
- freespaceRowCount,
- scrollingMode,
- resultHeight;
- if (that._freeSpaceRowElement && contentElement) {
- that._freeSpaceRowElement.hide();
- elementHeight = that._element().height();
- contentHeight = contentElement.outerHeight();
- resultHeight = elementHeight - contentHeight - that.getScrollbarWidth(true);
- if (that._dataController.items().length > 0)
- if (resultHeight > 0) {
- that._freeSpaceRowElement.height(resultHeight);
- that._freeSpaceRowElement.show()
- }
- else if (!that._hasHeight) {
- freespaceRowCount = that._dataController.pageSize() - that._dataController.items().length;
- scrollingMode = that.option('scrolling.mode');
- if (freespaceRowCount > 0 && that._dataController.pageCount() > 1 && scrollingMode !== 'virtual' && scrollingMode !== 'infinite') {
- that._freeSpaceRowElement.height(freespaceRowCount * that._rowHeight);
- that._freeSpaceRowElement.show()
- }
- }
- }
- },
- ctor: function(component) {
- this.callBase(component);
- this.scrollOffsetChanged = $.Callbacks()
- },
- init: function() {
- var that = this,
- visibleColumnIndex;
- that.callBase();
- that._editorFactoryController = that.getController("editorFactory");
- that._editorFactoryController && that._editorFactoryController.focused.add(function($element) {
- that._scrollable && that._scrollable.scrollToElement($element)
- });
- that._dataController = that.getController('data');
- that._columnsController.columnsChanged.add(function(e) {
- var editorFactory,
- column,
- $tables;
- if (dataGrid.checkChanges(e.optionNames, ['width'])) {
- column = e.column,
- visibleColumnIndex = that._columnsController.getVisibleIndex(e.columnIndex);
- if (visibleColumnIndex !== -1) {
- $tables = that._findContentElement().children();
- $.each($tables, function(key, table) {
- $(table).find('col').eq(visibleColumnIndex).css('width', column.width)
- });
- if (e.column.resizedCallbacks)
- e.column.resizedCallbacks.fire(column.width);
- editorFactory = that.getController('editorFactory');
- editorFactory && editorFactory.focus(editorFactory.focus())
- }
- }
- });
- that._rowHeight = 0;
- that._scrollTop = 0;
- that._hasHeight = false;
- that._dataController.changed.add(function(change) {
- switch (change.changeType) {
- case'refresh':
- case'prepend':
- case'append':
- that.render(null, change);
- break;
- default:
- that._update(change);
- break
- }
- });
- that._dataController.loadingChanged.add(function(isLoading, messageText) {
- that.setLoading(isLoading, messageText)
- });
- that._delayedTemplates = [];
- that._templatesCache = {};
- that.createAction("rowClick", {validatingTargetName: "rowElement"});
- that.createAction("cellClick", {validatingTargetName: "cellElement"});
- that.createAction("cellHoverChanged", {excludeValidators: ['gesture']})
- },
- publicMethods: function() {
- return ['isScrollbarVisible', 'getTopVisibleRowData']
- },
- renderDelayedTemplates: function() {
- var templateParameters,
- delayedTemplates = this._delayedTemplates;
- while (delayedTemplates.length) {
- templateParameters = delayedTemplates.shift();
- templateParameters.template.render(templateParameters.container, templateParameters.options);
- if (templateParameters.options.column)
- this._updateCell(templateParameters.container, templateParameters.options)
- }
- },
- getScrollbarWidth: function(isHorizontal) {
- var scrollableContainer = this._scrollableContainer && this._scrollableContainer.get(0),
- scrollbarWidth = 0;
- if (scrollableContainer)
- if (!isHorizontal)
- scrollbarWidth = scrollableContainer.offsetWidth - scrollableContainer.clientWidth;
- else
- scrollbarWidth = scrollableContainer.offsetHeight - scrollableContainer.clientHeight;
- return scrollbarWidth
- },
- resize: function() {
- var that = this,
- lastColumnWidths = that._lastColumnWidths || [],
- columnWidths = that.getColumnWidths(),
- columns = that._columnsController.getVisibleColumns(),
- dxScrollable,
- i;
- for (i = 0; i < columns.length; i++)
- if (columns[i].resizedCallbacks && !utils.isDefined(columns[i].groupIndex) && lastColumnWidths[i] !== columnWidths[i])
- columns[i].resizedCallbacks.fire(columnWidths[i]);
- that._lastColumnWidths = columnWidths;
- that._updateRowHeight();
- that._updateNoDataText();
- that.updateFreeSpaceRowHeight();
- dxScrollable = that._element().data('dxScrollable');
- if (dxScrollable)
- dxScrollable.update();
- that.callBase()
- },
- scrollToPage: function(pageIndex) {
- var that = this,
- scrollingMode = that.option('scrolling.mode'),
- dataController = that._dataController,
- pageSize = dataController ? dataController.pageSize() : 0,
- scrollPosition;
- if (scrollingMode === 'virtual' || scrollingMode === 'infinite')
- scrollPosition = pageIndex * that._rowHeight * pageSize;
- else
- scrollPosition = 0;
- that.scrollTo({
- y: scrollPosition,
- x: 0
- })
- },
- scrollTo: function(location) {
- var $element = this._element(),
- dxScrollable = $element && $element.data('dxScrollable');
- if (dxScrollable)
- dxScrollable.scrollTo(location)
- },
- height: function(height) {
- var that = this,
- $element = this._element();
- if (utils.isDefined(height)) {
- that._hasHeight = height !== 'auto';
- if ($element)
- $element.height(height);
- that._freeSpaceRowElement && that._freeSpaceRowElement.hide()
- }
- else
- return $element ? $element.height() : 0
- },
- setLoading: function(isLoading, messageText) {
- var that = this,
- loadPanel = that._loadPanel,
- dataController = that._dataController,
- hasBottomLoadPanel = !!that._findBottomLoadPanel() && dataController.isLoaded(),
- loadPanelOptions = that.option("loadPanel") || {},
- animation = dataController.isLoaded() ? loadPanelOptions.animation : null,
- visible = hasBottomLoadPanel ? false : isLoading,
- visibilityOptions;
- if (loadPanel) {
- visibilityOptions = {
- message: messageText || loadPanelOptions.text,
- animation: animation,
- visible: visible
- };
- clearTimeout(that._hideLoadingTimeoutID);
- if (loadPanel.option('visible') && !visible)
- that._hideLoadingTimeoutID = setTimeout(function() {
- loadPanel.option(visibilityOptions)
- }, DATAGRID_LOADPANEL_HIDE_TIMEOUT);
- else
- loadPanel.option(visibilityOptions);
- that._updateNoDataText()
- }
- },
- isScrollbarVisible: function() {
- var $element = this._element();
- return $element ? this._findContentElement().outerHeight() - $element.height() > 0 : false
- },
- setRowsOpacity: function(columnIndex, value) {
- var that = this,
- $rows = that._getRowElements().not('.' + DATAGRID_GROUP_ROW_CLASS) || [];
- $.each($rows, function(_, row) {
- $(row).children().eq(columnIndex).css({opacity: value})
- })
- },
- getTopVisibleItemIndex: function() {
- var that = this,
- itemIndex,
- prevOffsetTop = 0,
- offsetTop = 0,
- rowElements = that._getRowElements(),
- scrollPosition = that._scrollTop,
- contentElementOffsetTop = that._findContentElement().offset().top,
- items = that._dataController.items();
- for (itemIndex = 0; itemIndex < items.length; itemIndex++) {
- prevOffsetTop = offsetTop;
- offsetTop = rowElements.eq(itemIndex).offset().top - contentElementOffsetTop;
- if (offsetTop > scrollPosition) {
- if (scrollPosition * 2 < offsetTop + prevOffsetTop && itemIndex)
- itemIndex--;
- break
- }
- }
- if (itemIndex && itemIndex === items.length)
- itemIndex--;
- return itemIndex
- },
- getTopVisibleRowData: function() {
- var itemIndex = this.getTopVisibleItemIndex(),
- items = this._dataController.items();
- if (items[itemIndex])
- return items[itemIndex].data
- },
- optionChanged: function(name, value, prevValue) {
- var that = this;
- switch (name) {
- case'wordWrapEnabled':
- case'hoverStateEnabled':
- case'showColumnLines':
- case'showRowLines':
- case'rowAlternationEnabled':
- case'rowTemplate':
- case'cellPrepared':
- case'rowPrepared':
- that.render();
- that.component.resize();
- break;
- case'scrolling':
- case'rtlEnabled':
- that._rowHeight = null;
- that._tableElement = null;
- break;
- case"disabled":
- case'loadPanel':
- that._tableElement = null;
- that.render();
- that.component.resize();
- break;
- case'noDataText':
- that._updateNoDataText();
- break;
- case'cellHoverChanged':
- that.createAction("cellHoverChanged", {excludeValidators: ['gesture']});
- that.render();
- that.component.resize();
- break;
- case"rowClick":
- that.createAction("rowClick", {validatingTargetName: "rowElement"});
- break;
- case"cellClick":
- that.createAction("cellClick", {validatingTargetName: "cellElement"});
- break
- }
- },
- dispose: function() {
- clearTimeout(this._hideLoadingTimeoutID)
- }
- });
- dataGrid.formatValue = formatValue;
- $.extend(dataGrid.__internals, {
- DATAGRID_CELL_CONTENT_CLASS: DATAGRID_CELL_CONTENT_CLASS,
- DATAGRID_GROUP_ROW_CLASS: DATAGRID_GROUP_ROW_CLASS,
- DATAGRID_SEARCH_TEXT_CLASS: DATAGRID_SEARCH_TEXT_CLASS,
- DATAGRID_ROWS_VIEW_CLASS: DATAGRID_ROWS_VIEW_CLASS,
- DATAGRID_TABLE_CLASS: DATAGRID_TABLE_CLASS,
- DATAGRID_FREESPACE_CLASS: DATAGRID_FREESPACE_CLASS,
- DATAGRID_BOTTOM_LOAD_PANEL_CLASS: DATAGRID_BOTTOM_LOAD_PANEL_CLASS,
- DATAGRID_NODATA_TEXT_CLASS: DATAGRID_NODATA_TEXT_CLASS,
- DATAGRID_GROUP_SPACE_CLASS: DATAGRID_GROUP_SPACE_CLASS,
- DATAGRID_GROUP_OPENED_CLASS: DATAGRID_GROUP_OPENED_CLASS,
- DATAGRID_GROUP_CLOSED_CLASS: DATAGRID_GROUP_CLOSED_CLASS,
- DATAGRID_NOWRAP_CLASS: DATAGRID_NOWRAP_CLASS,
- DATAGRID_ROW_LINES_CLASS: DATAGRID_ROW_LINES_CLASS,
- DATAGRID_COLUMN_LINES_CLASS: DATAGRID_COLUMN_LINES_CLASS,
- DATAGRID_ROW_ALTERNATION_CLASS: DATAGRID_ROW_ALTERNATION_CLASS
- });
- dataGrid.registerModule('rows', {
- defaultOptions: function() {
- return {
- hoverStateEnabled: false,
- cellHoverChanged: null,
- scrolling: {
- mode: 'standard',
- preloadEnabled: false,
- useNativeScrolling: 'auto'
- },
- loadPanel: {
- enabled: true,
- text: Globalize.localize("Loading"),
- width: 200,
- height: 70,
- showIndicator: true,
- indicatorSrc: "",
- showPane: true
- },
- rowClick: null,
- cellClick: null,
- rowTemplate: null,
- columnAutoWidth: false,
- noDataText: Globalize.localize("dxDataGrid-noDataText"),
- wordWrapEnabled: false,
- showColumnLines: true,
- showRowLines: false,
- rowAlternationEnabled: false,
- cellPrepared: null,
- rowPrepared: null,
- activeStateEnabled: false
- }
- },
- views: {rowsView: dataGrid.RowsView},
- extenders: {controllers: {data: {
- _applyFilter: function() {
- var that = this,
- result = that.callBase();
- if (result && result.done)
- result.done(function() {
- that.getView('rowsView').scrollToPage(0)
- });
- return result
- },
- pageIndex: function(value) {
- var that = this,
- result = that.callBase(value);
- if (result && result.done)
- result.done(function() {
- that.getView('rowsView').scrollToPage(that.pageIndex())
- });
- return result
- },
- pageSize: function(value) {
- var that = this,
- result = that.callBase(value);
- if (result && result.done)
- result.done(function() {
- that.getView('rowsView').scrollToPage(that.pageIndex())
- });
- return result
- },
- _refreshDataSource: function() {
- var that = this;
- var changedHandler = function() {
- that.changed.remove(changedHandler);
- that.getView('rowsView').scrollToPage(0)
- };
- that.changed.add(changedHandler);
- that.callBase()
- }
- }}}
- })
- })(jQuery, DevExpress);
- /*! Module widgets-web, file ui.dataGrid.pager.js */
- (function($, DX) {
- var ui = DX.ui,
- events = ui.events,
- utils = DX.utils,
- dataGrid = ui.dataGrid;
- var DATAGRID_PAGER_CLASS = "dx-datagrid-pager";
- var MAX_PAGES_COUNT = 10;
- dataGrid.PagerView = dataGrid.View.inherit({
- init: function() {
- var that = this,
- dataController = that.getController('data');
- that._isVisible = false;
- dataController.changed.add(function() {
- that.render()
- })
- },
- _getPager: function() {
- var $element = this._element();
- return $element && $element.data('dxPager')
- },
- _renderCore: function() {
- var that = this,
- $element = that._element().addClass(DATAGRID_PAGER_CLASS),
- pagerOptions = that.option('pager'),
- dataController = that.getController('data'),
- rtlEnabled = that.option('rtlEnabled');
- $element.dxPager({
- maxPagesCount: MAX_PAGES_COUNT,
- pageIndex: dataController.pageIndex() + 1,
- pagesCount: dataController.pageCount(),
- pageSize: dataController.pageSize(),
- showPageSizes: pagerOptions && pagerOptions.showPageSizeSelector,
- pageSizes: that.getPageSizes(),
- rtlEnabled: rtlEnabled,
- hasKnownLastPage: dataController.hasKnownLastPage(),
- pageIndexChanged: function(pageIndex) {
- window.setTimeout(function() {
- dataController.pageIndex(pageIndex - 1)
- })
- },
- pageSizeChanged: function(pageSize) {
- window.setTimeout(function() {
- dataController.pageSize(pageSize)
- })
- }
- })
- },
- getPageSizes: function() {
- var that = this,
- dataController = that.getController('data'),
- pagerOptions = that.option('pager'),
- allowedPageSizes = pagerOptions && pagerOptions.allowedPageSizes,
- pageSize = dataController.pageSize();
- if (!utils.isDefined(that._pageSizes) || $.inArray(pageSize, that._pageSizes) === -1) {
- that._pageSizes = [];
- if (pagerOptions)
- if ($.isArray(allowedPageSizes))
- that._pageSizes = allowedPageSizes;
- else if (allowedPageSizes && pageSize > 1)
- that._pageSizes = [Math.floor(pageSize / 2), pageSize, pageSize * 2]
- }
- return that._pageSizes
- },
- isVisible: function() {
- var that = this,
- dataController = that.getController('data'),
- pagerOptions = that.option('pager'),
- pagerVisible = pagerOptions && pagerOptions.visible,
- scrolling = that.option('scrolling');
- if (that._isVisible)
- return true;
- if (pagerVisible === 'auto')
- if (scrolling && (scrolling.mode === 'virtual' || scrolling.mode === 'infinite'))
- pagerVisible = false;
- else
- pagerVisible = dataController.pageCount() > 1 || dataController.isLoaded() && !dataController.hasKnownLastPage();
- that._isVisible = pagerVisible;
- return pagerVisible
- },
- getHeight: function() {
- var pager = this._getPager();
- return pager && this.isVisible() ? pager.getHeight() : 0
- },
- optionChanged: function(name, value, prevValue) {
- var that = this;
- switch (name) {
- case'paging':
- case'pager':
- that._pageSizes = null;
- case'scrolling':
- that._isVisible = false;
- that.render();
- if (name === 'pager')
- that.component && that.component.resize();
- break
- }
- }
- });
- dataGrid.registerModule('pager', {
- defaultOptions: function() {
- return {
- paging: {
- enabled: true,
- pageSize: undefined,
- pageIndex: undefined
- },
- pager: {
- visible: 'auto',
- showPageSizeSelector: false,
- allowedPageSizes: 'auto'
- }
- }
- },
- views: {pagerView: dataGrid.PagerView}
- })
- })(jQuery, DevExpress);
- /*! Module widgets-web, file ui.dataGrid.gridView.js */
- (function($, DX) {
- var dataGrid = DX.ui.dataGrid,
- utils = DX.utils;
- var DATAGRID_CLASS = "dx-datagrid",
- EMPTY_GRID_ROWS_HEIGHT = 100,
- LOADPANEL_MARGIN = 50,
- VIEW_NAMES = ['columnsSeparatorView', 'blockSeparatorView', 'trackerView', 'headerPanel', 'columnHeadersView', 'rowsView', 'columnChooserView', 'pagerView', 'draggingHeaderView', 'contextMenuView', 'errorView'];
- var mergeArraysByMaxValue = function(values1, values2) {
- var result = [],
- i;
- if (values1 && values2 && values1.length && values1.length === values2.length)
- for (i = 0; i < values1.length; i++)
- result.push(values1[i] > values2[i] ? values1[i] : values2[i]);
- return result
- };
- var isPercentWidth = function(width) {
- return utils.isString(width) && width.slice(-1) === '%'
- };
- dataGrid.createColGroup = function(columns) {
- var colgroupElement = $('<colgroup />'),
- columnsLength = columns.length,
- i;
- for (i = 0; i < columnsLength; i++)
- $('<col />').width(columns[i].width).appendTo(colgroupElement);
- return colgroupElement
- };
- dataGrid.GridView = dataGrid.View.inherit({
- _initResizeHandlers: function() {
- var that = this;
- if (!that._refreshSizesHandler) {
- that._refreshSizesHandler = function(e) {
- if (!e || e.changeType === 'refresh' || e.changeType === 'append')
- that.resize()
- };
- that._dataController.changed.add(that._refreshSizesHandler);
- that._columnHeadersView.sizeChanged.add(that._refreshSizesHandler)
- }
- },
- _synchronizeColumns: function() {
- var that = this,
- rowsColumnWidths = that._rowsView.getColumnWidths(),
- headerColumnWidths = that._columnHeadersView.getColumnWidths(),
- unusedIndexes = {length: 0},
- hasAutoWidth = false,
- hasPercentWidth = false,
- $element = that.component._element(),
- width = that.option('width'),
- resultWidths = headerColumnWidths ? mergeArraysByMaxValue(rowsColumnWidths, headerColumnWidths) : rowsColumnWidths;
- $.each(that._columnsController.getVisibleColumns(), function(index) {
- if (!this.width || this.width === 'auto')
- hasAutoWidth = true;
- if (isPercentWidth(this.width))
- hasPercentWidth = true;
- if (this.width && this.width !== 'auto') {
- resultWidths[index] = this.width;
- unusedIndexes[index] = true;
- unusedIndexes.length++
- }
- });
- if ($element && that._maxWidth) {
- delete that._maxWidth;
- $element.css('max-width', '')
- }
- if (!hasAutoWidth && resultWidths.length) {
- var totalWidth = that._getTotalWidth(resultWidths, that._groupElement.width() - that._rowsView.getScrollbarWidth());
- if (totalWidth < that._groupElement.width() - that._rowsView.getScrollbarWidth()) {
- resultWidths[resultWidths.length - 1] = 'auto';
- if ((!width || width === 'auto') && !hasPercentWidth) {
- that._maxWidth = totalWidth;
- $element.css('max-width', that._maxWidth)
- }
- }
- }
- if (that.option('columnAutoWidth') && resultWidths.length > 0)
- that._processStretch(resultWidths, that._groupElement.width() - that._rowsView.getScrollbarWidth(), unusedIndexes);
- that._rowsView.setColumnWidths(resultWidths);
- that._columnHeadersView.setColumnWidths(resultWidths)
- },
- _processStretch: function(resultSizes, groupSize, unusedIndexes) {
- var tableSize = this._getTotalWidth(resultSizes, groupSize),
- diff,
- diffElement,
- onePixelElementsCount,
- i;
- diff = groupSize - tableSize;
- diffElement = Math.floor(diff / (resultSizes.length - unusedIndexes.length));
- onePixelElementsCount = diff - diffElement * (resultSizes.length - unusedIndexes.length);
- if (diff >= 0)
- for (i = 0; i < resultSizes.length; i++) {
- if (unusedIndexes[i])
- continue;
- resultSizes[i] += diffElement;
- if (i < onePixelElementsCount)
- resultSizes[i]++
- }
- },
- _getTotalWidth: function(widths, groupWidth) {
- var result = 0,
- width,
- i;
- for (i = 0; i < widths.length; i++) {
- width = widths[i];
- if (width)
- result += isPercentWidth(width) ? parseInt(width) * groupWidth / 100 : parseInt(width)
- }
- return Math.round(result)
- },
- getView: function(name) {
- return this.component._views[name]
- },
- getViews: function() {
- return this.component._views
- },
- resize: function() {
- var that = this,
- dataController = that._dataController,
- rootElementHeight = that._rootElement.height(),
- loadPanelOptions = that.option('loadPanel'),
- height = that.option('height'),
- rowsViewHeight,
- $testDiv;
- if (height && that._hasHeight ^ height !== 'auto') {
- $testDiv = $('<div>').height(height).appendTo(that._rootElement);
- that._hasHeight = !!$testDiv.height();
- $testDiv.remove()
- }
- if (that._hasHeight && rootElementHeight > 0 && that.option('scrolling'))
- that._rowsView.height(rootElementHeight - that._headerPanel.getHeight() - that._columnHeadersView.getHeight() - that._pagerView.getHeight());
- else if (!that._hasHeight && dataController.items().length === 0)
- rowsViewHeight = loadPanelOptions && loadPanelOptions.visible ? loadPanelOptions.height + LOADPANEL_MARGIN : EMPTY_GRID_ROWS_HEIGHT;
- else
- rowsViewHeight = 'auto';
- that._rowsView.height(rowsViewHeight);
- that._rowsView.resetColumnWidths();
- that._columnHeadersView.resetColumnWidths();
- that._columnHeadersView.setScrollerSpacing(that._rowsView.getScrollbarWidth());
- that._synchronizeColumns();
- $.each(VIEW_NAMES, function(index, viewName) {
- var view = that.getView(viewName);
- if (view)
- view.resize()
- })
- },
- optionChanged: function(name, value, prevValue) {
- switch (name) {
- case"width":
- case"height":
- this.resize()
- }
- },
- init: function() {
- var that = this;
- that._dataController = that.getController('data');
- that._columnsController = that.getController('columns');
- that._columnHeadersView = that.getView('columnHeadersView');
- that._headerPanel = that.getView('headerPanel');
- that._rowsView = that.getView('rowsView');
- that._pagerView = that.getView('pagerView');
- that._rowsView.scrollOffsetChanged.add(function(e) {
- that._columnHeadersView.scrollOffset(e.left)
- });
- that._dataController.changed.add(function() {
- that.component._fireContentReadyAction()
- });
- that._options = {}
- },
- element: function() {
- return this._groupElement
- },
- render: function(rootElement) {
- var that = this,
- isFirstRender,
- isLoading,
- groupElement = that._groupElement || $('<div />').addClass(DATAGRID_CLASS);
- that._rootElement = rootElement || that._rootElement;
- isFirstRender = !that._groupElement;
- that._groupElement = groupElement;
- $.each(VIEW_NAMES, function(index, viewName) {
- var view = that.getView(viewName);
- if (view)
- view.render(groupElement)
- });
- if (isFirstRender) {
- that._hasHeight = !!that._rootElement.height();
- that._groupElement = groupElement;
- groupElement.appendTo(that._rootElement);
- that._rowsView.renderDelayedTemplates()
- }
- that._initResizeHandlers();
- that.resize();
- isLoading = that._dataController.isLoading();
- if (!isLoading)
- that.component._fireContentReadyAction();
- that._rowsView.setLoading(isLoading)
- }
- });
- dataGrid.registerModule("gridView", {views: {gridView: dataGrid.GridView}});
- $.extend(dataGrid.__internals, {
- viewNames: VIEW_NAMES,
- DATAGRID_CLASS: DATAGRID_CLASS
- })
- })(jQuery, DevExpress);
- /*! Module widgets-web, file ui.dataGrid.columnsResizingReorderingModule.js */
- (function($, DX) {
- var ui = DX.ui,
- events = ui.events,
- addNamespace = events.addNamespace,
- utils = DX.utils,
- dataGrid = ui.dataGrid,
- fx = DX.fx;
- var DATAGRID_COLUMNS_SEPARATOR_CLASS = "dx-datagrid-columns-separator",
- DATAGRID_COLUMNS_SEPARATOR_TRANSPARENT = "dx-datagrid-columns-separator-transparent",
- DATAGRID_DRAGGING_HEADER_CLASS = "dx-datagrid-drag-header",
- DATAGRID_CELL_CONTENT_CLASS = "dx-datagrid-text-content",
- DATAGTID_HEADERS_ACTION_CLASS = "dx-datagrid-action-cursor",
- DATAGRID_TRACKER_CLASS = "dx-datagrid-tracker",
- DATAGRID_BLOCK_SEPARATOR_CLASS = "dx-block-separator",
- DATAGRID_HEADERS_DROP_HIGHLIGHT_CLASS = 'dx-datagrid-drop-highlight',
- DATAGRID_HEADER_ROW_CLASS = "dx-header-row",
- WIDGET_CLASS = "dx-widget",
- DATAGRID_MODULE_NAMESPACE = "dxDataGridResizingReordering",
- COLUMNS_SEPARATOR_TOUCH_TRACKER_WIDTH = 10,
- DRAGGING_DELTA = 5;
- var allowResizing = function(that) {
- return that.option("allowColumnResizing") || that.getController("columns").isColumnOptionUsed("allowResizing")
- };
- var allowReordering = function(that) {
- return that.option("allowColumnReordering") || that.getController("columns").isColumnOptionUsed("allowReordering")
- };
- dataGrid.getPointsByColumns = function(items, pointCreated, isVertical) {
- var cellsLength = items.length,
- cancel = false,
- i,
- point,
- item,
- offset,
- result = [],
- rtlEnabled,
- columnIndex = 0;
- for (i = 0; i <= cellsLength; i++) {
- if (i < cellsLength) {
- item = items.eq(columnIndex);
- offset = item.offset();
- rtlEnabled = item.css('direction') === 'rtl'
- }
- point = {
- index: i,
- x: offset ? offset.left + (!isVertical && rtlEnabled ^ i === cellsLength ? item.outerWidth() : 0) : 0,
- y: offset ? offset.top + (isVertical && i === cellsLength ? item.outerHeight() : 0) : 0,
- columnIndex: columnIndex
- };
- if (pointCreated)
- cancel = pointCreated(point);
- if (!cancel)
- result.push(point);
- columnIndex++
- }
- return result
- };
- dataGrid.TrackerView = dataGrid.View.inherit({
- _renderCore: function(options) {
- this.callBase();
- this._element().addClass(DATAGRID_TRACKER_CLASS);
- this.hide()
- },
- init: function() {
- var that = this,
- $element;
- that.callBase();
- that.getController("tablePosition").positionChanged.add(function(position) {
- $element = that._element();
- if ($element && $element.hasClass(DATAGRID_TRACKER_CLASS)) {
- $element.css({top: position.top});
- $element.height(position.height)
- }
- })
- },
- isVisible: function() {
- return allowResizing(this)
- },
- show: function() {
- this._element().show()
- },
- hide: function() {
- this._element().hide()
- },
- setHeight: function(value) {
- this._element().height(value)
- }
- });
- dataGrid.ColumnsSeparatorView = dataGrid.View.inherit({
- _isShown: true,
- _renderCore: function(options) {
- this.callBase(options);
- this._element().addClass(DATAGRID_COLUMNS_SEPARATOR_CLASS);
- this._isShown = true;
- this.hide()
- },
- _subscribeToEvent: function() {
- var that = this,
- $element;
- that.getController("tablePosition").positionChanged.add(function(position) {
- $element = that._element();
- if ($element) {
- $element.css({top: position.top});
- $element.height(position.height)
- }
- })
- },
- isVisible: function() {
- return this.option('showColumnHeaders') && (allowReordering(this) || allowResizing(this))
- },
- init: function() {
- this.callBase();
- this._isTransparent = allowResizing(this);
- if (this.isVisible())
- this._subscribeToEvent()
- },
- show: function(targetLocation) {
- var that = this,
- $element = this._element(),
- startAnimate = function(toOptions) {
- fx.stop($element, true);
- fx.animate($element, {
- type: "slide",
- from: {
- width: 0,
- display: toOptions.display
- },
- to: toOptions,
- duration: 300,
- easing: "swing"
- })
- };
- if ($element && !that._isShown)
- if (targetLocation === "group")
- startAnimate({
- width: "50px",
- display: "inline-block"
- });
- else if (targetLocation === "columnChooser")
- startAnimate({
- width: "100%",
- display: "block"
- });
- else if (that._isTransparent)
- $element.removeClass(DATAGRID_COLUMNS_SEPARATOR_TRANSPARENT);
- else
- $element.show();
- that._isShown = true
- },
- hide: function() {
- var $element = this._element();
- if ($element && this._isShown)
- if (this._isTransparent)
- $element.addClass(DATAGRID_COLUMNS_SEPARATOR_TRANSPARENT);
- else
- $element.hide();
- this._isShown = false
- },
- height: function(value) {
- var $element = this._element();
- if ($element)
- if (utils.isDefined(value))
- $element.height(value);
- else
- return $element.height()
- },
- width: function(value) {
- var $element = this._element();
- if ($element)
- if (utils.isDefined(value))
- $element.width(value);
- else
- return $element.width()
- },
- moveByX: function(outerX) {
- var $element = this._element();
- if ($element) {
- $element.css("left", outerX - this._parentElement().offset().left);
- this._testPosx = outerX
- }
- },
- changeCursor: function(cursorName) {
- cursorName = utils.isDefined(cursorName) ? cursorName : "";
- var $element = this._element();
- if ($element) {
- $element.css('cursor', cursorName);
- this._testCursorName = cursorName
- }
- }
- });
- dataGrid.BlockSeparatorView = dataGrid.ColumnsSeparatorView.inherit({
- _subscribeToEvent: function(){},
- _renderCore: function(options) {
- this._isTransparent = false;
- this.callBase(options);
- this._element().addClass(DATAGRID_BLOCK_SEPARATOR_CLASS).html(' ')
- },
- hide: function() {
- var that = this,
- $parent = this._parentElement();
- that.callBase();
- if ($parent && !$parent.children('.' + DATAGRID_BLOCK_SEPARATOR_CLASS).length)
- $parent.prepend(that._element())
- },
- isVisible: function() {
- var groupPanelOptions = this.option("groupPanel"),
- columnChooserOptions = this.option('columnChooser');
- return groupPanelOptions && groupPanelOptions.visible || columnChooserOptions && columnChooserOptions.enabled
- }
- });
- dataGrid.DraggingHeaderView = dataGrid.View.inherit({
- _isDragging: false,
- _getDropOptions: function() {
- var that = this;
- if (that._dragOptions)
- return {
- sourceColumnIndex: that._dragOptions.columnIndex,
- sourceColumnElement: that._dragOptions.columnElement,
- sourceLocation: that._dragOptions.sourceLocation,
- targetColumnIndex: that._dropColumnIndex,
- targetLocation: that._dropLocation
- }
- },
- _dropHeader: function(args) {
- var e = args.jQueryEvent,
- that = e.data.that,
- controller = that._controller;
- that._element().hide();
- if (controller && that._isDragging)
- controller.drop(that._getDropOptions());
- that._element().appendTo(that._parentElement());
- that._dragOptions = null;
- that._isDragging = false;
- document.onselectstart = that._onSelectStart || null
- },
- _getDraggingPanelByPos: function(pos) {
- var that = this,
- result;
- $.each(that._dragOptions.draggingPanels, function(index, draggingPanel) {
- if (draggingPanel) {
- var boundingRect = draggingPanel.getBoundingRect();
- if (boundingRect && (boundingRect.bottom === undefined || pos.y < boundingRect.bottom) && (boundingRect.top === undefined || pos.y > boundingRect.top) && (boundingRect.left === undefined || pos.x > boundingRect.left) && (boundingRect.right === undefined || pos.x < boundingRect.right)) {
- result = draggingPanel;
- return false
- }
- }
- });
- return result
- },
- _pointCreated: function(point, columns, location, sourceColumn) {
- var targetColumn = columns[point.columnIndex],
- prevColumn = columns[point.columnIndex - 1];
- switch (location) {
- case"columnChooser":
- return true;
- case"headers":
- return sourceColumn && !sourceColumn.allowReordering || (!targetColumn || !targetColumn.allowReordering) && (!prevColumn || !prevColumn.allowReordering);
- default:
- return columns.length === 0
- }
- },
- _moveHeader: function(args) {
- var e = args.jQueryEvent,
- that = e.data.that,
- columnElements,
- pointsByColumns,
- newLeft,
- newTop,
- moveDeltaX,
- moveDeltaY,
- eventData = events.eventData(e),
- targetDraggingPanel,
- controller = that._controller,
- i,
- params,
- dragOptions = that._dragOptions,
- isVerticalOrientation,
- centerPosition,
- axisName,
- rtlEnabled;
- if (that._isDragging) {
- moveDeltaX = Math.abs(eventData.x - dragOptions.columnElement.offset().left - dragOptions.deltaX);
- moveDeltaY = Math.abs(eventData.y - dragOptions.columnElement.offset().top - dragOptions.deltaY);
- if (that._element().is(':visible') || moveDeltaX > DRAGGING_DELTA || moveDeltaY > DRAGGING_DELTA) {
- that._element().show();
- newLeft = eventData.x - dragOptions.deltaX;
- newTop = eventData.y - dragOptions.deltaY;
- that._element().offset({
- left: newLeft,
- top: newTop
- });
- targetDraggingPanel = that._getDraggingPanelByPos(eventData);
- if (targetDraggingPanel) {
- rtlEnabled = that.option('rtlEnabled');
- isVerticalOrientation = targetDraggingPanel.getName() === 'columnChooser';
- axisName = isVerticalOrientation ? 'y' : 'x';
- columnElements = targetDraggingPanel.getColumnElements() || [];
- pointsByColumns = dataGrid.getPointsByColumns(columnElements, function(point) {
- return that._pointCreated(point, targetDraggingPanel.getColumns(), targetDraggingPanel.getName(), dragOptions.sourceColumn)
- }, axisName === 'y');
- that._dropLocation = targetDraggingPanel.getName();
- if (pointsByColumns.length > 0)
- for (i = 0; i < pointsByColumns.length; i++) {
- centerPosition = pointsByColumns[i + 1] && (pointsByColumns[i][axisName] + pointsByColumns[i + 1][axisName]) / 2;
- if (centerPosition === undefined || (rtlEnabled && axisName === 'x' ? eventData[axisName] > centerPosition : eventData[axisName] < centerPosition)) {
- that._dropColumnIndex = pointsByColumns[i].columnIndex;
- params = that._getDropOptions();
- if (columnElements[i])
- params.targetColumnElement = columnElements.eq(i);
- else {
- params.targetColumnElement = columnElements.last();
- params.isLast = true
- }
- params.posX = pointsByColumns[i].x;
- controller.dock(params);
- break
- }
- }
- else {
- that._dropColumnIndex = -1;
- params = that._getDropOptions();
- controller.dock(params)
- }
- }
- }
- e.preventDefault()
- }
- },
- _subscribeToEvents: function(rootElement) {
- var that = this;
- that._moveHeaderAction = this.createAction(this._moveHeader, {excludeValidators: ['gesture']});
- that._dropHeaderAction = this.createAction(this._dropHeader, {excludeValidators: ['gesture']});
- $(document).on(addNamespace('dxpointermove', DATAGRID_MODULE_NAMESPACE), {
- that: that,
- rootElement: rootElement
- }, that._moveHeaderAction);
- that._element().on(addNamespace('dxpointerup', DATAGRID_MODULE_NAMESPACE), {that: that}, that._dropHeaderAction);
- $(document).on(addNamespace('dxpointerup', DATAGRID_MODULE_NAMESPACE), {that: that}, that._dropHeaderAction)
- },
- _renderCore: function() {
- this._element().addClass(DATAGRID_DRAGGING_HEADER_CLASS + ' ' + DATAGRID_CELL_CONTENT_CLASS + ' ' + WIDGET_CLASS).css('display', 'none')
- },
- _afterRender: function($parent) {
- this._unsubscribeFromEvents();
- this._subscribeToEvents($parent)
- },
- _unsubscribeFromEvents: function() {
- if (this._dropHeaderAction) {
- this._element().off(addNamespace('dxpointerup', DATAGRID_MODULE_NAMESPACE), this._dropHeaderAction);
- $(document).off(addNamespace('dxpointerup', DATAGRID_MODULE_NAMESPACE), this._dropHeaderAction)
- }
- if (this._moveHeaderAction)
- $(document).off(addNamespace('dxpointermove', DATAGRID_MODULE_NAMESPACE), this._moveHeaderAction)
- },
- dispose: function() {
- this._dragOptions = null;
- this._unsubscribeFromEvents();
- this._element().parent().find('.' + DATAGRID_DRAGGING_HEADER_CLASS).remove()
- },
- isVisible: function() {
- var columnsController = this.getController("columns"),
- commonColumnSettings = columnsController.getCommonSettings();
- return this.option('showColumnHeaders') && (allowReordering(this) || commonColumnSettings.allowGrouping || commonColumnSettings.allowHiding)
- },
- init: function() {
- this.callBase();
- this._controller = this.getController("draggingHeader")
- },
- drag: function(options) {
- var that = this,
- columnElement = options.columnElement;
- that._dragOptions = options;
- that._isDragging = true;
- that._dropColumnIndex = options.columnIndex;
- that._dropLocation = options.sourceLocation;
- that._onSelectStart = document.onselectstart;
- document.onselectstart = function() {
- return false
- };
- that._element().css({
- textAlign: columnElement && columnElement.css('text-align'),
- height: columnElement && columnElement.height(),
- width: columnElement && columnElement.width(),
- whiteSpace: columnElement && columnElement.css('white-space')
- }).addClass(DATAGTID_HEADERS_ACTION_CLASS).text(options.sourceColumn.caption);
- that._element().appendTo($(document.body))
- }
- });
- dataGrid.ColumnsResizerViewController = dataGrid.ViewController.inherit({
- _pointCreated: function(point, cellsLength, columns) {
- var currentColumn,
- nextColumn;
- if (point.index > 0 && point.index < cellsLength) {
- point.columnIndex -= 1;
- currentColumn = columns[point.columnIndex] || {};
- nextColumn = columns[point.columnIndex + 1] || {};
- return !(currentColumn.allowResizing && nextColumn.allowResizing)
- }
- return true
- },
- _getTargetPoint: function(pointsByColumns, currentX, deltaX) {
- if (pointsByColumns)
- for (var i = 0; i < pointsByColumns.length; i++)
- if (pointsByColumns[i].x - deltaX <= currentX && currentX <= pointsByColumns[i].x + deltaX)
- return pointsByColumns[i];
- return null
- },
- _moveSeparator: function(args) {
- var e = args.jQueryEvent,
- that = e.data,
- pointsByColumns = that._pointsByColumns,
- columnsSeparatorWidth = that._columnsSeparatorView.width(),
- columnsSeparatorOffset = that._columnsSeparatorView._element().offset(),
- deltaX = columnsSeparatorWidth / 2,
- parentOffsetLeft = that._$parentContainer.offset().left,
- eventData = events.eventData(e);
- if (that._isResizing) {
- if (parentOffsetLeft <= eventData.x && eventData.x <= parentOffsetLeft + that._$parentContainer.width())
- if (that._updateColumnsWidthIfNeeded(that._targetPoint.columnIndex, eventData.x)) {
- that._columnsSeparatorView.moveByX(that._targetPoint.x + (eventData.x - that._resizingInfo.startPosX));
- that._tablePositionController.update();
- e.preventDefault()
- }
- }
- else {
- that._targetPoint = that._getTargetPoint(pointsByColumns, eventData.x, columnsSeparatorWidth);
- that._isReadyResizing = false;
- that._columnsSeparatorView.changeCursor();
- if (that._targetPoint && columnsSeparatorOffset.top <= eventData.y && columnsSeparatorOffset.top + that._columnsSeparatorView.height() >= eventData.y) {
- that._columnsSeparatorView.changeCursor('col-resize');
- that._columnsSeparatorView.moveByX(that._targetPoint.x - deltaX);
- that._isReadyResizing = true;
- e.preventDefault()
- }
- }
- },
- _endResizing: function(args) {
- var e = args.jQueryEvent,
- that = e.data;
- if (that._isResizing) {
- that._updatePointsByColumns();
- that._resizingInfo = null;
- that._columnsSeparatorView.hide();
- that._columnsSeparatorView.changeCursor();
- that._trackerView.hide();
- that._isReadyResizing = false;
- that._isResizing = false
- }
- },
- _setupResizingInfo: function(posX) {
- var that = this,
- currentHeader = that._columnHeadersView.getHeaderElement(that._targetPoint.columnIndex),
- nextHeader = that._columnHeadersView.getHeaderElement(that._targetPoint.columnIndex + 1);
- that._resizingInfo = {
- startPosX: posX,
- currentColumnWidth: currentHeader && currentHeader.length > 0 ? currentHeader.outerWidth() : 0,
- nextColumnWidth: nextHeader && nextHeader.length > 0 ? nextHeader.outerWidth() : 0
- }
- },
- _startResizing: function(args) {
- var e = args.jQueryEvent,
- that = e.data,
- eventData = events.eventData(e);
- if (events.isTouchEvent(e)) {
- that._targetPoint = that._getTargetPoint(that._pointsByColumns, eventData.x, COLUMNS_SEPARATOR_TOUCH_TRACKER_WIDTH);
- if (that._targetPoint) {
- that._columnsSeparatorView.moveByX(that._targetPoint.x - that._columnsSeparatorView.width() / 2);
- that._isReadyResizing = true
- }
- }
- if (that._isReadyResizing) {
- if (that._targetPoint)
- that._testColumnIndex = that._targetPoint.columnIndex;
- that._setupResizingInfo(eventData.x);
- that._columnsSeparatorView.show();
- that._trackerView.show();
- that._isResizing = true;
- e.preventDefault()
- }
- },
- _generatePointsByColumns: function() {
- var that = this,
- columns = that._columnsController ? that._columnsController.getVisibleColumns() : [],
- cells = that._columnHeadersView.getColumnElements(),
- pointsByColumns = [];
- if (cells && cells.length > 0)
- pointsByColumns = dataGrid.getPointsByColumns(cells, function(point) {
- return that._pointCreated(point, cells.length, columns)
- });
- that._pointsByColumns = pointsByColumns
- },
- _unsubscribeFromEvents: function() {
- this._moveSeparatorHandler && this._$parentContainer.off(addNamespace('dxpointermove', DATAGRID_MODULE_NAMESPACE), this._moveSeparatorHandler);
- this._startResizingHandler && this._columnsSeparatorView._element().off(addNamespace('dxpointerdown', DATAGRID_MODULE_NAMESPACE), this._startResizingHandler);
- if (this._endResizingHandler) {
- this._columnsSeparatorView._element().off(addNamespace('dxpointerup', DATAGRID_MODULE_NAMESPACE), this._endResizingHandler);
- $(document).off(addNamespace('dxpointerup', DATAGRID_MODULE_NAMESPACE), this._endResizingHandler)
- }
- },
- _subscribeToEvents: function() {
- this._moveSeparatorHandler = this.createAction(this._moveSeparator, {excludeValidators: ['gesture']});
- this._startResizingHandler = this.createAction(this._startResizing);
- this._endResizingHandler = this.createAction(this._endResizing, {excludeValidators: ['gesture']});
- this._$parentContainer.on(addNamespace('dxpointermove', DATAGRID_MODULE_NAMESPACE), this, this._moveSeparatorHandler);
- this._$parentContainer.on(addNamespace('dxpointerdown', DATAGRID_MODULE_NAMESPACE), this, this._startResizingHandler);
- this._columnsSeparatorView._element().on(addNamespace('dxpointerup', DATAGRID_MODULE_NAMESPACE), this, this._endResizingHandler);
- $(document).on(addNamespace('dxpointerup', DATAGRID_MODULE_NAMESPACE), this, this._endResizingHandler)
- },
- _updateColumnsWidthIfNeeded: function(columnIndex, posX) {
- var deltaX,
- isUpdated = false,
- nextCellWidth,
- visibleColumns = this._columnsController.getVisibleColumns(),
- columnsSeparatorWidth = this._columnsSeparatorView.width(),
- cellWidth;
- deltaX = posX - this._resizingInfo.startPosX;
- if (this.option("rtlEnabled"))
- deltaX = -deltaX;
- cellWidth = this._resizingInfo.currentColumnWidth + deltaX;
- nextCellWidth = this._resizingInfo.nextColumnWidth - deltaX;
- isUpdated = !(cellWidth <= columnsSeparatorWidth || nextCellWidth <= columnsSeparatorWidth);
- if (isUpdated) {
- visibleColumns[columnIndex] && this._columnsController.columnOption(visibleColumns[columnIndex].initialIndex, 'width', Math.floor(cellWidth));
- visibleColumns[columnIndex + 1] && this._columnsController.columnOption(visibleColumns[columnIndex + 1].initialIndex, 'width', Math.floor(nextCellWidth))
- }
- return isUpdated
- },
- _updatePointsByColumns: function() {
- var i,
- point,
- rtlEnabled = this.option("rtlEnabled"),
- headerElement;
- for (i = 0; i < this._pointsByColumns.length; i++) {
- point = this._pointsByColumns[i];
- headerElement = this._columnHeadersView.getHeaderElement(point.columnIndex + 1);
- if (headerElement && headerElement.length > 0)
- point.x = headerElement.offset().left + (rtlEnabled ? headerElement.outerWidth() : 0)
- }
- },
- init: function() {
- var that = this,
- gridView,
- previousScrollbarVisibility,
- generatePointsByColumnsScrollHandler = function(offset) {
- if (that._scrollLeft !== offset.left) {
- that._scrollLeft = offset.left;
- that._generatePointsByColumns()
- }
- },
- generatePointsByColumnsHandler = function() {
- that._generatePointsByColumns()
- };
- that.callBase();
- if (allowResizing(that)) {
- that._columnsSeparatorView = that.getView("columnsSeparatorView");
- that._columnHeadersView = that.getView("columnHeadersView");
- that._trackerView = that.getView("trackerView");
- that._rowsView = that.getView("rowsView");
- that._columnsController = that.getController("columns");
- that._tablePositionController = that.getController("tablePosition");
- that._$parentContainer = that._columnsSeparatorView.component._element();
- that._columnHeadersView.renderCompleted.add(generatePointsByColumnsHandler);
- that._columnHeadersView.resizeCompleted.add(generatePointsByColumnsHandler);
- that._columnsSeparatorView.renderCompleted.add(function() {
- that._unsubscribeFromEvents();
- that._subscribeToEvents()
- });
- that._rowsView.renderCompleted.add(function() {
- that._rowsView.scrollOffsetChanged.remove(generatePointsByColumnsScrollHandler);
- that._rowsView.scrollOffsetChanged.add(generatePointsByColumnsScrollHandler)
- });
- gridView = that.getView("gridView");
- previousScrollbarVisibility = that._rowsView.getScrollbarWidth() !== 0;
- that.getController("tablePosition").positionChanged.add(function() {
- if (that._isResizing && !that._rowsView.isResizing) {
- var scrollbarVisibility = that._rowsView.getScrollbarWidth() !== 0;
- if (previousScrollbarVisibility !== scrollbarVisibility) {
- previousScrollbarVisibility = scrollbarVisibility;
- gridView.resize()
- }
- else {
- that._rowsView.updateFreeSpaceRowHeight();
- that._columnHeadersView.processSizeChanged()
- }
- }
- })
- }
- },
- dispose: function() {
- this._unsubscribeFromEvents()
- }
- });
- dataGrid.TablePositionViewController = dataGrid.ViewController.inherit({
- update: function() {
- var $element = this._columnHeadersView._element(),
- columnsHeadersHeight = this._columnHeadersView ? this._columnHeadersView.getHeight() : 0,
- rowsHeight = this._rowsView ? this._rowsView.height() - this._rowsView.getScrollbarWidth(true) : 0;
- this.positionChanged.fire({
- height: columnsHeadersHeight + rowsHeight,
- top: $element && $element.length > 0 ? Math.floor($element[0].offsetTop) : 0
- })
- },
- init: function() {
- var that = this;
- that.callBase();
- that._columnHeadersView = this.getView("columnHeadersView");
- that._rowsView = this.getView("rowsView");
- that._pagerView = this.getView("pagerView");
- that._rowsView.resizeCompleted.add(function() {
- that.update()
- })
- },
- ctor: function(component) {
- this.callBase(component);
- this.positionChanged = $.Callbacks()
- }
- });
- dataGrid.DraggingHeaderViewController = dataGrid.ViewController.inherit({
- _subscribeToEvent: function(draggingHeader, draggingPanels) {
- var that = this;
- $.each(draggingPanels, function(_, draggingPanel) {
- if (draggingPanel) {
- var columnElements = draggingPanel.getColumnElements() || [],
- nameDraggingPanel = draggingPanel.getName(),
- columns = draggingPanel.getColumns() || [];
- $.each(columnElements, function(index, columnElement) {
- $(columnElement).off(addNamespace('dxpointerdown', DATAGRID_MODULE_NAMESPACE));
- if (draggingPanel.allowDragging(columns[index], draggingPanels))
- $(columnElement).on(addNamespace('dxpointerdown', DATAGRID_MODULE_NAMESPACE), that.createAction(function(args) {
- var e = args.jQueryEvent,
- eventData = events.eventData(e);
- e.preventDefault();
- draggingHeader.drag({
- deltaX: eventData.x - $(e.currentTarget).offset().left,
- deltaY: eventData.y - $(e.currentTarget).offset().top,
- sourceColumn: columns[index],
- columnIndex: index,
- columnElement: $(columnElement),
- sourceLocation: draggingPanel.getName(),
- draggingPanels: draggingPanels
- })
- }))
- })
- }
- })
- },
- _getSeparator: function(targetLocation) {
- return targetLocation === "headers" ? this._columnsSeparatorView : this._blockSeparatorView
- },
- hideSeparators: function() {
- var blockSeparator = this._blockSeparatorView,
- columnsSeparator = this._columnsSeparatorView;
- this._animationColumnIndex = null;
- blockSeparator && blockSeparator.hide();
- columnsSeparator && columnsSeparator.hide()
- },
- init: function() {
- var that = this,
- subscribeToEvent;
- that.callBase();
- that._columnsController = that.getController("columns");
- that._columnHeadersView = that.getView("columnHeadersView");
- that._columnsSeparatorView = that.getView("columnsSeparatorView");
- that._draggingHeaderView = that.getView("draggingHeaderView");
- that._rowsView = that.getView('rowsView');
- that._blockSeparatorView = that.getView("blockSeparatorView");
- that._headerPanelView = that.getView("headerPanel");
- that._columnChooserView = that.getView("columnChooserView");
- subscribeToEvent = function() {
- if (that._draggingHeaderView)
- that._subscribeToEvent(that._draggingHeaderView, [that._columnChooserView, that._columnHeadersView, that._headerPanelView])
- };
- that._columnHeadersView.renderCompleted.add(subscribeToEvent);
- that._headerPanelView.renderCompleted.add(subscribeToEvent);
- that._columnChooserView.renderCompleted.add(subscribeToEvent)
- },
- allowDrop: function(parameters) {
- return this._columnsController.allowMoveColumn(parameters.sourceColumnIndex, parameters.targetColumnIndex, parameters.sourceLocation, parameters.targetLocation)
- },
- allowDragColumn: function(columns, index, namePanel) {
- var column = columns[index],
- i,
- draggableColumnCount = 0;
- var allowDragFromHeaders = function(column) {
- return column.allowReordering || column.allowGrouping || column.allowHiding
- };
- if (!column)
- return false;
- switch (namePanel) {
- case"headers":
- for (i = 0; i < columns.length; i++)
- if (allowDragFromHeaders(columns[i]))
- draggableColumnCount++;
- return draggableColumnCount > 1 && allowDragFromHeaders(column);
- case"group":
- return column.allowGrouping;
- case"columnChooser":
- return column.allowHiding
- }
- },
- dock: function(parameters) {
- var that = this,
- targetColumnIndex = parameters.targetColumnIndex,
- sourceLocation = parameters.sourceLocation,
- sourceColumnIndex = parameters.sourceColumnIndex,
- sourceColumnElement = parameters.sourceColumnElement,
- targetLocation = parameters.targetLocation,
- separator = that._getSeparator(targetLocation),
- hasTargetColumnIndex = targetColumnIndex >= 0;
- var showSeparator = function() {
- if (that._animationColumnIndex !== targetColumnIndex) {
- that.hideSeparators();
- separator._element()[parameters.isLast ? 'insertAfter' : 'insertBefore'](parameters.targetColumnElement);
- that._animationColumnIndex = targetColumnIndex;
- separator.show(targetLocation)
- }
- };
- that._columnHeadersView._element().find('.' + DATAGRID_HEADER_ROW_CLASS).first().toggleClass(DATAGRID_HEADERS_DROP_HIGHLIGHT_CLASS, sourceLocation !== 'headers' && targetLocation === 'headers' && !hasTargetColumnIndex);
- if (separator) {
- if (sourceColumnElement) {
- sourceColumnElement.css({opacity: 0.5});
- if (sourceLocation === 'headers')
- that._rowsView.setRowsOpacity(sourceColumnIndex, 0.5)
- }
- if (that.allowDrop(parameters) && hasTargetColumnIndex)
- if (targetLocation === 'group' || targetLocation === 'columnChooser')
- showSeparator();
- else {
- that.hideSeparators();
- separator.moveByX(parameters.posX - separator.width());
- separator.show()
- }
- else
- that.hideSeparators()
- }
- },
- drop: function(parameters) {
- var sourceColumnElement = parameters.sourceColumnElement;
- if (sourceColumnElement) {
- sourceColumnElement.css({opacity: ''});
- this._rowsView.setRowsOpacity(parameters.sourceColumnIndex, '');
- this._columnHeadersView._element().find('.' + DATAGRID_HEADER_ROW_CLASS).first().removeClass(DATAGRID_HEADERS_DROP_HIGHLIGHT_CLASS)
- }
- if (this.allowDrop(parameters)) {
- var separator = this._getSeparator(parameters.targetLocation);
- if (separator)
- separator.hide();
- this._columnsController.moveColumn(parameters.sourceColumnIndex, parameters.targetColumnIndex, parameters.sourceLocation, parameters.targetLocation)
- }
- }
- });
- dataGrid.__internals = $.extend({}, dataGrid.__internals, {
- DATAGRID_COLUMNS_SEPARATOR_CLASS: DATAGRID_COLUMNS_SEPARATOR_CLASS,
- DATAGRID_COLUMNS_SEPARATOR_TRANSPARENT: DATAGRID_COLUMNS_SEPARATOR_TRANSPARENT,
- DATAGRID_DRAGGING_HEADER_CLASS: DATAGRID_DRAGGING_HEADER_CLASS,
- DATAGRID_CELL_CONTENT_CLASS: DATAGRID_CELL_CONTENT_CLASS,
- DATAGTID_HEADERS_ACTION_CLASS: DATAGTID_HEADERS_ACTION_CLASS,
- DATAGRID_TRACKER_CLASS: DATAGRID_TRACKER_CLASS,
- DATAGRID_MODULE_NAMESPACE: DATAGRID_MODULE_NAMESPACE,
- DATAGRID_HEADERS_DROP_HIGHLIGHT_CLASS: DATAGRID_HEADERS_DROP_HIGHLIGHT_CLASS,
- WIDGET_CLASS: WIDGET_CLASS
- });
- dataGrid.registerModule("columnsResizingReordering", {
- views: {
- columnsSeparatorView: dataGrid.ColumnsSeparatorView,
- blockSeparatorView: dataGrid.BlockSeparatorView,
- draggingHeaderView: dataGrid.DraggingHeaderView,
- trackerView: dataGrid.TrackerView
- },
- controllers: {
- draggingHeader: dataGrid.DraggingHeaderViewController,
- tablePosition: dataGrid.TablePositionViewController,
- columnsResizer: dataGrid.ColumnsResizerViewController
- }
- })
- })(jQuery, DevExpress);
- /*! Module widgets-web, file ui.dataGrid.contextMenuView.js */
- (function($, DX) {
- var ui = DX.ui,
- utils = DX.utils,
- dataGrid = ui.dataGrid;
- var DATAGRID_CLASS = "dx-datagrid",
- DATAGRID_CONTEXT_MENU = "dx-context-menu";
- dataGrid.ContextMenuView = dataGrid.View.inherit({
- viewNames: function() {
- return ["columnHeadersView"]
- },
- _renderCore: function() {
- var that = this;
- that._element().addClass(DATAGRID_CONTEXT_MENU).dxContextMenu({
- positioningAction: function(actionArgs) {
- var event = actionArgs.jQueryEvent,
- $targetElement = $(event.target),
- contextMenuInstance = actionArgs.component,
- items = [];
- $.each(that.viewNames(), function(index, viewName) {
- var view = that.getView(viewName),
- menuItems = view.getContextMenuItems($targetElement);
- if (menuItems.length) {
- items = menuItems;
- return false
- }
- });
- if (items.length)
- contextMenuInstance.option('items', items);
- else
- actionArgs.canceled = true
- },
- itemClickAction: function(params) {
- params.itemData.itemClickAction && params.itemData.itemClickAction(params)
- },
- rtlEnabled: that.option('rtlEnabled'),
- cssClass: DATAGRID_CLASS,
- target: that.component._element()
- })
- }
- });
- dataGrid.registerModule("contextMenu", {views: {contextMenuView: dataGrid.ContextMenuView}})
- })(jQuery, DevExpress);
- /*! Module widgets-web, file ui.dataGrid.keyboardNavigation.js */
- (function($, DX) {
- var ui = DX.ui,
- utils = DX.utils,
- events = ui.events,
- dataGrid = ui.dataGrid;
- var DATAGRID_ROW_CLASS = "dx-row",
- DATAGRID_GROUP_ROW_CLASS = "dx-group-row",
- DATAGRID_EDITING_MODE_BATCH = "batch",
- DATAGRID_ROWS_VIEW_CLASS = "dx-datagrid-rowsview",
- DATAGRID_VIEWS = ["rowsView"];
- dataGrid.KeyboardNavigationController = dataGrid.ViewController.inherit({
- _focusView: function(view, viewIndex) {
- view.focus();
- this._focusedViews.viewIndex = viewIndex;
- this._focusedView = view
- },
- _initFocusedViews: function() {
- var that = this,
- $cell,
- $input,
- clickHandler = that.createAction(function(e) {
- var event = e.jQueryEvent,
- $cell = $(event.currentTarget);
- if (!that._editingController.isEditing())
- if (that._isCellValid($cell)) {
- $cell.focus();
- that._focusView(event.data.view, event.data.viewIndex);
- that._updateFocusedCellPosition($cell)
- }
- else
- that._resetFocusedCell(that)
- });
- that._focusedViews = [];
- $.each(DATAGRID_VIEWS, function(key, viewName) {
- var view = that.getView(viewName);
- if (view.isVisible())
- that._focusedViews.push(view)
- });
- $.each(that._focusedViews, function(index, view) {
- if (view)
- view.renderCompleted.add(function() {
- var $element = view._element();
- $element.off(events.addNamespace("dxpointerdown", "dxDataGridKeyboardNavigation"), clickHandler);
- $element.on(events.addNamespace("dxpointerdown", "dxDataGridKeyboardNavigation"), "." + DATAGRID_ROW_CLASS + " td", {
- viewIndex: index,
- view: view
- }, clickHandler);
- that._initKeyDownProcessor(that, $element, that._keyDownHandler);
- if (that._focusedView && that._focusedView.name === view.name && that._isKeyDown) {
- $cell = that._getFocusedCell();
- if ($cell && $cell.length > 0) {
- that._focusView(view, index);
- if (that.getController('editorFactory').focus())
- that._focus($cell);
- setTimeout(function() {
- if (that._editingController.isEditing()) {
- $input = $cell.find('input').first();
- that._testFocusedInput = $input;
- $input.focus()
- }
- else {
- $cell.attr("tabindex", 0);
- $cell.focus()
- }
- })
- }
- }
- })
- })
- },
- _initKeyDownProcessor: function(context, element, handler) {
- if (this._keyDownProcessor) {
- this._keyDownProcessor.dispose();
- this._keyDownProcessor = null
- }
- this._keyDownProcessor = new ui.HierarchicalKeyDownProcessor({
- element: element,
- context: context,
- handler: handler
- })
- },
- _focusCell: function($cell) {
- var that = this;
- if ($cell) {
- that.getController('editorFactory').focus($cell);
- that._updateFocusedCellPosition($cell)
- }
- },
- _focusGroupRow: function($row) {
- if ($row) {
- this.getController('editorFactory').focus($row);
- this._focusedCellPosition.rowIndex = this._focusedView.getRowIndex($row)
- }
- },
- _getFocusedCell: function() {
- if (this._focusedView && this._focusedCellPosition)
- return this._focusedView.getCell(this._focusedCellPosition.columnIndex, this._focusedCellPosition.rowIndex)
- },
- _updateFocusedCellPosition: function($cell) {
- var that = this;
- if ($cell.length > 0)
- this._focusedCellPosition = {
- columnIndex: $cell[0].cellIndex,
- rowIndex: $cell.parent().length > 0 && that._focusedView ? that._focusedView.getRowIndex($cell.parent()) : null
- }
- },
- _isCellValid: function($cell) {
- var visibleColumns = this._columnsController.getVisibleColumns(),
- columnIndex = $cell[0].cellIndex;
- return visibleColumns.length > columnIndex && !(visibleColumns[columnIndex].command || utils.isDefined(visibleColumns[columnIndex].groupIndex))
- },
- _isGroupRow: function($row) {
- return $row && $row.hasClass(DATAGRID_GROUP_ROW_CLASS)
- },
- _focus: function($cell) {
- var $row = $cell && $cell.parent();
- if (this._isGroupRow($row))
- this._focusGroupRow($row);
- else
- this._focusCell($cell)
- },
- _keyDownHandler: function(e) {
- var editingOptions = this.option("editing"),
- isEditing = this._editingController.isEditing(),
- pageIndex = this._dataController.pageIndex(),
- pagesCount = this._dataController.pageCount(),
- rowIndex = this._focusedCellPosition ? this._focusedCellPosition.rowIndex : null,
- $row = this._focusedView && this._focusedView.getRow(rowIndex),
- $cell;
- this._isKeyDown = true;
- switch (e.key) {
- case"leftArrow":
- case"rightArrow":
- if (!isEditing && !this._isGroupRow($row)) {
- $cell = this._getNextCell(e.key);
- if ($cell && this._isCellValid($cell))
- this._focusCell($cell);
- e.originalEvent.preventDefault()
- }
- break;
- case"upArrow":
- case"downArrow":
- if (!isEditing) {
- if (rowIndex === 0 || rowIndex === this._focusedView.getRowsCount() - 1);
- $cell = this._getNextCell(e.key);
- if ($cell && this._isCellValid($cell))
- this._focus($cell);
- e.originalEvent.preventDefault()
- }
- break;
- case"pageUp":
- if (pageIndex > 0) {
- this._dataController.pageIndex(pageIndex - 1);
- e.originalEvent.preventDefault()
- }
- break;
- case"pageDown":
- if (pageIndex < pagesCount - 1) {
- this._dataController.pageIndex(pageIndex + 1);
- e.originalEvent.preventDefault()
- }
- break;
- case"space":
- if (this.option("selection") && this.option("selection").mode !== "none" && !isEditing)
- this._selectionController.changeItemSelection(rowIndex, {
- shift: e.shift,
- control: e.ctrl
- });
- break;
- case"A":
- if (e.ctrl && this.option("selection.mode") === "multiple" && this.option("selection.allowSelectAll")) {
- this._selectionController.selectAll();
- e.originalEvent.preventDefault()
- }
- break;
- case"tab":
- if (isEditing && this._editingController.getEditMode() === DATAGRID_EDITING_MODE_BATCH && e.originalEvent.target) {
- this._updateFocusedCellPosition($(e.originalEvent.target).closest('td'));
- $cell = this._getNextCell("rightArrow");
- this._focusCell($cell);
- this._editingController.editCell(this._focusedCellPosition.rowIndex, this._focusedCellPosition.columnIndex);
- e.originalEvent.preventDefault()
- }
- break;
- case"enter":
- if (this._isGroupRow($row)) {
- if (this.option("grouping") && this.option("grouping").allowCollapsing) {
- var path = this._dataController.getGroupPathByRowIndex(rowIndex);
- if (path)
- this._dataController.changeGroupExpand(path)
- }
- }
- else if (editingOptions.editEnabled)
- if (isEditing) {
- this._updateFocusedCellPosition($(e.originalEvent.target).closest('td'));
- if (this._editingController.getEditMode() === DATAGRID_EDITING_MODE_BATCH)
- this._editingController.closeEditCell();
- else
- setTimeout($.proxy(this._editingController.saveEditData, this._editingController))
- }
- else if (this._editingController.getEditMode() === DATAGRID_EDITING_MODE_BATCH)
- this._editingController.editCell(rowIndex, this._focusedCellPosition.columnIndex);
- else
- this._editingController.editRow(rowIndex);
- break;
- case"escape":
- if (editingOptions.editEnabled)
- if (isEditing) {
- this._updateFocusedCellPosition($(e.originalEvent.target).closest('td'));
- if (this._editingController.getEditMode() === DATAGRID_EDITING_MODE_BATCH)
- this._editingController.closeEditCell();
- else
- this._editingController.cancelEditData();
- e.originalEvent.preventDefault()
- }
- break;
- case"F":
- if (e.ctrl && this.option("searchPanel") && this.option("searchPanel").visible) {
- this._testHeaderPanelFocused = true;
- this._headerPanel.focus();
- e.originalEvent.preventDefault()
- }
- break
- }
- },
- _getNextCell: function(keyCode) {
- if (this._focusedView && this._focusedCellPosition) {
- var columnIndex = this._focusedCellPosition.columnIndex,
- visibleColumnsCount = this.getController("columns").getVisibleColumns().length,
- rowIndex = this._focusedCellPosition.rowIndex;
- switch (keyCode) {
- case"rightArrow":
- columnIndex = columnIndex < visibleColumnsCount - 1 ? columnIndex + 1 : columnIndex;
- break;
- case"leftArrow":
- columnIndex = columnIndex > 0 ? columnIndex - 1 : columnIndex;
- break;
- case"upArrow":
- rowIndex = rowIndex > 0 ? rowIndex - 1 : rowIndex;
- break;
- case"downArrow":
- rowIndex = rowIndex < this._dataController.items().length - 1 ? rowIndex + 1 : rowIndex;
- break
- }
- return this._focusedView.getCell(columnIndex, rowIndex)
- }
- return null
- },
- _resetFocusedCell: function(that) {
- var $cell = that._getFocusedCell();
- $cell && $cell.attr("tabindex", null);
- that._focusedCellPosition = null;
- that._isKeyDown = false
- },
- init: function() {
- var that = this;
- if (that.option("useKeyboard")) {
- that._dataController = that.getController("data");
- that._selectionController = that.getController("selection");
- that._editingController = that.getController("editing");
- that._headerPanel = that.getView("headerPanel");
- that._pagerView = that.getView("pagerView");
- that._columnsController = that.getController("columns");
- that._focusedCellPosition = {
- columnIndex: 0,
- rowIndex: 0
- };
- that._dataController.changed.add(function(change) {
- if (that._focusedCellPosition && change && change.changeType === 'prepend')
- that._focusedCellPosition.rowIndex += change.items.length
- });
- that._initFocusedViews();
- that._documentClickHandler = that.createAction(function(e) {
- if (!$(e.jQueryEvent.target).closest("." + DATAGRID_ROWS_VIEW_CLASS).length)
- that._resetFocusedCell(that)
- });
- $(document).on(events.addNamespace("dxpointerdown", "dxDataGridKeyboardNavigation"), that._documentClickHandler)
- }
- },
- dispose: function() {
- this.callBase();
- this._focusedView = null;
- this._focusedViews = null;
- this._keyDownProcessor && this._keyDownProcessor.dispose();
- $(document).off(events.addNamespace("dxpointerdown", "dxDataGridKeyboardNavigation"), this._documentClickHandler)
- }
- });
- $.extend(dataGrid.__internals, {
- DATAGRID_GROUP_ROW_CLASS: DATAGRID_GROUP_ROW_CLASS,
- DATAGRID_ROW_CLASS: DATAGRID_ROW_CLASS
- });
- dataGrid.registerModule("keyboardNavigation", {
- defaultOptions: function() {
- return {useKeyboard: true}
- },
- controllers: {keyboardNavigation: dataGrid.KeyboardNavigationController}
- })
- })(jQuery, DevExpress);
- /*! Module widgets-web, file ui.dataGrid.errorHandling.js */
- (function($, DX) {
- var ui = DX.ui,
- utils = DX.utils,
- dataGrid = ui.dataGrid;
- dataGrid.ErrorView = dataGrid.View.inherit({
- _renderCore: function() {
- this.toast({
- type: 'error',
- displayTime: 1000000,
- position: {
- my: 'center',
- at: 'center'
- },
- contentReadyAction: function(e) {
- this.content().on('dxclick', function() {
- e.component.hide()
- })
- }
- })
- },
- toast: function(options) {
- return this._element().dxToast(options || 'instance')
- },
- isVisible: function() {
- return this.option('dataErrorVisible')
- },
- init: function() {
- var that = this,
- dataController = that.getController('data');
- dataController.dataErrorOccurred.add(function(error) {
- var message = error && error.message || error;
- if (that.isVisible()) {
- that.toast({message: message});
- that.toast().show()
- }
- })
- }
- });
- dataGrid.registerModule('errorHandling', {views: {errorView: dataGrid.ErrorView}})
- })(jQuery, DevExpress);
- DevExpress.MOD_WIDGETS_WEB = true
- }
- if (!DevExpress.MOD_FRAMEWORK) {
- if (!window.DevExpress)
- throw Error('Required module is not referenced: core');
- /*! Module framework, file framework.js */
- (function($, DX, undefined) {
- var mergeWithReplace = function(destination, source, needReplaceFn) {
- var result = [];
- for (var i = 0, destinationLength = destination.length; i < destinationLength; i++)
- if (!needReplaceFn(destination[i], source))
- result.push(destination[i]);
- result.push.apply(result, source);
- return result
- };
- var getMergeCommands = function() {
- return function(destination, source) {
- return mergeWithReplace(destination, source, function(destObject, source) {
- return $.grep(source, function(srcObject) {
- var match = destObject.option("id") === srcObject.option("id") && srcObject.option("id") || destObject.option("behavior") === srcObject.option("behavior") && destObject.option("behavior");
- if (match)
- destObject._element().remove();
- return match
- }).length
- })
- }
- };
- var resolvePropertyValue = function(command, containerOptions, propertyName) {
- var defaultOption = containerOptions ? containerOptions[propertyName] : undefined;
- return command.option(propertyName) || defaultOption
- };
- var resolveTextValue = function(command, containerOptions) {
- var hasIcon = !!command.option("icon") || command.option("iconSrc"),
- titleValue = resolvePropertyValue(command, containerOptions, "title");
- return containerOptions.showText || !hasIcon ? titleValue : ""
- };
- var resolveIconValue = function(command, containerOptions, propertyName) {
- var hasText = !!command.option("title"),
- iconValue = resolvePropertyValue(command, containerOptions, propertyName);
- return containerOptions.showIcon || !hasText ? iconValue : undefined
- };
- var resolveTypeValue = function(command, containerOptions) {
- return resolvePropertyValue(command, containerOptions, "type")
- };
- DX.framework = {utils: {
- mergeCommands: getMergeCommands(),
- commandToContainer: {
- resolveTypeValue: resolveTypeValue,
- resolveIconValue: resolveIconValue,
- resolveTextValue: resolveTextValue,
- resolvePropertyValue: resolvePropertyValue
- }
- }}
- })(jQuery, DevExpress);
- /*! Module framework, file framework.routing.js */
- (function($, DX) {
- var JSON_URI_PREFIX = encodeURIComponent("json:");
- var Class = DX.Class;
- DX.framework.Route = Class.inherit({
- _trimSeparators: function(str) {
- return str.replace(/^[\/.]+|\/+$/g, "")
- },
- _escapeRe: function(str) {
- return str.replace(/\W/g, "\\$1")
- },
- _checkConstraint: function(param, constraint) {
- param = String(param);
- if (typeof constraint === "string")
- constraint = new RegExp(constraint);
- var match = constraint.exec(param);
- if (!match || match[0] !== param)
- return false;
- return true
- },
- _ensureReady: function() {
- var that = this;
- if (this._patternRe)
- return false;
- this._pattern = this._trimSeparators(this._pattern);
- this._patternRe = "";
- this._params = [];
- this._segments = [];
- this._separators = [];
- this._pattern.replace(/[^\/]+/g, function(segment, index) {
- that._segments.push(segment);
- if (index)
- that._separators.push(that._pattern.substr(index - 1, 1))
- });
- $.each(this._segments, function(index) {
- var isStatic = true,
- segment = this,
- separator = index ? that._separators[index - 1] : "";
- if (segment.charAt(0) === ":") {
- isStatic = false;
- segment = segment.substr(1);
- that._params.push(segment);
- that._patternRe += "(?:" + separator + "([^/]*))";
- if (segment in that._defaults)
- that._patternRe += "?"
- }
- else
- that._patternRe += separator + that._escapeRe(segment)
- });
- this._patternRe = new RegExp("^" + this._patternRe + "$")
- },
- ctor: function(pattern, defaults, constraints) {
- this._pattern = pattern || "";
- this._defaults = defaults || {};
- this._constraints = constraints || {}
- },
- parse: function(uri) {
- var that = this;
- this._ensureReady();
- var matches = this._patternRe.exec(uri);
- if (!matches)
- return false;
- var result = $.extend({}, this._defaults);
- $.each(this._params, function(i) {
- var index = i + 1;
- if (matches.length >= index && matches[index])
- result[this] = that.parseSegment(matches[index])
- });
- $.each(this._constraints, function(key) {
- if (!that._checkConstraint(result[key], that._constraints[key])) {
- result = false;
- return false
- }
- });
- return result
- },
- format: function(routeValues) {
- var that = this,
- query = "";
- this._ensureReady();
- var mergeValues = $.extend({}, this._defaults),
- useStatic = 0,
- ret = [],
- dels = [],
- unusedRouteValues = {};
- $.each(routeValues, function(paramName, paramValue) {
- routeValues[paramName] = that.formatSegment(paramValue);
- if (!(paramName in mergeValues))
- unusedRouteValues[paramName] = true
- });
- $.each(this._segments, function(index, segment) {
- ret[index] = index ? that._separators[index - 1] : '';
- if (segment.charAt(0) === ':') {
- var paramName = segment.substr(1);
- if (!(paramName in routeValues) && !(paramName in that._defaults)) {
- ret = null;
- return false
- }
- if (paramName in that._constraints && !that._checkConstraint(routeValues[paramName], that._constraints[paramName])) {
- ret = null;
- return false
- }
- if (paramName in routeValues) {
- if (routeValues[paramName] !== undefined) {
- mergeValues[paramName] = routeValues[paramName];
- ret[index] += routeValues[paramName];
- useStatic = index
- }
- delete unusedRouteValues[paramName]
- }
- else if (paramName in mergeValues) {
- ret[index] += mergeValues[paramName];
- dels.push(index)
- }
- }
- else {
- ret[index] += segment;
- useStatic = index
- }
- });
- $.each(mergeValues, function(key, value) {
- if (!!value && $.inArray(":" + key, that._segments) === -1 && routeValues[key] !== value) {
- ret = null;
- return false
- }
- });
- var unusedCount = 0;
- if (!$.isEmptyObject(unusedRouteValues)) {
- query = "?";
- $.each(unusedRouteValues, function(key) {
- query += key + "=" + routeValues[key] + "&";
- unusedCount++
- });
- query = query.substr(0, query.length - 1)
- }
- if (ret === null)
- return false;
- if (dels.length)
- $.map(dels, function(i) {
- if (i >= useStatic)
- ret[i] = ''
- });
- var path = ret.join('');
- path = path.replace(/\/+$/, "");
- return {
- uri: path + query,
- unusedCount: unusedCount
- }
- },
- formatSegment: function(value) {
- if ($.isArray(value) || $.isPlainObject(value))
- return JSON_URI_PREFIX + encodeURIComponent(JSON.stringify(value));
- return encodeURIComponent(value)
- },
- parseSegment: function(value) {
- if (value.substr(0, JSON_URI_PREFIX.length) === JSON_URI_PREFIX)
- try {
- return $.parseJSON(decodeURIComponent(value.substr(JSON_URI_PREFIX.length)))
- }
- catch(x) {}
- return decodeURIComponent(value)
- }
- });
- DX.framework.MvcRouter = DX.Class.inherit({
- ctor: function() {
- this._registry = []
- },
- _trimSeparators: function(str) {
- return str.replace(/^[\/.]+|\/+$/g, "")
- },
- _createRoute: function(pattern, defaults, constraints) {
- return new DX.framework.Route(pattern, defaults, constraints)
- },
- register: function(pattern, defaults, constraints) {
- this._registry.push(this._createRoute(pattern, defaults, constraints))
- },
- _parseQuery: function(query) {
- var result = {},
- values = query.split("&");
- $.each(values, function(index, value) {
- var keyValuePair = value.split("=");
- result[keyValuePair[0]] = decodeURIComponent(keyValuePair[1])
- });
- return result
- },
- parse: function(uri) {
- var that = this,
- ret;
- uri = this._trimSeparators(uri);
- var parts = uri.split("?", 2),
- path = parts[0],
- query = parts[1];
- $.each(this._registry, function() {
- var result = this.parse(path);
- if (result !== false) {
- ret = result;
- if (query)
- ret = $.extend(ret, that._parseQuery(query));
- return false
- }
- });
- return ret ? ret : false
- },
- format: function(obj) {
- var ret = false,
- minUnusedCount = 99999;
- obj = obj || {};
- $.each(this._registry, function() {
- var toFormat = $.extend(true, {}, obj);
- var result = this.format(toFormat);
- if (result !== false)
- if (minUnusedCount > result.unusedCount) {
- minUnusedCount = result.unusedCount;
- ret = result.uri
- }
- });
- return ret
- }
- });
- DX.framework.Route.__internals = {JSON_URI_PREFIX: JSON_URI_PREFIX}
- })(jQuery, DevExpress);
- /*! Module framework, file framework.command.js */
- (function($, DX) {
- var ui = DX.ui;
- DX.framework.dxCommand = DX.DOMComponent.inherit({
- ctor: function(element, options) {
- if ($.isPlainObject(element)) {
- options = element;
- element = $("<div />")
- }
- this.beforeExecute = $.Callbacks();
- this.afterExecute = $.Callbacks();
- this.callBase(element, options)
- },
- _setDefaultOptions: function() {
- this.callBase();
- this.option({
- action: null,
- id: null,
- title: "",
- icon: "",
- iconSrc: "",
- visible: true,
- disabled: false
- })
- },
- execute: function() {
- var isDisabled = this._options.disabled;
- if ($.isFunction(isDisabled))
- isDisabled = !!isDisabled.apply(this, arguments);
- if (isDisabled)
- throw new Error(DX.utils.stringFormat("Cannot execute command: {0}", this._options.id));
- this.beforeExecute.fire(arguments);
- this._createActionByOption("action", {excludeValidators: ["gesture"]}).apply(this, arguments);
- this.afterExecute.fire(arguments)
- },
- _render: function() {
- this.callBase();
- this._element().addClass("dx-command")
- },
- _renderDisabledState: $.noop,
- _dispose: function() {
- this.callBase();
- this._element().removeData(this.NAME);
- this.beforeExecute.empty();
- this.afterExecute.empty()
- }
- });
- DX.registerComponent("dxCommand", DX.framework.dxCommand)
- })(jQuery, DevExpress);
- /*! Module framework, file framework.commandMapping.js */
- (function($, DX) {
- DX.framework.CommandMapping = DX.Class.inherit({
- ctor: function() {
- this._commandMappings = {};
- this._containerDefaults = {}
- },
- setDefaults: function(containerId, defaults) {
- this._containerDefaults[containerId] = defaults;
- return this
- },
- mapCommands: function(containerId, commandMappings) {
- var that = this;
- $.each(commandMappings, function(index, commandMapping) {
- if (typeof commandMapping === "string")
- commandMapping = {id: commandMapping};
- var commandId = commandMapping.id;
- var mappings = that._commandMappings[containerId] || {};
- mappings[commandId] = $.extend({
- showIcon: true,
- showText: true
- }, that._containerDefaults[containerId] || {}, commandMapping);
- that._commandMappings[containerId] = mappings
- });
- this._initExistingCommands();
- return this
- },
- unmapCommands: function(containerId, commandIds) {
- var that = this;
- $.each(commandIds, function(index, commandId) {
- var mappings = that._commandMappings[containerId] || {};
- if (mappings)
- delete mappings[commandId]
- });
- this._initExistingCommands()
- },
- getCommandMappingForContainer: function(commandId, containerId) {
- return (this._commandMappings[containerId] || {})[commandId]
- },
- checkCommandsExist: function(commands) {
- var that = this,
- result = $.grep(commands, function(commandName, index) {
- return $.inArray(commandName, that._existingCommands) < 0 && $.inArray(commandName, commands) === index
- });
- if (result.length !== 0)
- throw new Error("The '" + result.join("', '") + "' command" + (result.length === 1 ? " is" : "s are") + " not registred in the application's command mapping. See http://dxpr.es/1bTjfj1 for more details.");
- },
- load: function(config) {
- if (!config)
- return;
- var that = this;
- $.each(config, function(name, container) {
- that.setDefaults(name, container.defaults);
- that.mapCommands(name, container.commands)
- });
- return this
- },
- _initExistingCommands: function() {
- var that = this;
- this._existingCommands = [];
- $.each(that._commandMappings, function(name, _commands) {
- $.each(_commands, function(index, command) {
- if ($.inArray(command.id, that._existingCommands) < 0)
- that._existingCommands.push(command.id)
- })
- })
- }
- });
- DX.framework.CommandMapping.defaultMapping = {
- "global-navigation": {
- defaults: {
- showIcon: true,
- showText: true
- },
- commands: []
- },
- "ios-header-toolbar": {
- defaults: {
- showIcon: false,
- showText: true,
- location: "after"
- },
- commands: ["edit", "save", {
- id: "back",
- location: "before"
- }, {
- id: "cancel",
- location: "before"
- }, {
- id: "create",
- showIcon: true,
- showText: false
- }]
- },
- "ios-action-sheet": {
- defaults: {
- showIcon: false,
- showText: true
- },
- commands: []
- },
- "ios-view-footer": {
- defaults: {
- showIcon: false,
- showText: true
- },
- commands: [{
- id: "delete",
- type: "danger"
- }]
- },
- "android-header-toolbar": {
- defaults: {
- showIcon: true,
- showText: false,
- location: "after"
- },
- commands: [{
- id: "back",
- showIcon: false,
- location: "before"
- }, "create", "edit", "save", {
- id: "cancel",
- showText: true,
- location: "menu"
- }, {
- id: "delete",
- showText: true,
- location: "menu"
- }]
- },
- "android-simple-toolbar": {
- defaults: {
- showIcon: true,
- showText: false,
- location: "after"
- },
- commands: [{
- id: "back",
- showIcon: false,
- location: "before"
- }, {id: "create"}, {
- id: "save",
- showText: true,
- location: "before"
- }, {
- id: "edit",
- showText: true,
- location: "menu"
- }, {
- id: "cancel",
- showText: true,
- location: "menu"
- }, {
- id: "delete",
- showText: true,
- location: "menu"
- }]
- },
- "android-footer-toolbar": {
- defaults: {location: "after"},
- commands: [{
- id: "create",
- showText: false,
- location: "center"
- }, {
- id: "edit",
- showText: false,
- location: "before"
- }, {
- id: "delete",
- location: "menu"
- }, {
- id: "save",
- showIcon: false,
- location: "before"
- }]
- },
- "tizen-header-toolbar": {
- defaults: {
- showIcon: true,
- showText: false,
- location: "after"
- },
- commands: [{
- id: "back",
- showIcon: false,
- location: "before"
- }, "create", "edit", "save", {
- id: "cancel",
- showText: true,
- location: "menu"
- }, {
- id: "delete",
- showText: true,
- location: "menu"
- }]
- },
- "tizen-footer-toolbar": {
- defaults: {location: "after"},
- commands: [{
- id: "create",
- showText: false
- }, {
- id: "edit",
- showText: false,
- location: "before"
- }, {
- id: "delete",
- location: "menu"
- }, {
- id: "save",
- showIcon: false,
- location: "before"
- }]
- },
- "tizen-simple-toolbar": {
- defaults: {
- showIcon: true,
- showText: false,
- location: "after"
- },
- commands: [{
- id: "back",
- showIcon: false,
- location: "before"
- }, {id: "create"}, {
- id: "save",
- showText: true,
- location: "before"
- }, {
- id: "edit",
- showText: true,
- location: "menu"
- }, {
- id: "cancel",
- showText: true,
- location: "menu"
- }, {
- id: "delete",
- showText: true,
- location: "menu"
- }]
- },
- "generic-header-toolbar": {
- defaults: {
- showIcon: false,
- showText: true,
- location: "after"
- },
- commands: ["edit", "save", {
- id: "back",
- location: "before"
- }, {
- id: "cancel",
- location: "before"
- }, {
- id: "create",
- showIcon: true,
- showText: false
- }]
- },
- "generic-view-footer": {
- defaults: {
- showIcon: false,
- showText: true
- },
- commands: [{
- id: "delete",
- type: "danger"
- }]
- },
- "win8-appbar": {
- defaults: {location: "after"},
- commands: ["edit", "cancel", "save", "delete", {
- id: "create",
- location: "before"
- }, {
- id: "refresh",
- location: "before"
- }]
- },
- "win8-toolbar": {
- defaults: {
- showText: false,
- location: "before"
- },
- commands: [{id: "previousPage"}]
- },
- "win8-phone-appbar": {
- defaults: {location: "center"},
- commands: ["create", "edit", "cancel", "save", "refresh", {
- id: "delete",
- location: "menu"
- }]
- },
- "win8-split-toolbar": {
- defaults: {
- showIcon: true,
- showText: false,
- location: "after"
- },
- commands: [{
- id: "back",
- showIcon: false,
- location: "before"
- }, {id: "create"}, {
- id: "save",
- showText: true,
- location: "before"
- }, {
- id: "edit",
- showText: true,
- location: "menu"
- }, {
- id: "cancel",
- showText: true,
- location: "menu"
- }, {
- id: "delete",
- showText: true,
- location: "menu"
- }]
- },
- "win8-master-detail-toolbar": {
- defaults: {
- showText: false,
- location: "before"
- },
- commands: ["back"]
- },
- "desktop-toolbar": {
- defaults: {
- showIcon: false,
- showText: true,
- location: "after"
- },
- commands: ["cancel", "create", "edit", "save", {
- id: "delete",
- type: "danger"
- }]
- }
- }
- })(jQuery, DevExpress);
- /*! Module framework, file framework.viewCache.js */
- (function($, DX, undefined) {
- var Class = DX.Class;
- DX.framework.ViewCache = Class.inherit({
- ctor: function(options) {
- this._cache = {};
- this.viewRemoved = $.Callbacks()
- },
- setView: function(key, viewInfo) {
- this._cache[key] = viewInfo
- },
- getView: function(key) {
- return this._cache[key]
- },
- removeView: function(key) {
- var result = this._cache[key];
- if (result) {
- delete this._cache[key];
- this.viewRemoved.fire({viewInfo: result})
- }
- return result
- },
- clear: function() {
- var that = this;
- $.each(this._cache, function(key) {
- that.removeView(key)
- })
- },
- hasView: function(key) {
- return key in this._cache
- }
- });
- DX.framework.NullViewCache = DX.framework.ViewCache.inherit({setView: function(key, viewInfo) {
- this.callBase(key, viewInfo);
- this.removeView(key)
- }});
- DX.framework.ConditionalViewCacheDecorator = Class.inherit({
- ctor: function(options) {
- this._filter = options.filter;
- this._viewCache = options.viewCache;
- this.viewRemoved = this._viewCache.viewRemoved
- },
- setView: function(key, viewInfo) {
- this._viewCache.setView(key, viewInfo);
- if (!this._filter(key, viewInfo))
- this._viewCache.removeView(key)
- },
- getView: function(key) {
- return this._viewCache.getView(key)
- },
- removeView: function(key) {
- return this._viewCache.removeView(key)
- },
- clear: function() {
- return this._viewCache.clear()
- },
- hasView: function(key) {
- return this._viewCache.hasView(key)
- }
- });
- var DEFAULT_VIEW_CACHE_CAPACITY = 10;
- DX.framework.CapacityViewCacheDecorator = Class.inherit({
- ctor: function(options) {
- this._keys = [];
- this._size = options.size || DEFAULT_VIEW_CACHE_CAPACITY;
- this._viewCache = options.viewCache;
- this.viewRemoved = this._viewCache.viewRemoved
- },
- setView: function(key, viewInfo) {
- if (!this.hasView(key)) {
- if (this._keys.length == this._size)
- this.removeView(this._keys[0]);
- this._keys.push(key)
- }
- this._viewCache.setView(key, viewInfo)
- },
- getView: function(key) {
- var index = $.inArray(key, this._keys);
- if (index < 0)
- return null;
- this._keys.push(key);
- this._keys.splice(index, 1);
- return this._viewCache.getView(key)
- },
- removeView: function(key) {
- var index = $.inArray(key, this._keys);
- if (index > -1)
- this._keys.splice(index, 1);
- return this._viewCache.removeView(key)
- },
- clear: function() {
- this._keys = [];
- return this._viewCache.clear()
- },
- hasView: function(key) {
- return this._viewCache.hasView(key)
- }
- });
- DX.framework.HistoryDependentViewCacheDecorator = Class.inherit({
- ctor: function(options) {
- this._viewCache = options.viewCache || new DX.framework.ViewCache;
- this._navigationManager = options.navigationManager;
- this._navigationManager.itemRemoved.add($.proxy(this._onNavigationItemRemoved, this));
- this.viewRemoved = this._viewCache.viewRemoved
- },
- _onNavigationItemRemoved: function(item) {
- this.removeView(item.key)
- },
- setView: function(key, viewInfo) {
- this._viewCache.setView(key, viewInfo)
- },
- getView: function(key) {
- return this._viewCache.getView(key)
- },
- removeView: function(key) {
- return this._viewCache.removeView(key)
- },
- clear: function() {
- return this._viewCache.clear()
- },
- hasView: function(key) {
- return this._viewCache.hasView(key)
- }
- })
- })(jQuery, DevExpress);
- /*! Module framework, file framework.stateManager.js */
- (function($, DX, undefined) {
- var Class = DX.Class;
- DX.framework.MemoryKeyValueStorage = Class.inherit({
- ctor: function() {
- this.storage = {}
- },
- getItem: function(key) {
- return this.storage[key]
- },
- setItem: function(key, value) {
- this.storage[key] = value
- },
- removeItem: function(key) {
- delete this.storage[key]
- }
- });
- DX.framework.StateManager = Class.inherit({
- ctor: function(options) {
- options = options || {};
- this.storage = options.storage || new DX.framework.MemoryKeyValueStorage;
- this.stateSources = options.stateSources || []
- },
- addStateSource: function(stateSource) {
- this.stateSources.push(stateSource)
- },
- removeStateSource: function(stateSource) {
- var index = $.inArray(stateSource, this.stateSources);
- if (index > -1) {
- this.stateSources.splice(index, 1);
- stateSource.removeState(this.storage)
- }
- },
- saveState: function() {
- var that = this;
- $.each(this.stateSources, function(index, stateSource) {
- stateSource.saveState(that.storage)
- })
- },
- restoreState: function() {
- var that = this;
- $.each(this.stateSources, function(index, stateSource) {
- stateSource.restoreState(that.storage)
- })
- },
- clearState: function() {
- var that = this;
- $.each(this.stateSources, function(index, stateSource) {
- stateSource.removeState(that.storage)
- })
- }
- })
- })(jQuery, DevExpress);
- /*! Module framework, file framework.browserAdapters.js */
- (function($, DX, undefined) {
- var Class = DX.Class;
- var ROOT_PAGE_URL = "__root__",
- BUGGY_ANDROID_BUFFER_PAGE_URL = "__buffer__";
- DX.framework.DefaultBrowserAdapter = Class.inherit({
- ctor: function(options) {
- options = options || {};
- this._window = options.window || window;
- this.popState = $.Callbacks();
- $(this._window).on("hashchange", $.proxy(this._onHashChange, this));
- this._tasks = DX.createQueue();
- this.canWorkInPureBrowser = true
- },
- replaceState: function(uri) {
- var that = this;
- return this._addTask(function() {
- uri = that._normalizeUri(uri);
- that._window.history.replaceState(null, null, "#" + uri);
- that._currentTask.resolve()
- })
- },
- pushState: function(uri) {
- var that = this;
- return this._addTask(function() {
- uri = that._normalizeUri(uri);
- that._window.history.pushState(null, null, "#" + uri);
- that._currentTask.resolve()
- })
- },
- createRootPage: function() {
- return this.replaceState(ROOT_PAGE_URL)
- },
- _onHashChange: function() {
- if (this._currentTask)
- this._currentTask.resolve();
- this.popState.fire()
- },
- back: function() {
- var that = this;
- return this._addTask(function() {
- that._window.history.back()
- })
- },
- getHash: function() {
- return this._normalizeUri(this._window.location.hash)
- },
- isRootPage: function() {
- return this.getHash() === ROOT_PAGE_URL
- },
- _normalizeUri: function(uri) {
- return (uri || "").replace(/^#+/, "")
- },
- _addTask: function(task) {
- var that = this,
- d = $.Deferred();
- this._tasks.add(function() {
- that._currentTask = d;
- task();
- return d
- });
- return d.promise()
- }
- });
- DX.framework.OldBrowserAdapter = DX.framework.DefaultBrowserAdapter.inherit({
- ctor: function() {
- this._innerEventCount = 0;
- this.callBase.apply(this, arguments);
- this._skipNextEvent = false
- },
- replaceState: function(uri) {
- var that = this;
- uri = that._normalizeUri(uri);
- if (that.getHash() !== uri) {
- that._addTask(function() {
- that._skipNextEvent = true;
- that._window.history.back()
- });
- return that._addTask(function() {
- that._skipNextEvent = true;
- that._window.location.hash = uri
- })
- }
- return $.Deferred().resolve().promise()
- },
- pushState: function(uri) {
- var that = this;
- uri = this._normalizeUri(uri);
- if (this.getHash() !== uri)
- return that._addTask(function() {
- that._skipNextEvent = true;
- that._window.location.hash = uri
- });
- return $.Deferred().resolve().promise()
- },
- createRootPage: function() {
- return this.pushState(ROOT_PAGE_URL)
- },
- _onHashChange: function() {
- var currentTask = this._currentTask;
- this._currentTask = null;
- if (this._skipNextEvent)
- this._skipNextEvent = false;
- else
- this.popState.fire();
- if (currentTask)
- currentTask.resolve()
- }
- });
- DX.framework.BuggyAndroidBrowserAdapter = DX.framework.OldBrowserAdapter.inherit({createRootPage: function() {
- this.pushState(BUGGY_ANDROID_BUFFER_PAGE_URL);
- return this.callBase()
- }});
- DX.framework.HistorylessBrowserAdapter = DX.framework.DefaultBrowserAdapter.inherit({
- ctor: function(options) {
- options = options || {};
- this._window = options.window || window;
- this.popState = $.Callbacks();
- $(this._window).on("dxback", $.proxy(this._onHashChange, this));
- this._currentHash = this._window.location.hash
- },
- replaceState: function(uri) {
- this._currentHash = this._normalizeUri(uri);
- return $.Deferred().resolve().promise()
- },
- pushState: function(uri) {
- return this.replaceState(uri)
- },
- createRootPage: function() {
- return this.replaceState(ROOT_PAGE_URL)
- },
- getHash: function() {
- return this._normalizeUri(this._currentHash)
- },
- back: function() {
- return this.replaceState(ROOT_PAGE_URL)
- },
- _onHashChange: function() {
- var promise = this.back();
- this.popState.fire();
- return promise
- }
- });
- DX.framework.BuggyCordovaWP81BrowserAdapter = DX.framework.DefaultBrowserAdapter.inherit({ctor: function(options) {
- this.callBase(options);
- this.canWorkInPureBrowser = false
- }})
- })(jQuery, DevExpress);
- /*! Module framework, file framework.navigationDevices.js */
- (function($, DX, undefined) {
- var Class = DX.Class;
- var SESSION_KEY = "dxPhoneJSApplication";
- DX.framework.HistoryBasedNavigationDevice = Class.inherit({
- ctor: function(options) {
- options = options || {};
- this._browserAdapter = options.browserAdapter || this._createBrowserAdapter(options);
- this.uriChanged = $.Callbacks();
- this._browserAdapter.popState.add($.proxy(this._onPopState, this))
- },
- init: $.noop,
- getUri: function() {
- return this._browserAdapter.getHash()
- },
- setUri: function(uri, replaceCurrent) {
- if (replaceCurrent)
- return this._browserAdapter.replaceState(uri);
- return this._browserAdapter.pushState(uri)
- },
- back: function() {
- return this._browserAdapter.back()
- },
- _onPopState: function() {
- this.uriChanged.fire(this.getUri())
- },
- _isBuggyAndroid2: function() {
- var realDevice = DX.devices.real();
- var version = realDevice.version;
- return realDevice.platform === "android" && version.length > 1 && (version[0] === 2 && version[1] < 4 || version[0] < 2)
- },
- _isBuggyAndroid4: function() {
- var realDevice = DX.devices.real();
- var version = realDevice.version;
- return realDevice.platform === "android" && version.length > 1 && version[0] === 4 && version[1] === 0
- },
- _isWindowsPhone8: function() {
- var realDevice = DX.devices.real();
- return realDevice.platform === "win8" && realDevice.phone
- },
- _createBrowserAdapter: function(options) {
- var sourceWindow = options.window || window,
- supportPushReplace = sourceWindow.history.replaceState && sourceWindow.history.pushState,
- result;
- if (this._isWindowsPhone8())
- result = new DX.framework.BuggyCordovaWP81BrowserAdapter(options);
- else if (sourceWindow !== sourceWindow.top)
- result = new DX.framework.HistorylessBrowserAdapter(options);
- else if (this._isBuggyAndroid4())
- result = new DX.framework.BuggyAndroidBrowserAdapter(options);
- else if (this._isBuggyAndroid2() || !supportPushReplace)
- result = new DX.framework.OldBrowserAdapter(options);
- else
- result = new DX.framework.DefaultBrowserAdapter(options);
- return result
- }
- });
- DX.framework.StackBasedNavigationDevice = DX.framework.HistoryBasedNavigationDevice.inherit({
- ctor: function(options) {
- this.callBase(options);
- this.backInitiated = $.Callbacks();
- this._deferredNavigate = null;
- $(window).on("unload", this._saveBrowserState)
- },
- init: function() {
- var that = this;
- if (that._browserAdapter.canWorkInPureBrowser)
- return that._initRootPage().done(function() {
- if (that._browserAdapter.isRootPage())
- that._browserAdapter.pushState("")
- });
- else
- return $.Deferred().resolve().promise()
- },
- setUri: function(uri) {
- return this.callBase(uri, !this._browserAdapter.isRootPage())
- },
- _saveBrowserState: function() {
- if (window.sessionStorage)
- sessionStorage.setItem(SESSION_KEY, true)
- },
- _initRootPage: function() {
- var hash = this.getUri();
- if (!window.sessionStorage || sessionStorage.getItem(SESSION_KEY))
- return $.Deferred().resolve().promise();
- sessionStorage.removeItem(SESSION_KEY);
- this._browserAdapter.createRootPage();
- return this._browserAdapter.pushState(hash)
- },
- _onPopState: function() {
- var navigationPending = this._deferredNavigate && this._deferredNavigate.state() === "pending";
- if (this._browserAdapter.isRootPage())
- if (navigationPending)
- this._deferredNavigate.resolve();
- else
- this.backInitiated.fire();
- else {
- if (!navigationPending)
- this._deferredNavigate = $.Deferred().done($.proxy(this.callBase, this));
- this.back()
- }
- }
- })
- })(jQuery, DevExpress);
- /*! Module framework, file framework.navigationManager.js */
- (function($, DX, undefined) {
- var Class = DX.Class;
- var NAVIGATION_TARGETS = {
- current: "current",
- blank: "blank",
- back: "back"
- },
- STORAGE_HISTORY_KEY = "__history";
- DX.framework.HistoryBasedNavigationManager = Class.inherit({
- ctor: function(options) {
- options = options || {};
- this._currentItem = undefined;
- this._previousItem = undefined;
- this.navigating = $.Callbacks();
- this.navigated = $.Callbacks();
- this.navigationCanceled = $.Callbacks();
- this.navigatingBack = $.Callbacks();
- this.itemRemoved = $.Callbacks();
- this._createNavigationDevice(options)
- },
- _createNavigationDevice: function(options) {
- this._navigationDevice = options.navigationDevice || new DX.framework.HistoryBasedNavigationDevice;
- this._navigationDevice.uriChanged.add($.proxy(this._uriChangedHandler, this))
- },
- _uriChangedHandler: function(uri) {
- while (DX.hideTopOverlayCallback.fire());
- this.navigate(uri, {target: "none"})
- },
- _cancelNavigation: function(args) {
- this.navigationCanceled.fire(args)
- },
- _getDefaultOptions: function() {
- return {
- direction: "none",
- target: NAVIGATION_TARGETS.blank
- }
- },
- _updateHistory: function(uri, options) {
- this._previousItem = this._currentItem;
- this._currentItem = {
- uri: uri,
- key: uri
- };
- if (options.target !== "none")
- this._navigationDevice.setUri(uri, options.target === "current")
- },
- navigate: function(uri, options) {
- options = options || {};
- var that = this,
- currentItem = that._currentItem || {},
- targetItem = options.item || {},
- currentUri = currentItem.uri,
- currentKey = currentItem.key,
- targetKey = targetItem.key,
- args;
- if (uri === undefined)
- uri = that._navigationDevice.getUri();
- if (/^_back$/.test(uri)) {
- that.back();
- return
- }
- options = $.extend(that._getDefaultOptions(), options || {});
- args = {
- currentUri: currentUri,
- uri: uri,
- cancel: false,
- navigateWhen: [],
- options: options
- };
- that.navigating.fire(args);
- uri = args.uri;
- if (args.cancel || currentUri === uri && (targetKey === undefined || targetKey === currentKey) && !that._forceNavigate)
- that._cancelNavigation(args);
- else {
- that._forceNavigate = false;
- $.when.apply($, args.navigateWhen).done(function() {
- DX.utils.executeAsync(function() {
- that._updateHistory(uri, options);
- that.navigated.fire({
- uri: uri,
- previousUri: currentUri,
- options: options,
- item: that._currentItem
- })
- })
- })
- }
- },
- back: function() {
- return this._navigationDevice.back()
- },
- previousItem: function() {
- return this._previousItem
- },
- currentItem: function() {
- return this._currentItem
- },
- rootUri: function() {
- return this._currentItem && this._currentItem.uri
- },
- canBack: function() {
- return true
- },
- saveState: $.noop,
- restoreState: $.noop,
- removeState: $.noop
- });
- DX.framework.StackBasedNavigationManager = DX.framework.HistoryBasedNavigationManager.inherit({
- ctor: function(options) {
- options = options || {};
- this.callBase(options);
- this._createNavigationStacks(options);
- DX.hardwareBackButton.add($.proxy(this._deviceBackInitiated, this));
- this._stateStorageKey = options.stateStorageKey || STORAGE_HISTORY_KEY
- },
- init: function() {
- return this._navigationDevice.init()
- },
- _createNavigationDevice: function(options) {
- if (!options.navigationDevice)
- options.navigationDevice = new DX.framework.StackBasedNavigationDevice;
- this.callBase(options);
- this._navigationDevice.backInitiated.add($.proxy(this._deviceBackInitiated, this))
- },
- _uriChangedHandler: function(uri) {
- this.navigate(uri)
- },
- _createNavigationStacks: function(options) {
- this.navigationStacks = {};
- this._keepPositionInStack = options.keepPositionInStack;
- this.currentStack = new DX.framework.NavigationStack
- },
- _deviceBackInitiated: function() {
- if (!DX.hideTopOverlayCallback.fire())
- this.back({isHardwareButton: true});
- else
- this._restoreDevicePreviousUri()
- },
- _restoreDevicePreviousUri: function() {
- var currentUri = this._currentItem && this._currentItem.uri;
- this._navigationDevice.setUri(currentUri)
- },
- _cancelNavigation: function(args) {
- this._restoreDevicePreviousUri();
- this.callBase(args)
- },
- _getDefaultOptions: function() {
- return {target: NAVIGATION_TARGETS.blank}
- },
- _createNavigationStack: function() {
- var result = new DX.framework.NavigationStack;
- result.itemsRemoved.add($.proxy(this._removeItems, this));
- return result
- },
- _setCurrentStack: function(stackKey) {
- if (!(stackKey in this.navigationStacks))
- this.navigationStacks[stackKey] = this._createNavigationStack();
- this.currentStack = this.navigationStacks[stackKey];
- this.currentStackKey = stackKey
- },
- _updateHistory: function(uri, options) {
- var isRoot = options.root,
- forceIsRoot = isRoot,
- forceToRoot = false,
- stackKey = options.stack || (isRoot ? uri : this.currentStackKey || uri),
- previousStack = this.currentStack,
- keepPositionInStack = options.keepPositionInStack !== undefined ? options.keepPositionInStack : this._keepPositionInStack;
- this._setCurrentStack(stackKey);
- if (isRoot || !this.currentStack.items.length) {
- forceToRoot = this.currentStack === previousStack;
- forceIsRoot = true
- }
- if (isRoot && this.currentStack.items.length) {
- if (!keepPositionInStack || forceToRoot) {
- this.currentStack.currentIndex = 0;
- if (this.currentItem().uri !== uri)
- this.currentStack.navigate(uri, true)
- }
- }
- else {
- var prevIndex = this.currentStack.currentIndex,
- prevItem = this.currentItem() || {};
- switch (options.target) {
- case NAVIGATION_TARGETS.blank:
- this.currentStack.navigate(uri);
- break;
- case NAVIGATION_TARGETS.current:
- this.currentStack.navigate(uri, true);
- break;
- case NAVIGATION_TARGETS.back:
- if (this.currentStack.currentIndex > 0)
- this.currentStack.back(uri);
- else
- this.currentStack.navigate(uri, true);
- break;
- default:
- throw Error(DX.utils.stringFormat("Unknown navigation target: \"{0}\". Use the DevExpress.framework.StackBasedNavigationManager.NAVIGATION_TARGETS enumerable values", options.target));
- }
- if (options.direction === undefined) {
- var indexDelta = this.currentStack.currentIndex - prevIndex;
- if (indexDelta < 0)
- options.direction = this.currentStack.currentItem().backDirection || "backward";
- else if (indexDelta > 0 && this.currentStack.currentIndex > 0)
- options.direction = "forward";
- else
- options.direction = "none"
- }
- prevItem.backDirection = options.direction === "forward" ? "backward" : "none"
- }
- options.root = forceIsRoot;
- this._currentItem = this.currentStack.currentItem();
- this._restoreDevicePreviousUri()
- },
- _removeItems: function(items) {
- var that = this;
- $.each(items, function(index, item) {
- that.itemRemoved.fire(item)
- })
- },
- back: function(options) {
- options = options || {};
- var navigatingBackArgs = $.extend({cancel: false}, options);
- this.navigatingBack.fire(navigatingBackArgs);
- if (navigatingBackArgs.cancel) {
- this._restoreDevicePreviousUri();
- return
- }
- var item = this.previousItem(navigatingBackArgs.stack);
- if (item)
- this.navigate(item.uri, {
- stack: navigatingBackArgs.stack,
- target: NAVIGATION_TARGETS.back,
- item: item
- });
- else
- this.callBase()
- },
- rootUri: function() {
- return this.currentStack.items.length ? this.currentStack.items[0].uri : this.callBase()
- },
- canBack: function(stackKey) {
- var stack = stackKey ? this.navigationStacks[stackKey] : this.currentStack;
- return stack.canBack()
- },
- saveState: function(storage) {
- if (this.currentStack.items.length) {
- var state = {
- items: this.currentStack.items,
- currentIndex: this.currentStack.currentIndex,
- currentStackKey: this.currentStack.items[0].uri
- };
- var json = JSON.stringify(state);
- storage.setItem(this._stateStorageKey, json)
- }
- else
- this.removeState(storage)
- },
- restoreState: function(storage) {
- if (this.disableRestoreState)
- return;
- var json = storage.getItem(this._stateStorageKey);
- if (json)
- try {
- var state = JSON.parse(json),
- stack = this._createNavigationStack();
- if (!state.items[0].uri)
- throw Error("Error while application state restoring. State has been cleared. Refresh the page");
- stack.items = state.items;
- stack.currentIndex = state.currentIndex;
- this.navigationStacks[stack.items[0].uri] = stack;
- this.currentStackKey = state.currentStackKey;
- this.currentStack = this.navigationStacks[this.currentStackKey];
- this._currentItem = this.currentStack.currentItem();
- this._navigationDevice.setUri(this.currentItem().uri);
- this._forceNavigate = true
- }
- catch(e) {
- this.removeState(storage);
- throw e;
- }
- },
- removeState: function(storage) {
- storage.removeItem(this._stateStorageKey)
- },
- currentIndex: function() {
- return this.currentStack.currentIndex
- },
- previousItem: function(stackKey) {
- var stack = stackKey ? this.navigationStacks[stackKey] : this.currentStack;
- return stack.previousItem()
- },
- getItemByIndex: function(index) {
- return this.currentStack.items[index]
- },
- clearHistory: function() {
- this.currentStack.clear()
- }
- });
- DX.framework.NavigationStack = Class.inherit({
- ctor: function(options) {
- options = options || {};
- this.itemsRemoved = $.Callbacks();
- this.clear()
- },
- currentItem: function() {
- return this.items[this.currentIndex]
- },
- previousItem: function() {
- return this.items.length > 1 ? this.items[this.currentIndex - 1] : undefined
- },
- canBack: function() {
- return this.currentIndex > 0
- },
- clear: function() {
- this._deleteItems(this.items);
- this.items = [];
- this.currentIndex = -1
- },
- back: function(uri) {
- this.currentIndex--;
- if (this.currentIndex < 0)
- throw Error("Unable to go back");
- var currentItem = this.currentItem();
- if (currentItem.uri !== uri)
- this._updateItem(this.currentIndex, uri)
- },
- forward: function() {
- this.currentIndex++;
- if (this.currentIndex >= this.items.length)
- throw Error("Unable to go forward");
- },
- navigate: function(uri, replaceCurrent) {
- if (this.currentIndex < this.items.length && this.currentIndex > -1 && this.items[this.currentIndex].uri === uri)
- return;
- if (replaceCurrent && this.currentIndex > -1)
- this.currentIndex--;
- if (this.currentIndex + 1 < this.items.length && this.items[this.currentIndex + 1].uri === uri)
- this.currentIndex++;
- else {
- var toDelete = this.items.splice(this.currentIndex + 1, this.items.length - this.currentIndex - 1);
- this.items.push({});
- this.currentIndex++;
- this._updateItem(this.currentIndex, uri);
- this._deleteItems(toDelete)
- }
- return this.currentItem()
- },
- _updateItem: function(index, uri) {
- var item = this.items[index];
- item.uri = uri;
- item.key = this.items[0].uri + "_" + index + "_" + uri
- },
- _deleteItems: function(items) {
- if (items)
- this.itemsRemoved.fire(items)
- }
- });
- DX.framework.HistoryBasedNavigationManager.NAVIGATION_TARGETS = NAVIGATION_TARGETS
- })(jQuery, DevExpress);
- /*! Module framework, file framework.actionExecutors.js */
- (function($, DX, undefined) {
- DX.framework.createActionExecutors = function(app) {
- return {
- routing: {execute: function(e) {
- var action = e.action,
- routeValues,
- options,
- uri;
- if ($.isPlainObject(action)) {
- routeValues = action.routeValues;
- if (routeValues && $.isPlainObject(routeValues))
- options = action.options;
- else
- routeValues = action;
- uri = app.router.format(routeValues);
- app.navigate(uri, options);
- e.handled = true
- }
- }},
- hash: {execute: function(e) {
- if (typeof e.action !== "string" || e.action.charAt(0) !== "#")
- return;
- var uriTemplate = e.action.substr(1),
- args = e.args[0],
- uri = uriTemplate;
- var defaultEvaluate = function(expr) {
- var getter = DX.data.utils.compileGetter(expr),
- model = e.args[0].model;
- return getter(model)
- };
- var evaluate = args.evaluate || defaultEvaluate;
- uri = uriTemplate.replace(/\{([^}]+)\}/g, function(entry, expr) {
- expr = $.trim(expr);
- if (expr.indexOf(",") > -1)
- expr = $.map(expr.split(","), $.trim);
- var value = evaluate(expr);
- if (value === undefined)
- value = "";
- value = DX.framework.Route.prototype.formatSegment(value);
- return value
- });
- var navigateOptions = (e.component || {}).NAME === "dxCommand" ? e.component.option() : {};
- app.navigate(uri, navigateOptions);
- e.handled = true
- }}
- }
- }
- })(jQuery, DevExpress);
- /*! Module framework, file framework.application.js */
- (function($, DX) {
- var Class = DX.Class,
- BACK_COMMAND_TITLE,
- INIT_IN_PROGRESS = "InProgress",
- INIT_COMPLETE = "Inited",
- frameworkNS = DX.framework;
- DX.framework.Application = Class.inherit({
- ctor: function(options) {
- options = options || {};
- this._options = options;
- this.namespace = options.namespace || options.ns || window;
- this._applicationMode = options.mode ? options.mode : "mobileApp";
- this.components = [];
- BACK_COMMAND_TITLE = DX.localization.localizeString("@Back");
- this.router = options.router || new DX.framework.MvcRouter;
- var navigationManagers = {
- mobileApp: DX.framework.StackBasedNavigationManager,
- webSite: DX.framework.HistoryBasedNavigationManager
- };
- this.navigationManager = options.navigationManager || new navigationManagers[this._applicationMode]({keepPositionInStack: options.navigateToRootViewMode === "keepHistory"});
- this.navigationManager.navigating.add($.proxy(this._onNavigating, this));
- this.navigationManager.navigatingBack.add($.proxy(this._onNavigatingBack, this));
- this.navigationManager.navigated.add($.proxy(this._onNavigated, this));
- this.navigationManager.navigationCanceled.add($.proxy(this._onNavigationCanceled, this));
- this.stateManager = options.stateManager || new DX.framework.StateManager({storage: options.stateStorage || sessionStorage});
- this.stateManager.addStateSource(this.navigationManager);
- this.viewCache = this._createViewCache(options);
- this.commandMapping = this._createCommandMapping(options.commandMapping);
- this.createNavigation(options.navigation);
- this.beforeViewSetup = $.Callbacks();
- this.afterViewSetup = $.Callbacks();
- this.viewShowing = $.Callbacks();
- this.viewShown = $.Callbacks();
- this.viewHidden = $.Callbacks();
- this.viewDisposing = $.Callbacks();
- this.viewDisposed = $.Callbacks();
- this.navigating = $.Callbacks();
- this.navigatingBack = $.Callbacks();
- this.initialized = $.Callbacks();
- this._isNavigating = false;
- this._viewLinksHash = {};
- DX.registerActionExecutor(DX.framework.createActionExecutors(this));
- DX.overlayTargetContainer(".dx-viewport");
- this.components.push(this.router);
- this.components.push(this.navigationManager)
- },
- _createViewCache: function(options) {
- var result;
- if (options.viewCache)
- result = options.viewCache;
- else if (options.disableViewCache)
- result = new DX.framework.NullViewCache;
- else
- result = new DX.framework.CapacityViewCacheDecorator({
- size: options.viewCacheSize,
- viewCache: new DX.framework.ViewCache
- });
- result.viewRemoved.add($.proxy(function(e) {
- this._releaseViewLink(e.viewInfo)
- }, this));
- return result
- },
- _createCommandMapping: function(commandMapping) {
- var result = commandMapping;
- if (!(commandMapping instanceof DX.framework.CommandMapping)) {
- result = new DX.framework.CommandMapping;
- result.load(DX.framework.CommandMapping.defaultMapping || {}).load(commandMapping || {})
- }
- return result
- },
- createNavigation: function(navigationConfig) {
- this.navigation = this._createNavigationCommands(navigationConfig);
- this._mapNavigationCommands(this.navigation, this.commandMapping)
- },
- _createNavigationCommands: function(commandConfig) {
- if (!commandConfig)
- return [];
- var that = this,
- generatedIdCount = 0;
- return $.map(commandConfig, function(item) {
- var command;
- if (item instanceof frameworkNS.dxCommand)
- command = item;
- else
- command = new frameworkNS.dxCommand($.extend({root: true}, item));
- if (!command.option("id"))
- command.option("id", "navigation_" + generatedIdCount++);
- return command
- })
- },
- _mapNavigationCommands: function(navigationCommands, commandMapping) {
- var navigationCommandIds = $.map(navigationCommands, function(command) {
- return command.option("id")
- });
- commandMapping.mapCommands("global-navigation", navigationCommandIds)
- },
- _callComponentMethod: function(methodName, args) {
- var tasks = [];
- $.each(this.components, function(index, component) {
- if (component[methodName] && $.isFunction(component[methodName])) {
- var result = component[methodName](args);
- if (result && result.done)
- tasks.push(result)
- }
- });
- return $.when.apply($, tasks)
- },
- init: function() {
- var that = this;
- that._initState = INIT_IN_PROGRESS;
- return that._callComponentMethod("init").done(function() {
- that._initState = INIT_COMPLETE;
- that._processEvent("initialized")
- })
- },
- _onNavigatingBack: function(args) {
- this._processEvent("navigatingBack", args)
- },
- _onNavigating: function(args) {
- var that = this;
- if (that._isNavigating) {
- that._pendingNavigationArgs = args;
- args.cancel = true;
- return
- }
- else {
- that._isNavigating = true;
- delete that._pendingNavigationArgs
- }
- var routeData = this.router.parse(args.uri);
- if (!routeData)
- throw new Error(DX.utils.stringFormat("Routing rule is not found for the \"{0}\" url", args.uri));
- var uri = this.router.format(routeData);
- if (args.uri !== uri && uri) {
- args.cancel = true;
- DX.utils.executeAsync(function() {
- that.navigate(uri, args.options)
- })
- }
- else
- that._processEvent("navigating", args)
- },
- _onNavigated: function(args) {
- var that = this,
- direction = args.options.direction,
- deferred = $.Deferred(),
- viewInfo = that._acquireViewInfo(args.item, args.options);
- if (!that._isViewReadyToShow(viewInfo))
- that._setViewLoadingState(viewInfo, direction).done(function() {
- DX.utils.executeAsync(function() {
- that._createViewModel(viewInfo);
- that._createViewCommands(viewInfo);
- deferred.resolve()
- })
- }).fail(function() {
- that._isNavigating = false;
- deferred.reject()
- });
- else
- deferred.resolve();
- deferred.done(function() {
- that._highlightCurrentNavigationCommand(viewInfo);
- that._showView(viewInfo, direction).always(function() {
- that._isNavigating = false;
- var pendingArgs = that._pendingNavigationArgs;
- if (pendingArgs)
- DX.utils.executeAsync(function() {
- that.navigate(pendingArgs.uri, pendingArgs.options)
- })
- })
- })
- },
- _isViewReadyToShow: function(viewInfo) {
- return !!viewInfo.model
- },
- _onNavigationCanceled: function(args) {
- var that = this;
- if (!that._pendingNavigationArgs || that._pendingNavigationArgs.uri !== args.uri) {
- var currentItem = that.navigationManager.currentItem();
- if (currentItem)
- DX.utils.executeAsync(function() {
- var viewInfo = that._acquireViewInfo(currentItem, args.options);
- that._highlightCurrentNavigationCommand(viewInfo)
- });
- that._isNavigating = false
- }
- },
- _disposeRemovedViews: function() {
- var that = this,
- args;
- $.each(that._viewLinksHash, function(key, link) {
- if (!link.linkCount) {
- args = {viewInfo: link.viewInfo};
- that._processEvent("viewDisposing", args, args.viewInfo.model);
- that._disposeView(link.viewInfo);
- that._processEvent("viewDisposed", args, args.viewInfo.model);
- delete that._viewLinksHash[key]
- }
- })
- },
- _onViewHidden: function(viewInfo) {
- var args = {viewInfo: viewInfo};
- this._processEvent("viewHidden", args, args.viewInfo.model)
- },
- _disposeView: function(viewInfo) {
- var commands = viewInfo.commands || [];
- $.each(commands, function(index, command) {
- command._dispose()
- })
- },
- _acquireViewInfo: function(navigationItem, navigateOptions) {
- var viewInfo = this.viewCache.getView(navigationItem.key);
- if (!viewInfo) {
- viewInfo = this._createViewInfo(navigationItem, navigateOptions);
- this._obtainViewLink(viewInfo);
- this.viewCache.setView(navigationItem.key, viewInfo)
- }
- return viewInfo
- },
- _processEvent: function(eventName, args, model) {
- this._callComponentMethod(eventName, args);
- if (this[eventName] && this[eventName].fire)
- this[eventName].fire(args);
- var modelMethod = (model || {})[eventName];
- if (modelMethod)
- modelMethod.call(model, args)
- },
- _createViewInfo: function(navigationItem, navigateOptions) {
- var uri = navigationItem.uri,
- routeData = this.router.parse(uri);
- var viewInfo = {
- viewName: routeData.view,
- routeData: routeData,
- uri: uri,
- key: navigationItem.key,
- canBack: this.canBack(),
- navigateOptions: navigateOptions,
- previousViewInfo: this._getPreviousViewInfo(navigateOptions)
- };
- return viewInfo
- },
- _createViewModel: function(viewInfo) {
- this._processEvent("beforeViewSetup", {viewInfo: viewInfo});
- viewInfo.model = viewInfo.model || this._callViewCodeBehind(viewInfo);
- this._processEvent("afterViewSetup", {viewInfo: viewInfo})
- },
- _createViewCommands: function(viewInfo) {
- viewInfo.commands = viewInfo.model.commands || [];
- if (viewInfo.canBack && this._applicationMode !== "webSite")
- this._appendBackCommand(viewInfo)
- },
- _callViewCodeBehind: function(viewInfo) {
- var setupFunc = $.noop,
- routeData = viewInfo.routeData;
- if (routeData.view in this.namespace)
- setupFunc = this.namespace[routeData.view];
- return setupFunc.call(this.namespace, routeData, viewInfo) || {}
- },
- _appendBackCommand: function(viewInfo) {
- var commands = viewInfo.commands,
- that = this,
- stackKey = this.navigationManager.currentStackKey,
- backTitle = BACK_COMMAND_TITLE;
- if (that._options.useViewTitleAsBackText)
- backTitle = ((viewInfo.previousViewInfo || {}).model || {}).title || backTitle;
- var toMergeTo = [new DX.framework.dxCommand({
- id: "back",
- title: backTitle,
- behavior: "back",
- action: function() {
- that.back({stack: stackKey})
- },
- icon: "arrowleft",
- type: "back"
- })];
- var result = DX.framework.utils.mergeCommands(toMergeTo, commands);
- commands.length = 0;
- commands.push.apply(commands, result)
- },
- _showView: function(viewInfo, direction) {
- var that = this;
- var eventArgs = {
- viewInfo: viewInfo,
- direction: direction
- };
- that._processEvent("viewShowing", eventArgs, viewInfo.model);
- return that._showViewImpl(eventArgs.viewInfo, eventArgs.direction).done(function() {
- DX.utils.executeAsync(function() {
- that._processEvent("viewShown", eventArgs, viewInfo.model);
- that._disposeRemovedViews()
- })
- })
- },
- _highlightCurrentNavigationCommand: function(viewInfo) {
- var that = this,
- selectedCommand,
- currentUri = viewInfo.uri,
- currentNavigationItemId = viewInfo.model && viewInfo.model.currentNavigationItemId;
- if (currentNavigationItemId !== undefined)
- $.each(this.navigation, function(index, command) {
- if (command.option("id") === currentNavigationItemId) {
- selectedCommand = command;
- return false
- }
- });
- if (!selectedCommand)
- $.each(this.navigation, function(index, command) {
- var commandUri = command.option("action");
- if (DX.utils.isString(commandUri)) {
- commandUri = commandUri.replace(/^#+/, "");
- if (commandUri === that.navigationManager.rootUri()) {
- selectedCommand = command;
- return false
- }
- }
- });
- $.each(this.navigation, function(index, command) {
- if (command === selectedCommand && command.option("highlighted"))
- command.optionChanged.fireWith(command, ["highlighted", true, true]);
- command.option("highlighted", command === selectedCommand)
- })
- },
- _setViewLoadingState: DX.abstract,
- _showViewImpl: DX.abstract,
- _obtainViewLink: function(viewInfo) {
- var key = viewInfo.key;
- if (!this._viewLinksHash[key])
- this._viewLinksHash[key] = {
- viewInfo: viewInfo,
- linkCount: 1
- };
- else
- this._viewLinksHash[key].linkCount++
- },
- _releaseViewLink: function(viewInfo) {
- if (this._viewLinksHash[viewInfo.key] === undefined)
- DX.utils.logger.warn("A view with the '" + viewInfo.key + "' key doesn't exist");
- if (this._viewLinksHash[viewInfo.key].linkCount === 0)
- DX.utils.logger.warn("A view with the '" + viewInfo.key + "' key has already been released");
- this._viewLinksHash[viewInfo.key].linkCount--
- },
- navigate: function(uri, options) {
- var that = this;
- if ($.isPlainObject(uri)) {
- uri = that.router.format(uri);
- if (uri === false)
- throw new Error("The passed object cannot be formatted into a uri string by router. An appropriate route should be registered.");
- }
- if (!that._initState)
- that.init().done(function() {
- that.restoreState();
- that.navigate(uri, options)
- });
- else if (that._initState === INIT_COMPLETE)
- that.navigationManager.navigate(uri, options);
- else
- throw new Error("Unable to navigate. Application is being initialized. Consider using the 'HtmlApplication.navigating' event to alter the navigation logic.");
- },
- canBack: function(stackKey) {
- return this.navigationManager.canBack(stackKey)
- },
- _getPreviousViewInfo: function(navigateOptions) {
- var previousNavigationItem = this.navigationManager.previousItem(navigateOptions.stack),
- result;
- if (previousNavigationItem)
- result = this.viewCache.getView(previousNavigationItem.key);
- return result
- },
- back: function(options) {
- this.navigationManager.back(options)
- },
- saveState: function() {
- this.stateManager.saveState()
- },
- restoreState: function() {
- this.stateManager.restoreState()
- },
- clearState: function() {
- this.stateManager.clearState()
- }
- })
- })(jQuery, DevExpress);
- /*! Module framework, file framework.html.js */
- (function($, DX, undefined) {
- DX.framework.html = {
- layoutControllers: [],
- layoutSets: {}
- }
- })(jQuery, DevExpress);
- /*! Module framework, file framework.widgetCommandAdapters.js */
- (function($, DX) {
- var commandToContainer = DX.framework.utils.commandToContainer,
- DX_COMMAND_TO_WIDGET_ADAPTER = "dxCommandToWidgetAdapter";
- var WidgetItemWrapperBase = DX.Class.inherit({
- ctor: function(command, containerOptions) {
- this.command = command;
- this.containerOptions = containerOptions;
- this._createWidgetItem(command, containerOptions);
- this._commandChangedHandler = $.proxy(this._onCommandChanged, this);
- command.optionChanged.add(this._commandChangedHandler)
- },
- _createWidgetItem: function(command, containerOptions) {
- this.widgetItem = $.extend({
- command: command,
- containerOptions: containerOptions
- }, containerOptions, command.option());
- this._updateItem()
- },
- _onCommandChanged: function(optionName, newValue, oldValue) {
- this.widgetItem[optionName] = newValue;
- this._updateItem(optionName, newValue, oldValue)
- },
- _updateItem: function(optionName, newValue, oldValue){},
- dispose: function() {
- if (this.command)
- this.command.optionChanged.remove(this._commandChangedHandler);
- delete this.command;
- delete this.containerOptions;
- delete this.widgetItem;
- delete this.updateItemHandler
- }
- });
- var WidgetAdapterBase = DX.Class.inherit({
- ctor: function($widgetElement) {
- this.$widgetElement = $widgetElement;
- this.$widgetElement.data(DX_COMMAND_TO_WIDGET_ADAPTER, this);
- this.widget = this._getWidgetByElement($widgetElement);
- this._widgetDisposingHandler = $.proxy(this._onWidgetDisposing, this);
- this.widget.disposing.add(this._widgetDisposingHandler);
- this.itemWrappers = []
- },
- addCommand: function(command, containerOptions) {
- var itemWrapper = this._createItemWrapper(command, containerOptions);
- this.itemWrappers.push(itemWrapper);
- this._addItemToWidget(itemWrapper);
- this.refresh();
- this._commandChangedHandler = $.proxy(this._onCommandChanged, this);
- itemWrapper.command.optionChanged.add(this._commandChangedHandler)
- },
- beginUpdate: function() {
- this.widget.beginUpdate()
- },
- endUpdate: function() {
- this.widget.endUpdate()
- },
- _onWidgetDisposing: function() {
- this.dispose(true)
- },
- _onCommandChanged: function(optionName, newValue, oldValue) {
- if (name !== "highlighted")
- this.refresh()
- },
- _addItemToWidget: function(itemWrapper) {
- var items = this.widget.option("items");
- items.push(itemWrapper.widgetItem)
- },
- refresh: function() {
- var items = this.widget.option("items");
- this.widget.option("items", items)
- },
- clear: function(widgetDisposing) {
- var that = this;
- $.each(that.itemWrappers, function(index, itemWrapper) {
- itemWrapper.command.optionChanged.remove(that._commandChangedHandler);
- itemWrapper.dispose()
- });
- this.itemWrappers.length = 0;
- if (!widgetDisposing)
- this._clearWidgetItems()
- },
- _clearWidgetItems: function() {
- this.widget.option("items", [])
- },
- dispose: function(widgetDisposing) {
- this.clear(widgetDisposing);
- if (this.widget) {
- this.widget.disposing.remove(this._widgetDisposingHandler);
- this.$widgetElement.removeData(DX_COMMAND_TO_WIDGET_ADAPTER);
- delete this.widget;
- delete this.$widgetElement
- }
- }
- });
- var CommandToWidgetAdapter = DX.Class.inherit({
- ctor: function(createAdapter) {
- this.createAdapter = createAdapter
- },
- _getWidgetAdapter: function($container) {
- var widgetAdapter = $container.data(DX_COMMAND_TO_WIDGET_ADAPTER);
- if (!widgetAdapter)
- widgetAdapter = this.createAdapter($container);
- return widgetAdapter
- },
- addCommand: function($container, command, containerOptions) {
- var widgetAdapter = this._getWidgetAdapter($container);
- widgetAdapter.addCommand(command, containerOptions)
- },
- clearContainer: function($container) {
- var widgetAdapter = this._getWidgetAdapter($container);
- widgetAdapter.clear()
- },
- beginUpdate: function($container) {
- var widgetAdapter = this._getWidgetAdapter($container);
- widgetAdapter.beginUpdate()
- },
- endUpdate: function($container) {
- var widgetAdapter = this._getWidgetAdapter($container);
- widgetAdapter.endUpdate()
- }
- });
- var dxToolbarItemWrapper = WidgetItemWrapperBase.inherit({_updateItem: function() {
- var widgetItem = this.widgetItem,
- command = this.command,
- containerOptions = this.containerOptions,
- location = commandToContainer.resolvePropertyValue(command, containerOptions, "location"),
- optionsTarget;
- widgetItem.location = location;
- if (location === "menu")
- optionsTarget = widgetItem;
- else {
- optionsTarget = $.extend({}, widgetItem);
- widgetItem.options = optionsTarget;
- widgetItem.widget = "button"
- }
- optionsTarget.text = commandToContainer.resolveTextValue(command, containerOptions);
- optionsTarget.disabled = command.option("disabled");
- optionsTarget.icon = commandToContainer.resolveIconValue(command, containerOptions, "icon");
- optionsTarget.iconSrc = commandToContainer.resolveIconValue(command, containerOptions, "iconSrc");
- optionsTarget.type = commandToContainer.resolveTypeValue(command, containerOptions)
- }});
- var dxToolbarAdapter = WidgetAdapterBase.inherit({
- ctor: function($widgetElement) {
- this.callBase($widgetElement);
- this.widget.option("itemClickAction", $.proxy(this._onToolbarItemClick, this))
- },
- _onToolbarItemClick: function(e) {
- if (e.itemData.command)
- e.itemData.command.execute(e)
- },
- _getWidgetByElement: function($element) {
- return $element.dxToolbar("instance")
- },
- _createItemWrapper: function(command, containerOptions) {
- return new dxToolbarItemWrapper(command, containerOptions)
- },
- addCommand: function(command, containerOptions) {
- this.callBase(command, containerOptions);
- this.widget.option("visible", true)
- }
- });
- var dxActionSheetItemWrapper = WidgetItemWrapperBase.inherit({_updateItem: function() {
- var widgetItem = this.widgetItem,
- command = this.command,
- containerOptions = this.containerOptions;
- widgetItem.text = commandToContainer.resolveTextValue(command, containerOptions);
- widgetItem.icon = commandToContainer.resolveIconValue(command, containerOptions, "icon");
- widgetItem.iconSrc = commandToContainer.resolveIconValue(command, containerOptions, "iconSrc")
- }});
- var dxActionSheetAdapter = WidgetAdapterBase.inherit({
- _createItemWrapper: function(command, containerOptions) {
- return new dxActionSheetItemWrapper(command, containerOptions)
- },
- _getWidgetByElement: function($element) {
- return $element.dxActionSheet("instance")
- }
- });
- var dxListItemWrapper = WidgetItemWrapperBase.inherit({
- _createWidgetItem: function(command, containerOptions) {
- this.callBase(command, containerOptions);
- this.widgetItem.clickAction = $.proxy(this._itemClick, this)
- },
- _updateItem: function() {
- var widgetItem = this.widgetItem,
- command = this.command,
- containerOptions = this.containerOptions;
- widgetItem.title = commandToContainer.resolveTextValue(command, containerOptions);
- widgetItem.icon = commandToContainer.resolveIconValue(command, containerOptions, "icon");
- widgetItem.iconSrc = commandToContainer.resolveIconValue(command, containerOptions, "iconSrc")
- },
- _itemClick: function(e) {
- if (!this.widgetItem.disabled)
- this.command.execute(e)
- }
- });
- var dxListAdapter = WidgetAdapterBase.inherit({
- _createItemWrapper: function(command, containerOptions) {
- return new dxListItemWrapper(command, containerOptions)
- },
- _getWidgetByElement: function($element) {
- return $element.dxList("instance")
- }
- });
- var dxNavBarItemWrapper = WidgetItemWrapperBase.inherit({_updateItem: function(optionName, newValue, oldValue) {
- var command = this.command,
- containerOptions = this.containerOptions;
- if (optionName !== "highlighted") {
- this.widgetItem.text = commandToContainer.resolveTextValue(command, containerOptions);
- this.widgetItem.icon = commandToContainer.resolveIconValue(command, containerOptions, "icon");
- this.widgetItem.iconSrc = commandToContainer.resolveIconValue(command, containerOptions, "iconSrc")
- }
- }});
- var dxNavBarAdapter = WidgetAdapterBase.inherit({
- ctor: function($widgetElement) {
- this.callBase($widgetElement);
- this.widget.option("itemClickAction", $.proxy(this._onNavBarItemClick, this))
- },
- _onNavBarItemClick: function(e) {
- var items = this.widget.option("items");
- for (var i = items.length; --i; )
- items[i].command.option("highlighted", false);
- e.itemData.command.execute(e)
- },
- _getWidgetByElement: function($element) {
- return $element.dxNavBar("instance")
- },
- _createItemWrapper: function(command, containerOptions) {
- return new dxNavBarItemWrapper(command, containerOptions)
- },
- addCommand: function(command, containerOptions) {
- this.callBase(command, containerOptions);
- this._updateSelectedIndex()
- },
- _onCommandChanged: function(name, newValue, oldValue) {
- if (name !== "highlighted" || newValue)
- this._updateSelectedIndex();
- this.callBase(name, newValue, oldValue)
- },
- _updateSelectedIndex: function() {
- var items = this.widget.option("items");
- for (var i = 0, itemsCount = items.length; i < itemsCount; i++)
- if (items[i].highlighted) {
- this.widget.option("selectedIndex", i);
- break
- }
- }
- });
- var dxPivotItemWrapper = WidgetItemWrapperBase.inherit({_updateItem: function(optionName, newValue, oldValue) {
- if (optionName === "title")
- this.widgetItem.title = commandToContainer.resolveTextValue(this.command, this.containerOptions)
- }});
- var dxPivotAdapter = WidgetAdapterBase.inherit({
- ctor: function($widgetElement) {
- this.callBase($widgetElement);
- this._highlighting = false;
- this.widget.option("itemSelectAction", $.proxy(this._onPivotItemSelect, this))
- },
- _onPivotItemSelect: function(e) {
- if (e.itemData && e.itemData.command)
- e.itemData.command.execute(e)
- },
- _getWidgetByElement: function($element) {
- return $element.dxPivot("instance")
- },
- _createItemWrapper: function(command, containerOptions) {
- return new dxToolbarItemWrapper(command, containerOptions)
- },
- addCommand: function(command, containerOptions) {
- this.callBase(command, containerOptions);
- this._updateSelectedIndex()
- },
- _onCommandChanged: function(optionName, newValue, oldValue) {
- if (optionName === "visible")
- this._rerenderPivot();
- else if (optionName !== "highlighted" || newValue)
- this._updateSelectedIndex()
- },
- _addItemToWidget: function(itemWrapper) {
- if (itemWrapper.command.option("visible"))
- this.callBase(itemWrapper)
- },
- _updateSelectedIndex: function() {
- var pivot = this.widget,
- items = pivot.option("items") || [];
- DX.fx.off = true;
- for (var i = 0, itemsCount = items.length; i < itemsCount; i++)
- if (items[i].highlighted) {
- if (this._highlighting && pivot.option("selectedIndex") === i)
- this._highlighting = false;
- pivot.option("selectedIndex", i);
- break
- }
- DX.fx.off = false
- },
- _rerenderPivot: function() {
- var that = this;
- that.widget.option("items", []);
- $.each(that.itemWrappers, function(index, itemWrapper) {
- if (itemWrapper.command.option("visible"))
- that._addItemToWidget(itemWrapper)
- });
- that.refresh();
- that._updateSelectedIndex()
- }
- });
- var dxSlideOutItemWrapper = WidgetItemWrapperBase.inherit({_updateItem: function(optionName, newValue, oldValue) {
- var widgetItem = this.widgetItem,
- command = this.command,
- containerOptions = this.containerOptions;
- if (name !== "highlighted") {
- widgetItem.title = commandToContainer.resolveTextValue(command, containerOptions);
- widgetItem.icon = commandToContainer.resolveIconValue(command, containerOptions, "icon");
- widgetItem.iconSrc = commandToContainer.resolveIconValue(command, containerOptions, "iconSrc")
- }
- }});
- var dxSlideOutAdapter = WidgetAdapterBase.inherit({
- ctor: function($widgetElement) {
- this.callBase($widgetElement);
- this.widget.option("itemClickAction", $.proxy(this._onSlideOutItemClick, this))
- },
- _onSlideOutItemClick: function(e) {
- e.itemData.command.execute(e)
- },
- _getWidgetByElement: function($element) {
- return $element.dxSlideOut("instance")
- },
- _createItemWrapper: function(command, containerOptions) {
- return new dxSlideOutItemWrapper(command, containerOptions)
- },
- _updateSelectedIndex: function() {
- var items = this.widget.option("items") || [];
- for (var i = 0, itemsCount = items.length; i < itemsCount; i++)
- if (items[i].highlighted) {
- this.widget.option("selectedIndex", i);
- break
- }
- },
- addCommand: function(command, containerOptions) {
- this.callBase(command, containerOptions);
- this._updateSelectedIndex()
- },
- _onCommandChanged: function(name, newValue, oldValue) {
- if (name !== "highlighted" || newValue)
- this._updateSelectedIndex();
- this.callBase(name, newValue, oldValue)
- }
- });
- var adapters = DX.framework.html.commandToDXWidgetAdapters = {};
- adapters.dxToolbar = new CommandToWidgetAdapter(function($widgetElement) {
- return new dxToolbarAdapter($widgetElement)
- });
- adapters.dxActionSheet = new CommandToWidgetAdapter(function($widgetElement) {
- return new dxActionSheetAdapter($widgetElement)
- });
- adapters.dxList = new CommandToWidgetAdapter(function($widgetElement) {
- return new dxListAdapter($widgetElement)
- });
- adapters.dxNavBar = new CommandToWidgetAdapter(function($widgetElement) {
- return new dxNavBarAdapter($widgetElement)
- });
- adapters.dxPivot = new CommandToWidgetAdapter(function($widgetElement) {
- return new dxPivotAdapter($widgetElement)
- });
- adapters.dxSlideOut = new CommandToWidgetAdapter(function($widgetElement) {
- return new dxSlideOutAdapter($widgetElement)
- });
- DX.framework.html.WidgetItemWrapperBase = WidgetItemWrapperBase;
- DX.framework.html.WidgetAdapterBase = WidgetAdapterBase
- })(jQuery, DevExpress);
- /*! Module framework, file framework.commandManager.js */
- (function($, DX, undefined) {
- var Class = DX.Class,
- ui = DevExpress.ui;
- DX.framework.dxCommandContainer = DX.DOMComponent.inherit({
- ctor: function(element, options) {
- if ($.isPlainObject(element)) {
- options = element;
- element = $("<div />")
- }
- this.callBase(element, options)
- },
- _setDefaultOptions: function() {
- this.callBase();
- this.option({id: null})
- },
- _render: function() {
- this.callBase();
- this._element().addClass("dx-command-container")
- }
- });
- DX.registerComponent("dxCommandContainer", DX.framework.dxCommandContainer);
- DX.framework.html.CommandManager = Class.inherit({
- ctor: function(options) {
- options = options || {};
- this.defaultWidgetAdapter = options.defaultWidgetAdapter || this._getDefaultWidgetAdapter();
- this.commandMapping = options.commandMapping || new DX.framework.CommandMapping
- },
- _getDefaultWidgetAdapter: function() {
- return {
- addCommand: this._defaultAddCommand,
- clearContainer: $.noop
- }
- },
- _getContainerAdapter: function($container) {
- var componentNames = $container.data("dxComponents"),
- adapters = DX.framework.html.commandToDXWidgetAdapters;
- if (componentNames)
- for (var index in componentNames) {
- var widgetName = componentNames[index];
- if (widgetName in adapters)
- return adapters[widgetName]
- }
- return this.defaultWidgetAdapter
- },
- findCommands: function($view) {
- var result = $.map($view.addBack().find(".dx-command"), function(element) {
- return $(element).dxCommand("instance")
- });
- return result
- },
- findCommandContainers: function($markup) {
- var result = $.map($markup.find(".dx-command-container"), function(element) {
- return $(element).dxCommandContainer("instance")
- });
- return result
- },
- _checkCommandId: function(id, command) {
- if (id === null)
- throw new Error("The command's 'id' option should be specified.\r\nProcessed markup: " + command._element().get(0).outerHTML);
- },
- renderCommandsToContainers: function(commands, containers) {
- var that = this,
- commandHash = {},
- commandIds = [];
- $.each(commands, function(i, command) {
- var id = command.option("id");
- that._checkCommandId(id, command);
- commandIds.push(id);
- commandHash[id] = command
- });
- that.commandMapping.checkCommandsExist(commandIds);
- $.each(containers, function(k, container) {
- var commandInfos = [];
- $.each(commandHash, function(id, command) {
- var commandId = id;
- var commandOptions = that.commandMapping.getCommandMappingForContainer(commandId, container.option("id"));
- if (commandOptions)
- commandInfos.push({
- command: command,
- options: commandOptions
- })
- });
- if (commandInfos.length)
- that._attachCommandsToContainer(container._element(), commandInfos)
- })
- },
- clearContainer: function(container) {
- var $container = container._element(),
- adapter = this._getContainerAdapter($container);
- adapter.clearContainer($container)
- },
- _arrangeCommandsToContainers: function(commands, containers) {
- DX.utils.logger.warn("The _arrangeCommandsToContainers function is deprecated. Use renderCommandsToContainers instead");
- this.renderCommandsToContainers(commands, containers)
- },
- _attachCommandsToContainer: function($container, commandInfos) {
- var adapter = this._getContainerAdapter($container);
- if (adapter.beginUpdate)
- adapter.beginUpdate($container);
- $.each(commandInfos, function(index, commandInfo) {
- adapter.addCommand($container, commandInfo.command, commandInfo.options)
- });
- if (adapter.endUpdate)
- adapter.endUpdate($container);
- return true
- },
- _defaultAddCommand: function($container, command, options) {
- var $source = command._element();
- if ($source) {
- $container.append($source);
- $source.on("dxclick", function() {
- command.execute()
- })
- }
- }
- })
- })(jQuery, DevExpress);
- /*! Module framework, file framework.layoutController.js */
- (function($, DX, undefined) {
- var Class = DX.Class;
- var HIDDEN_BAG_ID = "__hidden-bag";
- var TRANSITION_SELECTOR = ".dx-transition:not(.dx-transition .dx-transition)";
- var transitionSelector = function(transitionName) {
- return ".dx-transition-" + transitionName
- };
- DX.framework.html.DefaultLayoutController = Class.inherit({
- ctor: function(options) {
- options = options || {};
- this.name = options.layoutTemplateName || options.name || "";
- this._disableViewLoadingState = options.disableViewLoadingState;
- this._layoutModel = options.layoutModel || {};
- this._defaultPaneName = options.defaultPaneName || "content";
- this.viewReleased = $.Callbacks();
- this.viewRendered = $.Callbacks()
- },
- init: function(options) {
- options = options || {};
- this._visibleViews = {};
- this._$viewPort = options.$viewPort || $("body");
- this._$hiddenBag = options.$hiddenBag || $(document.getElementById(HIDDEN_BAG_ID)) || $("<div/>").hide().appendTo("body");
- this._commandManager = options.commandManager;
- this._viewEngine = options.viewEngine;
- this._prepareTemplates();
- this.DEFAULT_LOADING_TITLE = DX.localization.localizeString("@Loading");
- if (options.templateContext) {
- this._templateContextChanged = options.templateContext.optionChanged;
- this._proxiedTemplateContextChangedHandler = $.proxy(this._templateContextChangedHandler, this)
- }
- },
- activate: function() {
- var $rootElement = this._getRootElement();
- this._justActivated = true;
- $rootElement.show();
- this._moveToViewPort($rootElement);
- this._attachRefreshViewRequiredHandler()
- },
- deactivate: function() {
- this._releaseVisibleViews();
- this._moveToHiddenBag(this._getRootElement());
- this._detachRefreshViewRequiredHandler()
- },
- _releaseVisibleViews: function() {
- var that = this;
- $.each(this._visibleViews, function(index, viewInfo) {
- that._hideView(viewInfo);
- that._releaseView(viewInfo)
- });
- this._visibleViews = {}
- },
- _templateContextChangedHandler: function() {
- $.each(this._visibleViews, $.proxy(function(index, viewInfo) {
- this.showView(viewInfo)
- }, this))
- },
- _attachRefreshViewRequiredHandler: function() {
- if (this._templateContextChanged)
- this._templateContextChanged.add(this._proxiedTemplateContextChangedHandler)
- },
- _detachRefreshViewRequiredHandler: function() {
- if (this._templateContextChanged)
- this._templateContextChanged.remove(this._proxiedTemplateContextChangedHandler)
- },
- _getPreviousViewInfo: function(viewInfo) {
- return this._visibleViews[this._getViewPaneName(viewInfo.viewTemplateInfo)]
- },
- _prepareTemplates: function() {
- var that = this;
- var $layoutTemplate = that._viewEngine.findLayoutTemplate(this._getLayoutTemplateName()).removeClass("dx-hidden");
- that._$layoutTemplate = $layoutTemplate;
- that._$mainLayout = that._createEmptyLayout().show();
- that._viewEngine._applyTemplate(that._$mainLayout, that._layoutModel);
- that._$navigationWidget = that._createNavigationWidget();
- that._loadingStateViewInfo = that._createLoadingStateViewInfo($layoutTemplate)
- },
- renderNavigation: function(navigationCommands) {
- this._clearNavigationWidget();
- this._renderNavigationImpl(navigationCommands)
- },
- _renderNavigationImpl: function(navigationCommands) {
- this._renderCommands(this._$mainLayout, navigationCommands)
- },
- _createNavigationWidget: function() {
- var result;
- this._$mainLayout.find(".dx-command-container").each(function() {
- var container = $(this).dxCommandContainer("instance");
- if (container.option("id") === "global-navigation")
- result = $(this)
- });
- return result
- },
- _clearNavigationWidget: function() {
- if (this._$navigationWidget)
- this._commandManager.clearContainer(this._$navigationWidget.dxCommandContainer("instance"))
- },
- _getRootElement: function() {
- return this._$mainLayout
- },
- _getViewFrame: function(viewInfo) {
- return this._$mainLayout
- },
- _getLayoutTemplateName: function() {
- return this.name
- },
- _applyModelToTransitionElements: function($markup, model) {
- var that = this;
- this._getTransitionElements($markup).each(function(i, item) {
- that._viewEngine._applyTemplate($(item).children(), model)
- })
- },
- _createLoadingStateViewInfo: function($layoutTemplate) {
- var $loadingStateView = $layoutTemplate.clone().addClass("dx-loading-state-view").appendTo(this._$hiddenBag),
- model = {title: ko.observable()};
- this._viewEngine._createComponents($loadingStateView);
- this._applyModelToTransitionElements($loadingStateView, model);
- var result = {
- model: model,
- renderResult: {
- $markup: $loadingStateView,
- $viewItems: $()
- },
- isLoadingStateView: true
- };
- this._appendViewToLayout(result);
- return result
- },
- _createViewLayoutTemplate: function() {
- var that = this;
- var $viewLayoutTemplate = that._$layoutTemplate.clone().appendTo(that._$hiddenBag);
- that._viewEngine._createComponents($viewLayoutTemplate);
- return $viewLayoutTemplate
- },
- _createEmptyLayout: function() {
- var that = this;
- var $result = that._$layoutTemplate.clone().appendTo(that._$hiddenBag);
- that._viewEngine._createComponents($result);
- that._removeTransitionContent($result);
- return $result
- },
- _removeTransitionContent: function($markup) {
- var $transitionElements = this._getTransitionElements($markup);
- $transitionElements.children().remove()
- },
- _getTransitionElements: function($markup) {
- return $markup.find(TRANSITION_SELECTOR).addBack(TRANSITION_SELECTOR)
- },
- setViewLoadingState: function(viewInfo, direction) {
- var that = this;
- if (that._disableViewLoadingState)
- return $.Deferred().resolve().promise();
- var loadingStateViewInfo = $.extend({}, viewInfo, that._loadingStateViewInfo);
- that._loadingStateViewInfo.model.title((viewInfo.viewTemplateInfo || {}).title || this.DEFAULT_LOADING_TITLE);
- return that._showViewImpl(loadingStateViewInfo, direction)
- },
- showView: function(viewInfo, direction) {
- var that = this;
- var previousViewInfo = that._getPreviousViewInfo(viewInfo);
- if (previousViewInfo && previousViewInfo.isLoadingStateView)
- direction = "none";
- that._ensureViewRendered(viewInfo);
- return this._showViewImpl(viewInfo, direction).done(function() {
- that._onViewShown(viewInfo)
- })
- },
- disposeView: function(viewInfo) {
- this._clearRenderResult(viewInfo)
- },
- _clearRenderResult: function(viewInfo) {
- if (viewInfo.renderResult) {
- viewInfo.renderResult.$markup.remove();
- viewInfo.renderResult.$viewItems.remove();
- delete viewInfo.renderResult
- }
- },
- _prepareViewTemplate: function($viewTemplate, viewInfo) {
- this._viewEngine._createComponents($viewTemplate)
- },
- _renderViewImpl: function($viewTemplate, viewInfo) {
- var that = this,
- $layout = this._createViewLayoutTemplate(),
- $viewItems = $viewTemplate.children(),
- isSimplifiedMarkup = true,
- outOfContentItems = $();
- this._applyModelToTransitionElements($layout, viewInfo.model);
- this._viewEngine._applyLayoutCore($viewTemplate, $layout);
- $viewItems.each(function(i, item) {
- var $item = $(item);
- that._viewEngine._applyTemplate($item, viewInfo.model);
- if ($item.is(".dx-command,.dx-content,script"))
- isSimplifiedMarkup = false;
- else
- outOfContentItems = outOfContentItems.add($item)
- });
- if (outOfContentItems.length && !isSimplifiedMarkup)
- throw new Error("All the dxView element children should be either of the dxCommand or dxContent type.\r\nProcessed markup: " + outOfContentItems[0].outerHTML);
- viewInfo.renderResult = viewInfo.renderResult || {};
- viewInfo.renderResult.$viewItems = $viewItems;
- viewInfo.renderResult.$markup = $layout
- },
- _renderCommands: function($markup, commands) {
- var commandContainers = this._findCommandContainers($markup);
- this._commandManager.renderCommandsToContainers(commands, commandContainers)
- },
- _applyViewCommands: function(viewInfo) {
- var $viewItems = viewInfo.renderResult.$viewItems,
- $markup = viewInfo.renderResult.$markup,
- viewCommands = this._commandManager.findCommands($viewItems);
- viewInfo.commands = DX.framework.utils.mergeCommands(viewInfo.commands || [], viewCommands);
- this._renderCommands($markup, viewInfo.commands)
- },
- _findCommandContainers: function($markup) {
- return this._viewEngine._createComponents($markup, ["dxCommandContainer"])
- },
- _ensureViewRendered: function(viewInfo) {
- var viewTemplateInstance = viewInfo.$viewTemplate ? viewInfo.$viewTemplate.dxView("instance") : this._viewEngine.findViewComponent(viewInfo.viewName),
- currentViewId = viewTemplateInstance.getId(),
- $cachedMarkup = viewInfo.renderResult && viewInfo.renderResult.markupCache[currentViewId];
- if ($cachedMarkup)
- viewInfo.renderResult.$markup = $cachedMarkup;
- else {
- this._renderView(viewInfo);
- viewInfo.renderResult.markupCache = viewInfo.renderResult.markupCache || {};
- viewInfo.renderResult.markupCache[currentViewId] = viewInfo.renderResult.$markup
- }
- },
- _renderView: function(viewInfo) {
- var $viewTemplate = viewInfo.$viewTemplate || this._viewEngine.findViewTemplate(viewInfo.viewName);
- this._prepareViewTemplate($viewTemplate, viewInfo);
- this._renderViewImpl($viewTemplate, viewInfo);
- this._applyViewCommands(viewInfo);
- this._appendViewToLayout(viewInfo);
- $viewTemplate.remove();
- this._onRenderComplete(viewInfo);
- this.viewRendered.fire(viewInfo)
- },
- _appendViewToLayout: function(viewInfo) {
- var that = this,
- $viewFrame = that._getViewFrame(viewInfo),
- $markup = viewInfo.renderResult.$markup,
- $transitionContentElements = $();
- $.each($markup.find(".dx-content-placeholder"), function(index, el) {
- var placeholder = $(el).dxContentPlaceholder("instance");
- placeholder.prepareTransition()
- });
- $.each(that._getTransitionElements($viewFrame), function(index, transitionElement) {
- var $transition = $(transitionElement),
- $viewElement = $markup.find(transitionSelector($transition.data("dx-transition-name"))).children();
- that._hideViewElements($viewElement);
- $transition.append($viewElement);
- $transitionContentElements = $transitionContentElements.add($viewElement)
- });
- that._$mainLayout.append(viewInfo.renderResult.$viewItems.filter(".dx-command"));
- $markup.remove();
- viewInfo.renderResult.$markup = $transitionContentElements
- },
- _onRenderComplete: function(viewInfo){},
- _onViewShown: function(viewInfo) {
- $(document).trigger("dx.viewchanged")
- },
- _doTransition: function(viewInfo, direction) {
- var that = this,
- deferred = $.Deferred();
- var transitions = $.map(viewInfo.renderResult.$markup, function(transitionContent) {
- var $transitionContent = $(transitionContent),
- $transition = $transitionContent.parent(),
- transitionType = that._disableTransitions ? "none" : $transition.data("dx-transition-type");
- return {
- destination: $transition,
- source: $transitionContent,
- type: transitionType || "none",
- direction: direction || "none"
- }
- });
- that._executeTransitions(transitions).done(function() {
- deferred.resolve()
- });
- return deferred.promise()
- },
- _hideView: function(viewInfo) {
- if (viewInfo.renderResult)
- this._hideViewElements(viewInfo.renderResult.$markup)
- },
- _showViewImpl: function(viewInfo, direction) {
- var that = this,
- deferred = $.Deferred();
- if (this._justActivated) {
- this._justActivated = false;
- direction = "none"
- }
- return that._doTransition(viewInfo, direction).done(function() {
- that._changeView(viewInfo)
- })
- },
- _releaseView: function(viewInfo) {
- this.viewReleased.fireWith(this, [viewInfo])
- },
- _getViewPortElement: function() {
- return this._$viewPort
- },
- _getHiddenBagElement: function() {
- return this._$hiddenBag
- },
- _changeView: function(viewInfo) {
- var that = this;
- var previousViewInfo = that._getPreviousViewInfo(viewInfo);
- if (previousViewInfo && previousViewInfo !== viewInfo) {
- that._hideView(previousViewInfo);
- if (!previousViewInfo.isLoadingStateView)
- this._releaseView(previousViewInfo)
- }
- this._visibleViews[this._getViewPaneName(viewInfo.viewTemplateInfo)] = viewInfo
- },
- _getViewPaneName: function(viewTemplateInfo) {
- return this._defaultPaneName
- },
- _hideViewElements: function($elements) {
- DX.utils.triggerHidingEvent($elements.filter(".dx-active-view"));
- this._patchIDs($elements);
- this._disableInputs($elements);
- $elements.removeClass("dx-active-view").addClass("dx-inactive-view")
- },
- _showViewElements: function($elements) {
- this._unpatchIDs($elements);
- this._enableInputs($elements);
- $elements.removeClass("dx-inactive-view").addClass("dx-active-view");
- DX.utils.triggerShownEvent($elements.filter(".dx-active-view"))
- },
- _executeTransitions: function(transitions) {
- var that = this;
- var animatedTransitions = $.map(transitions, function(transitionOptions) {
- that._showViewElements(transitionOptions.source);
- if (transitionOptions.source.children().length)
- return DX.framework.html.TransitionExecutor.create(transitionOptions.destination, transitionOptions)
- });
- var animatedDeferreds = $.map(animatedTransitions, function(transition) {
- transition.options.source.addClass("dx-transition-source");
- return transition.exec()
- });
- var result = $.when.apply($, animatedDeferreds).done(function() {
- $.each(animatedTransitions, function(index, transition) {
- transition.finalize();
- that._hideViewElements(transition.options.source.parent().find(".dx-active-view:not(.dx-transition-source)"));
- transition.options.source.removeClass("dx-transition-source")
- })
- });
- return result
- },
- _patchIDs: function($markup) {
- this._processIDs($markup, function(id) {
- var result = id;
- if (id.indexOf(HIDDEN_BAG_ID) === -1)
- result = HIDDEN_BAG_ID + "-" + id;
- return result
- })
- },
- _unpatchIDs: function($markup) {
- this._processIDs($markup, function(id) {
- var result = id;
- if (id.indexOf(HIDDEN_BAG_ID) === 0)
- result = id.substr(HIDDEN_BAG_ID.length + 1);
- return result
- })
- },
- _processIDs: function($markup, process) {
- var elementsWithIds = $markup.find("[id]");
- $.each(elementsWithIds, function(index, element) {
- var $el = $(element),
- id = $el.attr("id");
- $el.attr("id", process(id))
- })
- },
- _enableInputs: function($markup) {
- var $inputs = $markup.find(":input[data-disabled=true]");
- $.each($inputs, function(index, input) {
- $(input).removeAttr("disabled").removeAttr("data-disabled")
- })
- },
- _disableInputs: function($markup) {
- var $inputs = $markup.find(":input:not([disabled], [disabled=true])");
- $.each($inputs, function(index, input) {
- $(input).attr({
- disabled: true,
- "data-disabled": true
- })
- })
- },
- _moveToViewPort: function($items) {
- $items.appendTo(this._getViewPortElement());
- $items.find(".dx-visibility-change-handler").each(function() {
- $(this).triggerHandler("dxshown")
- })
- },
- _moveToHiddenBag: function($items) {
- $items.appendTo(this._getHiddenBagElement())
- }
- });
- var layoutSets = DX.framework.html.layoutSets;
- layoutSets["default"] = layoutSets["default"] || [];
- layoutSets["default"].push({controller: new DX.framework.html.DefaultLayoutController})
- })(jQuery, DevExpress);
- /*! Module framework, file framework.templateEngine.js */
- (function($, DX, undefined) {
- var Class = DX.Class;
- DX.framework.html.KnockoutJSTemplateEngine = Class.inherit({applyTemplate: function(template, model) {
- ko.applyBindings(model, $(template).get(0))
- }})
- })(jQuery, DevExpress);
- /*! Module framework, file framework.viewEngine.js */
- (function($, DX, undefined) {
- var Class = DX.Class,
- ui = DX.ui,
- _VIEW_ROLE = "dxView",
- _LAYOUT_ROLE = "dxLayout",
- lastViewId = 0;
- DX.framework[_VIEW_ROLE] = DX.DOMComponent.inherit({
- _setDefaultOptions: function() {
- this.callBase();
- this.option({
- name: null,
- title: null,
- layout: null
- })
- },
- ctor: function() {
- this.callBase.apply(this, arguments);
- this._id = ++lastViewId
- },
- _render: function() {
- this.callBase();
- this._element().addClass("dx-view")
- },
- getId: function() {
- return this._id
- }
- });
- DX.registerComponent(_VIEW_ROLE, DX.framework.dxView);
- DX.framework[_LAYOUT_ROLE] = DX.DOMComponent.inherit({
- _setDefaultOptions: function() {
- this.callBase();
- this.option({name: null})
- },
- _render: function() {
- this.callBase();
- this._element().addClass("dx-layout")
- }
- });
- DX.registerComponent(_LAYOUT_ROLE, DX.framework.dxLayout);
- DX.framework.dxViewPlaceholder = DX.DOMComponent.inherit({
- _setDefaultOptions: function() {
- this.callBase();
- this.option({viewName: null})
- },
- _render: function() {
- this.callBase();
- this._element().addClass("dx-view-placeholder")
- }
- });
- DX.registerComponent("dxViewPlaceholder", DX.framework.dxViewPlaceholder);
- var setupTransitionElement = function($element, transitionType, transitionName, contentCssPosition) {
- if (contentCssPosition === "absolute")
- $element.addClass("dx-transition-absolute");
- else
- $element.addClass("dx-transition-static");
- $element.addClass("dx-transition").addClass("dx-transition-" + transitionName);
- $element.data("dx-transition-type", transitionType);
- $element.data("dx-transition-name", transitionName)
- };
- var setupTransitionInnerElement = function($element) {
- $element.addClass("dx-transition-inner-wrapper")
- };
- DX.framework.dxTransition = DX.DOMComponent.inherit({
- _setDefaultOptions: function() {
- this.callBase();
- this.option({
- name: null,
- type: "slide"
- })
- },
- _render: function() {
- this.callBase();
- var element = this._element();
- setupTransitionElement(element, this.option("type"), this.option("name"), "absolute");
- element.wrapInner("<div/>");
- setupTransitionInnerElement(element.children())
- },
- _clean: function() {
- this.callBase();
- this._element().empty()
- }
- });
- DX.registerComponent("dxTransition", DX.framework.dxTransition);
- DX.framework.dxContentPlaceholder = DX.DOMComponent.inherit({
- _setDefaultOptions: function() {
- this.callBase();
- this.option({
- name: null,
- transition: "none",
- contentCssPosition: "absolute"
- })
- },
- _render: function() {
- this.callBase();
- var $element = this._element();
- $element.addClass("dx-content-placeholder").addClass("dx-content-placeholder-" + this.option("name"));
- setupTransitionElement($element, this.option("transition"), this.option("name"), this.option("contentCssPosition"))
- },
- prepareTransition: function() {
- var $element = this._element();
- if ($element.children(".dx-content").length === 0) {
- $element.wrapInner("<div>");
- $element.children().dxContent({targetPlaceholder: this.option("name")})
- }
- }
- });
- DX.registerComponent("dxContentPlaceholder", DX.framework.dxContentPlaceholder);
- DX.framework.dxContent = DX.DOMComponent.inherit({
- _setDefaultOptions: function() {
- this.callBase();
- this.option({targetPlaceholder: null})
- },
- _optionChanged: function(name) {
- this._refresh()
- },
- _clean: function() {
- this.callBase();
- this._element().removeClass(this._currentClass)
- },
- _render: function() {
- this.callBase();
- var element = this._element();
- element.addClass("dx-content");
- this._currentClass = "dx-content-" + this.option("targetPlaceholder");
- element.addClass(this._currentClass);
- setupTransitionInnerElement(element)
- }
- });
- DX.registerComponent("dxContent", DX.framework.dxContent);
- DX.framework.html.ViewEngine = Class.inherit({
- ctor: function(options) {
- options = options || {};
- this.$root = options.$root;
- this.device = options.device || {};
- this.templateEngine = options.templateEngine;
- this.dataOptionsAttributeName = options.dataOptionsAttributeName || "data-options";
- this._templateMap = {};
- this._pendingViewContainer = null;
- this.viewSelecting = $.Callbacks();
- this.modelFromViewDataExtended = $.Callbacks();
- this.layoutSelecting = $.Callbacks();
- this._templateContext = options.templateContext
- },
- init: function() {
- var that = this;
- this._initDefaultLayout();
- return this._loadExternalTemplates().done(function() {
- that._loadTemplatesFromMarkupCore(that.$root.children());
- that._processTemplates()
- })
- },
- _enumerateTemplates: function(processFn) {
- var that = this;
- $.each(that._templateMap, function(name, templatesByRoleMap) {
- $.each(templatesByRoleMap, function(role, templates) {
- $.each(templates, function(index, template) {
- processFn(template)
- })
- })
- })
- },
- _findComponent: function(name, role) {
- var components = (this._templateMap[name] || {})[role] || [],
- filter = this._templateContext && this._templateContext.option() || {};
- components = this._filterTemplates(filter, components);
- this._checkMatchedTemplates(components);
- return components[0]
- },
- _findTemplate: function(name, role) {
- var component = this._findComponent(name, role);
- if (!component)
- throw new Error("Error 404: Template not found. role: " + role + ", name: " + name);
- var $template = component._element(),
- $result = $template.clone();
- this._createComponents($result, [role]);
- return $result
- },
- _extendModelFromViewData: function($view, model) {
- DX.utils.extendFromObject(model, $view.data(_VIEW_ROLE).option());
- this.modelFromViewDataExtended.fire({
- view: $view,
- model: model
- })
- },
- _createComponents: function($markup, types) {
- var that = this;
- var result = [];
- $markup.find("*").addBack().filter("[" + that.dataOptionsAttributeName + "]").each(function(index, element) {
- var $element = $(element),
- optionsString = $element.attr(that.dataOptionsAttributeName),
- options;
- try {
- options = new Function("return {" + optionsString + "}")()
- }
- catch(ex) {
- throw new Error(DX.utils.stringFormat("Unable to parse options.\nMessage: {0};\nOptions value: {1}", ex, optionsString));
- }
- for (var componentName in options)
- if (!types || $.inArray(componentName, types) > -1)
- if ($element[componentName]) {
- $element[componentName](options[componentName]);
- result.push($element[componentName]("instance"))
- }
- });
- return result
- },
- _loadTemplatesFromMarkupCore: function($markup) {
- if ($markup.find("[data-dx-role]").length)
- throw Error("View templates should be updated according to the 13.1 changes. Go to http://dxpr.es/15ikrJA for more details");
- var that = this;
- $markup.appendTo(this.$root);
- DX.localization.localizeNode($markup);
- var components = that._createComponents($markup, [_VIEW_ROLE, _LAYOUT_ROLE]);
- $.each(components, function(index, component) {
- var $element = component._element();
- $element.addClass("dx-hidden");
- that._registerTemplateComponent(component);
- component._element().detach()
- })
- },
- _registerTemplateComponent: function(component) {
- var role = component.NAME,
- options = component.option(),
- templateName = options.name,
- componentsByRoleMap = this._templateMap[templateName] || {};
- componentsByRoleMap[role] = componentsByRoleMap[role] || [];
- componentsByRoleMap[role].push(component);
- this._templateMap[templateName] = componentsByRoleMap
- },
- _applyPartialViews: function($render) {
- var that = this;
- this._createComponents($render, ["dxViewPlaceholder"]);
- $.each($render.find(".dx-view-placeholder"), function() {
- var $partialPlaceholder = $(this);
- if ($partialPlaceholder.children().length)
- return;
- var viewName = $partialPlaceholder.data("dxViewPlaceholder").option("viewName"),
- $view = that._findTemplate(viewName, _VIEW_ROLE);
- that._applyPartialViews($view);
- $partialPlaceholder.append($view);
- $view.removeClass("dx-hidden")
- })
- },
- _ajaxImpl: function() {
- return $.ajax.apply($, arguments)
- },
- _loadTemplatesFromURL: function(url) {
- var that = this,
- options = this._getLoadOptions(),
- deferred = $.Deferred();
- this._ajaxImpl({
- url: options.winPhonePrefix + url,
- isLocal: options.isLocal,
- dataType: "html"
- }).done(function(data) {
- that._loadTemplatesFromMarkupCore(DX.utils.createMarkupFromString(data));
- deferred.resolve()
- }).fail(function(jqXHR, textStatus, errorThrown) {
- var error = new Error(DX.utils.stringFormat("Remote template cannot be loaded.\r\nUrl:{0}\r\nError:{1}.", url, errorThrown));
- deferred.reject(error)
- });
- return deferred.promise()
- },
- _getLoadOptions: function() {
- if (location.protocol.indexOf("wmapp") >= 0)
- return {
- winPhonePrefix: location.protocol + "www/",
- isLocal: true
- };
- return {
- winPhonePrefix: "",
- isLocal: undefined
- }
- },
- _loadExternalTemplates: function() {
- var tasks = [],
- that = this;
- $("head").find("link[rel='dx-template']").each(function(index, link) {
- var task = that._loadTemplatesFromURL($(link).attr("href"));
- tasks.push(task)
- });
- return $.when.apply($, tasks)
- },
- _processTemplates: function() {
- var that = this;
- $.each(that._templateMap, function(name, templatesByRoleMap) {
- $.each(templatesByRoleMap, function(role, templates) {
- that._filterTemplatesByDevice(templates)
- })
- });
- that._enumerateTemplates(function(template) {
- that._applyPartialViews(template._element())
- })
- },
- _filterTemplatesByDevice: function(components) {
- var filteredComponents = this._filterTemplates(this.device, components);
- $.each(components, function(index, component) {
- if ($.inArray(component, filteredComponents) < 0) {
- component._dispose();
- component._element().remove()
- }
- });
- components.length = 0;
- components.push.apply(components, filteredComponents)
- },
- _filterTemplates: function(filter, components) {
- return DX.utils.findBestMatches(filter, components, function(component) {
- return component.option()
- })
- },
- _checkMatchedTemplates: function(bestMatches) {
- if (bestMatches.length > 1) {
- var message = "Concurrent templates are found:\r\n";
- $.each(bestMatches, function(index, match) {
- message += match._element().attr("data-options") + "\r\n"
- });
- message += "Target device:\r\n";
- message += JSON.stringify(this.device);
- throw Error(message);
- }
- },
- _extendModelFormViewTemplate: function($viewTemplate, model) {
- this._extendModelFromViewData($viewTemplate, model)
- },
- _ensureTemplates: function(viewInfo) {
- this._ensureViewTemplate(viewInfo)
- },
- _ensureViewTemplate: function(viewInfo) {
- viewInfo.$viewTemplate = viewInfo.$viewTemplate || this.findViewTemplate(viewInfo.viewName);
- return viewInfo.$viewTemplate
- },
- _wrapViewDefaultContent: function($viewTemplate) {
- $viewTemplate.wrapInner("<div class=\"dx-full-height\"></div>");
- $viewTemplate.children().eq(0).dxContent({targetPlaceholder: 'content'})
- },
- _initDefaultLayout: function() {
- this._$defaultLayoutTemplate = $("<div class=\"dx-full-height\" data-options=\"dxLayout : { name: 'default' } \"> \
- <div class=\"dx-full-height\" data-options=\"dxContentPlaceholder : { name: 'content' } \" ></div> \
- </div>")
- },
- _getDefaultLayoutTemplate: function() {
- var $result = this._$defaultLayoutTemplate.clone();
- this._createComponents($result);
- return $result
- },
- _applyTemplate: function($markup, model) {
- var that = this;
- $markup.each(function(i, element) {
- that.templateEngine.applyTemplate(element, model)
- })
- },
- _applyLayoutCore: function($view, $layout) {
- if ($layout === undefined || $layout.length === 0)
- $layout = this._getDefaultLayoutTemplate();
- if ($view.children(".dx-content").length === 0)
- this._wrapViewDefaultContent($view);
- var $toMerge = $().add($layout).add($view);
- var $placeholderContents = $toMerge.find(".dx-content");
- $.each($placeholderContents, function() {
- var $placeholderContent = $(this);
- var placeholderId = $placeholderContent.data("dxContent").option("targetPlaceholder");
- var $placeholder = $toMerge.find(".dx-content-placeholder-" + placeholderId);
- $placeholder.empty();
- $placeholder.append($placeholderContent)
- });
- $placeholderContents.filter(":not(.dx-content-placeholder .dx-content)").remove();
- return $layout
- },
- findViewTemplate: function(viewName) {
- var findViewEventArgs = {viewName: viewName};
- this.viewSelecting.fire(findViewEventArgs);
- return findViewEventArgs.view ? $(findViewEventArgs.view) : this._findTemplate(viewName, _VIEW_ROLE, true)
- },
- findViewComponent: function(name) {
- return this._findComponent(name, "dxView")
- },
- findLayoutTemplate: function(layoutName) {
- if (!layoutName)
- return this._getDefaultLayoutTemplate();
- var findLayoutEventArgs = {layoutName: layoutName};
- this.layoutSelecting.fire(findLayoutEventArgs);
- return findLayoutEventArgs.layout ? $(findLayoutEventArgs.layout) : this._findTemplate(layoutName, _LAYOUT_ROLE)
- },
- loadTemplates: function(source) {
- var result;
- if (typeof source === "string")
- result = this._loadTemplatesFromURL(source);
- else {
- this._loadTemplatesFromMarkupCore(source);
- result = $.Deferred().resolve().promise()
- }
- return result.done($.proxy(this._processTemplates, this))
- }
- })
- })(jQuery, DevExpress);
- /*! Module framework, file framework.htmlApplication.js */
- (function($, DX, undefined) {
- var frameworkNS = DX.framework,
- htmlNS = frameworkNS.html;
- var VIEW_PORT_CLASSNAME = "dx-viewport";
- var HIDDEN_BAG_ID = "__hidden-bag";
- var HIDDEN_BAG_CLASSNAME = "dx-hidden-bag";
- htmlNS.HtmlApplication = frameworkNS.Application.inherit({
- ctor: function(options) {
- options = options || {};
- this.callBase(options);
- this._$root = $(options.rootNode || document.body);
- this._initViewport(options.viewPort);
- if (this._applicationMode === "mobileApp")
- DX.utils.initMobileViewport(options.viewPort);
- this.device = options.device || DX.devices.current();
- var layoutSets = DX.framework.html.layoutSets;
- this.commandManager = options.commandManager || new DX.framework.html.CommandManager({commandMapping: this.commandMapping});
- $.each(options.layoutControllers || DX.framework.html.layoutControllers, function(_, layoutControllerInfo) {
- var targetLayoutSet = layoutControllerInfo.navigationType;
- layoutSets[targetLayoutSet] = layoutSets[targetLayoutSet] || [];
- layoutSets[targetLayoutSet].push(layoutControllerInfo);
- delete layoutControllerInfo.navigationType
- });
- if (options.navigationType)
- DX.utils.logger.warn("The 'navigationType' option is deprecated, use 'layoutSet' instead");
- if (options.defaultLayout)
- DX.utils.logger.warn("The 'defaultLayout' option is deprecated, use 'layoutSet' instead");
- var navigationType = options.navigationType || options.defaultLayout;
- if (navigationType)
- options.layoutSet = layoutSets[navigationType];
- this._initHiddenBag();
- this._initTemplateContext();
- this.viewEngine = options.viewEngine || new htmlNS.ViewEngine({
- $root: this._$root,
- device: this.device,
- templateEngine: options.templateEngine || new htmlNS.KnockoutJSTemplateEngine({navigationManager: this.navigationManager}),
- templateContext: this._templateContext
- });
- this.components.push(this.viewEngine);
- this.viewRendered = $.Callbacks();
- this._layoutSet = options.layoutSet || (options.layoutControllers && options.layoutControllers.length ? options.layoutControllers : layoutSets["default"]);
- this._availableLayoutControllers = [];
- this.resolveLayoutController = $.Callbacks()
- },
- _createViewCache: function(options) {
- var result = this.callBase(options);
- if (!options.viewCache)
- result = new DX.framework.ConditionalViewCacheDecorator({
- filter: function(key, viewInfo) {
- return !viewInfo.viewTemplateInfo.disableCache
- },
- viewCache: result
- });
- return result
- },
- _initViewport: function() {
- this._$viewPort = this._getViewPort();
- DX.ui.themes.attachCssClasses(this._$viewPort);
- DX.devices.attachCssClasses(this._$viewPort)
- },
- _getViewPort: function() {
- var $viewPort = $("." + VIEW_PORT_CLASSNAME);
- if (!$viewPort.length)
- $viewPort = $("<div>").addClass(VIEW_PORT_CLASSNAME).appendTo(this._$root);
- return $viewPort
- },
- _initHiddenBag: function() {
- this._$hiddenBag = this._getHiddenBag(this._$root, this._$viewPort)
- },
- _getHiddenBag: function($root, $viewPort) {
- var $hiddenBag = $("#" + HIDDEN_BAG_ID);
- if (!$hiddenBag.length)
- $hiddenBag = $("<div/>").addClass(HIDDEN_BAG_CLASSNAME).attr("id", HIDDEN_BAG_ID).appendTo($root);
- $hiddenBag.addClass(($viewPort.attr("class") || "").replace(VIEW_PORT_CLASSNAME, ""));
- return $hiddenBag
- },
- _initTemplateContext: function() {
- this._templateContext = new DX.Component({orientation: DX.devices.orientation()});
- DX.devices.orientationChanged.add($.proxy(function(args) {
- this._templateContext.option("orientation", args.orientation)
- }, this))
- },
- _showViewImpl: function(viewInfo, direction) {
- this._activateLayoutController(viewInfo.layoutController);
- this._obtainViewLink(viewInfo);
- return this._activeLayoutController.showView(viewInfo, direction)
- },
- _setViewLoadingState: function(viewInfo, direction) {
- this._activateLayoutController(viewInfo.layoutController);
- return this._activeLayoutController.setViewLoadingState(viewInfo, direction)
- },
- _resolveLayoutController: function(viewInfo) {
- var args = {
- viewInfo: viewInfo,
- layoutController: null,
- availableLayoutControllers: this._availableLayoutControllers
- };
- this._processEvent("resolveLayoutController", args, viewInfo.model);
- return args.layoutController || this._resolveLayoutControllerImpl(viewInfo)
- },
- _resolveLayoutControllerImpl: function(viewInfo) {
- var target = $.extend({
- root: !viewInfo.canBack,
- customResolveRequired: false,
- pane: (viewInfo.viewTemplateInfo || {}).pane
- }, DX.devices.current());
- var matches = DX.utils.findBestMatches(target, this._availableLayoutControllers);
- if (!matches.length)
- throw Error("The layout controller cannot be resolved. There are no appropriate layout controllers for the current context. Make sure you have the corresponding *.js references in your main *.html file.");
- if (matches.length > 1)
- throw Error("The layout controller cannot be resolved. Two or more layout controllers suit the current context. Make the layout controllers registration more specific.");
- return matches[0].controller
- },
- _activateLayoutController: function(layoutController) {
- var that = this;
- if (that._activeLayoutController !== layoutController) {
- if (that._activeLayoutController)
- that._activeLayoutController.deactivate();
- layoutController.activate();
- that._activeLayoutController = layoutController
- }
- },
- init: function() {
- var that = this,
- result = this.callBase();
- result.done(function() {
- that._initLayoutControllers();
- that.renderNavigation()
- });
- return result
- },
- _disposeView: function(viewInfo) {
- if (viewInfo.layoutController.disposeView)
- viewInfo.layoutController.disposeView(viewInfo);
- this.callBase(viewInfo)
- },
- viewPort: function() {
- return this._$viewPort
- },
- _createViewInfo: function(navigationItem, navigateOptions) {
- var viewInfo = this.callBase.apply(this, arguments),
- templateInfo = this.getViewTemplateInfo(viewInfo.viewName);
- if (!templateInfo)
- throw new Error("The '" + viewInfo.viewName + "' view template is not found. Make sure case is correct and the template fits the current context.");
- viewInfo.viewTemplateInfo = templateInfo;
- viewInfo.layoutController = this._resolveLayoutController(viewInfo);
- return viewInfo
- },
- _createViewModel: function(viewInfo) {
- this.callBase(viewInfo);
- var templateInfo = viewInfo.viewTemplateInfo,
- model = viewInfo.model;
- for (var name in templateInfo)
- if (!(name in model))
- model[name] = templateInfo[name]
- },
- _initLayoutControllers: function() {
- var that = this;
- $.each(that._layoutSet, function(index, controllerInfo) {
- var controller = controllerInfo.controller,
- target = DX.devices.current();
- if (DX.utils.findBestMatches(target, [controllerInfo]).length) {
- that._availableLayoutControllers.push(controllerInfo);
- if (controller.init)
- controller.init({
- app: that,
- $viewPort: that._$viewPort,
- $hiddenBag: that._$hiddenBag,
- navigationManager: that.navigationManager,
- viewEngine: that.viewEngine,
- templateContext: that._templateContext,
- commandManager: that.commandManager
- });
- if (controller.viewReleased)
- controller.viewReleased.add(function(viewInfo) {
- that._onViewReleased(viewInfo)
- });
- if (controller.viewRendered)
- controller.viewRendered.add(function(viewInfo) {
- that._processEvent("viewRendered", {viewInfo: viewInfo}, viewInfo.model)
- })
- }
- })
- },
- _onViewReleased: function(viewInfo) {
- this._onViewHidden(viewInfo);
- this._releaseViewLink(viewInfo)
- },
- renderNavigation: function() {
- var that = this;
- $.each(that._availableLayoutControllers, function(index, controllerInfo) {
- var controller = controllerInfo.controller;
- if (controller.renderNavigation)
- controller.renderNavigation(that.navigation)
- })
- },
- getViewTemplate: function(viewName) {
- return this.viewEngine.findViewTemplate(viewName)
- },
- getViewTemplateInfo: function(viewName) {
- var viewComponent = this.viewEngine.findViewComponent(viewName);
- return viewComponent && viewComponent.option()
- },
- loadTemplates: function(source) {
- return this.viewEngine.loadTemplates(source)
- },
- templateContext: function() {
- return this._templateContext
- }
- })
- })(jQuery, DevExpress);
- /*! Module framework, file framework.transitionExecutor.js */
- (function($, DX) {
- $.fn.extend({unwrapInner: function(selector) {
- return this.each(function() {
- var t = this,
- c = $(t).children(selector);
- c.each(function() {
- var e = $(this);
- e.contents().appendTo(t);
- e.remove()
- })
- })
- }});
- var TRANSITION_DURATION = 400;
- var TransitionExecutor = DX.Class.inherit({
- ctor: function(container, options) {
- this.container = container;
- this.options = options
- },
- exec: function() {
- var that = this,
- options = that.options;
- var $source = options.source,
- $destination = options.destination;
- var $sourceAbsoluteWrapper = $source,
- $destinationRelativeWrapper = $destination,
- $destinationAbsoluteWrapper = that._getTransitionInnerElement($destination);
- this._finalize = function(){};
- return that._animate($.extend({}, options, {
- source: $sourceAbsoluteWrapper,
- destination: $destinationAbsoluteWrapper
- }))
- },
- finalize: function() {
- if (!this._finalize)
- throw Error("The \"exec\" method should be called before the \"finalize\" one");
- this._finalize()
- },
- _getTransitionInnerElement: function($transitionElement) {
- return $transitionElement.children(".dx-active-view:not(.dx-transition-source)")
- },
- _animate: function() {
- return (new $.Deferred).resolve().promise()
- }
- });
- var NoneTransitionExecutor = TransitionExecutor.inherit({_animate: function(options) {
- var $source = options.source,
- $destination = options.destination;
- var containerWidth = this.container.width();
- DX.fx.animate($source, {
- type: "slide",
- from: {left: 0},
- to: {left: 0},
- duration: 0
- });
- DX.fx.animate($destination, {
- type: "slide",
- from: {left: -containerWidth},
- to: {left: -containerWidth},
- duration: 0
- });
- return $.Deferred().resolve().promise()
- }});
- var SlideTransitionExecutor = TransitionExecutor.inherit({_animate: function(options) {
- if (options.direction === "none")
- return $.Deferred().resolve().promise();
- var $source = options.source,
- $destination = options.destination;
- var directionModifier = options.direction === "backward" ? -1 : 1,
- rtlModifier = DX.rtlEnabled ? -1 : 1,
- containerWidth = this.container.width() * directionModifier * rtlModifier;
- var promiseSource = DX.fx.animate($source, {
- type: "slide",
- from: {left: containerWidth},
- to: {left: 0},
- duration: TRANSITION_DURATION
- });
- var promiseDestination = DX.fx.animate($destination, {
- type: "slide",
- from: {left: 0},
- to: {left: -containerWidth},
- duration: TRANSITION_DURATION
- });
- return $.when(promiseDestination, promiseSource)
- }});
- var SlideIOS7TransitionExecutor = TransitionExecutor.inherit({_animate: function(options) {
- if (options.direction === "none")
- return $.Deferred().resolve().promise();
- var $source = options.source,
- $destination = options.destination;
- var rtlModifier = DX.rtlEnabled ? -1 : 1,
- containerWidth = this.container.width() * rtlModifier,
- slowTransitionWidth = containerWidth / 5,
- sourceLeftFrom,
- sourceLeftTo,
- destinationLeftFrom,
- destinationLeftTo,
- sourceZIndex = $source.css("z-index"),
- destinationZIndex = $destination.css("z-index");
- if (options.direction === "backward") {
- sourceLeftFrom = -slowTransitionWidth;
- sourceLeftTo = 0;
- destinationLeftFrom = 0;
- destinationLeftTo = containerWidth;
- $source.css("z-index", 1);
- $destination.css("z-index", 2)
- }
- else {
- sourceLeftFrom = containerWidth;
- sourceLeftTo = 0;
- destinationLeftFrom = 0;
- destinationLeftTo = -slowTransitionWidth;
- $source.css("z-index", 2);
- $destination.css("z-index", 1)
- }
- var promiseSource = DX.fx.animate($source, {
- type: "slide",
- from: {left: sourceLeftFrom},
- to: {left: sourceLeftTo},
- duration: TRANSITION_DURATION
- });
- var promiseDestination = DX.fx.animate($destination, {
- type: "slide",
- from: {left: destinationLeftFrom},
- to: {left: destinationLeftTo},
- duration: TRANSITION_DURATION
- });
- return $.when(promiseDestination, promiseSource).done(function() {
- $source.css("z-index", sourceZIndex);
- $destination.css("z-index", destinationZIndex)
- })
- }});
- var OverflowTransitionExecutor = TransitionExecutor.inherit({_animate: function(options) {
- var $source = options.source,
- $destination = options.destination,
- destinationTop = $destination.position().top,
- destinationLeft = $destination.position().left,
- containerWidth = this.container.width();
- if (options.direction === "backward")
- containerWidth = -containerWidth;
- var animations = [];
- if (options.direction === "forward")
- animations.push(DX.fx.animate($source, {
- type: "slide",
- from: {
- top: destinationTop,
- left: containerWidth + destinationLeft,
- "z-index": 1
- },
- to: {left: destinationLeft},
- duration: TRANSITION_DURATION
- }));
- else {
- animations.push(DX.fx.animate($source, {
- type: "slide",
- from: {
- left: destinationLeft,
- "z-index": 1
- },
- to: {left: destinationLeft},
- duration: TRANSITION_DURATION
- }));
- animations.push(DX.fx.animate($destination, {
- type: "slide",
- from: {"z-index": 2},
- to: {left: destinationLeft - containerWidth},
- duration: TRANSITION_DURATION
- }))
- }
- return $.when.apply($, animations)
- }});
- var FadeTransitionExecutor = TransitionExecutor.inherit({_animate: function(options) {
- var $source = options.source,
- $destination = options.destination,
- d = new $.Deferred;
- $source.css({opacity: 0});
- $destination.animate({opacity: 0}, TRANSITION_DURATION);
- $source.animate({opacity: 1}, TRANSITION_DURATION, function() {
- d.resolve()
- });
- return d.promise()
- }});
- var transitionType = function(options) {
- if (options.type === "fade")
- return options.type;
- if (options.direction === "none")
- return "none";
- return options.type
- };
- TransitionExecutor.create = function(container, options) {
- var device = DX.devices.current();
- switch (transitionType(options)) {
- case"none":
- return new NoneTransitionExecutor(container, options);
- case"slide":
- if (device.platform === "ios" && device.version[0] === 7)
- return new SlideIOS7TransitionExecutor(container, options);
- else
- return new SlideTransitionExecutor(container, options);
- case"fade":
- return new FadeTransitionExecutor(container, options);
- case"overflow":
- return new OverflowTransitionExecutor(container, options);
- default:
- throw Error(DX.utils.formatString("Unknown transition type \"{0}\"", options.type));
- }
- };
- DX.framework.html.TransitionExecutor = TransitionExecutor;
- DX.framework.html.NoneTransitionExecutor = NoneTransitionExecutor;
- DX.framework.html.SlideIOS7TransitionExecutor = SlideIOS7TransitionExecutor;
- DX.framework.html.SlideTransitionExecutor = SlideTransitionExecutor;
- DX.framework.html.OverflowTransitionExecutor = OverflowTransitionExecutor;
- DX.framework.html.FadeTransitionExecutor = FadeTransitionExecutor
- })(jQuery, DevExpress);
- DevExpress.MOD_FRAMEWORK = true
- }
- if (!DevExpress.MOD_VIZ_CORE) {
- if (!window.DevExpress)
- throw Error('Required module is not referenced: core');
- /*! Module viz-core, file namespaces.js */
- (function(DevExpress) {
- DevExpress.viz = {}
- })(DevExpress);
- /*! Module viz-core, file namespaces.js */
- (function(DevExpress) {
- DevExpress.viz.core = {}
- })(DevExpress);
- /*! Module viz-core, file errorsWarnings.js */
- (function(DevExpress) {
- DevExpress.viz.core.errorsWarnings = {
- E2001: "Invalid data source",
- E2002: "Axis type and data type are incompatible",
- E2003: "\"{0}\" data source field contains data of unsupported type",
- E2004: "\"{0}\" data source field is inconsistent",
- E2101: "Unknown series type was specified: {0}",
- E2102: "Ambiguity occurred between two value axes with the same name",
- E2103: "\"{0}\" option must be a function",
- E2104: "Invalid logarithm base",
- E2105: "Invalid value of a \"{0}\"",
- E2106: "Invalid visible range",
- E2201: "Invalid type of data source field",
- E2202: "Invalid scale {0} value",
- E2203: "The \"{0}\" field of the \"selectedRange\" configuration object is not valid",
- W2001: "{0} cannot be drawn because its container is invisible",
- W2002: "The {0} data field is absent",
- W2003: "Tick interval is too small",
- W2101: "\"{0}\" pane does not exist; \"{1}\" pane is used instead",
- W2102: "Value axis with the \"{0}\" name was created automatically",
- W2103: "Chart title was hidden due to container size",
- W2104: "Legend was hidden due to container size",
- W2105: "Title of \"{0}\" axis was hidden due to container size",
- W2106: "Labels of \"{0}\" axis were hidden due to container size",
- W2301: "Invalid value range"
- }
- })(DevExpress);
- /*! Module viz-core, file tickProvider.js */
- (function($, DX, undefined) {
- var utils = DX.utils,
- math = Math,
- mathCeil = math.ceil,
- mathFloor = math.floor,
- mathAbs = math.abs,
- mathRound = math.round,
- core = DX.viz.core;
- var TICKS_COUNT_LIMIT = 2000;
- core.outOfScreen = {
- x: -1000,
- y: -1000
- };
- core.tickIntervalCalculator = {
- _defaultNumberMultipliers: [1, 2, 3, 5],
- _defaultGridSpacingFactor: 30,
- _getCommonTickInterval: function(deltaCoef, numberMultipliers) {
- var factor,
- result = 0,
- hasResult = false,
- i;
- for (factor = 1; !hasResult; factor *= 10)
- for (i = 0; i < numberMultipliers.length; i++) {
- result = numberMultipliers[i] * factor;
- if (deltaCoef <= result) {
- hasResult = true;
- break
- }
- }
- return result
- },
- _getNumericTickInterval: function(deltaCoef, numberMultipliers) {
- var factor,
- result = 0,
- newResult,
- hasResult = false,
- i;
- if (deltaCoef > 1.0)
- result = this._getCommonTickInterval(deltaCoef, numberMultipliers);
- else if (deltaCoef > 0) {
- result = 1;
- for (factor = 0.1; !hasResult; factor /= 10)
- for (i = numberMultipliers.length - 1; i >= 0; i--) {
- newResult = numberMultipliers[i] * factor;
- if (deltaCoef > newResult) {
- hasResult = true;
- break
- }
- result = newResult
- }
- }
- return utils.adjustValue(result)
- },
- _getLogarithmicTickInterval: function(deltaCoef, numberMultipliers) {
- var result = 0;
- if (deltaCoef !== 0)
- result = this._getCommonTickInterval(deltaCoef, numberMultipliers);
- return utils.adjustValue(result)
- },
- _getDateTimeTickInterval: function(deltaCoef, numberMultipliers) {
- var dateTimeMultipliers = {
- millisecond: [1, 2, 5, 10, 25, 100, 250, 300, 500],
- second: [1, 2, 3, 5, 10, 15, 20, 30],
- minute: [1, 2, 3, 5, 10, 15, 20, 30],
- hour: [1, 2, 3, 4, 6, 8, 12],
- day: [1, 2, 3, 5, 7, 10, 14],
- month: [1, 2, 3, 6]
- },
- result = {},
- factor,
- key,
- specificMultipliers,
- yearsCount,
- i;
- if (deltaCoef > 0 && deltaCoef < 1.0)
- return {milliseconds: 1};
- else if (deltaCoef === 0)
- return 0;
- for (key in dateTimeMultipliers)
- if (dateTimeMultipliers.hasOwnProperty(key)) {
- specificMultipliers = dateTimeMultipliers[key];
- for (i = 0; i < specificMultipliers.length; i++)
- if (deltaCoef <= utils.convertDateUnitToMilliseconds(key, specificMultipliers[i])) {
- result[key + 's'] = specificMultipliers[i];
- return result
- }
- }
- for (factor = 1; ; factor *= 10)
- for (i = 0; i < numberMultipliers.length; i++) {
- yearsCount = factor * numberMultipliers[i];
- if (deltaCoef <= utils.convertDateUnitToMilliseconds('year', yearsCount))
- return {years: yearsCount}
- }
- return null
- },
- getTickInterval: function(options) {
- var that = this,
- gridSpacingFactor = options.gridSpacingFactor || that._defaultGridSpacingFactor,
- numberMultipliers = options.numberMultipliers || that._defaultNumberMultipliers,
- businessDelta = options.businessDelta,
- screenDelta = options.screenDelta,
- deltaCoef = screenDelta > 0 && gridSpacingFactor < screenDelta ? gridSpacingFactor * businessDelta / screenDelta : 0;
- that._testNumberMultipliers = numberMultipliers;
- if (options.axisType === 'logarithmic')
- return that._getLogarithmicTickInterval(deltaCoef, numberMultipliers);
- else
- switch (options.dataType) {
- case'numeric':
- return that._getNumericTickInterval(deltaCoef, numberMultipliers);
- break;
- case'datetime':
- return that._getDateTimeTickInterval(deltaCoef, numberMultipliers);
- break
- }
- return null
- }
- };
- core.minorTickIntervalCalculator = {
- _defaultNumberMultipliers: [2, 4, 5, 8, 10],
- _defaultGridSpacingFactor: 15,
- _getDateTimeTickInterval: function(businessDelta, deltaCoef, numberMultipliers) {
- var result,
- i;
- for (i = numberMultipliers.length - 1; i >= 0; i--) {
- this.testResultNumberMultiplier = numberMultipliers[i];
- result = mathFloor(businessDelta / numberMultipliers[i]);
- if (deltaCoef <= result)
- return utils.convertMillisecondsToDateUnits(result)
- }
- return 0
- },
- _getCommonTickInterval: function(businessDelta, deltaCoef, numberMultipliers) {
- var result,
- i;
- for (i = numberMultipliers.length - 1; i >= 0; i--) {
- this.testResultNumberMultiplier = numberMultipliers[i];
- result = businessDelta / numberMultipliers[i];
- if (deltaCoef <= result)
- return utils.adjustValue(result)
- }
- return 0
- },
- getTickInterval: function(options) {
- var that = this,
- gridSpacingFactor = !utils.isDefined(options.gridSpacingFactor) ? that._defaultGridSpacingFactor : options.gridSpacingFactor,
- numberMultipliers = options.numberMultipliers || that._defaultNumberMultipliers,
- businessDelta = options.businessDelta,
- deltaCoef = gridSpacingFactor * businessDelta / options.screenDelta;
- if (options.axisType === 'logarithmic')
- return that._getCommonTickInterval(businessDelta, deltaCoef, numberMultipliers);
- else
- switch (options.dataType) {
- case'numeric':
- return that._getCommonTickInterval(businessDelta, deltaCoef, numberMultipliers);
- case'datetime':
- return that._getDateTimeTickInterval(businessDelta, deltaCoef, numberMultipliers)
- }
- return 0
- }
- };
- core.tickProvider = {
- _appendFakeSVGElement: function(value, text, options) {
- var textOptions = $.extend({}, options.textOptions, {rotate: 0});
- return options.renderer.createText(text, core.outOfScreen.x + (options.translator.translate(value) || 0), core.outOfScreen.y, textOptions).append()
- },
- _getDistanceByAngle: function(elementHeight, rotationAngle) {
- return elementHeight / mathAbs(math.sin(rotationAngle * (math.PI / 180)))
- },
- _areDisplayValuesValid: function(value1, value2, options) {
- var that = this,
- getText = that._getTextFunc(options),
- rotationAngle = options.textOptions && utils.isNumber(options.textOptions.rotate) ? options.textOptions.rotate : 0,
- svgElement1 = that._appendFakeSVGElement(value1, getText(value1), options),
- svgElement2 = that._appendFakeSVGElement(value2, getText(value2), options),
- bBox1 = svgElement1.getBBox(),
- bBox2 = svgElement2.getBBox(),
- result,
- translator = options.translator;
- if (rotationAngle !== 0)
- result = that._getDistanceByAngle(bBox1.height, rotationAngle) <= mathAbs(bBox2.x - bBox1.x);
- else if (options.isHorizontal)
- result = !translator.getBusinessRange().invert ? bBox1.x + bBox1.width < bBox2.x : bBox2.x + bBox2.width < bBox1.x;
- else
- result = mathAbs(translator.translate(value1) - translator.translate(value2)) > bBox1.height;
- svgElement1.remove();
- svgElement2.remove();
- return result
- },
- _removeInvalidDatesWithUnitBegining: function(dates, options) {
- if (dates.length <= 1 || !options.setTicksAtUnitBeginning || !utils.isDate(options.min))
- return;
- if (!this._areDisplayValuesValid(dates[0], dates[1], options))
- dates.splice(1, 1)
- },
- _getValueSize: function(values, options) {
- var that = this,
- value,
- rotationAngle = options.textOptions ? options.textOptions.rotate : 0,
- svgElement,
- bBox,
- result,
- getText = that._getTextFunc(options),
- i;
- if (values.length === 0)
- return 0;
- options.isRotate = utils.isNumber(rotationAngle) && rotationAngle !== 0;
- if (options.isRotate || !options.isHorizontal)
- value = getText(values[0]);
- else {
- value = [];
- for (i = 0; i < values.length; i++)
- value.push(getText(values[i]));
- value = value.join('\n')
- }
- svgElement = that._appendFakeSVGElement(value, value, options);
- bBox = svgElement.getBBox();
- if (options.isRotate)
- result = that._getDistanceByAngle(bBox.height, rotationAngle);
- else
- result = options.isHorizontal ? bBox.width : bBox.height;
- svgElement.remove();
- return mathCeil(result)
- },
- _adjustNumericTickValue: function(value, interval, min) {
- return utils.isExponential(value) ? utils.adjustValue(value) : utils.applyPrecisionByMinDelta(min, interval, value)
- },
- _generateStartTick: function(tickInterval, options) {
- var that = this,
- milliseconds = 0,
- boundedRule = options.min - options.max < 0,
- startTick = options.min,
- isDate = utils.isDate(options.min),
- currentTickInterval = isDate ? utils.convertDateTickIntervalToMilliseconds(tickInterval) : tickInterval,
- nextTick;
- if (options.axisType === 'logarithmic')
- startTick = utils.raiseTo(mathFloor(utils.adjustValue(utils.getLog(options.min, options.base)) / currentTickInterval * currentTickInterval), options.base);
- else {
- startTick = mathFloor(options.min / currentTickInterval) * currentTickInterval;
- startTick = isDate ? new Date(startTick) : that._adjustNumericTickValue(startTick, currentTickInterval, options.min)
- }
- while (boundedRule === startTick - options.min < 0 && startTick !== options.min) {
- nextTick = that._nextTick(startTick, tickInterval, options);
- if (nextTick !== startTick)
- startTick = nextTick;
- else
- return nextTick
- }
- return startTick
- },
- _nextTick: function(tick, tickInterval, options) {
- var nextTick,
- lgPower,
- that = this;
- if (options.axisType === 'logarithmic') {
- lgPower = utils.addInterval(utils.adjustValue(utils.getLog(tick, options.base)), tickInterval, options.min > options.max);
- nextTick = utils.raiseTo(lgPower, options.base);
- nextTick = that._adjustNumericTickValue(nextTick, tickInterval, math.min(options.min, options.max))
- }
- else {
- nextTick = utils.addInterval(tick, tickInterval, options.min > options.max);
- if (options.dataType === 'numeric')
- nextTick = that._adjustNumericTickValue(nextTick, tickInterval, options.min);
- if (options.dataType === 'datetime' && options.setTicksAtUnitBeginning)
- utils.correctDateWithUnitBeginning(nextTick, tickInterval)
- }
- return nextTick
- },
- _addMinorTicks: function(majorTick1, majorTick2, ticksInfo, options, isReverse) {
- var that = this,
- i,
- dataType = options.dataType,
- businessDelta,
- minorTicks = [],
- interval = 0,
- minorTickIntervalsCount = options.minorTickCount + 1,
- intervalsCount,
- tickInterval;
- options.min = majorTick1;
- options.max = majorTick2;
- if (!utils.isDefined(options.tickInterval)) {
- options.businessDelta = businessDelta = mathAbs(options.max - options.min);
- options.screenDelta = businessDelta * options.deltaCoef;
- if (utils.isDefined(options.minorTickCount)) {
- if (!ticksInfo.majorTicks.autoArrangementStep || ticksInfo.majorTicks.autoArrangementStep <= 1) {
- intervalsCount = options.minorTickCount + 1;
- interval = dataType === 'datetime' ? utils.convertDateTickIntervalToMilliseconds(ticksInfo.majorTickInterval) : ticksInfo.majorTickInterval;
- minorTickIntervalsCount = mathRound(businessDelta / interval * intervalsCount) || 1
- }
- tickInterval = dataType === 'datetime' ? utils.convertMillisecondsToDateUnits(businessDelta / minorTickIntervalsCount) : businessDelta / minorTickIntervalsCount;
- if ($.isNumeric(tickInterval))
- tickInterval = utils.adjustValue(tickInterval)
- }
- else if (utils.isDate(majorTick1))
- tickInterval = core.minorTickIntervalCalculator.getTickInterval(options)
- }
- options = $.extend(true, {}, options, {tickInterval: tickInterval});
- minorTicks = that.getTicks(options);
- if (isReverse)
- minorTicks.reverse();
- if (minorTicks.length > 0)
- if (mathCeil(mathAbs(majorTick2 - minorTicks[minorTicks.length - 1]) * options.deltaCoef) < 2)
- minorTicks.pop();
- for (i = 0; i < minorTicks.length; i++) {
- ticksInfo.minorTicks.push(minorTicks[i]);
- ticksInfo.fullTicks.push(minorTicks[i])
- }
- },
- _addLeftBoudedTicks: function(ticksInfo, min, minorTicksOptions) {
- if (utils.isDefined(min) && ticksInfo.majorTicks[0].valueOf() !== min.valueOf()) {
- minorTicksOptions.addMinMax.max = true;
- this._addMinorTicks(ticksInfo.majorTicks[0], min, ticksInfo, minorTicksOptions, true);
- minorTicksOptions.addMinMax.max = false;
- if (minorTicksOptions.showCustomBoundaryTicks) {
- if (ticksInfo.minorTicks.length > 0 && ticksInfo.minorTicks[0].valueOf() === min.valueOf())
- ticksInfo.minorTicks.shift(min);
- ticksInfo.customBoundaryTicks.push(min);
- ticksInfo.fullTicks.unshift(min)
- }
- }
- },
- _addRightBoudedTicks: function(ticksInfo, max, minorTicksOptions) {
- var lastMajorTick = ticksInfo.majorTicks[ticksInfo.majorTicks.length - 1];
- ticksInfo.fullTicks.push(lastMajorTick);
- if (utils.isDefined(max) && lastMajorTick.valueOf() !== max.valueOf()) {
- minorTicksOptions.addMinMax.min = false;
- minorTicksOptions.addMinMax.max = true;
- this._addMinorTicks(lastMajorTick, max, ticksInfo, minorTicksOptions);
- if (minorTicksOptions.showCustomBoundaryTicks) {
- if (ticksInfo.minorTicks.length > 0 && ticksInfo.minorTicks[ticksInfo.minorTicks.length - 1].valueOf() === max.valueOf())
- ticksInfo.minorTicks.pop(max);
- ticksInfo.customBoundaryTicks.push(max);
- ticksInfo.fullTicks.push(max)
- }
- }
- },
- _correctBoundedTicks: function(min, max, ticks, addMinMax) {
- addMinMax = $.extend({}, {
- min: true,
- max: true
- }, addMinMax);
- if (ticks.length > 0) {
- if (!addMinMax.min && ticks[0].valueOf() === min.valueOf())
- ticks.shift();
- if (!addMinMax.max || ticks[ticks.length - 1].valueOf() !== max.valueOf())
- ticks.pop()
- }
- },
- _initializeMinorTicksOptions: function(min, max, screenDelta, ticksInfo, options) {
- var that = this,
- businessDelta,
- hasMinorsCount = utils.isDefined(options.minorTickCount);
- $.extend(true, options, {
- addMinMax: {
- min: false,
- max: false
- },
- deltaCoef: that._getDeltaCoef(screenDelta, max, min, options.axisType, options.base)
- }, options);
- options.numberMultipliers = hasMinorsCount ? [options.minorTickCount + 1] : options.numberMultipliers;
- options.gridSpacingFactor = hasMinorsCount ? 0 : options.gridSpacingFactor;
- if (!hasMinorsCount && ticksInfo.majorTicks.length > 1) {
- options.businessDelta = businessDelta = that._getBusinessDelta(options.axisType, ticksInfo.majorTicks[0], ticksInfo.majorTicks[1], options.base);
- if (that.needTickIntervalCalculation(businessDelta, ticksInfo.minorTickInterval, options.incidentOccured)) {
- options.screenDelta = businessDelta * options.deltaCoef;
- ticksInfo.minorTickInterval = core.minorTickIntervalCalculator.getTickInterval(options);
- if (utils.isNumber(min))
- options.tickInterval = ticksInfo.minorTickInterval;
- else
- options.tickInterval = undefined
- }
- }
- },
- _getDataType: function(value) {
- return utils.isDate(value) ? 'datetime' : 'numeric'
- },
- _getBusinessDelta: function(type, min, max, base) {
- return type === 'logarithmic' ? mathRound(mathAbs(utils.getLog(min, base) - utils.getLog(max, base))) : mathAbs(min - max)
- },
- _getDeltaCoef: function(screenDelta, max, min, type, base) {
- return screenDelta / this._getBusinessDelta(type, min, max, base)
- },
- _initializeMajorTicksOptions: function(min, max, screenDelta, ticksInfo, options) {
- var businessDelta;
- options.screenDelta = screenDelta;
- $.extend(true, options, {
- min: min,
- max: max,
- screenDelta: screenDelta,
- isHorizontal: true
- });
- if (utils.isDefined(min) && utils.isDefined(max)) {
- options.businessDelta = businessDelta = this._getBusinessDelta(options.axisType, min, max, options.base);
- if (this.needTickIntervalCalculation(businessDelta, ticksInfo.majorTickInterval, options.incidentOccured)) {
- options.isStartTickGenerated = true;
- ticksInfo.majorTickInterval = core.tickIntervalCalculator.getTickInterval(options);
- options.tickInterval = ticksInfo.majorTickInterval
- }
- }
- },
- _getTextFunc: function(options) {
- return options.getText || function(value) {
- return value.toString()
- }
- },
- _generateTicks: function(options) {
- var that = this,
- ticks = [],
- tick,
- boundedRule = options.max - options.min > 0,
- leftBound,
- rightBound,
- tickInterval,
- isStartTickGenerated = options.isStartTickGenerated,
- businessDelta,
- useTicksAutoArrangement = options.useTicksAutoArrangement;
- options.dataType = options.dataType || that._getDataType(options.min);
- options.businessDelta = businessDelta = that._getBusinessDelta(options.axisType, options.min, options.max, options.base);
- if (!utils.isDefined(options.min) || !utils.isDefined(options.max) || isNaN(options.min) || isNaN(options.max)) {
- ticks = options.isHorizontal ? ['canvas_position_left', 'canvas_position_center', 'canvas_position_right'] : ['canvas_position_bottom', 'canvas_position_middle', 'canvas_position_top'];
- useTicksAutoArrangement = false;
- ticks.hideLabels = true
- }
- else {
- tickInterval = $.isNumeric(options.min) && $.isNumeric(options.max) && !$.isNumeric(options.tickInterval) ? undefined : options.tickInterval;
- if (this.needTickIntervalCalculation(businessDelta, tickInterval, options.incidentOccured)) {
- isStartTickGenerated = utils.isDefined(isStartTickGenerated) ? isStartTickGenerated : true;
- tickInterval = core.tickIntervalCalculator.getTickInterval(options)
- }
- ticks.tickInterval = tickInterval;
- that.isTestStartTickGenerated = isStartTickGenerated;
- that.isTestTickInterval = tickInterval;
- that.testGridSpacingFactor = options.gridSpacingFactor;
- if (tickInterval && tickInterval.valueOf() !== 0 && options.min.valueOf() !== options.max.valueOf()) {
- tick = isStartTickGenerated ? that._generateStartTick(tickInterval, options) : options.min;
- do {
- ticks.push(tick);
- tick = that._nextTick(tick, tickInterval, options);
- if (ticks[ticks.length - 1].valueOf() === tick.valueOf())
- break;
- leftBound = tick - options.min > 0;
- rightBound = options.max - tick > 0
- } while (boundedRule === leftBound && boundedRule === rightBound);
- ticks.push(tick);
- that._correctBoundedTicks(options.min, options.max, ticks, options.addMinMax)
- }
- if (options.min.valueOf() === options.max.valueOf()) {
- tick = options.min;
- ticks.push(tick)
- }
- }
- return ticks
- },
- _getAutoArrangementStep: function(ticks, options) {
- var that = this,
- requiredValuesCount,
- addedSpacing = options.isHorizontal ? options.textSpacing : 0;
- if (options.getCustomAutoArrangementStep)
- return options.getCustomAutoArrangementStep(ticks, options);
- if (options.maxDisplayValueSize > 0) {
- requiredValuesCount = mathFloor((options.screenDelta + options.textSpacing) / (options.maxDisplayValueSize + addedSpacing));
- return mathCeil((options.ticksCount || ticks.length) / requiredValuesCount)
- }
- return 1
- },
- _getAutoArrangementTicks: function(ticks, options, step) {
- var that = this,
- resultTicks = ticks,
- i;
- if (step > 1) {
- resultTicks = [];
- for (i = 0; i < ticks.length; i += step)
- resultTicks.push(ticks[i]);
- resultTicks.tickInterval = ticks.tickInterval * step
- }
- return resultTicks
- },
- isOverlappedTicks: function(ticks, options) {
- options.maxDisplayValueSize = this._getValueSize(ticks, options);
- return this._getAutoArrangementStep(ticks, options) > 1
- },
- getCorrectedTicks: function(ticks, ticksOptions) {
- var step = Math.ceil(core.tickIntervalCalculator.getTickInterval({
- screenDelta: ticksOptions.screenDelta * 4,
- businessDelta: ticks.length,
- gridSpacingFactor: ticksOptions.gridSpacingFactor,
- numberMultipliers: ticksOptions.numberMultipliers,
- dataType: "numeric"
- })) || ticks.length;
- return this._getAutoArrangementTicks(ticks, ticksOptions, step)
- },
- needTickIntervalCalculation: function(businessDelta, tickInterval, incidentOccured) {
- var date;
- if (utils.isDefined(tickInterval)) {
- if (!utils.isNumber(tickInterval)) {
- date = new Date;
- tickInterval = utils.addInterval(date, tickInterval) - date;
- if (!tickInterval)
- return true
- }
- if (utils.isNumber(tickInterval))
- if (tickInterval > 0 && businessDelta / tickInterval > TICKS_COUNT_LIMIT) {
- if (incidentOccured)
- incidentOccured('W2003')
- }
- else
- return false
- }
- return true
- },
- getTickIntervals: function(min, max, screenDelta, majorTicksOptions, minorTicksOptions, options) {
- var that = this,
- i,
- options = options || {},
- ticksInfo = {
- majorTickInterval: majorTicksOptions.tickInterval,
- minorTickInterval: minorTicksOptions.tickInterval,
- majorTicks: []
- };
- majorTicksOptions.base = minorTicksOptions.base = options.base;
- majorTicksOptions.axisType = minorTicksOptions.axisType = options.axisType;
- majorTicksOptions.dataType = minorTicksOptions.dataType = options.dataType;
- that._initializeMajorTicksOptions(min, max, screenDelta, ticksInfo, majorTicksOptions);
- if (utils.isDefined(min) && utils.isDefined(max)) {
- ticksInfo.majorTicks.push(min);
- ticksInfo.majorTicks.push(that._nextTick(min, ticksInfo.majorTickInterval, {
- min: min,
- max: max,
- setTicksAtUnitBeginning: majorTicksOptions.setTicksAtUnitBeginning,
- dataType: options.dataType,
- axisType: options.axisType,
- base: options.base
- }));
- that._initializeMinorTicksOptions(min, max, screenDelta, ticksInfo, minorTicksOptions)
- }
- return ticksInfo
- },
- getFullTicks: function(min, max, screenDelta, majorTicksOptions, minorTicksOptions, options) {
- var that = this,
- i,
- options = options || {},
- ticksInfo = {
- customBoundaryTicks: [],
- fullTicks: [],
- majorTickInterval: majorTicksOptions.tickInterval,
- majorTicks: [],
- minorTickInterval: minorTicksOptions.tickInterval,
- minorTicks: []
- };
- majorTicksOptions.base = minorTicksOptions.base = options.base;
- majorTicksOptions.axisType = minorTicksOptions.axisType = options.axisType;
- majorTicksOptions.dataType = minorTicksOptions.dataType = options.dataType || that._getDataType(min);
- that._initializeMajorTicksOptions(min, max, screenDelta, ticksInfo, majorTicksOptions);
- ticksInfo.majorTicks = that.getTicks(majorTicksOptions);
- if (utils.isDefined(min) && utils.isDefined(max) && ticksInfo.majorTicks.length > 0) {
- if (ticksInfo.majorTicks.autoArrangementStep && ticksInfo.majorTicks.autoArrangementStep > 1 && !utils.isDefined(minorTicksOptions.tickInterval) && !utils.isDefined(minorTicksOptions.minorTickCount))
- minorTicksOptions.tickInterval = ticksInfo.minorTickInterval = majorTicksOptions.tickInterval;
- that._initializeMinorTicksOptions(min, max, screenDelta, ticksInfo, minorTicksOptions);
- that._addLeftBoudedTicks(ticksInfo, min, minorTicksOptions);
- for (i = 0; i < ticksInfo.majorTicks.length - 1; i++) {
- ticksInfo.fullTicks.push(ticksInfo.majorTicks[i]);
- that._addMinorTicks(ticksInfo.majorTicks[i], ticksInfo.majorTicks[i + 1], ticksInfo, minorTicksOptions)
- }
- that._addRightBoudedTicks(ticksInfo, max, minorTicksOptions)
- }
- return ticksInfo
- },
- getTicks: function(options) {
- var that = this,
- step,
- maxDisplayValue,
- ticks = options.customTicks ? options.customTicks : that._generateTicks(options);
- if (options.useTicksAutoArrangement) {
- options.maxDisplayValueSize = that._getValueSize(ticks, options);
- step = that._getAutoArrangementStep(ticks, options);
- if (step > 1) {
- if (utils.isDefined(options.tickInterval) || utils.isDefined(options.customTicks)) {
- utils.isDefined(options.customTicks) && (ticks.tickInterval = options.tickInterval);
- ticks = that._getAutoArrangementTicks(ticks, options, step)
- }
- else
- ticks = that._generateTicks($.extend({}, options, {gridSpacingFactor: options.maxDisplayValueSize}));
- ticks.autoArrangementStep = step
- }
- that._removeInvalidDatesWithUnitBegining(ticks, options)
- }
- return ticks
- }
- }
- })(jQuery, DevExpress);
- /*! Module viz-core, file numericTranslator.js */
- (function($, DX, undefined) {
- var utils = DX.utils,
- isDefined = utils.isDefined,
- getPower = utils.getPower,
- round = Math.round;
- DX.viz.core.numericTranslatorFunctions = {
- translate: function(bp) {
- var that = this,
- canvasOptions = that._canvasOptions,
- doubleError = canvasOptions.rangeDoubleError,
- specialValue = that.translateSpecialCase(bp);
- if (isDefined(specialValue))
- return specialValue;
- if (isNaN(bp) || bp.valueOf() + doubleError < canvasOptions.rangeMin || bp.valueOf() - doubleError > canvasOptions.rangeMax)
- return null;
- return round(that._calculateProjection((bp - canvasOptions.rangeMinVisible) * canvasOptions.ratioOfCanvasRange))
- },
- untranslate: function(pos) {
- var canvasOptions = this._canvasOptions,
- startPoint = canvasOptions.startPoint;
- if (pos < startPoint || pos > canvasOptions.endPoint)
- return null;
- return this._calculateUnProjection((pos - startPoint) / canvasOptions.ratioOfCanvasRange)
- },
- getInterval: function() {
- return round(this._canvasOptions.ratioOfCanvasRange * (this._businessRange.interval || Math.abs(this._canvasOptions.rangeMax - this._canvasOptions.rangeMin)))
- }
- }
- })(jQuery, DevExpress);
- /*! Module viz-core, file datetimeTranslator.js */
- (function($, DX, undefined) {
- var core = DX.viz.core,
- numericTranslator = core.numericTranslatorFunctions;
- core.datetimeTranslatorFunctions = {
- translate: numericTranslator.translate,
- untranslate: function(pos) {
- var result = numericTranslator.untranslate.call(this, pos);
- return result === null ? result : new Date(result)
- },
- getInterval: numericTranslator.getInterval
- }
- })(jQuery, DevExpress);
- /*! Module viz-core, file categoryTranslator.js */
- (function($, DX, undefined) {
- var isDefined = DX.utils.isDefined,
- round = Math.round;
- function doubleRound(value) {
- return round(round(value * 10) / 10)
- }
- DX.viz.core.categoryTranslatorFunctions = {
- translate: function(category) {
- var that = this,
- canvasOptions = that._canvasOptions,
- categoryRecord = that._categoriesToPoints[category],
- stickDelta,
- specialValue = that.translateSpecialCase(category);
- if (isDefined(specialValue))
- return specialValue;
- if (!categoryRecord)
- return 0;
- stickDelta = that._businessRange.stick ? categoryRecord.index : categoryRecord.index + 0.5;
- return round(canvasOptions.startPoint + canvasOptions.interval * stickDelta)
- },
- untranslate: function(pos) {
- var that = this,
- canvasOptions = that._canvasOptions,
- startPoint = canvasOptions.startPoint,
- categoriesLength = that._categories.length,
- result = 0;
- if (pos < startPoint || pos > canvasOptions.endPoint)
- return null;
- result = doubleRound((pos - startPoint) / canvasOptions.interval + (that._businessRange.stick ? 0.5 : 0) - 0.5);
- if (categoriesLength === result)
- result--;
- if (canvasOptions.invert)
- result = categoriesLength - result - 1;
- return that._categories[result]
- },
- getInterval: function() {
- return this._canvasOptions.interval
- }
- }
- })(jQuery, DevExpress);
- /*! Module viz-core, file logarithmicTranslator.js */
- (function($, DX, undefined) {
- var core = DX.viz.core,
- numericTranslator = core.numericTranslatorFunctions,
- utils = DX.utils,
- raiseTo = utils.raiseTo,
- getLog = utils.getLog;
- core.logarithmicTranslatorFunctions = {
- translate: function(bp) {
- var that = this,
- specialValue = that.translateSpecialCase(bp);
- if (utils.isDefined(specialValue))
- return specialValue;
- return numericTranslator.translate.call(that, getLog(bp, that._businessRange.base))
- },
- untranslate: function(pos) {
- var result = numericTranslator.untranslate.call(this, pos);
- return result === null ? result : raiseTo(result, this._businessRange.base)
- },
- getInterval: numericTranslator.getInterval
- }
- })(jQuery, DevExpress);
- /*! Module viz-core, file translator1D.js */
- (function(DX, undefined) {
- var _Number = Number;
- function Translator1D() {
- this.setDomain(arguments[0], arguments[1]).setCodomain(arguments[2], arguments[3])
- }
- Translator1D.prototype = {
- constructor: Translator1D,
- setDomain: function(domain1, domain2) {
- var that = this;
- that._domain1 = _Number(domain1);
- that._domain2 = _Number(domain2);
- that._domainDelta = that._domain2 - that._domain1;
- return that
- },
- setCodomain: function(codomain1, codomain2) {
- var that = this;
- that._codomain1 = _Number(codomain1);
- that._codomain2 = _Number(codomain2);
- that._codomainDelta = that._codomain2 - that._codomain1;
- return that
- },
- getDomain: function() {
- return [this._domain1, this._domain2]
- },
- getCodomain: function() {
- return [this._codomain1, this._codomain2]
- },
- getDomainStart: function() {
- return this._domain1
- },
- getDomainEnd: function() {
- return this._domain2
- },
- getCodomainStart: function() {
- return this._codomain1
- },
- getCodomainEnd: function() {
- return this._codomain2
- },
- getDomainRange: function() {
- return this._domainDelta
- },
- getCodomainRange: function() {
- return this._codomainDelta
- },
- translate: function(value) {
- var ratio = (_Number(value) - this._domain1) / this._domainDelta;
- return 0 <= ratio && ratio <= 1 ? this._codomain1 + ratio * this._codomainDelta : NaN
- },
- adjust: function(value) {
- var ratio = (_Number(value) - this._domain1) / this._domainDelta,
- result = NaN;
- if (ratio < 0)
- result = this._domain1;
- else if (ratio > 1)
- result = this._domain2;
- else if (0 <= ratio && ratio <= 1)
- result = _Number(value);
- return result
- }
- };
- DX.viz.core.Translator1D = Translator1D
- })(DevExpress);
- /*! Module viz-core, file translator2D.js */
- (function($, DX, undefined) {
- var core = DX.viz.core,
- utils = DX.utils,
- getLog = utils.getLog,
- getPower = utils.getPower,
- raiseTo = utils.raiseTo,
- isDefined = utils.isDefined,
- CANVAS_PROP = ["width", "height", "left", "top", "bottom", "right"],
- NUMBER_EQUALITY_CORRECTION = 1,
- DATETIME_EQUALITY_CORRECTION = 60000;
- var validateCanvas = function(canvas) {
- $.each(CANVAS_PROP, function(_, prop) {
- canvas[prop] = parseInt(canvas[prop]) || 0
- });
- return canvas
- };
- var raiseToFlooredLog = function(value, base, correction) {
- return raiseTo(Math.floor(getLog(value, base)) + (correction || 0), base)
- };
- var makeCategoriesToPoints = function(categories, invert) {
- var categoriesToPoints = {},
- category,
- length = categories.length,
- i;
- for (i = 0; i < length; i++) {
- category = categories[i];
- categoriesToPoints[category] = {
- name: category,
- index: invert ? length - 1 - i : i
- }
- }
- return categoriesToPoints
- };
- var validateBusinessRange = function(businessRange) {
- function validate(valueSelector, baseValueSeletor) {
- if (!isDefined(businessRange[valueSelector]) && isDefined(businessRange[baseValueSeletor]))
- businessRange[valueSelector] = businessRange[baseValueSeletor]
- }
- validate("minVisible", "min");
- validate("maxVisible", "max");
- return businessRange
- };
- core.Translator2D = function(businessRange, canvas, options) {
- var that = this;
- that._options = $.extend(that._options || {}, options);
- that._canvas = validateCanvas(canvas);
- that.updateBusinessRange(businessRange)
- };
- $.extend(core.Translator2D.prototype, {
- reinit: function() {
- var that = this,
- range = that._businessRange,
- categories = range.categories || [],
- script = {},
- canvasOptions = that._prepareCanvasOptions(),
- interval,
- correctedCategoriesCount;
- switch (range.axisType) {
- case"logarithmic":
- script = core.logarithmicTranslatorFunctions;
- break;
- case"discrete":
- script = core.categoryTranslatorFunctions;
- that._categories = categories;
- correctedCategoriesCount = categories.length - (range.stick ? 1 : 0);
- if (correctedCategoriesCount > 0)
- interval = canvasOptions.canvasLength / correctedCategoriesCount;
- else
- interval = canvasOptions.canvasLength;
- canvasOptions.interval = interval;
- that._categoriesToPoints = makeCategoriesToPoints(categories, canvasOptions.invert);
- break;
- default:
- if (range.dataType === "datetime")
- script = core.datetimeTranslatorFunctions;
- else
- script = core.numericTranslatorFunctions
- }
- that.translate = script.translate;
- that.untranslate = script.untranslate;
- that.getInterval = script.getInterval
- },
- _getCanvasBounds: function(range) {
- var min = range.min,
- max = range.max,
- minVisible = range.minVisible,
- maxVisible = range.maxVisible,
- newMin,
- newMax,
- base = range.base,
- isDateTime = utils.isDate(max) || utils.isDate(min),
- correction = isDateTime ? DATETIME_EQUALITY_CORRECTION : NUMBER_EQUALITY_CORRECTION;
- if (isDefined(min) && isDefined(max) && min.valueOf() === max.valueOf()) {
- newMin = min.valueOf() - correction;
- newMax = max.valueOf() + correction;
- if (isDateTime) {
- min = new Date(newMin);
- max = new Date(newMax)
- }
- else {
- min = min !== 0 ? newMin : 0;
- max = newMax
- }
- }
- if (isDefined(minVisible) && isDefined(maxVisible) && minVisible.valueOf() === maxVisible.valueOf()) {
- newMin = minVisible.valueOf() - correction;
- newMax = maxVisible.valueOf() + correction;
- if (isDateTime) {
- minVisible = newMin < min.valueOf() ? min : new Date(newMin);
- maxVisible = newMax > max.valueOf() ? max : new Date(newMax)
- }
- else {
- if (minVisible !== 0)
- minVisible = newMin < min ? min : newMin;
- maxVisible = newMax > max ? max : newMax
- }
- }
- if (range.axisType === 'logarithmic') {
- maxVisible = getLog(maxVisible, base);
- minVisible = getLog(minVisible, base);
- min = getLog(min, base);
- max = getLog(max, base)
- }
- return {
- base: base,
- rangeMin: min,
- rangeMax: max,
- rangeMinVisible: minVisible,
- rangeMaxVisible: maxVisible
- }
- },
- _prepareCanvasOptions: function() {
- var that = this,
- rangeMin,
- rangeMax,
- rangeMinVisible,
- rangeMaxVisible,
- businessRange = that._businessRange,
- canvasOptions = that._canvasOptions = that._getCanvasBounds(businessRange),
- length;
- if (that._options.direction === "horizontal") {
- canvasOptions.startPoint = that._canvas.left;
- length = that._canvas.width;
- canvasOptions.endPoint = that._canvas.width - that._canvas.right;
- canvasOptions.invert = businessRange.invert
- }
- else {
- canvasOptions.startPoint = that._canvas.top;
- length = that._canvas.height;
- canvasOptions.endPoint = that._canvas.height - that._canvas.bottom;
- canvasOptions.invert = !businessRange.invert
- }
- that.canvasLength = canvasOptions.canvasLength = canvasOptions.endPoint - canvasOptions.startPoint;
- canvasOptions.rangeDoubleError = Math.pow(10, getPower(canvasOptions.rangeMax - canvasOptions.rangeMin) - getPower(length) - 2);
- canvasOptions.ratioOfCanvasRange = canvasOptions.canvasLength / (canvasOptions.rangeMaxVisible - canvasOptions.rangeMinVisible);
- return canvasOptions
- },
- updateBusinessRange: function(businessRange) {
- this._businessRange = validateBusinessRange(businessRange);
- this.reinit()
- },
- getBusinessRange: function() {
- return this._businessRange
- },
- getCanvasVisibleArea: function() {
- return {
- min: this._canvasOptions.startPoint,
- max: this._canvasOptions.endPoint
- }
- },
- translateSpecialCase: function(value) {
- var that = this,
- canvasOptions = that._canvasOptions,
- startPoint = canvasOptions.startPoint,
- endPoint = canvasOptions.endPoint,
- range = that._businessRange,
- minVisible = range.minVisible,
- maxVisible = range.maxVisible,
- invert,
- result = null;
- switch (value) {
- case"canvas_position_default":
- if (minVisible <= 0 && maxVisible >= 0)
- result = that.translate(0);
- else {
- invert = range.invert ^ (minVisible <= 0 && maxVisible <= 0);
- if (that._options.direction === "horizontal")
- result = invert ? endPoint : startPoint;
- else
- result = invert ? startPoint : endPoint
- }
- break;
- case"canvas_position_left":
- case"canvas_position_top":
- result = startPoint;
- break;
- case"canvas_position_center":
- case"canvas_position_middle":
- result = startPoint + canvasOptions.canvasLength / 2;
- break;
- case"canvas_position_right":
- case"canvas_position_bottom":
- result = endPoint;
- break;
- case"canvas_position_start":
- result = range.invert ? endPoint : startPoint;
- break;
- case"canvas_position_end":
- result = range.invert ? startPoint : endPoint;
- break
- }
- return result
- },
- _calculateProjection: function(distance) {
- var canvasOptions = this._canvasOptions;
- return canvasOptions.invert ? canvasOptions.endPoint - distance : canvasOptions.startPoint + distance
- },
- _calculateUnProjection: function(distance) {
- var canvasOptions = this._canvasOptions;
- return canvasOptions.invert ? canvasOptions.rangeMaxVisible.valueOf() - distance : canvasOptions.rangeMinVisible.valueOf() + distance
- }
- })
- })(jQuery, DevExpress);
- /*! Module viz-core, file rectangle.js */
- (function(DX, undefined) {
- var isFinite = window.isFinite;
- DX.viz.core.Rectangle = DX.Class.inherit({
- ctor: function(options) {
- var that = this;
- options = options || {};
- that.left = Number(options.left) || 0;
- that.right = Number(options.right) || 0;
- that.top = Number(options.top) || 0;
- that.bottom = Number(options.bottom) || 0
- },
- width: function() {
- return this.right - this.left
- },
- height: function() {
- return this.bottom - this.top
- },
- horizontalMiddle: function() {
- return (this.left + this.right) / 2
- },
- verticalMiddle: function() {
- return (this.top + this.bottom) / 2
- },
- raw: function() {
- var that = this;
- return {
- left: that.left,
- top: that.top,
- right: that.right,
- bottom: that.bottom
- }
- },
- clone: function() {
- return new this.constructor(this.raw())
- },
- move: function(dx, dy) {
- var result = this.clone();
- if (isFinite(dx) && isFinite(dy)) {
- result.left += Number(dx);
- result.right += Number(dx);
- result.top += Number(dy);
- result.bottom += Number(dy)
- }
- return result
- },
- inflate: function(dx, dy) {
- var result = this.clone();
- if (isFinite(dx) && isFinite(dy)) {
- result.left -= Number(dx);
- result.right += Number(dx);
- result.top -= Number(dy);
- result.bottom += Number(dy)
- }
- return result
- },
- scale: function(factor) {
- var that = this;
- if (factor > 0)
- return that.inflate(that.width() * (factor - 1) / 2, that.height() * (factor - 1) / 2);
- return that.clone()
- }
- })
- })(DevExpress);
- /*! Module viz-core, file themes.js */
- (function($, DX, undefined) {
- var viz = DX.viz,
- core = viz.core;
- var currentThemeId = 0;
- var findThemeId = function(themeName) {
- var themeId,
- themes = viz.themes;
- for (themeId = 0; themeId < themes.length; themeId++)
- if (themes[themeId].name === themeName)
- return themeId;
- return -1
- };
- core.findTheme = function(themeName) {
- var themeId = findThemeId(themeName),
- themes = viz.themes;
- if (themeId < 0)
- themeId = currentThemeId;
- return themes[themeId]
- };
- core.currentTheme = function(themeName, colorScheme, version) {
- var themeId = -1,
- themes = viz.themes;
- if (themeName === undefined)
- return themes[currentThemeId].name;
- else {
- if (version && colorScheme)
- themeId = findThemeId(themeName + ':' + version + '-' + colorScheme);
- if (themeId < 0 && version)
- themeId = findThemeId(themeName + ':' + version);
- if (colorScheme && themeId < 0)
- themeId = findThemeId(themeName + '-' + colorScheme);
- if (themeId < 0)
- themeId = findThemeId(themeName);
- currentThemeId = themeId >= 0 ? themeId : 0
- }
- };
- core.registerTheme = function(theme, basedOnThemeName) {
- var baseTheme,
- extendedTheme,
- themes = viz.themes;
- if (!theme || !theme.name || !core.findTheme(theme.name))
- return;
- baseTheme = core.findTheme(basedOnThemeName);
- if (baseTheme) {
- extendedTheme = $.extend(true, {}, baseTheme, theme);
- themes.push(extendedTheme)
- }
- else
- themes.push(theme)
- }
- })(jQuery, DevExpress);
- /*! Module viz-core, file palette.js */
- (function(DX, $, undefined) {
- var _String = window.String,
- _Color = DX.Color,
- _isArray = DX.utils.isArray,
- _isString = DX.utils.isString,
- _extend = $.extend;
- var palettes = {
- 'default': {
- simpleSet: ['#5f8b95', '#ba4d51', '#af8a53', '#955f71', '#859666', '#7e688c'],
- indicatingSet: ['#a3b97c', '#e1b676', '#ec7f83'],
- gradientSet: ['#5f8b95', '#ba4d51']
- },
- 'harmony light': {
- simpleSet: ['#fcb65e', '#679ec5', '#ad79ce', '#7abd5c', '#e18e92', '#b6d623', '#b7abea', '#85dbd5'],
- indicatingSet: ['#b6d623', '#fcb65e', '#e18e92'],
- gradientSet: ['#7abd5c', '#fcb65e']
- },
- 'soft pastel': {
- simpleSet: ['#60a69f', '#78b6d9', '#6682bb', '#a37182', '#eeba69', '#90ba58', '#456c68', '#7565a4'],
- indicatingSet: ['#90ba58', '#eeba69', '#a37182'],
- gradientSet: ['#78b6d9', '#eeba69']
- },
- pastel: {
- simpleSet: ['#bb7862', '#70b3a1', '#bb626a', '#057d85', '#ab394b', '#dac599', '#153459', '#b1d2c6'],
- indicatingSet: ['#70b3a1', '#dac599', '#bb626a'],
- gradientSet: ['#bb7862', '#70b3a1']
- },
- bright: {
- simpleSet: ['#70c92f', '#f8ca00', '#bd1550', '#e97f02', '#9d419c', '#7e4452', '#9ab57e', '#36a3a6'],
- indicatingSet: ['#70c92f', '#f8ca00', '#bd1550'],
- gradientSet: ['#e97f02', '#f8ca00']
- },
- soft: {
- simpleSet: ['#cbc87b', '#9ab57e', '#e55253', '#7e4452', '#e8c267', '#565077', '#6babac', '#ad6082'],
- indicatingSet: ['#9ab57e', '#e8c267', '#e55253'],
- gradientSet: ['#9ab57e', '#e8c267']
- },
- ocean: {
- simpleSet: ['#75c099', '#acc371', '#378a8a', '#5fa26a', '#064970', '#38c5d2', '#00a7c6', '#6f84bb'],
- indicatingSet: ['#c8e394', '#7bc59d', '#397c8b'],
- gradientSet: ['#acc371', '#38c5d2']
- },
- vintage: {
- simpleSet: ['#dea484', '#efc59c', '#cb715e', '#eb9692', '#a85c4c', '#f2c0b5', '#c96374', '#dd956c'],
- indicatingSet: ['#ffe5c6', '#f4bb9d', '#e57660'],
- gradientSet: ['#efc59c', '#cb715e']
- },
- violet: {
- simpleSet: ['#d1a1d1', '#eeacc5', '#7b5685', '#7e7cad', '#a13d73', '#5b41ab', '#e287e2', '#689cc1'],
- indicatingSet: ['#d8e2f6', '#d0b2da', '#d56a8a'],
- gradientSet: ['#eeacc5', '#7b5685']
- }
- };
- var currentPaletteName = 'default';
- function currentPalette(name) {
- if (name === undefined)
- return currentPaletteName;
- else {
- name = String(name).toLowerCase();
- currentPaletteName = name in palettes ? name : 'default'
- }
- }
- function getPalette(palette, parameters) {
- var result;
- if (_isArray(palette))
- result = palette;
- else {
- parameters = parameters || {};
- var type = parameters.type || 'simpleSet';
- if (_isString(palette)) {
- var name = palette.toLowerCase(),
- baseContainer = palettes[name],
- themedContainer = parameters.theme && palettes[name + '_' + _String(parameters.theme).toLowerCase()];
- result = themedContainer && themedContainer[type] || baseContainer && baseContainer[type]
- }
- if (!result)
- result = palettes[currentPaletteName][type]
- }
- return result ? result.slice(0) : null
- }
- function registerPalette(name, palette, theme) {
- var item = {};
- if (_isArray(palette))
- item.simpleSet = palette.slice(0);
- else if (palette) {
- item.simpleSet = _isArray(palette.simpleSet) ? palette.simpleSet.slice(0) : undefined;
- item.indicatingSet = _isArray(palette.indicatingSet) ? palette.indicatingSet.slice(0) : undefined;
- item.gradientSet = _isArray(palette.gradientSet) ? palette.gradientSet.slice(0) : undefined
- }
- if (item.simpleSet || item.indicatingSet || item.gradientSet) {
- var paletteName = _String(name).toLowerCase();
- if (theme)
- paletteName = paletteName + '_' + _String(theme).toLowerCase();
- _extend(palettes[paletteName] = palettes[paletteName] || {}, item)
- }
- }
- function RingBuf(buf) {
- var ind = 0;
- this.next = function() {
- var res = buf[ind++];
- if (ind == buf.length)
- this.reset();
- return res
- };
- this.reset = function() {
- ind = 0
- }
- }
- function Palette(palette, parameters) {
- parameters = parameters || {};
- this._originalPalette = getPalette(palette, parameters);
- var stepHighlight = parameters ? parameters.stepHighlight || 0 : 0;
- this._paletteSteps = new RingBuf([0, stepHighlight, -stepHighlight]);
- this._resetPalette()
- }
- _extend(Palette.prototype, {
- dispose: function() {
- this._originalPalette = this._palette = this._paletteSteps = null;
- return this
- },
- getNextColor: function() {
- var that = this;
- if (that._currentColor >= that._palette.length)
- that._resetPalette();
- return that._palette[that._currentColor++]
- },
- _resetPalette: function() {
- var that = this;
- that._currentColor = 0;
- var step = that._paletteSteps.next(),
- originalPalette = that._originalPalette;
- if (step) {
- var palette = that._palette = [],
- i = 0,
- ii = originalPalette.length;
- for (; i < ii; ++i)
- palette[i] = getNewColor(originalPalette[i], step)
- }
- else
- that._palette = originalPalette.slice(0)
- },
- reset: function() {
- this._paletteSteps.reset();
- this._resetPalette();
- return this
- }
- });
- function getNewColor(currentColor, step) {
- var newColor = new _Color(currentColor).alter(step),
- lightness = getLightness(newColor);
- if (lightness > 200 || lightness < 55)
- newColor = new _Color(currentColor).alter(-step / 2);
- return newColor.toHex()
- }
- function getLightness(color) {
- return color.r * 0.3 + color.g * 0.59 + color.b * 0.11
- }
- function GradientPalette(source, size) {
- var palette = getPalette(source, {type: 'gradientSet'});
- palette = size > 0 ? createGradientColors(palette[0], palette[1], size) : [];
- this.getColor = function(index) {
- return palette[index] || null
- };
- this._DEBUG_source = source;
- this._DEBUG_size = size
- }
- function createGradientColors(start, end, count) {
- var startColor = new _Color(start),
- endColor = new _Color(end);
- if (count === 1)
- return [startColor.blend(endColor, 0.5).toHex()];
- else {
- var list = [],
- step = 1 / (count - 1),
- i,
- ii = count;
- list.push(0);
- for (i = 1; i < ii - 1; ++i)
- list.push(step * i);
- list.push(1);
- for (i = 0; i < ii; ++i)
- list[i] = startColor.blend(endColor, list[i]).toHex();
- return list
- }
- }
- _extend(DX.viz.core, {
- registerPalette: registerPalette,
- getPalette: getPalette,
- Palette: Palette,
- GradientPalette: GradientPalette,
- currentPalette: currentPalette
- });
- DX.viz.core._DEBUG_palettes = palettes
- })(DevExpress, jQuery);
- /*! Module viz-core, file baseThemeManager.js */
- (function(DX, $, undefined) {
- var _isString = DX.utils.isString,
- _findTheme = DX.viz.core.findTheme,
- _extend = $.extend,
- _each = $.each;
- DX.viz.core.BaseThemeManager = DX.Class.inherit({
- dispose: function() {
- this._theme = this._font = null;
- return this
- },
- setTheme: function(theme) {
- theme = theme || {};
- var that = this,
- themeObj = _findTheme(_isString(theme) ? theme : theme.name);
- that._themeName = themeObj.name;
- that._font = _extend({}, themeObj.font, theme.font);
- that._themeSection && _each(that._themeSection.split('.'), function(_, path) {
- themeObj = _extend(true, {}, themeObj[path], that._IE8 ? themeObj[path + 'IE8'] : {})
- });
- that._theme = _extend(true, {}, themeObj, _isString(theme) ? {} : theme);
- that._initializeTheme();
- return that
- },
- theme: function() {
- return this._theme
- },
- themeName: function() {
- return this._themeName
- },
- _initializeTheme: function(){},
- _initializeFont: function(font) {
- _extend(font, this._font, _extend({}, font))
- }
- })
- })(DevExpress, jQuery);
- /*! Module viz-core, file textCloud.js */
- (function(DX, undefined) {
- var min = Math.min;
- DX.viz.core.TextCloud = DX.Class.inherit(function() {
- var DEFAULT_OPTIONS = {
- horMargin: 8,
- verMargin: 4,
- tailLength: 10
- };
- var COEFFICIENTS_MAP = {};
- COEFFICIENTS_MAP['right-bottom'] = COEFFICIENTS_MAP['rb'] = [0, -1, -1, 0, 0, 1, 1, 0];
- COEFFICIENTS_MAP['bottom-right'] = COEFFICIENTS_MAP['br'] = [-1, 0, 0, -1, 1, 0, 0, 1];
- COEFFICIENTS_MAP['left-bottom'] = COEFFICIENTS_MAP['lb'] = [0, -1, 1, 0, 0, 1, -1, 0];
- COEFFICIENTS_MAP['bottom-left'] = COEFFICIENTS_MAP['bl'] = [1, 0, 0, -1, -1, 0, 0, 1];
- COEFFICIENTS_MAP['left-top'] = COEFFICIENTS_MAP['lt'] = [0, 1, 1, 0, 0, -1, -1, 0];
- COEFFICIENTS_MAP['top-left'] = COEFFICIENTS_MAP['tl'] = [1, 0, 0, 1, -1, 0, 0, -1];
- COEFFICIENTS_MAP['right-top'] = COEFFICIENTS_MAP['rt'] = [0, 1, -1, 0, 0, -1, 1, 0];
- COEFFICIENTS_MAP['top-right'] = COEFFICIENTS_MAP['tr'] = [-1, 0, 0, 1, 1, 0, 0, -1];
- return {
- setup: function(options) {
- var that = this,
- ops = $.extend({}, DEFAULT_OPTIONS, options),
- x = ops.x,
- y = ops.y,
- type = COEFFICIENTS_MAP[ops.type],
- cloudWidth = ops.textWidth + 2 * ops.horMargin,
- cloudHeight = ops.textHeight + 2 * ops.verMargin,
- tailWidth = ops.tailLength,
- tailHeight = tailWidth,
- cx = x,
- cy = y;
- if (type[0] & 1)
- tailHeight = min(tailHeight, cloudHeight / 3);
- else
- tailWidth = min(tailWidth, cloudWidth / 3);
- that._points = [x, y, x += type[0] * (cloudWidth + tailWidth), y += type[1] * (cloudHeight + tailHeight), x += type[2] * cloudWidth, y += type[3] * cloudHeight, x += type[4] * cloudWidth, y += type[5] * cloudHeight, x += type[6] * (cloudWidth - tailWidth), y += type[7] * (cloudHeight - tailHeight)];
- that._cx = cx + type[0] * tailWidth + (type[0] + type[2]) * cloudWidth / 2;
- that._cy = cy + type[1] * tailHeight + (type[1] + type[3]) * cloudHeight / 2;
- that._cloudWidth = cloudWidth;
- that._cloudHeight = cloudHeight;
- that._tailLength = ops.tailLength;
- return that
- },
- points: function() {
- return this._points.slice(0)
- },
- cx: function() {
- return this._cx
- },
- cy: function() {
- return this._cy
- },
- width: function() {
- return this._cloudWidth
- },
- height: function() {
- return this._cloudHeight
- },
- tailLength: function() {
- return this._tailLength
- }
- }
- }())
- })(DevExpress);
- /*! Module viz-core, file parseUtils.js */
- (function($, DX) {
- var viz = DX.viz,
- core = viz.core,
- Class = DX.Class,
- isDefined = DX.utils.isDefined;
- var parseUtils = Class.inherit({
- ctor: function(options) {
- options = options || {};
- this._incidentOccured = $.isFunction(options.incidentOccured) ? options.incidentOccured : $.noop
- },
- correctValueType: function(type) {
- return type === 'numeric' || type === 'datetime' || type === 'string' ? type : ''
- },
- _parsers: {
- string: function(val) {
- return isDefined(val) ? '' + val : val
- },
- numeric: function(val) {
- if (!isDefined(val))
- return val;
- var parsedVal = Number(val);
- if (isNaN(parsedVal))
- parsedVal = undefined;
- return parsedVal
- },
- datetime: function(val) {
- if (!isDefined(val))
- return val;
- var parsedVal,
- numVal = Number(val);
- if (!isNaN(numVal))
- parsedVal = new Date(numVal);
- else
- parsedVal = new Date(val);
- if (isNaN(Number(parsedVal)))
- parsedVal = undefined;
- return parsedVal
- }
- },
- getParser: function(valueType, entity) {
- var that = this,
- parser,
- message = 'valueType is unknown.';
- if (entity)
- message = 'The type specified as the "valueType" field of the ' + entity + ' configuration object is unknown.';
- valueType = that.correctValueType(valueType);
- parser = that._parsers[valueType];
- if (!parser)
- this._incidentOccured.call(null, message);
- return parser || $.noop
- }
- });
- core.ParseUtils = parseUtils
- })(jQuery, DevExpress);
- /*! Module viz-core, file utils.js */
- (function($, DX) {
- var core = DX.viz.core,
- math = Math;
- core.utils = {decreaseGaps: function(object, keys, decrease) {
- var arrayGaps,
- eachDecrease,
- middleValue;
- do {
- arrayGaps = $.map(keys, function(key) {
- return object[key] ? object[key] : null
- });
- middleValue = math.ceil(decrease / arrayGaps.length);
- arrayGaps.push(middleValue);
- eachDecrease = math.min.apply(null, arrayGaps);
- $.each(keys, function(_, key) {
- if (object[key]) {
- object[key] -= eachDecrease;
- decrease -= eachDecrease
- }
- })
- } while (decrease > 0 && arrayGaps.length > 1);
- return decrease
- }}
- })(jQuery, DevExpress);
- /*! Module viz-core, file loadIndicator.js */
- (function($, DX) {
- var viz = DX.viz,
- core = viz.core,
- ANIMATION_SETTINGS = {
- easing: 'linear',
- duration: 150
- },
- INVISIBLE_POINT = {
- x: -10000,
- y: -10000
- };
- var applySettings = function(element, settings, animate, complete) {
- var prevAnimation = element.animation;
- if (prevAnimation) {
- prevAnimation.options.complete = null;
- prevAnimation.stop()
- }
- if (animate)
- element.animate(settings, {complete: complete});
- else {
- element.applySettings(settings);
- complete && complete()
- }
- };
- core.LoadIndicator = DX.Class.inherit({
- ctor: function(options, widgetContainer) {
- var that = this;
- that._$widgetContainer = $(widgetContainer);
- that._$container = $('<div>', {css: {
- position: 'relative',
- height: 0,
- padding: 0,
- margin: 0,
- border: 0
- }}).appendTo(that._$widgetContainer);
- that._updateContainer();
- that.applyOptions(options);
- that._endLoadingCompleteHandler = function() {
- that._endLoad = false;
- that._externalComplete && that._externalComplete();
- that._externalComplete = null;
- that._onCompleteAction && that[that._onCompleteAction]();
- that._onCompleteAction = null
- };
- that._$container.hide()
- },
- _updateRenderer: function(width, height, top) {
- if (this._renderer)
- this._renderer.recreateCanvas(width, height);
- else if (this._$container.get(0)) {
- this._renderer = new viz.renderers.Renderer({
- width: width,
- height: height,
- animation: ANIMATION_SETTINGS
- });
- this._renderer.draw(this._$container[0])
- }
- this._renderer && this._renderer.getRoot().applySettings({style: {
- position: 'absolute',
- top: top,
- left: 0
- }});
- return this._renderer
- },
- applyOptions: function(options, width, height) {
- var pane = this._pane;
- if (pane && options) {
- pane.rect.applySettings({fill: options.backgroundColor});
- pane.text.applySettings({
- font: options.font,
- text: options.text
- })
- }
- if (this.isShown && (width || height))
- this._updateContainer(width, height)
- },
- _draw: function() {
- var pane,
- renderer = this._renderer;
- if (renderer) {
- pane = this._pane = {};
- pane.rect = renderer.createRect(0, 0, 0, 0, 0, {opacity: 0}).append();
- pane.text = renderer.createText('', 0, 0, {
- align: 'center',
- translateX: INVISIBLE_POINT.x,
- translateY: INVISIBLE_POINT.y
- }).append()
- }
- },
- _updateContainer: function(width, height) {
- var that = this,
- $widgetContainer = that._$widgetContainer,
- canvasTop;
- width = width || $widgetContainer.width();
- height = height || $widgetContainer.height();
- if ($widgetContainer.get(0))
- canvasTop = $widgetContainer.offset().top - that._$container.offset().top;
- else
- canvasTop = -height;
- that._updateRenderer(width, height, canvasTop);
- if (!that._pane)
- that._draw();
- else {
- that._pane.rect.applySettings({
- width: width,
- height: height
- });
- that._pane.text.move(width / 2, height / 2)
- }
- },
- dispose: function() {
- this._$widgetContainer = null;
- this._$container.remove().detach();
- this._$container = null;
- this._renderer.dispose();
- this._renderer = null;
- this._pane = null
- },
- toForeground: function() {
- this._$container.appendTo(this._$widgetContainer)
- },
- show: function(width, height) {
- if (this._endLoad) {
- this._onCompleteAction = 'show';
- return
- }
- this._$container.show();
- this._updateContainer(width, height);
- applySettings(this._pane.rect, {opacity: 0.85}, true);
- this.isShown = true
- },
- endLoading: function(complete, disableAnimation) {
- this._externalComplete = complete;
- if (this._endLoad)
- return;
- if (this.isShown) {
- this._endLoad = true;
- applySettings(this._pane.rect, {opacity: 1}, !disableAnimation, this._endLoadingCompleteHandler)
- }
- else
- complete && complete()
- },
- hide: function() {
- var that = this;
- if (this._endLoad) {
- this._onCompleteAction = 'hide';
- return
- }
- if (this.isShown) {
- this._pane.text.move(INVISIBLE_POINT.x, INVISIBLE_POINT.y);
- applySettings(that._pane.rect, {opacity: 0}, true, function() {
- that._$container.hide()
- });
- this.isShown = false
- }
- }
- })
- })(jQuery, DevExpress);
- /*! Module viz-core, file tooltip.js */
- (function($, DX, undefined) {
- var ARROW_WIDTH = 20,
- MAX_SHADOW_SIZE = 10,
- formatHelper = DX.formatHelper,
- X_INTERVAL = 15,
- _max = Math.max,
- _round = Math.round,
- _isFunction = DX.utils.isFunction,
- _isDefined = DX.utils.isDefined,
- _extend = $.extend,
- FORMAT_PRECISION = {
- argument: ['argumentFormat', 'argumentPrecision'],
- percent: ['percent', 'percentPrecision'],
- value: ['format', 'precision']
- },
- VISIBLE = {visibility: 'visible'},
- HIDDEN = {visibility: 'hidden'},
- LEFT = 'left',
- RIGHT = 'right';
- DX.viz.core.Tooltip = DX.Class.inherit({
- ctor: function(options, group, renderer) {
- this._state = {};
- this._options = {};
- this._renderer = renderer;
- this._group = group;
- this._cloud = renderer.createArea();
- this._textGroup = renderer.createGroup();
- if (!$.isEmptyObject(options))
- this.update(options);
- this._createTextContent()
- },
- dispose: function() {
- this._shadow.dispose();
- this._shadow = null;
- this._cloud = null;
- this._text = null;
- this._group = null;
- this._options = null;
- this._renderer = null;
- this._tooltipTextArray = null;
- this._textGroup = null;
- return this
- },
- update: function(options) {
- options = options || {};
- var that = this,
- group = that._group,
- shadowOptions = options.shadow || {},
- shadow = that._shadow = that._shadow || that._renderer.createFilter('shadow').applySettings({
- width: '200%',
- height: '200%',
- color: shadowOptions.color,
- opacity: shadowOptions.opacity,
- dx: shadowOptions.offsetX,
- dy: shadowOptions.offsetY,
- blur: shadowOptions.blur,
- x: '-50%',
- y: '-50%'
- }),
- borderSettings = options.border,
- shapeSettings = _extend({
- opacity: options.opacity,
- filter: shadow.append().ref
- }, borderSettings && borderSettings.visible ? {
- strokeWidth: borderSettings.width,
- stroke: borderSettings.color,
- strokeOpacity: borderSettings.opacity,
- dashStyle: borderSettings.dashStyle
- } : {
- strokeWidth: null,
- stroke: null
- }),
- textSettings = _extend({}, {
- align: 'center',
- font: options.font
- }, options.text);
- that._options = options;
- that.setSize(options.canvasWidth, options.canvasHeight);
- that._customizeTooltip = _isFunction(options.customizeTooltip) ? options.customizeTooltip : null;
- if (!that._customizeTooltip && _isFunction(options.customizeText))
- that._customizeTooltip = function() {
- return {text: options.customizeText.apply(this, arguments)}
- };
- that._cloud.applySettings(shapeSettings).append(group);
- that._text && options.font && that._text.applySettings({font: {size: options.font.size}});
- that._textGroup.applySettings(textSettings).append(group);
- that.hide();
- return that
- },
- formatValue: function(value, specialFormat) {
- var formatObj = FORMAT_PRECISION[specialFormat || 'value'],
- format = formatObj[0] in this._options ? this._options[formatObj[0]] : specialFormat;
- return formatHelper.format(value, format, this._options[formatObj[1]] || 0)
- },
- prepare: function(formatObject, params, defaultTextValueField) {
- this._state = this._state || {};
- defaultTextValueField = defaultTextValueField || 'valueText';
- var defaultText = formatObject[defaultTextValueField] || '';
- _extend(this._state, params);
- if (this._customizeTooltip) {
- var customize = this._customizeTooltip.call(formatObject, formatObject);
- customize = $.isPlainObject(customize) ? customize : {};
- if ('text' in customize)
- this._state.text = _isDefined(customize.text) ? String(customize.text) : '';
- else {
- if ($.isArray(defaultText)) {
- this._options._justify = true;
- this._createTextContent();
- defaultText = defaultText.join('<br/>')
- }
- this._state.text = defaultText
- }
- this._state.color = customize.color || this._options.color
- }
- else {
- this._state.text = defaultText;
- this._state.color = this._options.color
- }
- if (this._options._justify)
- this._state.text = this._state.text.split('<br/>');
- if (this._state.visibility == VISIBLE && !!this._state.text)
- this.show();
- return !!this._state.text
- },
- enabled: function() {
- return !!this._options.enabled
- },
- formatColorTooltip: function(that) {
- return that._customizeTooltip && that._customizeTooltip.call(this, this)
- },
- _getData: function() {
- var that = this,
- x = that._state.x,
- y = that._state.y,
- xt = x,
- yt = y,
- align = 'center',
- points = [],
- bbox = that._state.textBBox,
- options = that._options,
- paddingLeftRight = options.paddingLeftRight,
- paddingTopBottom = options.paddingTopBottom,
- arrowLength = options.arrowLength > 0 ? options.arrowLength : 0,
- horPosition = options.cloudHorizontalPosition,
- verPosition = options.cloudVerticalPosition,
- isHorPositionDefined = horPosition !== undefined && horPosition !== null,
- isVerPositionDefined = verPosition !== undefined && verPosition !== null,
- cloudWidth = bbox.width + paddingLeftRight * 2,
- cloudHeight = bbox.height + paddingTopBottom * 2,
- updatedText;
- updatedText = that._checkWidthText(cloudWidth, cloudHeight);
- if (updatedText) {
- that._state.textBBox = bbox = updatedText.bbox;
- cloudWidth = updatedText.cloudWidth;
- cloudHeight = updatedText.cloudHeight;
- paddingLeftRight = updatedText.paddingLeftRight;
- paddingTopBottom = updatedText.paddingTopBottom
- }
- if (isHorPositionDefined ? horPosition === RIGHT : cloudWidth / 2 > x) {
- points = that._setArrowLeft(cloudWidth, cloudHeight, arrowLength, x, y);
- align = LEFT;
- xt += paddingLeftRight
- }
- else if (isHorPositionDefined ? horPosition === LEFT : x + cloudWidth / 2 > that._canvasWidth) {
- points = that._setArrowRight(cloudWidth, cloudHeight, arrowLength, x, y);
- align = RIGHT;
- xt -= paddingLeftRight
- }
- else
- points = that._setArrowCenter(cloudWidth, cloudHeight, arrowLength, x, y);
- if (isVerPositionDefined ? verPosition === 'top' : cloudHeight + arrowLength < y) {
- yt -= arrowLength + cloudHeight / 2 - bbox.height / 2 + that._state.offset;
- that.tooltipInverted = false
- }
- else {
- yt += arrowLength + cloudHeight / 2 + bbox.height / 2 + that._state.offset;
- that.tooltipInverted = true
- }
- yt = that._correctYTextContent(yt);
- return {
- points: points,
- text: {
- x: xt,
- y: yt,
- align: align
- }
- }
- },
- _updateTextContent: function() {
- if (this._options._justify) {
- this._textGroup.clear();
- this._calculateTextContent();
- this._locateTextContent(0, 0, 'center')
- }
- else
- this._text.updateText(this._state.text);
- this._state.textBBox = this._textGroup.getBBox()
- },
- _correctYTextContent: function(y) {
- var bbox;
- if (this._options._justify) {
- this._locateTextContent(0, y, 'center');
- bbox = this._textGroup.getBBox()
- }
- else {
- this._text.applySettings({y: y});
- bbox = this._text.getBBox()
- }
- return y - (bbox.y + bbox.height - y)
- },
- _adjustTextContent: function(data) {
- if (this._options._justify)
- this._locateTextContent(data.text.x, data.text.y, data.text.align);
- else
- this._text.applySettings({
- x: data.text.x,
- y: data.text.y,
- align: data.text.align
- })
- },
- _updateTooltip: function() {
- var that = this,
- box,
- data,
- scale;
- data = that._getData();
- that._cloud.applySettings({
- points: data.points,
- fill: that._state.color,
- 'class': that._state.className
- });
- that._adjustTextContent(data);
- box = that._group.getBBox();
- if (box.y + box.height > that._canvasHeight) {
- scale = (that._canvasHeight - box.y) / box.height;
- that._group.applySettings({
- scale: scale,
- translateX: that._state.x * (1 - scale),
- translateY: that._state.y * (1 - scale)
- })
- }
- else
- that._group.applySettings({
- scale: 1,
- translateX: 0,
- translateY: 0
- })
- },
- _createTextContent: function() {
- var that = this,
- options = that._options,
- fontSize;
- that._textGroup.clear();
- that._text = null;
- if (!options._justify) {
- fontSize = options.font && options.font.size;
- that._text = that._renderer.createText(undefined, 0, 0, {font: {size: fontSize}}).append(that._textGroup)
- }
- },
- _getTextContentParams: function() {
- var that = this,
- i,
- text,
- textBBox,
- textArray = that._state.text,
- textArrayLength = textArray.length,
- textParams = {
- width: [],
- height: []
- };
- that._tooltipTextArray = [];
- for (i = 0; i < textArrayLength; i++) {
- text = that._renderer.createText(textArray[i], 0, 0, {}).append(this._textGroup);
- that._tooltipTextArray.push(text);
- textBBox = text.getBBox();
- textParams.width.push(textBBox.width)
- }
- that._lineHeight = -2 * textBBox.y - textBBox.height;
- return textParams
- },
- _locateTextContent: function(x, y, alignment) {
- var that = this,
- tooltipTextArray = that._tooltipTextArray,
- textWidth = that._textContentWidth,
- lineSpacing = that._options.lineSpacing,
- yDelta = (lineSpacing > 0 ? lineSpacing : 0) + that._lineHeight,
- leftXCoord,
- rightXCoord,
- i,
- rtl = that._options._rtl;
- if (alignment === LEFT)
- leftXCoord = x;
- else if (alignment === RIGHT)
- leftXCoord = x - textWidth;
- else
- leftXCoord = _round(x - textWidth / 2);
- rightXCoord = leftXCoord + textWidth;
- for (i = tooltipTextArray.length - 1; i >= 0; i -= 2) {
- tooltipTextArray[i].applySettings({
- x: !rtl ? rightXCoord : leftXCoord,
- y: y,
- align: !rtl ? RIGHT : LEFT
- });
- if (tooltipTextArray[i - 1])
- tooltipTextArray[i - 1].applySettings({
- x: !rtl ? leftXCoord : rightXCoord,
- y: y,
- align: !rtl ? LEFT : RIGHT
- });
- y -= yDelta
- }
- },
- _calculateTextContent: function() {
- var that = this,
- textArray = that._state.text,
- textArrayLength = textArray.length,
- textParams,
- width,
- stringWidthArray = [],
- i;
- textParams = that._getTextContentParams();
- for (i = 0; i < textArrayLength; i += 2) {
- if (textParams.width[i + 1])
- width = textParams.width[i] + X_INTERVAL + textParams.width[i + 1];
- else
- width = textParams.width[i];
- stringWidthArray.push(width)
- }
- that._textContentWidth = _max.apply(null, stringWidthArray)
- },
- setSize: function(width, height) {
- this._canvasWidth = _isDefined(width) ? width : this._canvasWidth;
- this._canvasHeight = _isDefined(height) ? height : this._canvasHeight;
- return this
- },
- getBBox: function() {
- var that = this,
- options = that._options,
- paddingLeftRight = options.paddingLeftRight || 0,
- paddingTopBottom = options.paddingTopBottom || 0,
- borderWidth = options.border.visible && options.border.width || 0,
- tooltipBBox = that._textGroup.getBBox();
- return tooltipBBox.isEmpty ? tooltipBBox : {
- x: tooltipBBox.x - paddingLeftRight - borderWidth / 2 - MAX_SHADOW_SIZE,
- y: tooltipBBox.y - paddingTopBottom - borderWidth / 2 - MAX_SHADOW_SIZE,
- height: tooltipBBox.height + 2 * paddingTopBottom + borderWidth + MAX_SHADOW_SIZE * 2,
- width: tooltipBBox.width + 2 * paddingLeftRight + borderWidth + MAX_SHADOW_SIZE * 2,
- isEmpty: false
- }
- },
- show: function() {
- this._state.visibility = VISIBLE;
- this._updateTextContent();
- this.move(this._state.x, this._state.y, this._state.offset);
- this._cloud.applySettings(VISIBLE);
- this._textGroup.applySettings(VISIBLE);
- return this
- },
- hide: function() {
- this._state.visibility = HIDDEN;
- this._cloud.applySettings(HIDDEN);
- this._textGroup.applySettings(HIDDEN);
- return this
- },
- move: function(x, y, offset) {
- this._state.x = _isDefined(x) ? x : this._state.x || 0;
- this._state.y = _isDefined(y) ? y : this._state.y || 0;
- this._state.offset = _isDefined(offset) ? offset : this._state.offset || 0;
- this._updateTooltip();
- return this
- },
- _setArrowCenter: function(cloudWidth, cloudHeight, arrowLength, x, y) {
- var that = this,
- position = that._options.cloudVerticalPosition,
- isPosDefined = position !== undefined && position !== null,
- verticalInvert = !(isPosDefined ? position === 'top' : cloudHeight + arrowLength < y),
- x0 = x,
- y0 = verticalInvert ? y + that._state.offset : y - that._state.offset,
- x1 = x0 + ARROW_WIDTH / 2,
- y1 = verticalInvert ? y0 + arrowLength : y0 - arrowLength,
- x2 = x1 + cloudWidth / 2 - ARROW_WIDTH / 2,
- y2 = y1,
- x3 = x2,
- y3 = verticalInvert ? y2 + cloudHeight : y2 - cloudHeight,
- x4 = x3 - cloudWidth,
- y4 = y3,
- x5 = x4,
- y5 = verticalInvert ? y4 - cloudHeight : y4 + cloudHeight,
- x6 = x5 + cloudWidth / 2 - ARROW_WIDTH / 2,
- y6 = y5;
- return [x0, y0, x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6]
- },
- _setArrowLeft: function(cloudWidth, cloudHeight, arrowLength, x, y) {
- var that = this,
- position = that._options.cloudVerticalPosition,
- isPosDefined = position !== undefined && position !== null,
- verticalInvert = !(isPosDefined ? position === 'top' : cloudHeight + arrowLength < y),
- x0 = x,
- y0 = verticalInvert ? y + that._state.offset : y - that._state.offset,
- x1 = x0 + ARROW_WIDTH,
- y1 = verticalInvert ? y0 + arrowLength : y0 - arrowLength,
- x2 = x1 + cloudWidth - ARROW_WIDTH,
- y2 = y1,
- x3 = x2,
- y3 = verticalInvert ? y2 + cloudHeight : y2 - cloudHeight,
- x4 = x3 - cloudWidth,
- y4 = y3,
- x5 = x4,
- y5 = verticalInvert ? y4 - cloudHeight - arrowLength : y4 + cloudHeight + arrowLength;
- return [x0, y0, x1, y1, x2, y2, x3, y3, x4, y4, x5, y5]
- },
- _setArrowRight: function(cloudWidth, cloudHeight, arrowLength, x, y) {
- var that = this,
- position = that._options.cloudVerticalPosition,
- isPosDefined = position !== undefined && position !== null,
- verticalInvert = !(isPosDefined ? position === 'top' : cloudHeight + arrowLength < y),
- x0 = x,
- y0 = verticalInvert ? y + that._state.offset : y - that._state.offset,
- x1 = x0,
- y1 = verticalInvert ? y0 + arrowLength + cloudHeight : y0 - arrowLength - cloudHeight,
- x2 = x1 - cloudWidth,
- y2 = y1,
- x3 = x2,
- y3 = verticalInvert ? y2 - cloudHeight : y2 + cloudHeight,
- x4 = x3 + cloudWidth - ARROW_WIDTH,
- y4 = y3,
- x5 = x4 + ARROW_WIDTH,
- y5 = verticalInvert ? y4 - arrowLength : y4 + arrowLength;
- return [x0, y0, x1, y1, x2, y2, x3, y3, x4, y4, x5, y5]
- },
- _checkWidthText: function(cloudWidth, cloudHeight) {
- if (this._options._justify)
- return;
- var x = this._state.x,
- text = this._state.text,
- index,
- paddingLeftRight = this._options.paddingLeftRight,
- paddingTopBottom = this._options.paddingTopBottom,
- textLength,
- maxTooltipWidth,
- remainLength,
- newIndex,
- bbox = this._state.textBBox;
- if (cloudWidth < x || x + cloudWidth < this._canvasWidth || cloudWidth / 2 < x && x + cloudWidth / 2 < this._canvasWidth)
- return false;
- if (text.indexOf("<br/>") === -1 && text.indexOf(" ") !== -1) {
- maxTooltipWidth = _max(x, this._canvasWidth - x, 2 * Math.min(x, this._canvasWidth - x));
- textLength = text.length * maxTooltipWidth / bbox.width;
- index = text.substr(0, ~~textLength).lastIndexOf(" ");
- if (index === -1)
- index = text.substr(0).indexOf(" ");
- remainLength = text.substr(index + 1).length;
- this._state.text = text.substr(0, index) + "<br/>";
- while (textLength <= remainLength) {
- newIndex = text.substr(index + 1, ~~textLength).lastIndexOf(" ");
- if (newIndex === -1)
- newIndex = text.substr(index + 1).indexOf(" ");
- if (newIndex !== -1) {
- this._state.text += text.substr(index + 1, newIndex) + "<br/>";
- remainLength = text.substr(index + 1 + newIndex).length;
- index += newIndex + 1
- }
- else
- break
- }
- this._state.text += text.substr(index + 1);
- this._text.updateText(this._state.text);
- bbox = this._text.getBBox();
- cloudWidth = bbox.width + paddingLeftRight * 2;
- cloudHeight = bbox.height + paddingTopBottom * 2
- }
- if (cloudWidth > x && x + cloudWidth > this._canvasWidth && (cloudWidth / 2 > x || x + cloudWidth / 2 > this._canvasWidth)) {
- paddingLeftRight = 5;
- paddingTopBottom = 5;
- cloudWidth = bbox.width + 2 * paddingLeftRight;
- cloudHeight = bbox.height + 2 * paddingTopBottom
- }
- return {
- bbox: bbox,
- cloudWidth: cloudWidth,
- cloudHeight: cloudHeight,
- paddingTopBottom: paddingTopBottom,
- paddingLeftRight: paddingLeftRight
- }
- }
- })
- })(jQuery, DevExpress);
- /*! Module viz-core, file legend.js */
- (function(DX, $, undefined) {
- var DEFAULT_MARGIN = 10,
- _math = Math,
- _round = _math.round,
- _ceil = _math.ceil,
- _floor = _math.floor,
- CENTER = 'center',
- RIGHT = 'right',
- LEFT = 'left',
- TOP = 'top',
- BOTTOM = 'bottom',
- HORIZONTAL = 'horizontal',
- VERTICAL = 'vertical',
- INSIDE = 'inside',
- OUTSIDE = 'outside',
- NONE = 'none',
- decreaseGaps = DevExpress.viz.core.utils.decreaseGaps,
- DEFAULT_MARKER_HATCHING_WIDTH = 2,
- DEFAULT_MARKER_HATCHING_STEP = 5;
- function getPatternId(renderer, states, action, color) {
- if (!states)
- return;
- var direction = states[action].hatching.direction,
- hatching,
- colorFromAction = states[action].fill;
- color = colorFromAction === NONE ? color : colorFromAction;
- direction = !direction || direction === NONE ? RIGHT : direction;
- hatching = $.extend({}, states[action].hatching, {
- direction: direction,
- step: DEFAULT_MARKER_HATCHING_STEP,
- width: DEFAULT_MARKER_HATCHING_WIDTH
- });
- return renderer.createPattern(color, hatching).append().id
- }
- function getMaxBBox(groups) {
- var maxWidth = 0,
- maxHeight = 0,
- bbox;
- $.each(groups, function(_, group) {
- bbox = group.getBBox();
- if (bbox.width > maxWidth)
- maxWidth = bbox.width;
- if (bbox.height > maxHeight)
- maxHeight = bbox.height
- });
- return {
- width: maxWidth,
- height: maxHeight
- }
- }
- DX.viz.core.Legend = DX.Class.inherit({
- ctor: function(data, options, renderer, group) {
- var that = this;
- that._renderer = renderer;
- that._legendGroup = group;
- that._markersPatternsIds = [];
- that._data = data;
- that._init(options)
- },
- _init: function(options) {
- if (!options)
- return;
- var debug = DX.utils.debug;
- debug.assertParam(options.visible, 'Visibility was not passed');
- debug.assertParam(options.markerSize, 'markerSize was not passed');
- debug.assertParam(options.font.color, 'fontColor was not passed');
- debug.assertParam(options.font.family, 'fontFamily was not passed');
- debug.assertParam(options.font.size, 'fontSize was not passed');
- debug.assertParam(options.paddingLeftRight, 'paddingLeftRight was not passed');
- debug.assertParam(options.paddingTopBottom, 'paddingTopBottom was not passed');
- debug.assertParam(options.columnItemSpacing, 'columnItemSpacing was not passed');
- debug.assertParam(options.rowItemSpacing, 'rowItemSpacing was not passed');
- debug.assertParam(options.equalColumnWidth, 'equalColumnWidth was not passed');
- var that = this,
- i;
- that._parseMargins(options);
- that._parseAlignments(options);
- options.orientation = (options.orientation || '').toLowerCase();
- if (options.orientation !== VERTICAL && options.orientation !== HORIZONTAL) {
- if (options.horizontalAlignment === CENTER)
- options.orientation = HORIZONTAL;
- if (options.horizontalAlignment === RIGHT || options.horizontalAlignment === LEFT)
- options.orientation = VERTICAL
- }
- if (!options.itemTextPosition)
- options.itemTextPosition = options.orientation === HORIZONTAL ? BOTTOM : RIGHT;
- else
- options.itemTextPosition = options.itemTextPosition;
- options.position = (options.position || '').toLowerCase();
- if (options.position !== OUTSIDE && options.position !== INSIDE)
- options.position = OUTSIDE;
- options.hoverMode = (options.hoverMode || '').toLowerCase();
- options.customizeText = $.isFunction(options.customizeText) ? options.customizeText : function() {
- return this.seriesName
- };
- that._options = options;
- !that._trackerGroup && (that._trackerGroup = that._renderer.createGroup({
- 'class': 'dxc-legend-trackers',
- stroke: NONE,
- fill: 'grey',
- opacity: 0.0001
- }));
- that.__initialized = true
- },
- _parseMargins: function(options) {
- if (options.margin >= 0) {
- options.margin = Number(options.margin);
- options.margin = {
- top: options.margin,
- bottom: options.margin,
- left: options.margin,
- right: options.margin
- }
- }
- else
- options.margin = {
- top: options.margin.top >= 0 ? Number(options.margin.top) : DEFAULT_MARGIN,
- bottom: options.margin.bottom >= 0 ? Number(options.margin.bottom) : DEFAULT_MARGIN,
- left: options.margin.left >= 0 ? Number(options.margin.left) : DEFAULT_MARGIN,
- right: options.margin.right >= 0 ? Number(options.margin.right) : DEFAULT_MARGIN
- }
- },
- _parseAlignments: function(options) {
- options.horizontalAlignment = (options.horizontalAlignment || '').toLowerCase();
- if (options.horizontalAlignment !== CENTER && options.horizontalAlignment !== RIGHT && options.horizontalAlignment !== LEFT)
- options.horizontalAlignment = RIGHT;
- options.verticalAlignment = (options.verticalAlignment || '').toLowerCase();
- if (options.verticalAlignment !== TOP && options.verticalAlignment !== BOTTOM) {
- if (options.horizontalAlignment === CENTER)
- options.verticalAlignment = BOTTOM;
- if (options.horizontalAlignment === RIGHT || options.horizontalAlignment === LEFT)
- options.verticalAlignment = TOP
- }
- },
- update: function(data, options) {
- this._data = data;
- this.boundingRect = {
- width: 0,
- height: 0,
- x: 0,
- y: 0
- };
- this._init(options);
- return this
- },
- setSize: function(size) {
- this._size = size;
- return this
- },
- draw: function() {
- if (!this._options)
- return this;
- var that = this,
- renderer = that._renderer,
- options = that._options,
- items = that._data,
- itemsLength = items.length,
- seriesGroups = [],
- i,
- label,
- marker,
- singleSeriesGroup,
- trackers = [],
- insideLegendGroup,
- markersId = new Array(itemsLength),
- passedId,
- border = options.border,
- borderVisible = border.visible && border.width && border.color && border.color !== NONE,
- markers = new Array(itemsLength);
- if (!(options.visible && items && itemsLength)) {
- that._disposeTrackers();
- return that
- }
- that._cleanLegendGroups();
- insideLegendGroup = that._insideLegendGroup = renderer.createGroup().append(that._legendGroup);
- that._createBackground(borderVisible);
- for (i = 0; i < itemsLength; i++) {
- singleSeriesGroup = renderer.createGroup({'class': 'dxc-item'}).append(insideLegendGroup);
- marker = that._createMarker(items[i], singleSeriesGroup, i);
- passedId = items[i].id;
- label = that._createLabel(items[i], passedId, singleSeriesGroup);
- markersId[i] = passedId;
- that._locateLabelAndMarker(label, marker);
- markers[i] = marker;
- trackers.push({
- rect: renderer.createRect(0, 0, 0, 0, 0, {
- stroke: NONE,
- fill: 'grey',
- opacity: 0.0001,
- inh: true
- }),
- id: passedId
- });
- seriesGroups.push(singleSeriesGroup)
- }
- that._seriesGroups = seriesGroups;
- that._trackers = trackers;
- that.drawTrackers();
- that._markers = markers;
- that._markersId = markersId;
- that._locateElements(options);
- return that
- },
- _locateElements: function(options) {
- var that = this,
- border = options.border,
- borderVisible = border.visible && border.width && border.color && border.color !== NONE;
- that._moveInInitialValues();
- that._locateRowsColumns(that._seriesGroups, that._trackers, that._data.length, that._background, options);
- if (that._background)
- that._adjustBackgroundSettings(that._background, borderVisible, options);
- that._setBoundingRect(options)
- },
- _moveInInitialValues: function() {
- var that = this;
- that._legendGroup && that._legendGroup.move(0, 0);
- that._trackerGroup && that._trackerGroup.move(0, 0);
- that._background && that._background.applySettings({
- x: 0,
- y: 0,
- width: 0,
- height: 0
- })
- },
- _applyMarkerOptions: function(marker, options) {
- if (marker)
- marker.applySettings(options)
- },
- applySelected: function(id) {
- var index = this._getIndexById(id);
- if (index !== null)
- this._applyMarkerOptions(this._markers[index], {fill: this._markersPatternsIds[index].selectedPatternId});
- return this
- },
- applyHover: function(id) {
- var index = this._getIndexById(id);
- if (index !== null)
- this._applyMarkerOptions(this._markers[index], {fill: this._markersPatternsIds[index].hoverPatternId});
- return this
- },
- resetItem: function(id) {
- var index = this._getIndexById(id);
- if (index !== null)
- this._applyMarkerOptions(this._markers[index], {fill: this._data[index].color || this._data[index].states.normal.fill})
- },
- _getIndexById: function(id) {
- var i,
- markersId = this._markersId,
- markersIdLen = markersId.length;
- for (i = 0; i < markersIdLen; i++)
- if (markersId[i] === id)
- return i;
- return null
- },
- drawTrackers: function() {
- if (!this._options.visible || !this._insideLegendGroup)
- return;
- var that = this,
- trackerGroup = that._trackerGroup.append(that._legendGroup);
- $.each(that._trackers || [], function(i, tracker) {
- var trackerRect = tracker.rect;
- trackerRect.data({
- itemIndex: tracker.id,
- mode: that._options.hoverMode
- });
- trackerRect.append(trackerGroup)
- });
- return that
- },
- _disposeTrackers: function() {
- var that = this;
- $.each(that._trackers || [], function(_, tracker) {
- tracker.rect.removeData()
- });
- that._trackers = null
- },
- _createMarker: function(data, group, markerIndex) {
- var that = this,
- renderer = that._renderer,
- markersPatternsIds = that._markersPatternsIds,
- size = that._options.markerSize,
- states = data.states,
- marker;
- marker = renderer.createRect(0, 0, size, size, 0, {fill: data.color}).append(group);
- markersPatternsIds[markerIndex] = {
- hoverPatternId: getPatternId(renderer, states, 'hover', data.color),
- selectedPatternId: getPatternId(renderer, states, 'selection', data.color)
- };
- return marker
- },
- _createLabel: function(data, index, group) {
- var that = this,
- options = that._options,
- position = options.itemTextPosition,
- align = position === TOP || position === BOTTOM ? CENTER : LEFT,
- text,
- label,
- labelFormatObject = {
- seriesName: data.text,
- seriesNumber: index,
- seriesColor: data.color
- };
- text = that._formatLabel.call(labelFormatObject, options);
- label = that._renderer.createText(text, 0, 0, {
- font: options.font,
- align: align
- }).append(group);
- return label
- },
- _cleanLegendGroups: function() {
- var that = this,
- trackerGroup = that._trackerGroup,
- legendGroup = that._legendGroup;
- if (legendGroup) {
- legendGroup.clear();
- that._insideLegendGroup && that._insideLegendGroup.dispose();
- that._insideLegendGroup = null
- }
- if (trackerGroup)
- trackerGroup.clear()
- },
- _createBackground: function(borderVisible) {
- var that = this,
- options = that._options,
- isInside = options.position === INSIDE,
- color = options.backgroundColor,
- fill = color || (isInside ? options.containerBackgroundColor : NONE);
- if (isInside || color || borderVisible)
- that._background = that._renderer.createRect(0, 0, 0, 0, 0, {
- fill: fill,
- 'class': 'dxc-border'
- }).append(that._insideLegendGroup)
- },
- _formatLabel: function(options) {
- return options.customizeText.call(this, this)
- },
- _locateLabelAndMarker: function(label, marker) {
- var that = this,
- defaultXMargin = 7,
- defaultTopMargin = 4,
- defaultBottomMargin = 2,
- labelX = 0,
- labelY = 0,
- markerX,
- markerY,
- labelBox = label.getBBox(),
- markerWidth = that._options.markerSize,
- markerHeight = markerWidth,
- approximateLabelY = markerHeight / 2 - (labelBox.y + labelBox.height / 2),
- approximateLabelX = markerWidth / 2 - (labelBox.x + labelBox.width / 2);
- switch (that._options.itemTextPosition) {
- case LEFT:
- labelY = _round(approximateLabelY);
- markerX = labelBox.width + defaultXMargin;
- break;
- case RIGHT:
- labelX = markerWidth + defaultXMargin;
- labelY = _round(approximateLabelY);
- break;
- case TOP:
- labelX = _round(approximateLabelX);
- markerY = defaultTopMargin;
- break;
- case BOTTOM:
- labelX = _round(approximateLabelX);
- labelY = markerHeight + defaultBottomMargin - labelBox.y;
- break
- }
- label.applySettings({
- x: labelX,
- y: labelY
- });
- marker.applySettings({
- x: markerX,
- y: markerY
- })
- },
- _locateRowsColumns: function(groups, trackers, count, background, options) {
- var that = this,
- itemTextPosition = options.itemTextPosition,
- size = that._size,
- legendBox,
- rowsColumns = that._getRowsColumns(count),
- rows = rowsColumns.rows,
- columns = rowsColumns.columns,
- margin = options.margin,
- paddingLeftRight = background ? options.paddingLeftRight : 0,
- paddingTopBottom = background ? options.paddingTopBottom : 0,
- placeholderWidth = size.width - margin.left - margin.right - 2 * paddingLeftRight,
- placeholderHeight = size.height - margin.top - margin.bottom - 2 * paddingTopBottom,
- rowsColumnsData,
- condition,
- maxBBox = getMaxBBox(groups);
- var moveRowsColumns = function(rows, columns) {
- rowsColumnsData = that._getDataRowsColumns(groups, columns, rows);
- that._moveItems(rowsColumnsData, groups, itemTextPosition, trackers, options)
- };
- moveRowsColumns(rows, columns);
- legendBox = that._insideLegendGroup ? that._insideLegendGroup.getBBox() : {};
- if (rowsColumns.autoEdit)
- if (rows === 1) {
- if (legendBox.width > placeholderWidth && columns > 1) {
- columns = _floor(placeholderWidth / (maxBBox.width + options.columnItemSpacing)) || 1;
- columns = validate(columns, count);
- rows = _ceil(count / columns);
- moveRowsColumns(rows, columns)
- }
- }
- else if (columns === 1)
- if (legendBox.height > placeholderHeight && rows > 1) {
- rows = _floor(placeholderHeight / (maxBBox.height + options.rowItemSpacing)) || 1;
- rows = validate(rows, count);
- columns = _ceil(count / rows);
- moveRowsColumns(rows, columns)
- }
- that._rowsCountDrawed = rows;
- that._columnsCountDrawed = columns;
- function validate(rowsOrColumns, count) {
- if (rowsOrColumns > count || rowsOrColumns < 1)
- rowsOrColumns = count;
- return rowsOrColumns
- }
- },
- _moveItems: function(data, seriesGroups, horizontalTextPosition, trackers, options) {
- var that = this,
- i,
- j,
- rows,
- cols,
- number,
- group,
- box,
- xShift = 0,
- yShift = 0,
- widthColumn,
- xPadding = options.columnItemSpacing,
- yPadding = options.rowItemSpacing,
- equalColumnWidth = options.equalColumnWidth,
- renderer = that._renderer,
- maxWidthPerColumn = [],
- maxWidthColumn = 0,
- maxHeightRow = 0;
- rows = data.rows;
- cols = data.cols;
- maxHeightRow = data.maxHeightRow;
- maxWidthColumn = data.maxWidthColumn;
- maxWidthPerColumn = data.maxWidthPerColumn;
- for (i = 0; i < rows; i++) {
- for (j = 0; j < cols; j++) {
- if (rows < cols)
- number = i * cols + j;
- else
- number = i + j * rows;
- group = seriesGroups[number];
- if (!group)
- break;
- box = group.getBBox();
- widthColumn = !equalColumnWidth ? maxWidthPerColumn[j] : maxWidthColumn;
- if (horizontalTextPosition === RIGHT) {
- group.move(xShift - box.x, yShift);
- trackers[number].rect.applySettings({
- x: xShift - xPadding / 2,
- y: yShift + box.y - yPadding / 2,
- height: maxHeightRow + yPadding,
- width: widthColumn + xPadding
- })
- }
- else if (horizontalTextPosition === LEFT) {
- group.move(box.x + widthColumn - box.width + xShift - xPadding / 2, yShift);
- trackers[number].rect.applySettings({
- x: box.x + widthColumn - box.width + xShift - xPadding / 2,
- y: yShift + box.y - yPadding / 2,
- height: maxHeightRow + yPadding,
- width: widthColumn + xPadding
- })
- }
- else {
- group.move(xShift - box.x - box.width / 2 + widthColumn / 2, yShift);
- trackers[number].rect.applySettings({
- x: xShift - xPadding / 2,
- y: yShift + box.y - yPadding / 2,
- height: maxHeightRow + yPadding,
- width: widthColumn + xPadding
- })
- }
- xShift = xShift + widthColumn + xPadding
- }
- yShift = yShift + maxHeightRow + yPadding;
- xShift = 0
- }
- },
- _getDataRowsColumns: function(seriesGroups, cols, rows) {
- var that = this,
- i,
- j,
- options = that._options,
- equalColumnWidth = options.equalColumnWidth,
- series = that.series || {},
- maxWidthPerColumn = [],
- maxWidthColumn = 0,
- maxHeightRow = 0,
- group,
- box;
- for (i = 0; i < cols; i++)
- maxWidthPerColumn[i] = 0;
- for (i = 0; i < rows; i++)
- for (j = 0; j < cols; j++) {
- if (rows < cols)
- group = seriesGroups[i * cols + j];
- else
- group = seriesGroups[i + j * rows];
- if (!group)
- break;
- box = group.getBBox();
- if (maxHeightRow < box.height)
- maxHeightRow = box.height;
- if (!equalColumnWidth) {
- if (maxWidthPerColumn[j] < box.width)
- maxWidthPerColumn[j] = box.width
- }
- else if (maxWidthColumn < box.width)
- maxWidthColumn = box.width
- }
- return {
- rows: rows,
- cols: cols,
- maxWidthPerColumn: maxWidthPerColumn,
- maxWidthColumn: maxWidthColumn,
- maxHeightRow: maxHeightRow
- }
- },
- _getRowsColumns: function(count) {
- var that = this,
- options = that._options,
- isHorizontal = options.orientation === HORIZONTAL,
- rows = options.rowCount,
- onRows = _ceil(count / rows),
- columns = options.columnCount,
- onColumns = _ceil(count / columns),
- autoEdit;
- if (columns && !rows)
- rows = onColumns;
- else if (!columns && rows)
- columns = onRows;
- else if (columns && rows) {
- if (isHorizontal && columns < onRows)
- columns = onRows;
- else if (!isHorizontal && rows < onColumns)
- rows = onColumns
- }
- else {
- autoEdit = true;
- if (isHorizontal) {
- rows = 1;
- columns = count
- }
- else {
- columns = 1;
- rows = count
- }
- }
- return {
- rows: rows,
- columns: columns,
- autoEdit: autoEdit
- }
- },
- _adjustBackgroundSettings: function(background, borderVisible, options) {
- var that = this,
- border = options.border,
- legendBox = that._insideLegendGroup.getBBox(),
- backgroundSettings = {
- x: _round(legendBox.x - options.paddingLeftRight),
- y: _round(legendBox.y - options.paddingTopBottom),
- width: _round(legendBox.width) + 2 * options.paddingLeftRight,
- height: _round(legendBox.height) + 2 * options.paddingTopBottom,
- opacity: options.backgroundOpacity
- };
- if (borderVisible) {
- backgroundSettings.strokeWidth = border.width;
- backgroundSettings.stroke = border.color;
- backgroundSettings.strokeOpacity = border.opacity;
- backgroundSettings.dashStyle = border.dashStyle;
- backgroundSettings.rx = border.cornerRadius || 0;
- backgroundSettings.ry = border.cornerRadius || 0
- }
- background.applySettings(backgroundSettings)
- },
- _setBoundingRect: function(options) {
- var that = this,
- box,
- margin = options.margin;
- if (!that._insideLegendGroup)
- return;
- box = that._insideLegendGroup.getBBox();
- box.height += margin.top + margin.bottom;
- box.width += margin.left + margin.right;
- box.x -= margin.left;
- box.y -= margin.top;
- that.boundingRect = box
- },
- changeSize: function(size) {
- var that = this,
- options = $.extend(true, {}, that._options),
- margin = options.margin;
- if (size.height >= 0) {
- size.height = decreaseGaps(margin, ["top", "bottom"], size.height);
- if (options.border.visible)
- size.height = 2 * decreaseGaps(options, ["paddingTopBottom"], size.height / 2);
- if (that._rowsCountDrawed - 1)
- size.height = (that._rowsCountDrawed - 1) * decreaseGaps(options, ["rowItemSpacing"], size.height / (that._rowsCountDrawed - 1))
- }
- if (size.width >= 0) {
- size.width = decreaseGaps(margin, ["left", "right"], size.width);
- if (options.border.visible)
- size.width = 2 * decreaseGaps(options, ["paddingLeftRight"], size.width / 2);
- if (that._columnsCountDrawed - 1)
- size.width = (that._columnsCountDrawed - 1) * decreaseGaps(options, ["columnItemSpacing"], size.width / (that._columnsCountDrawed - 1))
- }
- if (that._insideLegendGroup)
- if (size.height > 0 || size.width > 0) {
- that._options._incidentOccured("W2104");
- that._insideLegendGroup.remove();
- that._insideLegendGroup = null;
- that._trackerGroup && that._trackerGroup.clear()
- }
- else
- that._locateElements(options)
- },
- getTrackerGroup: function() {
- return this._trackerGroup
- },
- getActionCallback: function(point) {
- var that = this;
- if (that._options.visible)
- return function(act) {
- var pointType = point.type,
- isSeries = pointType ? true : false,
- seriesType = pointType || point.series.type;
- if (isSeries || seriesType === 'pie' || seriesType === 'doughnut' || seriesType === 'donut')
- that[act] && that[act](point.index)
- };
- else
- return $.noop
- },
- getLayoutOptions: function() {
- var options = this._options,
- boundingRect = this._insideLegendGroup ? this.boundingRect : {
- width: 0,
- height: 0,
- x: 0,
- y: 0
- };
- if (options) {
- boundingRect.verticalAlignment = options.verticalAlignment;
- boundingRect.horizontalAlignment = options.horizontalAlignment;
- if (options.orientation === 'horizontal')
- boundingRect.cutLayoutSide = options.verticalAlignment;
- else
- boundingRect.cutLayoutSide = options.horizontalAlignment === 'center' ? options.verticalAlignment : options.horizontalAlignment;
- return boundingRect
- }
- return null
- },
- shift: function(x, y) {
- var that = this,
- settings = {},
- box = that.getLayoutOptions();
- settings.translateX = x - box.x;
- settings.translateY = y - box.y;
- that._insideLegendGroup && that._insideLegendGroup.applySettings(settings);
- that._trackerGroup && that._trackerGroup.applySettings(settings)
- },
- getPosition: function() {
- return this._options.position
- },
- dispose: function() {
- var that = this;
- that._disposeTrackers();
- that._legendGroup = null;
- that._trackerGroup = null;
- that._insideLegendGroup = null;
- that._renderer = null;
- that._options = null;
- that._data = null;
- return that
- }
- })
- })(DevExpress, jQuery);
- /*! Module viz-core, file range.js */
- (function($, DX, undefined) {
- var core = DX.viz.core,
- utils = DX.utils,
- isDefinedUtils = utils.isDefined,
- isDateUtils = utils.isDate,
- getLogUtils = utils.getLog,
- raiseToUtils = utils.raiseTo;
- var NUMBER_EQUALITY_CORRECTION = 1,
- DATETIME_EQUALITY_CORRECTION = 60000;
- var minSelector = 'min',
- maxSelector = 'max',
- minVisibleSelector = 'minVisible',
- maxVisibleSelector = 'maxVisible',
- minValueMarginSelector = 'minValueMargin',
- maxValueMarginSelector = 'maxValueMargin',
- categoriesSelector = 'categories',
- keepValueMarginsSelector = 'keepValueMargins',
- baseSelector = 'base',
- axisTypeSelector = 'axisType';
- var raiseToFlooredLog = function(value, base, correction) {
- return raiseToUtils(Math.floor(getLogUtils(value, base)) + (correction || 0), base)
- };
- var otherLessThan = function(thisValue, otherValue) {
- return otherValue < thisValue
- };
- var otherGreaterThan = function(thisValue, otherValue) {
- return otherValue > thisValue
- };
- var compareAndReplace = function(thisValue, otherValue, setValue, compare) {
- var otherValueDefined = isDefinedUtils(otherValue);
- if (isDefinedUtils(thisValue)) {
- if (otherValueDefined && compare(thisValue, otherValue))
- setValue(otherValue)
- }
- else if (otherValueDefined)
- setValue(otherValue)
- };
- var applyMargin = function(value, margin, rangeLength, coef, isDateTime) {
- value = value.valueOf() + coef * rangeLength * margin;
- return isDateTime ? new Date(value) : value
- };
- DX.viz.core.__NUMBER_EQUALITY_CORRECTION = NUMBER_EQUALITY_CORRECTION;
- DX.viz.core.__DATETIME_EQUALITY_CORRECTION = DATETIME_EQUALITY_CORRECTION;
- core.Range = function(range) {
- range && $.extend(this, range)
- };
- $.extend(core.Range.prototype, {
- dispose: function() {
- this[categoriesSelector] = null
- },
- addRange: function(otherRange) {
- var that = this,
- categories = that[categoriesSelector],
- categoriesValues,
- otherCategories = otherRange[categoriesSelector],
- i,
- j,
- length,
- found;
- var setIndentByPriority = function(prefix) {
- var prioritySelector = prefix + 'Priority',
- priorityRelation = (that[prioritySelector] || 0) - (otherRange[prioritySelector] || 0);
- if ((that[prefix] || 0) < otherRange[prefix] && priorityRelation === 0 || priorityRelation < 0) {
- that[prefix] = otherRange[prefix];
- that[prioritySelector] = otherRange[prioritySelector]
- }
- };
- var compareAndReplaceByField = function(field, compare) {
- compareAndReplace(that[field], otherRange[field], function(value) {
- that[field] = value
- }, compare)
- };
- var controlValuesByVisibleBounds = function(valueField, visibleValueField, compare) {
- compareAndReplace(that[valueField], that[visibleValueField], function(value) {
- isDefinedUtils(that[valueField]) && (that[valueField] = value)
- }, compare)
- };
- var checkField = function(field) {
- that[field] = that[field] || otherRange[field]
- };
- if (utils.isDefined(otherRange["stick"]))
- that["stick"] = otherRange["stick"];
- checkField('invert');
- checkField(axisTypeSelector);
- checkField('dataType');
- checkField(keepValueMarginsSelector);
- if (that[axisTypeSelector] === 'logarithmic')
- checkField(baseSelector);
- else
- that[baseSelector] = undefined;
- compareAndReplaceByField(minSelector, otherLessThan);
- compareAndReplaceByField(maxSelector, otherGreaterThan);
- compareAndReplaceByField(minVisibleSelector, otherLessThan);
- compareAndReplaceByField(maxVisibleSelector, otherGreaterThan);
- compareAndReplaceByField('interval', otherLessThan);
- setIndentByPriority(minValueMarginSelector);
- setIndentByPriority(maxValueMarginSelector);
- controlValuesByVisibleBounds(minSelector, minVisibleSelector, otherLessThan);
- controlValuesByVisibleBounds(minSelector, maxVisibleSelector, otherLessThan);
- controlValuesByVisibleBounds(maxSelector, maxVisibleSelector, otherGreaterThan);
- controlValuesByVisibleBounds(maxSelector, minVisibleSelector, otherGreaterThan);
- if (categories === undefined)
- that[categoriesSelector] = otherCategories;
- else {
- length = categories.length;
- if (otherCategories && otherCategories.length)
- for (i = 0; i < otherCategories.length; i++) {
- for (j = 0, found = false; j < length; j++)
- if (categories[j].valueOf() === otherCategories[i].valueOf()) {
- found = true;
- break
- }
- !found && categories.push(otherCategories[i])
- }
- }
- return this
- },
- isDefined: function() {
- return isDefinedUtils(this[minSelector]) && isDefinedUtils(this[maxSelector]) || isDefinedUtils(this[categoriesSelector])
- },
- setStubData: function(dataType) {
- var that = this,
- year = (new Date).getYear() - 1,
- isDate = dataType === 'datetime',
- isCategories = that.axisType === 'discrete';
- if (isCategories)
- that.categories = ['0', '1', '2'];
- else {
- that[minSelector] = isDate ? new Date(year, 0, 1) : 0;
- that[maxSelector] = isDate ? new Date(year, 11, 31) : 10
- }
- that.stubData = true;
- return that
- },
- applyValueMargins: function() {
- var that = this,
- base = that[baseSelector],
- isDateTime = isDateUtils(that[maxSelector]) || isDateUtils(that[minSelector]);
- var applyMarginWithZeroCorrection = function(min, max, rangeLength) {
- var minValue = that[min],
- maxValue = that[max],
- minMargin = that[minValueMarginSelector],
- maxMargin = that[maxValueMarginSelector],
- minCorrected = false,
- maxCorrected = false;
- if (rangeLength && !isDateTime && !that[keepValueMarginsSelector]) {
- if (minValue <= 0 && maxValue <= 0 && maxMargin > maxValue / (minValue - maxValue)) {
- that[max] = 0;
- maxCorrected = true
- }
- if (minValue >= 0 && maxValue >= 0 && minMargin > minValue / (maxValue - minValue)) {
- that[min] = 0;
- minCorrected = true
- }
- }
- if (isDefinedUtils(maxValue) && !maxCorrected && maxMargin)
- that[max] = applyMargin(maxValue, maxMargin, rangeLength, 1, isDateTime);
- if (isDefinedUtils(minValue) && !minCorrected && minMargin)
- that[min] = applyMargin(minValue, minMargin, rangeLength, -1, isDateTime)
- };
- var correctValueByBoundaries = function(visibleSelector, valueSelector) {
- that[visibleSelector] = isDefinedUtils(that[visibleSelector]) ? that[visibleSelector] : that[valueSelector]
- };
- var processLogarithmicMinValue = function(valueField) {
- if (isDefinedUtils(that[valueField])) {
- var intermediateValue = raiseToFlooredLog(that[valueField], base);
- if (getLogUtils(that[valueField] / intermediateValue, base) < 0.1 && that.alwaysCorrectMin && !that[keepValueMarginsSelector])
- that[valueField] = raiseToFlooredLog(that[valueField], base, -1);
- else if (that.alwaysCorrectMin && !that[keepValueMarginsSelector])
- that[valueField] = intermediateValue;
- else if (getLogUtils(that[valueField] / intermediateValue, base) < 0.5)
- that[valueField] = intermediateValue
- }
- };
- var processLogarithmicMaxValue = function(valueField) {
- if (isDefinedUtils(that[valueField])) {
- var intermediateValue = raiseToFlooredLog(that[valueField], base);
- if (getLogUtils(that[valueField] / intermediateValue, base) > 0.5)
- that[valueField] = raiseToUtils(Math.ceil(getLogUtils(that[valueField], base)), base)
- }
- };
- var correctLogVisibleValue = function(visibleValueSelector, valueSelector, compare) {
- if (!isDefinedUtils(that[visibleValueSelector]) || compare)
- that[visibleValueSelector] = that[valueSelector]
- };
- if (that[axisTypeSelector] === 'logarithmic' && that[minSelector] !== that[maxSelector]) {
- processLogarithmicMinValue(minSelector);
- processLogarithmicMaxValue(maxSelector);
- if (that.isValueRange && that[minVisibleSelector] !== that[maxVisibleSelector]) {
- processLogarithmicMinValue(minVisibleSelector);
- processLogarithmicMaxValue(maxVisibleSelector)
- }
- correctLogVisibleValue(minVisibleSelector, minSelector, that[minVisibleSelector] < that[minSelector]);
- correctLogVisibleValue(maxVisibleSelector, maxSelector, that[maxVisibleSelector] > that[maxSelector])
- }
- else {
- correctValueByBoundaries(minVisibleSelector, minSelector);
- correctValueByBoundaries(maxVisibleSelector, maxSelector);
- applyMarginWithZeroCorrection(minSelector, maxSelector, that[maxSelector] - that[minSelector]);
- applyMarginWithZeroCorrection(minVisibleSelector, maxVisibleSelector, that[maxVisibleSelector] - that[minVisibleSelector])
- }
- return this
- },
- correctValueZeroLevel: function() {
- var that = this;
- if (isDateUtils(that[maxSelector]) || isDateUtils(that[minSelector]))
- return that;
- function setZeroLevel(min, max) {
- that[min] < 0 && that[max] < 0 && (that[max] = 0);
- that[min] > 0 && that[max] > 0 && (that[min] = 0)
- }
- setZeroLevel(minSelector, maxSelector);
- setZeroLevel(minVisibleSelector, maxVisibleSelector);
- return that
- }
- })
- })(jQuery, DevExpress);
- /*! Module viz-core, file seriesConsts.js */
- (function(DX) {
- DX.viz.core.series = DX.viz.core.series || {};
- DX.viz.core.series.helpers = DX.viz.core.series.helpers || {};
- DX.viz.core.series.helpers.consts = {
- events: {
- mouseover: "mouseover",
- mouseout: "mouseout",
- mousemove: "mousemove",
- touchstart: "touchstart",
- touchmove: "touchmove",
- touchend: "touchend",
- mousedown: "mousedown",
- mouseup: "mouseup",
- click: "click",
- selectSeries: "selectseries",
- deselectSeries: "deselectseries",
- selectPoint: "selectpoint",
- deselectPoint: "deselectpoint",
- showPointTooltip: "showpointtooltip",
- hidePointTooltip: "hidepointtooltip"
- },
- states: {
- hover: "hover",
- normal: "normal",
- selected: "selected",
- normalMark: 0,
- hoverMark: 1,
- selectedMark: 2
- },
- animations: {
- showDuration: {duration: 400},
- hideGroup: {opacity: 0.0001},
- showGroup: {opacity: 1}
- }
- }
- })(DevExpress);
- /*! Module viz-core, file seriesFamily.js */
- (function($, DX, undefined) {
- var utils = DX.utils,
- _round = Math.round,
- _abs = Math.abs,
- _pow = Math.pow;
- DX.viz.core.series.helpers.SeriesFamily = DX.Class.inherit(function() {
- var ctor = function(options) {
- var debug = DX.utils.debug;
- debug.assert(options.type, "type was not passed or empty");
- var that = this,
- stubFunction = $.noop;
- $.extend(that, options);
- that.type = that.type.toLowerCase();
- that.series = [];
- switch (that.type) {
- case"bar":
- that.adjustSeriesDimensions = adjustBarSeriesDimensions;
- that.adjustSeriesValues = stubFunction;
- that.updateSeriesValues = updateBarSeriesValues;
- break;
- case"rangebar":
- that.adjustSeriesDimensions = adjustBarSeriesDimensions;
- that.adjustSeriesValues = stubFunction;
- that.updateSeriesValues = stubFunction;
- break;
- case"fullstackedbar":
- that.fullStacked = true;
- that.adjustSeriesDimensions = adjustStackedBarSeriesDimensions;
- that.adjustSeriesValues = adjustStackedSeriesValues;
- that.updateSeriesValues = updateStackedSeriesValues;
- break;
- case"stackedbar":
- that.adjustSeriesDimensions = adjustStackedBarSeriesDimensions;
- that.adjustSeriesValues = adjustStackedSeriesValues;
- that.updateSeriesValues = updateStackedSeriesValues;
- break;
- case"fullstackedarea":
- case"fullstackedline":
- that.fullStacked = true;
- that.adjustSeriesDimensions = stubFunction;
- that.adjustSeriesValues = adjustStackedSeriesValues;
- that.updateSeriesValues = stubFunction;
- break;
- case"stackedarea":
- case"stackedline":
- that.adjustSeriesDimensions = stubFunction;
- that.adjustSeriesValues = adjustStackedSeriesValues;
- that.updateSeriesValues = stubFunction;
- break;
- case"candlestick":
- case"stock":
- that.adjustSeriesDimensions = adjustCandlestickSeriesDimensions;
- that.adjustSeriesValues = stubFunction;
- that.updateSeriesValues = stubFunction;
- break;
- case"bubble":
- that.adjustSeriesDimensions = adjustBubbleSeriesDimensions;
- that.adjustSeriesValues = stubFunction;
- that.updateSeriesValues = stubFunction;
- break;
- default:
- that.adjustSeriesDimensions = stubFunction;
- that.adjustSeriesValues = stubFunction;
- that.updateSeriesValues = stubFunction;
- break
- }
- };
- var dispose = function() {
- this.series = null;
- this.translators = null
- };
- var add = function(series) {
- var that = this,
- singleSeries,
- i;
- if (!$.isArray(series))
- series = [series];
- for (i = 0; i < series.length; i++) {
- singleSeries = series[i];
- if (singleSeries.type.toLowerCase() === that.type)
- that.series.push(singleSeries)
- }
- };
- var adjustBarSeriesDimensionsCore = function(series, interval, stackCount, equalBarWidth, seriesStackIndexCallback) {
- var spacing,
- width,
- maxWidth,
- middleIndex,
- stackIndex,
- i,
- point,
- points,
- seriesOffset,
- stackName,
- argumentsKeeper = {},
- stackKeepers = {},
- stacksWithArgument,
- count;
- if (equalBarWidth) {
- width = equalBarWidth.width && equalBarWidth.width < 0 ? 0 : equalBarWidth.width;
- spacing = equalBarWidth.spacing && equalBarWidth.spacing < 0 ? 0 : equalBarWidth.spacing;
- if (width && !spacing)
- if (stackCount > 1) {
- spacing = _round((interval * 0.7 - width * stackCount) / (stackCount - 1));
- if (spacing < 1)
- spacing = 1
- }
- else
- spacing = 0;
- else if (spacing && !width) {
- width = _round((interval * 0.7 - spacing * (stackCount - 1)) / stackCount);
- if (width < 2)
- width = 2
- }
- else if (!spacing && !width) {
- if (stackCount > 1) {
- spacing = _round(interval * 0.7 / stackCount * 0.2);
- if (spacing < 1)
- spacing = 1
- }
- else
- spacing = 0;
- width = _round((interval * 0.7 - spacing * (stackCount - 1)) / stackCount);
- if (width < 2)
- width = 2
- }
- if (width * stackCount + spacing * (stackCount - 1) > interval) {
- spacing = _round((interval * 0.7 - width * stackCount) / (stackCount - 1));
- if (spacing < 1) {
- spacing = 1;
- maxWidth = _round((interval * 0.7 - spacing * (stackCount - 1)) / stackCount)
- }
- }
- middleIndex = stackCount / 2;
- for (i = 0; i < series.length; i++) {
- stackIndex = seriesStackIndexCallback(i);
- points = series[i].getPoints();
- seriesOffset = (stackIndex - middleIndex + 0.5) * (maxWidth || width) - (middleIndex - stackIndex - 0.5) * spacing;
- $.each(points, function(_, point) {
- point.correctCoordinates({
- width: width,
- offset: seriesOffset
- })
- })
- }
- }
- else {
- $.each(series, function(i, singleSeries) {
- stackName = singleSeries.getStackName && singleSeries.getStackName();
- stackName = stackName || i.toString();
- if (!stackKeepers[stackName])
- stackKeepers[stackName] = [];
- stackKeepers[stackName].push(singleSeries)
- });
- $.each(series, function(i, singleSeries) {
- $.each(singleSeries.getPoints(), function(_, point) {
- var argument = point.argument;
- if (!argumentsKeeper.hasOwnProperty(argument))
- argumentsKeeper[argument.valueOf()] = 1
- })
- });
- for (var argument in argumentsKeeper) {
- if (!argumentsKeeper.hasOwnProperty(argument))
- continue;
- stacksWithArgument = [];
- $.each(stackKeepers, function(stackName, seriesInStack) {
- $.each(seriesInStack, function(i, singleSeries) {
- point = singleSeries.getPointByArg(argument);
- if (point && point.value) {
- stacksWithArgument.push(stackName);
- return false
- }
- })
- });
- count = stacksWithArgument.length;
- spacing = _round(interval * 0.7 / count * 0.2);
- if (spacing < 1)
- spacing = 1;
- width = _round((interval * 0.7 - spacing * (count - 1)) / count);
- if (width < 2)
- width = 2;
- middleIndex = count / 2;
- $.each(stackKeepers, function(stackName, seriesInStack) {
- stackIndex = $.inArray(stackName, stacksWithArgument);
- if (stackIndex === -1)
- return;
- seriesOffset = (stackIndex - middleIndex + 0.5) * width - (middleIndex - stackIndex - 0.5) * spacing;
- $.each(seriesInStack, function(i, singleSeries) {
- var point = singleSeries.getPointByArg(argument);
- if (point && point.value)
- point.correctCoordinates({
- width: width,
- offset: seriesOffset
- })
- })
- })
- }
- }
- };
- var getVisibleSeries = function(that) {
- return $.map(that.series, function(s) {
- return s.isVisible() ? s : null
- })
- };
- var adjustBarSeriesDimensions = function(translators) {
- var debug = DX.utils.debug;
- debug.assert(translators, "translator was not passed or empty");
- var that = this,
- equalBarWidth = that.equalBarWidth,
- series = getVisibleSeries(that);
- adjustBarSeriesDimensionsCore(series, getInterval(that, translators), series.length, equalBarWidth, function(seriesIndex) {
- return seriesIndex
- })
- };
- var adjustStackedBarSeriesDimensions = function(translators) {
- var debug = DX.utils.debug;
- debug.assert(translators, "translators was not passed or empty");
- var that = this,
- interval,
- series = getVisibleSeries(that),
- stackIndexes = {},
- stackCount = 0,
- equalBarWidth = that.equalBarWidth;
- $.each(series, function() {
- var stackName = this.getStackName();
- if (!stackIndexes.hasOwnProperty(stackName))
- stackIndexes[stackName] = stackCount++
- });
- adjustBarSeriesDimensionsCore(series, getInterval(that, translators), stackCount, equalBarWidth, function(seriesIndex) {
- return stackIndexes[series[seriesIndex].getStackName()]
- })
- };
- var adjustStackedSeriesValues = function() {
- var that = this,
- series = getVisibleSeries(that),
- stackKeepers = {
- positive: {},
- negative: {}
- };
- $.each(series, function(_, singleSeries) {
- var points = singleSeries.getPoints();
- $.each(points, function(index, point) {
- var value = point.initialValue,
- argument = point.argument,
- stackName = singleSeries.getStackName ? singleSeries.getStackName() : "default",
- valueType = value >= 0 ? "positive" : "negative",
- currentStack;
- stackKeepers[valueType][stackName] = stackKeepers[valueType][stackName] || {};
- currentStack = stackKeepers[valueType][stackName];
- if (currentStack[argument.valueOf()]) {
- points[index].correctValue(currentStack[argument.valueOf()]);
- currentStack[argument.valueOf()] += value
- }
- else {
- currentStack[argument.valueOf()] = value;
- points[index].resetCorrection()
- }
- })
- });
- setPercentStackedValues(series, stackKeepers, that.fullStacked)
- };
- var setPercentStackedValues = function(series, stackKeepers, fullStacked) {
- $.each(series, function(_, singleSeries) {
- var points = singleSeries.getPoints();
- $.each(points, function(index, point) {
- var value = point.value,
- stackName = singleSeries.getStackName ? singleSeries.getStackName() : "default",
- valueType = value >= 0 ? "positive" : "negative",
- currentStack;
- stackKeepers[valueType][stackName] = stackKeepers[valueType][stackName] || {};
- currentStack = stackKeepers[valueType][stackName];
- points[index].setPercentValue(currentStack[point.argument.valueOf()], fullStacked)
- })
- })
- };
- var getMinShownBusinessValue = function(that, translators, minBarSize) {
- var rotated = that.rotated,
- valTranslator = rotated ? translators.x : translators.y,
- canvas = valTranslator.getCanvasVisibleArea();
- if (minBarSize)
- return _abs(valTranslator.untranslate(canvas.min) - valTranslator.untranslate(canvas.min + minBarSize))
- };
- var updateStackedSeriesValues = function(translators) {
- var that = this,
- series = getVisibleSeries(that),
- stackKeepers = {
- positive: {},
- negative: {}
- };
- $.each(series, function(_, singleSeries) {
- var points = singleSeries.getPoints(),
- minBarSize = singleSeries.getOptions().minBarSize;
- $.each(points, function(index, point) {
- var value = point.value,
- minValue = point.minValue,
- argument = point.argument,
- updateValue,
- pointSize,
- minShownBusinessValue,
- stackName = singleSeries.getStackName ? singleSeries.getStackName() : "default",
- valueType = value >= 0 ? "positive" : "negative",
- currentStack;
- minShownBusinessValue = getMinShownBusinessValue(that, translators, minBarSize);
- currentStack = stackKeepers[valueType][stackName] = stackKeepers[valueType][stackName] || {};
- if (currentStack[argument.valueOf()]) {
- minValue = utils.isNumber(minValue) ? minValue : 0,
- pointSize = _abs(minValue - value);
- if (minShownBusinessValue && pointSize < minShownBusinessValue)
- updateValue = minShownBusinessValue;
- else
- updateValue = value - minValue;
- points[index].minValue = currentStack[argument.valueOf()];
- points[index].value = currentStack[argument.valueOf()] + updateValue;
- currentStack[argument.valueOf()] += updateValue
- }
- else {
- pointSize = value;
- if (minShownBusinessValue && pointSize < minShownBusinessValue)
- updateValue = minShownBusinessValue;
- else
- updateValue = value;
- points[index].value = updateValue;
- currentStack[argument.valueOf()] = updateValue
- }
- })
- });
- if (that.fullStacked)
- updateFullStackedSeriesValues(series, stackKeepers)
- };
- var updateFullStackedSeriesValues = function(series, stackKeepers) {
- $.each(series, function(_, singleSeries) {
- var stackName = singleSeries.getStackName ? singleSeries.getStackName() : "default",
- points = singleSeries.getPoints();
- $.each(points, function(index, point) {
- var value = point.value,
- argument = point.argument,
- valueType = value >= 0 ? "positive" : "negative",
- currentStack;
- stackKeepers[valueType][stackName] = stackKeepers[valueType][stackName] || {};
- currentStack = stackKeepers[valueType][stackName];
- points[index].value = points[index].value / currentStack[argument.valueOf()] || 0;
- if (DX.utils.isNumber(points[index].minValue))
- points[index].minValue = points[index].minValue / currentStack[argument.valueOf()] || 0
- })
- })
- };
- var updateBarSeriesValues = function(translators) {
- var that = this;
- $.each(that.series, function(_, singleSeries) {
- var points = singleSeries.getPoints(),
- minBarSize = singleSeries.getOptions().minBarSize;
- $.each(points, function(index, point) {
- var value = point.value,
- updateValue,
- pointSize,
- minShownBusinessValue;
- minShownBusinessValue = getMinShownBusinessValue(that, translators, minBarSize);
- pointSize = _abs(value);
- if (minShownBusinessValue && pointSize < minShownBusinessValue)
- updateValue = value >= 0 ? minShownBusinessValue : -minShownBusinessValue;
- else
- updateValue = value;
- points[index].value = updateValue
- })
- })
- };
- var adjustCandlestickSeriesDimensions = function(translators) {
- var debug = DX.utils.debug;
- debug.assert(translators, "translator was not passed or empty");
- var that = this,
- series = getVisibleSeries(that);
- adjustBarSeriesDimensionsCore(series, getInterval(that, translators), series.length, true, function(seriesIndex) {
- return seriesIndex
- })
- };
- var getInterval = function(that, translators) {
- var argTranslator = !that.rotated ? translators.x : translators.y;
- return that.interval = argTranslator.getInterval()
- };
- var adjustBubbleSeriesDimensions = function(translators) {
- var debug = DX.utils.debug;
- debug.assert(translators, "translator was not passed or empty");
- var that = this,
- series = getVisibleSeries(that),
- points,
- i,
- visibleAreaX = translators.x.getCanvasVisibleArea(),
- visibleAreaY = translators.y.getCanvasVisibleArea(),
- min = Math.min(visibleAreaX.max - visibleAreaX.min, visibleAreaY.max - visibleAreaY.min),
- minBubbleArea = _pow(that.minBubbleSize, 2),
- maxBubbleArea = _pow(min * that.maxBubbleSize, 2),
- equalBubbleSize = (min * that.maxBubbleSize + that.minBubbleSize) / 2,
- minPointSize = Infinity,
- maxPointSize = 0,
- pointSize,
- bubbleArea,
- sizeProportion,
- sizeDispersion,
- areaDispersion;
- for (i = 0; i < series.length; i++) {
- points = series[i].getPoints();
- $.each(points, function(_, point) {
- maxPointSize = maxPointSize > point.size ? maxPointSize : point.size;
- minPointSize = minPointSize < point.size ? minPointSize : point.size
- })
- }
- sizeDispersion = maxPointSize - minPointSize;
- areaDispersion = _abs(maxBubbleArea - minBubbleArea);
- minPointSize = minPointSize < 0 ? 0 : minPointSize;
- for (i = 0; i < series.length; i++) {
- points = series[i].getPoints();
- $.each(points, function(_, point) {
- if (maxPointSize === minPointSize)
- pointSize = _round(equalBubbleSize);
- else {
- sizeProportion = _abs(point.size - minPointSize) / sizeDispersion;
- bubbleArea = areaDispersion * sizeProportion + minBubbleArea;
- pointSize = _round(Math.sqrt(bubbleArea))
- }
- point.correctCoordinates(pointSize)
- })
- }
- };
- return {
- ctor: ctor,
- dispose: dispose,
- add: add
- }
- }())
- })(jQuery, DevExpress);
- /*! Module viz-core, file baseSeries.js */
- (function($, DX) {
- var viz = DX.viz,
- utils = DX.utils,
- _isDefined = utils.isDefined,
- _each = $.each,
- _extend = $.extend,
- _isEmptyObject = $.isEmptyObject,
- _Event = $.Event,
- _noop = $.noop,
- SELECTED_STATE = 2,
- HOVER_STATE = 1,
- NONE_MODE = "none",
- INCLUDE_POINTS = "includepoints",
- EXLUDE_POINTS = "excludepoints",
- ALL_SERIES_POINTS_MODE = "allseriespoints",
- APPLY_SELECTED = "applySelected",
- APPLY_HOVER = "applyHover",
- getEmptyBusinessRange = function() {
- return {
- arg: {},
- val: {}
- }
- };
- viz.core.series.mixins = {
- chart: {},
- pieChart: {}
- };
- viz.core.series.Series = DX.Class.inherit({
- ctor: function(renderer, options) {
- this.fullState = 0;
- this._renderer = renderer;
- this._group = renderer.createGroup({"class": "dxc-series"});
- this.updateOptions(options)
- },
- update: function(data, options) {
- this.updateOptions(options);
- this.updateData(data)
- },
- _createLegendState: function(styleOptions, defaultColor) {
- return {
- fill: styleOptions.color || defaultColor,
- hatching: styleOptions.hatching
- }
- },
- getLegendStyles: function() {
- return this._styles.legendStyles
- },
- _createStyles: function(options) {
- var mainSeriesColor = options.mainSeriesColor,
- specialMainColor = this._getSpecialColor(mainSeriesColor);
- this._styles = {
- normal: this._parseStyle(options, mainSeriesColor, mainSeriesColor),
- hover: this._parseStyle(options.hoverStyle || {}, specialMainColor, mainSeriesColor),
- selection: this._parseStyle(options.selectionStyle || {}, specialMainColor, mainSeriesColor),
- legendStyles: {
- normal: this._createLegendState(options, mainSeriesColor),
- hover: this._createLegendState(options.hoverStyle || {}, specialMainColor),
- selection: this._createLegendState(options.selectionStyle || {}, specialMainColor)
- }
- }
- },
- setAdjustSeriesLabels: function(adjustSeriesLabels) {
- _each(this._points || [], function(_, point) {
- point.setAdjustSeriesLabels(adjustSeriesLabels)
- })
- },
- setClippingParams: function(id, forceClipping) {
- this._paneClipRectID = id;
- this._forceClipping = forceClipping
- },
- getTagField: function() {
- return this._options.tagField || "tag"
- },
- getValueFields: _noop,
- getArgumentField: _noop,
- getPoints: function() {
- return this._points
- },
- _createPoint: function(data, pointsArray, index) {
- data.index = index;
- if (this._checkData(data)) {
- var point = pointsArray[index],
- options = this._customizePoint(data) || this._getCreatingPointOptions();
- if (point)
- point.update(data, options);
- else {
- point = viz.core.CoreFactory.createPoint(data, options);
- pointsArray.push(point)
- }
- this.pointsByArgument[point.argument.valueOf()] = this.pointsByArgument[point.argument.valueOf()] || point;
- return true
- }
- },
- getRangeData: function(zoomArgs, calcIntervalFunction) {
- return this._visible ? _extend(true, {}, this._getRangeData(zoomArgs, calcIntervalFunction)) : getEmptyBusinessRange()
- },
- _deleteElementsGroup: function() {
- if (this._elementsGroup) {
- this._elementsGroup.detach();
- this._elementsGroup = null
- }
- },
- _deleteBordersGroup: function() {
- if (this._bordersGroup) {
- this._bordersGroup.detach();
- this._bordersGroup = null
- }
- },
- _saveOldAnimationMethods: function() {
- this._oldClearingAnimation = this._clearingAnimation;
- this._oldUpdateElement = this._updateElement
- },
- _deleteOldAnimationMethods: function() {
- this._oldClearingAnimation = null;
- this._oldUpdateElement = null
- },
- updateOptions: function(newOptions) {
- var that = this,
- widgetType = newOptions.widgetType,
- oldType = that.type,
- newType = newOptions.type;
- that.type = newType && newType.toString().toLowerCase();
- if (!that._checkType(widgetType)) {
- that.dispose();
- that.isUpdated = false;
- return
- }
- if (oldType !== that.type) {
- that._firstDrawing = true;
- that._saveOldAnimationMethods();
- that._resetType(oldType, widgetType);
- that._setType(that.type, widgetType)
- }
- that._options = newOptions;
- that._pointOptions = null;
- that._deletePatterns();
- that._patterns = [];
- that.name = newOptions.name;
- that.pane = newOptions.pane;
- that.axis = newOptions.axis;
- that.tag = newOptions.tag;
- that._createStyles(newOptions);
- that._updateOptions(newOptions);
- that._visible = newOptions.visible;
- that.isUpdated = true
- },
- _disposePoints: function(points) {
- $.each(points || [], function(_, p) {
- p.dispose()
- })
- },
- _correctPointsLength: function(length, points) {
- this._disposePoints(this._oldPoints);
- this._oldPoints = points.splice(length, points.length)
- },
- _getTicksForAggregation: function(min, max, screenDelta, pointSize) {
- return viz.core.tickProvider.getTicks({
- min: min,
- max: max,
- screenDelta: screenDelta,
- gridSpacingFactor: pointSize
- })
- },
- updateDataType: function(settings) {
- var that = this;
- that.argumentType = settings.argumentType;
- that.valueType = settings.valueType;
- that.argumentAxisType = settings.argumentAxisType;
- that.valueAxisType = settings.valueAxisType
- },
- getValueCategories: function() {
- return this._options.valueCategories || []
- },
- getOptions: function() {
- return this._options
- },
- getArgumentCategories: function() {
- return this._options.argumentCategories || []
- },
- updateData: function(data) {
- var that = this,
- points,
- lastPointIndex = 0,
- options = that._options,
- pointData;
- that.pointsByArgument = {};
- points = that._originalPoints || [];
- that._rangeData = getEmptyBusinessRange();
- if (data && data.length)
- that._canRenderCompleteHandle = true;
- that._beginUpdateData();
- _each(data, function(index, dataItem) {
- pointData = that._getPointData(dataItem, options);
- if (that._createPoint(pointData, points, lastPointIndex)) {
- that._processRange(points[lastPointIndex], lastPointIndex > 0 ? points[lastPointIndex - 1] : null);
- lastPointIndex++
- }
- });
- that._points = that._originalPoints = points;
- that._correctPointsLength(lastPointIndex, points);
- that._endUpdateData()
- },
- getTeamplatedFields: function() {
- var that = this,
- fields = that.getValueFields(),
- teampleteFields = [];
- fields.push(that.getTagField());
- _each(fields, function(_, field) {
- var fieldsObject = {};
- fieldsObject.teamplateField = field + that.name;
- fieldsObject.originalField = field;
- teampleteFields.push(fieldsObject)
- });
- return teampleteFields
- },
- resamplePoints: function(translators, min, max) {
- var that = this,
- originalPoints = that.getAllPoints(),
- argTranslator = that._options.rotated ? translators.y : translators.x,
- minI,
- maxI,
- sizePoint,
- ticks;
- if (originalPoints.length) {
- _each(originalPoints, function(i, point) {
- minI = point.argument - min <= 0 ? i : minI;
- if (!maxI)
- maxI = point.argument - max > 0 ? i : null
- });
- minI = minI ? minI : 1;
- maxI = utils.isDefined(maxI) ? maxI : originalPoints.length - 1;
- min = originalPoints[minI - 1].argument;
- max = originalPoints[maxI].argument;
- sizePoint = that._getPointSize();
- if (that.argumentAxisType !== "discrete" && that.valueAxisType !== "discrete")
- ticks = that._getTicksForAggregation(min, max, argTranslator.canvasLength, sizePoint);
- else
- ticks = argTranslator.canvasLength / sizePoint;
- that._points = that._resample(ticks, ticks.tickInterval)
- }
- },
- _removeOldSegments: function(startIndex) {
- var that = this;
- _each(that._graphics.splice(startIndex, that._graphics.length) || [], function(_, elem) {
- that._removeElement(elem)
- });
- if (that._trackers)
- _each(that._trackers.splice(startIndex, that._trackers.length) || [], function(_, elem) {
- elem.remove()
- })
- },
- draw: function(translators, animationEnabled, hideLayoutLabels, legendCallback) {
- var that = this;
- if (that._oldClearingAnimation && animationEnabled && that._firstDrawing) {
- var drawComplete = function() {
- that._draw(translators, true, hideLayoutLabels)
- };
- that._oldClearingAnimation(translators, drawComplete)
- }
- else
- that._draw(translators, animationEnabled, hideLayoutLabels, legendCallback)
- },
- _clearSeries: function() {
- this._deleteElementsGroup();
- this._deleteBordersGroup();
- this._deleteTrackers();
- this._graphics = [];
- this._trackers = []
- },
- _draw: function(translators, animationEnabled, hideLayoutLabels, legendCallback) {
- var that = this,
- points = that._points || [],
- segment = [],
- segmentCount = 0,
- firstDrawing = that._firstDrawing,
- markersGroup,
- labelsGroup;
- that._graphics = that._graphics || [],
- that._graphics = that._graphics || [];
- that._prepareSeriesToDrawing();
- if (!that._visible) {
- animationEnabled = false;
- this._group.detach();
- return
- }
- else
- that._group.append(that._options.seriesGroup);
- that.translators = translators;
- that._createGroups(animationEnabled, undefined, firstDrawing);
- that._segments = [];
- markersGroup = that._markersGroup;
- labelsGroup = that._labelsGroup;
- that._drawedPoints = [];
- that._firstDrawing = points.length ? false : true;
- _each(this._patterns || [], function(_, pattern) {
- pattern.append()
- });
- _each(points, function(i, p) {
- p.translate(translators);
- if (p.hasValue()) {
- that._drawPoint(p, markersGroup, labelsGroup, animationEnabled, firstDrawing);
- segment.push(p)
- }
- else if (segment.length) {
- that._drawSegment(segment, animationEnabled, segmentCount++);
- segment = []
- }
- });
- segment.length && that._drawSegment(segment, animationEnabled, segmentCount++);
- that._removeOldSegments(segmentCount);
- that._defaultSegments = that._generateDefaultSegments();
- that._adjustLabels(firstDrawing);
- hideLayoutLabels && that.hideLabels();
- animationEnabled && that._animate(firstDrawing);
- if (that.isSelected())
- that._changeStyle(legendCallback, APPLY_SELECTED);
- else if (this.isHovered())
- this._changeStyle(legendCallback, APPLY_HOVER)
- },
- drawTrackers: function() {
- var that = this,
- trackers = that._trackers = that._trackers || [],
- trackersGroup = that._trackersGroup = that._trackersGroup || that._renderer.createGroup(),
- markerTrackerGroup = that._markerTrackerGroup = that._markerTrackerGroup || that._renderer.createGroup();
- if (!that.isVisible()) {
- trackersGroup.detach();
- markerTrackerGroup.detach();
- return
- }
- else {
- trackersGroup.append(that._options.trackersGroup);
- markerTrackerGroup.append(that._options.markerTrackerGroup)
- }
- _each(that._segments || [], function(i, segment) {
- if (!trackers[i]) {
- trackers[i] = that._drawTrackerElement(segment).append(trackersGroup);
- trackers[i].data({series: that})
- }
- else
- that._updateTrackerElement(segment, trackers[i])
- });
- _each(that.getVisiblePoints(), function(_, p) {
- p.drawTracker(that._renderer, markerTrackerGroup)
- });
- that._applyTrackersClippings()
- },
- _checkType: function(widgetType) {
- return !!viz.core.series.mixins[widgetType][this.type]
- },
- _resetType: function(seriesType, widgetType) {
- var that = this;
- if (seriesType)
- _each(viz.core.series.mixins[widgetType][seriesType], function(methodName) {
- delete that[methodName]
- })
- },
- _setType: function(seriesType, widgetType) {
- var that = this;
- _each(viz.core.series.mixins[widgetType][seriesType], function(methodName, method) {
- that[methodName] = method
- })
- },
- _setSelectedState: function(state, mode, legendCallback) {
- this.lastSelectionMode = mode = (mode || this._options.selectionMode).toLowerCase();
- if (state && !this.isSelected()) {
- this.fullState = this.fullState | SELECTED_STATE;
- this._changeStyle(legendCallback, APPLY_SELECTED)
- }
- else if (!state && this.isSelected()) {
- this.fullState = this.fullState & ~SELECTED_STATE;
- if (this.isHovered())
- this._changeStyle(legendCallback, APPLY_HOVER);
- else
- this._changeStyle(legendCallback, "resetItem")
- }
- },
- _setHoverState: function(state, mode, legendCallback) {
- this.lastHoverMode = mode = (mode || this._options.hoverMode).toLowerCase();
- if (state && !this.isHovered()) {
- this.fullState = this.fullState | HOVER_STATE;
- !this.isSelected() && this._changeStyle(legendCallback, APPLY_HOVER)
- }
- else if (!state && this.isHovered()) {
- this.fullState = this.fullState & ~HOVER_STATE;
- !this.isSelected() && this._changeStyle(legendCallback, "resetItem")
- }
- },
- setHoverState: function(mode, legendCallback) {
- this._setHoverState(true, mode, legendCallback)
- },
- releaseHoverState: function(mode, legendCallback) {
- this._setHoverState(false, mode, legendCallback)
- },
- setSelectedState: function(mode, legendCallback) {
- this._setSelectedState(true, mode, legendCallback)
- },
- releaseSelectedState: function(mode, legendCallback) {
- this._setSelectedState(false, mode, legendCallback)
- },
- isFullStackedSeries: function() {
- return this.type.indexOf("fullstacked") === 0
- },
- isStackedSeries: function() {
- return this.type.indexOf("stacked") === 0
- },
- isFinancialSeries: function() {
- return this.type === "stock" || this.type === "candlestick"
- },
- _changeStyle: function(legendCallBack, legendAction) {
- var style = this._calcStyle(),
- pointStyle;
- if (style.mode === NONE_MODE)
- return;
- legendCallBack && legendCallBack(legendAction);
- if (style.mode === INCLUDE_POINTS || style.mode === ALL_SERIES_POINTS_MODE) {
- pointStyle = style.pointStyle;
- _each(this._points || [], function(_, p) {
- !p.isSelected() && p.applyStyle(pointStyle)
- })
- }
- this._applyStyle(style.series)
- },
- _calcStyle: function() {
- var styles = this._styles,
- isHoverIncludeModeAndSeriesExcludeMode = false,
- result;
- switch (this.fullState & 3) {
- case 0:
- result = {
- pointStyle: "normal",
- mode: INCLUDE_POINTS,
- series: styles.normal
- };
- break;
- case 1:
- result = {
- pointStyle: "hover",
- mode: this.lastHoverMode,
- series: styles.hover
- };
- break;
- case 2:
- result = {
- pointStyle: "selection",
- mode: this.lastSelectionMode,
- series: styles.selection
- };
- break;
- case 3:
- isHoverIncludeModeAndSeriesExcludeMode = this.lastSelectionMode === EXLUDE_POINTS && (this.lastHoverMode === INCLUDE_POINTS || this.lastHoverMode === ALL_SERIES_POINTS_MODE);
- result = {
- pointStyle: isHoverIncludeModeAndSeriesExcludeMode ? "normal" : "selection",
- mode: isHoverIncludeModeAndSeriesExcludeMode ? INCLUDE_POINTS : this.lastSelectionMode,
- series: styles.selection
- }
- }
- return result
- },
- _getMainAxisName: function() {
- return this._options.rotated ? "X" : "Y"
- },
- areLabelsVisible: function() {
- return !_isDefined(this._options.maxLabelCount) || this._points.length <= this._options.maxLabelCount
- },
- getLabelVisibility: function() {
- return this.areLabelsVisible() && this._options.label && this._options.label.visible
- },
- _customizePoint: function(pointData) {
- var that = this,
- options = that._options,
- customizePoint = that._options.customizePoint,
- customizeObject,
- pointOptions,
- customLabelOptions,
- customOptions,
- customizeLabel = that._options.customizeLabel,
- useLabelCustomOptions,
- usePointCustomOptions;
- if (customizeLabel && customizeLabel.call) {
- customizeObject = _extend({
- seriesName: that.name,
- series: that
- }, pointData);
- customLabelOptions = customizeLabel.call(customizeObject, customizeObject);
- useLabelCustomOptions = customLabelOptions && !_isEmptyObject(customLabelOptions);
- customLabelOptions = useLabelCustomOptions ? _extend(true, {}, options.label, customLabelOptions) : null
- }
- if (customizePoint && customizePoint.call) {
- customizeObject = customizeObject || _extend({
- seriesName: that.name,
- series: that
- }, pointData);
- customOptions = customizePoint.call(customizeObject, customizeObject);
- usePointCustomOptions = customOptions && !_isEmptyObject(customOptions)
- }
- if (useLabelCustomOptions || usePointCustomOptions) {
- pointOptions = that._parsePointOptions(that._preparePointOptions(customOptions), customLabelOptions || options.label);
- pointOptions.styles.useLabelCustomOptions = useLabelCustomOptions;
- pointOptions.styles.usePointCustomOptions = usePointCustomOptions
- }
- return pointOptions
- },
- _getLabelOptions: function(labelOptions, defaultColor) {
- var opt = labelOptions || {},
- labelFont = opt.font || {},
- labelBorder = opt.border || {},
- labelConnector = opt.connector || {},
- labelAttributes = {
- align: opt.alignment,
- font: {
- color: opt.backgroundColor === "none" && labelFont.color.toLowerCase() === "#ffffff" && opt.position !== "inside" ? defaultColor : labelFont.color,
- family: labelFont.family,
- weight: labelFont.weight,
- size: labelFont.size,
- opacity: labelFont.opacity
- },
- style: opt.style
- },
- backgroundAttr = {
- fill: opt.backgroundColor || defaultColor,
- strokeWidth: labelBorder.visible ? labelBorder.width || 0 : 0,
- stroke: labelBorder.visible && labelBorder.width ? labelBorder.color : "none",
- dashStyle: labelBorder.dashStyle
- },
- connectorAttr = {
- stroke: labelConnector.visible && labelConnector.width ? labelConnector.color || defaultColor : "none",
- strokeWidth: labelConnector.visible ? labelConnector.width || 0 : 0
- };
- return {
- format: opt.format,
- argumentFormat: opt.argumentFormat,
- precision: opt.precision,
- argumentPrecision: opt.argumentPrecision,
- percentPrecision: opt.percentPrecision,
- customizeText: $.isFunction(opt.customizeText) ? opt.customizeText : undefined,
- attributes: labelAttributes,
- visible: labelFont.size !== 0 ? opt.visible : false,
- showForZeroValues: opt.showForZeroValues,
- horizontalOffset: opt.horizontalOffset,
- verticalOffset: opt.verticalOffset,
- radialOffset: opt.radialOffset,
- background: backgroundAttr,
- position: opt.position,
- connector: connectorAttr,
- rotationAngle: opt.rotationAngle,
- resolveLabelsOverlapping: this._options.resolveLabelsOverlapping
- }
- },
- show: function() {
- if (!this._visible) {
- this._visible = true;
- this.hidePointTooltip();
- this._options.visibilityChanged()
- }
- },
- hide: function() {
- if (this._visible) {
- this._visible = false;
- this.hidePointTooltip();
- this._options.visibilityChanged()
- }
- },
- hideLabels: function() {
- _each(this._points, function(_, point) {
- point._label.hide()
- })
- },
- _parsePointOptions: function(pointOptions, labelOptions) {
- var options = this._options,
- styles = this._createPointStyles(pointOptions),
- parsedOptions;
- parsedOptions = _extend(true, {}, pointOptions, {
- type: options.type,
- tag: this.tag,
- rotated: options.rotated,
- series: this,
- styles: styles,
- visibilityChanged: options.visibilityChanged
- });
- parsedOptions.label = this._getLabelOptions(labelOptions, styles.normal.fill);
- return parsedOptions
- },
- _resample: function(ticks, ticksInterval) {
- var that = this,
- fusPoints = [],
- arrayFusPoints,
- nowIndexTicks = 0,
- lastPointIndex = 0,
- originalPoints = that.getAllPoints();
- if (that.argumentAxisType === "discrete" || that.valueAxisType === "discrete") {
- ticksInterval = originalPoints.length / ticks;
- arrayFusPoints = $.map(originalPoints, function(point, index) {
- if (Math.floor(nowIndexTicks) <= index) {
- nowIndexTicks += ticksInterval;
- return point
- }
- point.setInvisibility();
- return null
- });
- return arrayFusPoints
- }
- that._aggregatedPoints = that._aggregatedPoints || [];
- _each(originalPoints, function(_, point) {
- switch (that._isInInterval(point.argument, ticks, nowIndexTicks, ticksInterval)) {
- case true:
- fusPoints.push(point);
- break;
- case"nextInterval":
- var pointData = that._fusionPoints(fusPoints, ticks[nowIndexTicks], nowIndexTicks);
- while (that._isInInterval(point.argument, ticks, nowIndexTicks, ticksInterval) === "nextInterval")
- nowIndexTicks++;
- fusPoints = [];
- that._isInInterval(point.argument, ticks, nowIndexTicks, ticksInterval) === true && fusPoints.push(point);
- if (that._createPoint(pointData, that._aggregatedPoints, lastPointIndex))
- lastPointIndex++
- }
- });
- if (fusPoints.length) {
- var pointData = that._fusionPoints(fusPoints, ticks[nowIndexTicks], nowIndexTicks);
- if (that._createPoint(pointData, that._aggregatedPoints, lastPointIndex))
- lastPointIndex++
- }
- that._correctPointsLength(lastPointIndex, that._aggregatedPoints);
- that._endUpdateData();
- return that._aggregatedPoints
- },
- _isInInterval: function(argument, ticks, nowIndexTicks, ticksInterval) {
- var minTick = ticks[nowIndexTicks],
- maxTick = ticks[nowIndexTicks + 1],
- sumMinTickTicksInterval;
- ticksInterval = $.isNumeric(ticksInterval) ? ticksInterval : utils.convertDateTickIntervalToMilliseconds(ticksInterval);
- sumMinTickTicksInterval = utils.isDate(minTick) ? new Date(minTick.getTime() + ticksInterval) : minTick + ticksInterval;
- if (argument >= minTick && argument < sumMinTickTicksInterval)
- return true;
- if (argument < minTick || maxTick === undefined)
- return false;
- return "nextInterval"
- },
- canRenderCompleteHandle: function() {
- var result = this._canRenderCompleteHandle;
- delete this._canRenderCompleteHandle;
- return !!result
- },
- isHovered: function() {
- return !!(this.fullState & 1)
- },
- isSelected: function() {
- return !!(this.fullState & 2)
- },
- isVisible: function() {
- return this._visible
- },
- getAllPoints: function() {
- return (this._originalPoints || []).slice()
- },
- getPointByPos: function(pos) {
- return (this._points || [])[pos]
- },
- getVisiblePoints: function() {
- return (this._drawedPoints || []).slice()
- },
- setPointHoverState: function(point, legendCallback) {
- point.fullState = point.fullState | HOVER_STATE;
- if (!(this.isSelected() && (this.lastSelectionMode === ALL_SERIES_POINTS_MODE || this.lastSelectionMode === INCLUDE_POINTS)) && !point.isSelected()) {
- point.applyStyle("hover");
- legendCallback && legendCallback("applyHover")
- }
- },
- releasePointHoverState: function(point, legendCallback) {
- point.fullState = point.fullState & ~HOVER_STATE;
- if (!(this.isSelected() && (this.lastSelectionMode === ALL_SERIES_POINTS_MODE || this.lastSelectionMode === INCLUDE_POINTS)) && !point.isSelected())
- if (!(this.isHovered() && (this.lastHoverMode === ALL_SERIES_POINTS_MODE || this.lastHoverMode === INCLUDE_POINTS))) {
- point.applyStyle("normal");
- legendCallback && legendCallback("resetItem")
- }
- },
- setPointSelectedState: function(point, legendCallback) {
- point.fullState = point.fullState | SELECTED_STATE;
- point.applyStyle("selection");
- legendCallback && legendCallback("applySelected")
- },
- releasePointSelectedState: function(point, legendCallback) {
- point.fullState = point.fullState & ~SELECTED_STATE;
- if (this.isHovered() && (this.lastHoverMode === ALL_SERIES_POINTS_MODE || this.lastHoverMode === INCLUDE_POINTS) || point.isHovered()) {
- point.applyStyle("hover");
- legendCallback && legendCallback("applyHover")
- }
- else if (this.isSelected() && (this.lastSelectionMode === ALL_SERIES_POINTS_MODE || this.lastSelectionMode === INCLUDE_POINTS)) {
- point.applyStyle("selection");
- legendCallback && legendCallback("applySelected")
- }
- else {
- point.applyStyle("normal");
- legendCallback && legendCallback("resetItem")
- }
- },
- selectPoint: function(point) {
- this._options.seriesGroup && this._options.seriesGroup.trigger(new _Event("selectpoint"), point)
- },
- deselectPoint: function(point) {
- this._options.seriesGroup && this._options.seriesGroup.trigger(new _Event("deselectpoint"), point)
- },
- showPointTooltip: function(point) {
- this._options.seriesGroup && this._options.seriesGroup.trigger(new _Event("showpointtooltip"), point)
- },
- hidePointTooltip: function(point) {
- this._options.seriesGroup && this._options.seriesGroup.trigger(new _Event("hidepointtooltip"), point)
- },
- select: function() {
- this._options.seriesGroup && this._options.seriesGroup.trigger(new _Event("selectseries", {target: this}), this._options.selectionMode);
- this._group.toForeground();
- this._trackersGroup && this._trackersGroup.toBackground()
- },
- clearSelection: function clearSelection() {
- this._options.seriesGroup && this._options.seriesGroup.trigger(new _Event("deselectseries", {target: this}), this._options.selectionMode)
- },
- getPointByArg: function(arg) {
- return this.pointsByArgument[arg.valueOf()] || null
- },
- _deletePoints: function() {
- this._disposePoints(this._originalPoints);
- this._disposePoints(this._aggregatedPoints);
- this._disposePoints(this._oldPoints);
- this._points = null;
- this._oldPoints = null;
- this._aggregatedPoints = null;
- this._originalPoints = null;
- this._drawedPoint = null
- },
- _deletePatterns: function() {
- _each(this._patterns || [], function(_, pattern) {
- pattern && pattern.dispose()
- });
- this._patterns = null
- },
- _deleteTrackers: function() {
- var that = this;
- _each(that._trackers || [], function(_, tracker) {
- tracker.remove()
- });
- that._trackersGroup && that._trackersGroup.detach();
- that._markerTrackerGroup && that._markerTrackerGroup.detach();
- that._trackers = that._trackersGroup = that._markerTrackerGroup = null
- },
- dispose: function() {
- this._deletePoints();
- this._group.detach();
- this._labelsGroup && this._labelsGroup.detach();
- this._deletePatterns();
- this._deleteTrackers();
- this._group = null;
- this._markersGroup = null;
- this._elementsGroup = null;
- this._bordersGroup = null;
- this._labelsGroup = null;
- this._graphics = null;
- this._rangeData = null;
- this._renderer = null;
- this.translators = null;
- this._styles = null;
- this._options = null;
- this._pointOptions = null;
- this._drawedPoints = null;
- this._aggregatedPoints = null;
- this.pointsByArgument = null;
- this._segments = null
- },
- correctPosition: _noop,
- getColor: function() {
- return this.getLegendStyles().normal.fill
- },
- getStackName: function() {
- return this.type === "stackedbar" || this.type === "fullstackedbar" ? this._stackName : null
- }
- })
- })(jQuery, DevExpress);
- /*! Module viz-core, file rangeDataCalculator.js */
- (function($, DX) {
- var _math = Math,
- _abs = _math.abs,
- _min = _math.min,
- _each = $.each,
- _isEmptyObject = $.isEmptyObject,
- _isDefined = DevExpress.utils.isDefined,
- FULLSTACKED_SERIES_VALUE_MARGIN_PRIORITY = 15,
- BAR_ZERO_VALUE_MARGIN_PRIORITY = 20,
- SERIES_VALUE_MARGIN_PRIORITY = 20,
- SERIES_LABEL_VALUE_MARGIN = 0.3,
- CATEGORIES_SELECTOR = "categories",
- INTERVAL_SELECTOR = "interval",
- MIN_VALUE_MARGIN_SELECTOR = "minValueMargin",
- MAX_VALUE_MARGIN_SELECTOR = "maxValueMargin",
- MIN = "min",
- MAX = "max",
- MIN_VISIBLE = "minVisible",
- MAX_VISIBLE = "maxVisible";
- DevExpress.viz.core.series.helpers.rangeDataCalculator = function() {
- var _truncateValue = function(data, minField, maxField, value) {
- var min = data[minField],
- max = data[maxField];
- data[minField] = value < min || !_isDefined(min) ? value : data[minField];
- data[maxField] = value > max || !_isDefined(max) ? value : data[maxField]
- };
- var _processTwoValues = function(series, point, prevPoint, highValueName, lowValueName) {
- var val = point[highValueName],
- minVal = point[lowValueName],
- arg = point.argument,
- prevVal = prevPoint && prevPoint[highValueName],
- prevMinVal = prevPoint && prevPoint[lowValueName],
- prevArg = prevPoint && prevPoint.argument;
- point.hasValue() && _processRangeValue(series, val, minVal, prevVal, prevMinVal);
- _processValue(series, "arg", arg, prevArg)
- };
- var _processValue = function(series, type, value, prevValue, calcInterval) {
- var axis = type === "arg" ? "argument" : "value",
- data = series._rangeData[type],
- minInterval = data[INTERVAL_SELECTOR],
- interval;
- if (series[axis + "AxisType"] === "discrete") {
- data[CATEGORIES_SELECTOR] = data[CATEGORIES_SELECTOR] || [];
- data[CATEGORIES_SELECTOR].push(value)
- }
- else {
- _truncateValue(data, "min", "max", value);
- if (type === "arg") {
- interval = (_isDefined(prevValue) ? _abs(calcInterval ? calcInterval(value, prevValue) : value - prevValue) : interval) || minInterval;
- data[INTERVAL_SELECTOR] = _isDefined(interval) && (interval < minInterval || !_isDefined(minInterval)) ? interval : minInterval
- }
- }
- };
- var _addToVisibleRange = function(series, value) {
- var data = series._rangeData.val,
- isDiscrete = series.valueAxisType === "discrete";
- if (isDiscrete) {
- data.visibleCategories = data.visibleCategories || [];
- data.visibleCategories.push(value)
- }
- else {
- if (value < data.minVisible || !_isDefined(data.minVisible))
- data.minVisible = value;
- if (value > data.maxVisible || !_isDefined(data.maxVisible))
- data.maxVisible = value
- }
- };
- var _processRangeValue = function(series, val, minVal, prevVal, prevMinVal) {
- var data = series._rangeData.val,
- interval,
- currentInterval = data[INTERVAL_SELECTOR];
- if (series.valueAxisType === "discrete") {
- data.categories = data.categories || [];
- data.categories.push(val, minVal)
- }
- else {
- _truncateValue(data, MIN, MAX, val);
- _truncateValue(data, MIN, MAX, minVal)
- }
- };
- var _unique = function(array) {
- var values = {};
- return $.map(array, function(item) {
- var result = !values[item] ? item : null;
- values[item] = true;
- return result
- })
- };
- var _processZoomArgument = function(series, zoomArgs) {
- var data = series._rangeData.arg,
- minArg,
- maxArg;
- minArg = zoomArgs.minArg < zoomArgs.maxArg ? zoomArgs.minArg : zoomArgs.maxArg;
- maxArg = zoomArgs.maxArg > zoomArgs.minArg ? zoomArgs.maxArg : zoomArgs.minArg;
- data.min = minArg < data.min ? minArg : data.min;
- data.max = maxArg > data.max ? maxArg : data.max;
- data.minVisible = minArg;
- data.maxVisible = maxArg
- };
- var _correctZoomValue = function(series, zoomArgs) {
- var minVal,
- maxVal;
- if (_isDefined(zoomArgs.minVal) && _isDefined(zoomArgs.maxVal)) {
- minVal = zoomArgs.minVal < zoomArgs.maxVal ? zoomArgs.minVal : zoomArgs.maxVal;
- maxVal = zoomArgs.maxVal > zoomArgs.minVal ? zoomArgs.maxVal : zoomArgs.minVal
- }
- if (_isDefined(zoomArgs.minVal)) {
- series._rangeData.val.min = minVal < series._rangeData.val.min ? minVal : series._rangeData.val.min;
- series._rangeData.val.minVisible = minVal
- }
- if (_isDefined(zoomArgs.maxVal)) {
- series._rangeData.val.max = maxVal > series._rangeData.val.max ? maxVal : series._rangeData.val.max;
- series._rangeData.val.maxVisible = maxVal
- }
- };
- var _processZoomValue = function(series, zoomArgs) {
- var adjustOnZoom = zoomArgs.adjustOnZoom,
- points = series._points || [],
- lastVisibleIndex,
- prevPointAdded = false;
- _each(points, function(index, point) {
- var arg = point.argument,
- prevPoint = index > 0 ? points[index - 1] : null;
- if (adjustOnZoom && arg >= series._rangeData.arg.minVisible && arg <= series._rangeData.arg.maxVisible) {
- if (!prevPointAdded) {
- prevPoint && prevPoint.hasValue() && _addToVisibleRange(series, prevPoint.value);
- prevPointAdded = true
- }
- point.hasValue() && _addToVisibleRange(series, point.value);
- lastVisibleIndex = index
- }
- });
- if (_isDefined(lastVisibleIndex) && lastVisibleIndex < points.length - 1 && points[lastVisibleIndex + 1].hasValue())
- _addToVisibleRange(series, points[lastVisibleIndex + 1].value);
- _correctZoomValue(series, zoomArgs)
- };
- var _processZoomRangeValue = function(series, zoomArgs, maxValueName, minValueName) {
- var adjustOnZoom = zoomArgs.adjustOnZoom,
- points = series._points || [],
- lastVisibleIndex,
- prevPointAdded = false;
- _each(points, function(index, point) {
- var arg = point.argument,
- prevPoint = index > 0 ? points[index - 1] : null;
- if (adjustOnZoom && arg >= series._rangeData.arg.minVisible && arg <= series._rangeData.arg.maxVisible) {
- if (!prevPointAdded) {
- if (prevPoint && prevPoint.hasValue()) {
- _addToVisibleRange(series, prevPoint[maxValueName]);
- _addToVisibleRange(series, prevPoint[minValueName])
- }
- prevPointAdded = true
- }
- if (point.hasValue()) {
- _addToVisibleRange(series, point[maxValueName]);
- _addToVisibleRange(series, point[minValueName])
- }
- lastVisibleIndex = index
- }
- });
- if (_isDefined(lastVisibleIndex) && lastVisibleIndex < points.length - 1 && points[lastVisibleIndex + 1].hasValue())
- _addToVisibleRange(series, points[lastVisibleIndex + 1].value);
- _correctZoomValue(series, zoomArgs)
- };
- var _processNewInterval = function(series, calcInterval) {
- var data = series._rangeData,
- points = series._points || [],
- isArgumentAxisDiscrete = series.argumentAxisType === "discrete";
- delete data.arg.interval;
- _each(points, function(index, point) {
- var arg = point.argument,
- prevPoint = index > 0 ? points[index - 1] : null,
- prevArg = prevPoint && prevPoint.argument;
- !isArgumentAxisDiscrete && _processValue(series, "arg", arg, prevArg, calcInterval)
- })
- };
- var _fillRangeData = function(series) {
- var data = series._rangeData,
- mainAxis = series._getMainAxisName(),
- axis = mainAxis === "X" ? "Y" : "X";
- data.arg.categories && (data.arg.categories = _unique(data.arg.categories));
- data.val.categories && (data.val.categories = _unique(data.val.categories));
- data.arg.visibleCategories && (data.arg.visibleCategories = _unique(data.arg.visibleCategories));
- data.val.visibleCategories && (data.val.visibleCategories = _unique(data.val.visibleCategories));
- data.arg.axisType = series.argumentAxisType;
- data.arg.dataType = series.argumentType;
- data.val.axisType = series.valueAxisType;
- data.val.dataType = series.valueType;
- data.val.isValueRange = true
- };
- var _setPadding = function(range, prefix, val, priority) {
- range[prefix] = val;
- range[prefix + "Priority"] = priority
- };
- var _setZeroPadding = function(range, val, prefix) {
- val === 0 && _setPadding(range, prefix, 0, BAR_ZERO_VALUE_MARGIN_PRIORITY)
- };
- var _calculateRangeMinValue = function(series, zoomArgs) {
- var data = series._rangeData.val,
- minVisible = data[MIN_VISIBLE],
- maxVisible = data[MAX_VISIBLE];
- zoomArgs = zoomArgs || {};
- if (data) {
- data.alwaysCorrectMin = true;
- series._rangeData.arg.keepValueMargins = true;
- if (series.valueAxisType !== "logarithmic" && series.valueType !== "datetime" && series.getOptions().showZero !== false) {
- data[MIN_VISIBLE] = minVisible > (zoomArgs.minVal || 0) ? zoomArgs.minVal || 0 : minVisible;
- data[MAX_VISIBLE] = maxVisible < (zoomArgs.maxVal || 0) ? zoomArgs.maxVal || 0 : maxVisible;
- data[MIN] = data[MIN] > 0 ? 0 : data[MIN];
- _setZeroPadding(data, data[MIN], MIN_VALUE_MARGIN_SELECTOR);
- data[MAX] = data[MAX] < 0 ? 0 : data[MAX];
- if (data[MAX] === 0 || data[MAX] > 0 && data[MIN] < 0) {
- data[MIN_VALUE_MARGIN_SELECTOR] = data[MAX_VALUE_MARGIN_SELECTOR];
- data[MIN_VALUE_MARGIN_SELECTOR + "Priority"] = data[MAX_VALUE_MARGIN_SELECTOR + "Priority"]
- }
- _setZeroPadding(data, data[MAX], MAX_VALUE_MARGIN_SELECTOR)
- }
- }
- };
- var _processFullStackedRange = function(series) {
- var data = series._rangeData.val,
- isRangeEmpty = _isEmptyObject(data);
- _setPadding(data, "minValueMargin", 0, FULLSTACKED_SERIES_VALUE_MARGIN_PRIORITY);
- _setPadding(data, "maxValueMargin", 0, FULLSTACKED_SERIES_VALUE_MARGIN_PRIORITY);
- !isRangeEmpty && (data.min = 0)
- };
- var _processRange = function(series, point, prevPoint) {
- var val = point.value,
- arg = point.argument,
- prevVal = prevPoint && prevPoint.value,
- prevArg = prevPoint && prevPoint.argument;
- point.hasValue() && _processValue(series, "val", val, prevVal);
- _processValue(series, "arg", arg, prevArg)
- };
- var _addLabelPaddings = function(series) {
- var labelOptions = series.getOptions().label;
- if (series.areLabelsVisible() && labelOptions && labelOptions.visible && labelOptions.position !== "inside")
- _setPadding(series._rangeData.val, "maxValueMargin", SERIES_LABEL_VALUE_MARGIN, SERIES_VALUE_MARGIN_PRIORITY)
- };
- var _addRangeSeriesLabelPaddings = function(series) {
- var data = series._rangeData.val;
- if (series.areLabelsVisible() && series._options.label.visible && series._options.label.position !== "inside") {
- _setPadding(data, "maxValueMargin", SERIES_LABEL_VALUE_MARGIN, SERIES_VALUE_MARGIN_PRIORITY);
- _setPadding(data, "minValueMargin", SERIES_LABEL_VALUE_MARGIN, SERIES_VALUE_MARGIN_PRIORITY)
- }
- };
- var _calculateRangeData = function(series, zoomArgs, calcIntervalFunction) {
- var valueData = series._rangeData.val;
- if (series.argumentAxisType !== "discrete" && zoomArgs && _isDefined(zoomArgs.minArg) && _isDefined(zoomArgs.maxArg)) {
- valueData[MIN_VISIBLE] = zoomArgs.minVal;
- valueData[MAX_VISIBLE] = zoomArgs.maxVal;
- _processZoomArgument(series, zoomArgs);
- _processZoomValue(series, zoomArgs)
- }
- else if (!zoomArgs && calcIntervalFunction)
- _processNewInterval(series, calcIntervalFunction);
- _fillRangeData(series)
- };
- var _calculateTwoValuesRangeData = function(series, zoomArgs, calcIntervalFunction, maxValueName, minValueName) {
- var valueData = series._rangeData.val;
- if (series.argumentAxisType !== "discrete" && zoomArgs && _isDefined(zoomArgs.minArg) && _isDefined(zoomArgs.maxArg)) {
- valueData[MIN_VISIBLE] = zoomArgs.minVal;
- valueData[MAX_VISIBLE] = zoomArgs.maxVal;
- _processZoomArgument(series, zoomArgs);
- _processZoomRangeValue(series, zoomArgs, maxValueName, minValueName)
- }
- else if (!zoomArgs && calcIntervalFunction)
- _processNewInterval(series);
- _fillRangeData(series)
- };
- return {
- processRange: _processRange,
- calculateRangeData: _calculateRangeData,
- calculateTwoValuesRangeData: _calculateTwoValuesRangeData,
- addLabelPaddings: _addLabelPaddings,
- addRangeSeriesLabelPaddings: _addRangeSeriesLabelPaddings,
- processFullStackedRange: _processFullStackedRange,
- calculateRangeMinValue: _calculateRangeMinValue,
- processTwoValues: _processTwoValues
- }
- }
- })(jQuery, DevExpress);
- /*! Module viz-core, file scatterSeries.js */
- (function($, DX) {
- var viz = DX.viz,
- series = viz.core.series,
- rangeCalculator = series.helpers.rangeDataCalculator(),
- _each = $.each,
- _extend = $.extend,
- _map = $.map,
- _noop = $.noop,
- _isDefined = DX.utils.isDefined,
- _floor = Math.floor,
- DEFAULT_SYMBOL_POINT_SIZE = 2,
- DEFAULT_TRACKER_WIDTH = 20,
- DEFAULT_DURATION = 400;
- series.mixins.chart.scatter = {
- _defaultDuration: DEFAULT_DURATION,
- _defaultTrackerWidth: DEFAULT_TRACKER_WIDTH,
- _applyStyle: _noop,
- _adjustLabels: _noop,
- _updateOptions: _noop,
- _parseStyle: _noop,
- _prepareSegment: _noop,
- _drawSegment: _noop,
- _generateDefaultSegments: _noop,
- _prepareSeriesToDrawing: function() {
- this._deleteOldAnimationMethods();
- this._firstDrawing && this._clearSeries();
- this._disposePoints(this._oldPoints);
- this._oldPoints = null
- },
- _applyTrackersClippings: function() {
- this._markerTrackerGroup.applySettings({clipId: this._forceClipping ? this._paneClipRectID : null})
- },
- updateTeamplateFieldNames: function() {
- var that = this,
- options = that._options;
- options.valueField = that.getValueFields()[0] + that.name;
- options.tagField = that.getTagField() + that.name
- },
- _applyElementsClipRect: function(settings) {
- settings.clipId = this._paneClipRectID
- },
- _applyMarkerClipRect: function(settings) {
- settings.clipId = this._forceClipping ? this._paneClipRectID : null
- },
- _createGroup: function(groupName, parent, target, settings) {
- var group = parent[groupName];
- if (!group)
- parent[groupName] = group = this._renderer.createGroup(settings);
- else
- group.applySettings(settings);
- group.append(target)
- },
- _applyClearingSettings: function(settings) {
- settings.opacity = null;
- settings.scale = null;
- if (this._options.rotated)
- settings.translateX = null;
- else
- settings.translateY = null
- },
- _createMarkerGroup: function() {
- var settings = this._getPointOptions().styles.normal;
- settings["class"] = "dxc-markers";
- settings.opacity = 1;
- this._applyMarkerClipRect(settings);
- this._createGroup("_markersGroup", this, this._group, settings)
- },
- _createLabelGroup: function() {
- var settings = {
- "class": "dxc-labels",
- visibility: this.getLabelVisibility() ? "visible" : "hidden"
- };
- this._applyElementsClipRect(settings);
- this._applyClearingSettings(settings);
- this._createGroup("_labelsGroup", this, this._options.labelsGroup, settings)
- },
- _createGroups: function(animationEnabled) {
- this._createMarkerGroup();
- this._createLabelGroup();
- animationEnabled && this._labelsGroup && this._labelsGroup.applySettings({opacity: 0.001})
- },
- _getCreatingPointOptions: function() {
- if (!this._predefinedPointOptions) {
- var defaultPointOptions = this._getPointOptions(),
- r = defaultPointOptions.styles && defaultPointOptions.styles.normal && defaultPointOptions.styles.normal.r,
- strokeWidth = defaultPointOptions.styles && defaultPointOptions.styles.normal && defaultPointOptions.styles.normal.strokeWidth,
- creatingPointOptions = _extend(true, {}, defaultPointOptions);
- creatingPointOptions.styles = creatingPointOptions.styles || {};
- creatingPointOptions.styles.normal = {
- r: r,
- strokeWidth: strokeWidth
- };
- this._predefinedPointOptions = creatingPointOptions
- }
- return this._predefinedPointOptions
- },
- _getSpecialColor: function(mainSeriesColor) {
- return mainSeriesColor
- },
- _getPointOptions: function() {
- return this._pointOptions || (this._pointOptions = this._parsePointOptions(this._preparePointOptions(), this._options.label))
- },
- _preparePointOptions: function(customOptions) {
- return customOptions ? _extend(true, {}, this._options.point, customOptions) : this._options.point
- },
- _parsePointStyle: function(style, defaultColor, defaultBorderColor) {
- var border = style.border || {};
- return {
- fill: style.color || defaultColor,
- stroke: border.color || defaultBorderColor,
- strokeWidth: border.visible ? border.width : 0,
- r: style.size / 2 + (border.visible && style.size !== 0 ? ~~(border.width / 2) || 0 : 0)
- }
- },
- _createPointStyles: function(pointOptions) {
- var mainPointColor = pointOptions.color || this._options.mainSeriesColor,
- containerColor = this._options.containerBackgroundColor,
- normalStyle = this._parsePointStyle(pointOptions, mainPointColor, mainPointColor);
- normalStyle.visibility = pointOptions.visible ? "visible" : "hidden";
- return {
- normal: normalStyle,
- hover: this._parsePointStyle(pointOptions.hoverStyle, containerColor, mainPointColor),
- selection: this._parsePointStyle(pointOptions.selectionStyle, containerColor, mainPointColor)
- }
- },
- _checkData: function(data) {
- return _isDefined(data.argument) && data.value !== undefined
- },
- _processRange: function(point, prevPoint) {
- rangeCalculator.processRange(this, point, prevPoint)
- },
- _getRangeData: function(zoomArgs, calcIntervalFunction) {
- rangeCalculator.calculateRangeData(this, zoomArgs, calcIntervalFunction);
- rangeCalculator.addLabelPaddings(this);
- return this._rangeData
- },
- _getPointData: function(data, options) {
- var argumentField = options.argumentField || "arg",
- valueField = options.valueField || "val",
- tagField = options.tagField || "tag";
- return {
- value: data[valueField],
- argument: data[argumentField],
- tag: data[tagField]
- }
- },
- _drawPoint: function(point, markersGroup, labelsGroup, animationEnabled, firstDrawing) {
- if (point.isInVisibleArea()) {
- point.clearVisibility();
- point.draw(this._renderer, markersGroup, labelsGroup, animationEnabled, firstDrawing);
- this._drawedPoints.push(point)
- }
- else
- point.setInvisibility()
- },
- _clearingAnimation: function(translators, drawComplete) {
- var that = this,
- params = {opacity: 0.001},
- options = {
- duration: that._defaultDuration,
- partitionDuration: 0.5
- };
- that._labelsGroup && that._labelsGroup.animate(params, options, function() {
- that._markersGroup && that._markersGroup.animate(params, options, drawComplete)
- })
- },
- _animate: function(complete) {
- var that = this,
- lastPointIndex = that._drawedPoints.length - 1,
- labelAnimFunc = function() {
- that._labelsGroup && that._labelsGroup.animate({opacity: 1}, {duration: that._defaultDuration})
- },
- settings;
- _each(that._drawedPoints || [], function(i, p) {
- settings = {translate: {
- x: p.x,
- y: p.y
- }};
- p.animate(i === lastPointIndex ? labelAnimFunc : undefined, settings)
- })
- },
- _getPointSize: function() {
- return this._options.point.visible ? this._options.point.size : DEFAULT_SYMBOL_POINT_SIZE
- },
- _calcMedianValue: function(fusionPoints, valueField) {
- var result,
- allValue;
- allValue = _map(fusionPoints, function(point) {
- return point[valueField]
- });
- allValue.sort(function(a, b) {
- return a - b
- });
- result = allValue[_floor(allValue.length / 2)];
- return _isDefined(result) ? result : null
- },
- _fusionPoints: function(fusionPoints, tick, index) {
- var result = this._calcMedianValue(fusionPoints, "value");
- return {
- value: result,
- argument: tick,
- tag: null,
- index: index,
- seriesName: this.name
- }
- },
- _endUpdateData: function() {
- delete this._predefinedPointOptions
- },
- getArgumentField: function() {
- return this._options.argumentField || "arg"
- },
- getValueFields: function() {
- return [this._options.valueField || "val"]
- },
- _beginUpdateData: $.noop
- }
- })(jQuery, DevExpress);
- /*! Module viz-core, file lineSeries.js */
- (function($, DX) {
- var viz = DX.viz,
- series = viz.core.series.mixins.chart,
- utils = DX.utils,
- scatterSeries = series.scatter,
- _extend = $.extend,
- _map = $.map,
- _each = $.each;
- series.line = _extend({}, scatterSeries, {
- _createElementsGroup: function(elementsStyle) {
- var settings = _extend({"class": "dxc-elements"}, elementsStyle);
- this._applyElementsClipRect(settings);
- this._createGroup("_elementsGroup", this, this._group, settings)
- },
- _createBordersGroup: function(borderStyle) {
- var settings = _extend({"class": "dxc-borders"}, borderStyle);
- this._applyElementsClipRect(settings);
- this._createGroup("_bordersGroup", this, this._group, settings)
- },
- _applyTrackersClippings: function() {
- scatterSeries._applyTrackersClippings.call(this);
- this._trackersGroup.applySettings({clipId: this._paneClipRectID})
- },
- _createGroups: function(animationEnabled, style) {
- var style = style || this._styles.normal;
- this._createElementsGroup(style.elements);
- this._areBordersVisible() && this._createBordersGroup(style.border);
- scatterSeries._createGroups.call(this, animationEnabled, {});
- animationEnabled && this._markersGroup && this._markersGroup.applySettings({opacity: 0.001})
- },
- _areBordersVisible: function() {
- return false
- },
- _getDefaultSegment: function(segment) {
- return {line: _map(segment.line || [], function(pt) {
- return pt.getDefaultCoords()
- })}
- },
- _prepareSegment: function(points) {
- return {line: points}
- },
- _parseLineOptions: function(options, defaultColor) {
- return {
- stroke: options.color || defaultColor,
- strokeWidth: options.width,
- dashStyle: options.dashStyle || 'solid'
- }
- },
- _parseStyle: function(options, defaultColor) {
- return {elements: this._parseLineOptions(options, defaultColor)}
- },
- _applyStyle: function(style) {
- this._elementsGroup && this._elementsGroup.applySettings(style.elements);
- _each(this._graphics || [], function(_, graphic) {
- graphic.line && graphic.line.applySettings({strokeWidth: style.elements.strokeWidth})
- })
- },
- _drawElement: function(segment, group) {
- return {line: this._createMainElement(segment.line, {strokeWidth: this._styles.normal.elements.strokeWidth}).append(group)}
- },
- _removeElement: function(element) {
- element.line.remove()
- },
- _generateDefaultSegments: function() {
- var that = this,
- segments = [];
- _each(that._segments || [], function(_, segment) {
- segments.push(that._getDefaultSegment(segment))
- });
- return segments
- },
- _updateElement: function(element, segment, animate, animateParams, complete) {
- var params = {points: segment.line};
- animate ? element.line.animate(params, animateParams, complete) : element.line.applySettings(params)
- },
- _clearingAnimation: function(translator, drawComplete) {
- var that = this,
- lastIndex = that._graphics.length - 1,
- settings = {opacity: 0.001},
- options = {
- duration: that._defaultDuration,
- partitionDuration: 0.5
- };
- that._labelsGroup && that._labelsGroup.animate(settings, options, function() {
- that._markersGroup && that._markersGroup.animate(settings, options, function() {
- _each(that._defaultSegments || [], function(i, segment) {
- that._oldUpdateElement(that._graphics[i], segment, true, {partitionDuration: 0.5}, i === lastIndex ? drawComplete : undefined)
- })
- })
- })
- },
- _animate: function() {
- var that = this,
- lastIndex = that._graphics.length - 1;
- _each(that._graphics || [], function(i, elem) {
- that._updateElement(elem, that._segments[i], true, {complete: i === lastIndex ? function() {
- that._labelsGroup && that._labelsGroup.animate({opacity: 1}, {duration: that._defaultDuration});
- that._markersGroup && that._markersGroup.animate({opacity: 1}, {duration: that._defaultDuration})
- } : undefined})
- })
- },
- _drawPoint: function(point, group, labelsGroup) {
- scatterSeries._drawPoint.call(this, point, group, labelsGroup)
- },
- _createMainElement: function(points, settings) {
- return this._renderer.createPath(points, settings)
- },
- _drawSegment: function(points, animationEnabled, segmentCount) {
- var segment = this._prepareSegment(points, this._options.rotated);
- this._segments.push(segment);
- if (!this._graphics[segmentCount])
- this._graphics[segmentCount] = this._drawElement(animationEnabled ? this._getDefaultSegment(segment) : segment, this._elementsGroup);
- else if (!animationEnabled)
- this._updateElement(this._graphics[segmentCount], segment)
- },
- _getTrackerSettings: function() {
- return {
- strokeWidth: this._styles.normal.elements.strokeWidth > this._defaultTrackerWidth ? this._styles.normal.elements.strokeWidth : this._defaultTrackerWidth,
- fill: "none"
- }
- },
- _getMainPointsFromSegment: function(segment) {
- return segment.line
- },
- _drawTrackerElement: function(segment) {
- return this._createMainElement(this._getMainPointsFromSegment(segment), this._getTrackerSettings(segment))
- },
- _updateTrackerElement: function(segment, element) {
- var settings = this._getTrackerSettings(segment);
- settings.points = this._getMainPointsFromSegment(segment);
- element.applySettings(settings)
- }
- });
- series.stepline = _extend({}, series.line, {
- _calculateStepLinePoints: function(points) {
- var segment = [];
- _each(points, function(i, pt) {
- var stepY;
- if (!i) {
- segment.push(pt);
- return
- }
- stepY = segment[segment.length - 1].y;
- if (stepY !== pt.y) {
- var point = utils.clone(pt);
- point.y = stepY;
- segment.push(point)
- }
- segment.push(pt)
- });
- return segment
- },
- _prepareSegment: function(points) {
- return series.line._prepareSegment(this._calculateStepLinePoints(points))
- }
- });
- series.stackedline = _extend({}, series.line, {});
- series.fullstackedline = _extend({}, series.line, {_getRangeData: function(zoomArgs, calcIntervalFunction) {
- var rangeCalculator = viz.core.series.helpers.rangeDataCalculator();
- rangeCalculator.calculateRangeData(this, zoomArgs, calcIntervalFunction);
- rangeCalculator.addLabelPaddings(this);
- rangeCalculator.processFullStackedRange(this);
- return this._rangeData
- }});
- series.spline = _extend({}, series.line, {
- _calculateBezierPoints: function(src, rotated) {
- var bezierPoints = [],
- pointsCopy = src;
- var checkExtr = function(otherPointCoord, pointCoord, controlCoord) {
- return otherPointCoord > pointCoord && controlCoord > otherPointCoord || otherPointCoord < pointCoord && controlCoord < otherPointCoord ? otherPointCoord : controlCoord
- };
- var clonePoint = function(point, newX, newY) {
- var p = utils.clone(point);
- p.x = newX;
- p.y = newY;
- return p
- };
- if (pointsCopy.length !== 1)
- _each(pointsCopy, function(i, curPoint) {
- var leftControlX,
- leftControlY,
- rightControlX,
- rightControlY,
- prevPoint,
- nextPoint,
- xCur,
- yCur,
- x1,
- x2,
- y1,
- y2,
- delta,
- lambda = 0.5,
- curIsExtremum,
- leftPoint,
- rightPoint,
- a,
- b,
- c,
- xc,
- yc,
- shift;
- if (!i) {
- bezierPoints.push(curPoint);
- bezierPoints.push(curPoint);
- return
- }
- prevPoint = pointsCopy[i - 1];
- if (i < pointsCopy.length - 1) {
- nextPoint = pointsCopy[i + 1];
- xCur = curPoint.x;
- yCur = curPoint.y;
- x1 = prevPoint.x;
- x2 = nextPoint.x;
- y1 = prevPoint.y;
- y2 = nextPoint.y;
- curIsExtremum = !!(!rotated && (yCur <= prevPoint.y && yCur <= nextPoint.y || yCur >= prevPoint.y && yCur >= nextPoint.y) || rotated && (xCur <= prevPoint.x && xCur <= nextPoint.x || xCur >= prevPoint.x && xCur >= nextPoint.x));
- if (curIsExtremum)
- if (!rotated) {
- rightControlY = leftControlY = yCur;
- rightControlX = (xCur + nextPoint.x) / 2;
- leftControlX = (xCur + prevPoint.x) / 2
- }
- else {
- rightControlX = leftControlX = xCur;
- rightControlY = (yCur + nextPoint.y) / 2;
- leftControlY = (yCur + prevPoint.y) / 2
- }
- else {
- a = y2 - y1;
- b = x1 - x2;
- c = y1 * x2 - x1 * y2;
- if (!rotated) {
- xc = xCur;
- yc = -1 * (a * xc + c) / b;
- shift = yc - yCur || 0;
- y1 -= shift;
- y2 -= shift
- }
- else {
- yc = yCur;
- xc = -1 * (b * yc + c) / a;
- shift = xc - xCur || 0;
- x1 -= shift;
- x2 -= shift
- }
- rightControlX = (xCur + lambda * x2) / (1 + lambda);
- rightControlY = (yCur + lambda * y2) / (1 + lambda);
- leftControlX = (xCur + lambda * x1) / (1 + lambda);
- leftControlY = (yCur + lambda * y1) / (1 + lambda)
- }
- if (!rotated) {
- leftControlY = checkExtr(prevPoint.y, yCur, leftControlY);
- rightControlY = checkExtr(nextPoint.y, yCur, rightControlY)
- }
- else {
- leftControlX = checkExtr(prevPoint.x, xCur, leftControlX);
- rightControlX = checkExtr(nextPoint.x, xCur, rightControlX)
- }
- leftPoint = clonePoint(curPoint, leftControlX, leftControlY);
- rightPoint = clonePoint(curPoint, rightControlX, rightControlY);
- bezierPoints.push(leftPoint, curPoint, rightPoint)
- }
- else {
- bezierPoints.push(curPoint, curPoint);
- return
- }
- });
- else
- bezierPoints.push(pointsCopy[0]);
- return bezierPoints
- },
- _prepareSegment: function(points, rotated) {
- return series.line._prepareSegment(this._calculateBezierPoints(points, rotated))
- },
- _createMainElement: function(points, settings) {
- return this._renderer.createBezierPath(points, settings)
- }
- })
- })(jQuery, DevExpress);
- /*! Module viz-core, file areaSeries.js */
- (function($, DX) {
- var viz = DX.viz,
- utils = DX.utils,
- series = viz.core.series.mixins.chart,
- lineSeries = series.line,
- _map = $.map,
- _extend = $.extend,
- HOVER_COLOR_HIGHLIGHTING = 20;
- series.area = _extend({}, lineSeries, {
- _createBorderElement: lineSeries._createMainElement,
- _processSinglePointsAreaSegment: function(points, rotated) {
- if (points.length == 1) {
- var p = points[0],
- p1 = utils.clone(p),
- coord = rotated ? "y" : "x";
- p1[coord] += 1;
- return [p, p1]
- }
- return points
- },
- _prepareSegment: function(points, rotated) {
- var processedPoints = this._processSinglePointsAreaSegment(points, rotated);
- return {
- line: processedPoints,
- area: _map(processedPoints, function(pt) {
- return pt.getCoords()
- }).concat(_map(processedPoints.slice().reverse(), function(pt) {
- return pt.getCoords(true)
- })),
- singlePointSegment: processedPoints !== points
- }
- },
- _getSpecialColor: function(color) {
- return this._options._IE8 ? new DX.Color(color).highlight(HOVER_COLOR_HIGHLIGHTING) : color
- },
- _getRangeData: function(zoomArgs, calcIntervalFunction) {
- var rangeCalculator = viz.core.series.helpers.rangeDataCalculator();
- rangeCalculator.calculateRangeData(this, zoomArgs, calcIntervalFunction);
- rangeCalculator.addLabelPaddings(this);
- rangeCalculator.calculateRangeMinValue(this, zoomArgs);
- return this._rangeData
- },
- _getDefaultSegment: function(segment) {
- var defaultSegment = lineSeries._getDefaultSegment(segment);
- defaultSegment.area = defaultSegment.line.concat(defaultSegment.line.slice().reverse());
- return defaultSegment
- },
- _updateElement: function(element, segment, animate, animateParams, complete) {
- var lineParams = {points: segment.line},
- areaParams = {points: segment.area},
- borderElement = element.line;
- if (animate) {
- borderElement && borderElement.animate(lineParams, animateParams);
- element.area.animate(areaParams, animateParams, complete)
- }
- else {
- borderElement && borderElement.applySettings(lineParams);
- element.area.applySettings(areaParams)
- }
- },
- _removeElement: function(element) {
- element.line && element.line.remove();
- element.area.remove()
- },
- _drawElement: function(segment, group) {
- return {
- line: this._bordersGroup && this._createBorderElement(segment.line, {strokeWidth: this._styles.normal.border.strokeWidth}).append(this._bordersGroup),
- area: this._createMainElement(segment.area).append(this._elementsGroup)
- }
- },
- _applyStyle: function(style) {
- this._elementsGroup && this._elementsGroup.applySettings(style.elements);
- this._bordersGroup && this._bordersGroup.applySettings(style.border);
- $.each(this._graphics || [], function(_, graphic) {
- graphic.line && graphic.line.applySettings({strokeWidth: style.border.strokeWidth})
- })
- },
- _createPattern: function(color, hatching) {
- if (hatching && utils.isObject(hatching)) {
- var pattern = this._renderer.createPattern(color, hatching);
- this._patterns.push(pattern);
- return pattern.id
- }
- return color
- },
- _parseStyle: function(options, defaultColor, defaultBorderColor) {
- var borderOptions = options.border || {},
- borderStyle = lineSeries._parseLineOptions(borderOptions, defaultBorderColor);
- borderStyle.strokeWidth = borderOptions.visible ? borderStyle.strokeWidth : 0;
- return {
- border: borderStyle,
- elements: {
- stroke: "none",
- fill: this._createPattern(options.color || defaultColor, options.hatching),
- opacity: options.opacity
- }
- }
- },
- _areBordersVisible: function() {
- var options = this._options;
- return options.border.visible || options.hoverStyle.border.visible || options.selectionStyle.border.visible
- },
- _createMainElement: function(points, settings) {
- return this._renderer.createArea(points, settings)
- },
- _getTrackerSettings: function(segment) {
- return {strokeWidth: segment.singlePointSegment ? this._defaultTrackerWidth : 0}
- },
- _getMainPointsFromSegment: function(segment) {
- return segment.area
- }
- });
- series.steparea = _extend({}, series.area, {_prepareSegment: function(points, rotated) {
- points = series.area._processSinglePointsAreaSegment(points, rotated);
- return series.area._prepareSegment.call(this, series.stepline._calculateStepLinePoints(points))
- }});
- series.splinearea = _extend({}, series.area, {
- _areaPointsToSplineAreaPoints: function(areaPoints) {
- var lastFwPoint = areaPoints[areaPoints.length / 2 - 1],
- firstBwPoint = areaPoints[areaPoints.length / 2];
- areaPoints.splice(areaPoints.length / 2, 0, {
- x: lastFwPoint.x,
- y: lastFwPoint.y
- }, {
- x: firstBwPoint.x,
- y: firstBwPoint.y
- });
- if (lastFwPoint.defaultCoords)
- areaPoints[areaPoints.length / 2].defaultCoords = true;
- if (firstBwPoint.defaultCoords)
- areaPoints[areaPoints.length / 2 - 1].defaultCoords = true
- },
- _prepareSegment: function(points, rotated) {
- var areaSeries = series.area,
- processedPoints = areaSeries._processSinglePointsAreaSegment(points, rotated),
- areaSegment = areaSeries._prepareSegment.call(this, series.spline._calculateBezierPoints(processedPoints, rotated));
- this._areaPointsToSplineAreaPoints(areaSegment.area);
- areaSegment.singlePointSegment = processedPoints !== points;
- return areaSegment
- },
- _getDefaultSegment: function(segment) {
- var areaDefaultSegment = series.area._getDefaultSegment(segment);
- this._areaPointsToSplineAreaPoints(areaDefaultSegment.area);
- return areaDefaultSegment
- },
- _createMainElement: function(points, settings) {
- return this._renderer.createBezierArea(points, settings)
- },
- _createBorderElement: series.spline._createMainElement
- })
- })(jQuery, DevExpress);
- /*! Module viz-core, file barSeries.js */
- (function($, DX) {
- var viz = DX.viz,
- series = viz.core.series.mixins.chart,
- scatterSeries = series.scatter,
- areaSeries = series.area,
- _extend = $.extend,
- _each = $.each,
- DEFAULT_BAR_POINT_SIZE = 3;
- series.bar = _extend({}, scatterSeries, {
- _getSpecialColor: areaSeries._getSpecialColor,
- _createPattern: areaSeries._createPattern,
- _updateOptions: function(options) {
- this._stackName = "axis_" + (options.axis || "default") + "_stack_" + (options.stack || "default")
- },
- _getRangeData: function(zoomArgs, calcIntervalFunction) {
- var rangeData = areaSeries._getRangeData.apply(this, arguments);
- rangeData.arg.stick = false;
- return rangeData
- },
- _parsePointStyle: function(style, defaultColor, defaultBorderColor) {
- var color = this._createPattern(style.color || defaultColor, style.hatching),
- base = scatterSeries._parsePointStyle.call(this, style, color, defaultBorderColor);
- base.fill = color;
- base.dashStyle = style.border && style.border.dashStyle || "solid";
- delete base.r;
- return base
- },
- _applyMarkerClipRect: function(settings) {
- settings.clipId = null
- },
- _applyTrackersClippings: function() {
- this._markerTrackerGroup.applySettings({clipId: this._paneClipRectID})
- },
- _clearingAnimation: function(translators, drawComplete) {
- var that = this,
- settings;
- if (that._options.rotated)
- settings = {
- scale: {
- x: 0.001,
- y: 1
- },
- translate: {x: translators.x.translate("canvas_position_default")}
- };
- else
- settings = {
- scale: {
- x: 1,
- y: 0.001
- },
- translate: {y: translators.y.translate("canvas_position_default")}
- };
- that._labelsGroup && that._labelsGroup.animate({opacity: 0.001}, {
- duration: that._defaultDuration,
- partitionDuration: 0.5
- }, function() {
- that._markersGroup.animate(settings, {partitionDuration: 0.5}, function() {
- that._markersGroup.applySettings({
- scale: null,
- translateX: 0,
- translateY: 0
- });
- drawComplete()
- })
- })
- },
- _createGroups: function(animationEnabled, style, firstDrawing) {
- var settings = {};
- scatterSeries._createGroups.apply(this, arguments);
- if (animationEnabled && firstDrawing)
- if (!this._options.rotated)
- settings = {
- scale: {
- x: 1,
- y: 0.001
- },
- translateY: this.translators.y.translate("canvas_position_default")
- };
- else
- settings = {
- scale: {
- x: 0.001,
- y: 1
- },
- translateX: this.translators.x.translate("canvas_position_default")
- };
- else if (!animationEnabled)
- settings = {
- scale: {
- x: 1,
- y: 1
- },
- translateX: 0,
- translateY: 0
- };
- this._markersGroup.applySettings(settings)
- },
- _drawPoint: function(point, markersGroup, labelsGroup, animationEnabled, firstDrawing) {
- scatterSeries._drawPoint.call(this, point, markersGroup, labelsGroup, animationEnabled && !firstDrawing)
- },
- _getMainColor: function() {
- return this._options.mainSeriesColor
- },
- _createPointStyles: function(pointOptions) {
- var mainColor = pointOptions.color || this._getMainColor(),
- specialMainColor = this._getSpecialColor(mainColor);
- return {
- normal: this._parsePointStyle(pointOptions, mainColor, mainColor),
- hover: this._parsePointStyle(pointOptions.hoverStyle || {}, specialMainColor, mainColor),
- selection: this._parsePointStyle(pointOptions.selectionStyle || {}, specialMainColor, mainColor)
- }
- },
- _preparePointOptions: function(customOptions) {
- return customOptions ? _extend(true, {}, this._options, customOptions) : this._options
- },
- _animate: function(firstDrawing) {
- var that = this,
- labelAnimFunc = function() {
- that._labelsGroup && that._labelsGroup.animate({opacity: 1}, {duration: that._defaultDuration})
- },
- lastPointIndex;
- that._markersGroup.animate({
- scale: {
- x: 1,
- y: 1
- },
- translate: {
- y: 0,
- x: 0
- }
- }, undefined, labelAnimFunc);
- if (!firstDrawing) {
- lastPointIndex = that._drawedPoints.length - 1;
- _each(this._drawedPoints || [], function(i, point) {
- point.animate(i === lastPointIndex ? labelAnimFunc : undefined, {
- x: point.x,
- y: point.y,
- height: point.height,
- width: point.width
- })
- })
- }
- },
- _getPointSize: function() {
- return DEFAULT_BAR_POINT_SIZE
- }
- })
- })(jQuery, DevExpress);
- /*! Module viz-core, file rangeSeries.js */
- (function($, DX) {
- var viz = DX.viz,
- series = viz.core.series.mixins.chart,
- _extend = $.extend,
- _isDefined = DX.utils.isDefined,
- _map = $.map,
- rangeCalculator = viz.core.series.helpers.rangeDataCalculator(),
- areaSeries = series.area;
- var baseRangeSeries = {
- _checkData: function(data) {
- return _isDefined(data.argument) && data.value !== undefined && data.minValue !== undefined
- },
- updateTeamplateFieldNames: function() {
- var that = this,
- options = that._options,
- valueFields = that.getValueFields(),
- name = that.name;
- options.rangeValue1Field = valueFields[0] + name;
- options.rangeValue2Field = valueFields[1] + name;
- options.tagField = that.getTagField() + name
- },
- _processRange: function(point, prevPoint) {
- rangeCalculator.processTwoValues(this, point, prevPoint, "value", "minValue")
- },
- _getRangeData: function(zoomArgs, calcIntervalFunction) {
- rangeCalculator.calculateTwoValuesRangeData(this, zoomArgs, calcIntervalFunction, "value", "minValue");
- rangeCalculator.addRangeSeriesLabelPaddings(this);
- return this._rangeData
- },
- _getPointData: function(data, options) {
- var argumentField = options.argumentField || "arg",
- tagField = options.tagField || "tag",
- rangeValue1Field = options.rangeValue1Field || "val1",
- rangeValue2Field = options.rangeValue2Field || "val2";
- return {
- tag: data[tagField],
- minValue: data[rangeValue1Field],
- value: data[rangeValue2Field],
- argument: data[argumentField]
- }
- },
- _fusionPoints: function(fusionPoints, tick, index) {
- var scatterSeries = series.scatter,
- value = scatterSeries._calcMedianValue.call(this, fusionPoints, "value"),
- minValue = scatterSeries._calcMedianValue.call(this, fusionPoints, "minValue"),
- pointData;
- if (value === null || minValue === null)
- value = minValue = null;
- pointData = {
- minValue: minValue,
- value: value,
- argument: tick,
- tag: null
- };
- return pointData
- },
- getValueFields: function() {
- return [this._options.rangeValue1Field || "val1", this._options.rangeValue2Field || "val2"]
- }
- };
- series.rangebar = _extend({}, series.bar, baseRangeSeries);
- series.rangearea = _extend({}, areaSeries, {
- _drawPoint: function(point, markersGroup, labelsGroup, animationEnabled) {
- if (point.isInVisibleArea()) {
- point.clearVisibility();
- point.draw(this._renderer, markersGroup, labelsGroup, animationEnabled);
- this._drawedPoints.push(point);
- if (!point.visibleTopMarker)
- point.hideMarker("top");
- if (!point.visibleBottomMarker)
- point.hideMarker("bottom")
- }
- else
- point.setInvisibility()
- },
- _prepareSegment: function(points, rotated) {
- var processedPoints = this._processSinglePointsAreaSegment(points, rotated),
- processedMinPointsCoords = $.map(processedPoints, function(pt) {
- return pt.getCoords(true)
- });
- return {
- line: processedPoints,
- bottomLine: processedMinPointsCoords,
- area: $.map(processedPoints, function(pt) {
- return pt.getCoords()
- }).concat(processedMinPointsCoords.slice().reverse()),
- singlePointSegment: processedPoints !== points
- }
- },
- _getDefaultSegment: function(segment) {
- var defaultSegment = areaSeries._getDefaultSegment.call(this, segment);
- defaultSegment.bottomLine = defaultSegment.line;
- return defaultSegment
- },
- _removeElement: function(element) {
- areaSeries._removeElement.call(this, element);
- element.bottomLine && element.bottomLine.remove()
- },
- _drawElement: function(segment, group) {
- var drawnElement = areaSeries._drawElement.call(this, segment, group);
- drawnElement.bottomLine = this._bordersGroup && this._createBorderElement(segment.bottomLine, {strokeWidth: this._styles.normal.border.strokeWidth}).append(this._bordersGroup);
- return drawnElement
- },
- _applyStyle: function(style) {
- this._elementsGroup && this._elementsGroup.applySettings(style.elements);
- this._bordersGroup && this._bordersGroup.applySettings(style.border);
- $.each(this._graphics || [], function(_, graphic) {
- graphic.line && graphic.line.applySettings({strokeWidth: style.border.strokeWidth});
- graphic.bottomLine && graphic.bottomLine.applySettings({strokeWidth: style.border.strokeWidth})
- })
- },
- _updateElement: function(element, segment, animate, animateParams, complete) {
- areaSeries._updateElement.call(this, element, segment, animate, animateParams, complete);
- var bottomLineParams = {points: segment.bottomLine},
- bottomBorderElement = element.bottomLine;
- if (bottomBorderElement)
- animate ? bottomBorderElement.animate(bottomLineParams, animateParams) : bottomBorderElement.applySettings(bottomLineParams)
- }
- }, baseRangeSeries)
- })(jQuery, DevExpress);
- /*! Module viz-core, file bubbleSeries.js */
- (function($, DX) {
- var viz = DX.viz,
- series = viz.core.series.mixins.chart,
- scatterSeries = series.scatter,
- barSeries = series.bar,
- _isDefined = DX.utils.isDefined,
- _extend = $.extend,
- _each = $.each;
- series.bubble = _extend({}, scatterSeries, {
- _applyTrackersClippings: barSeries._applyTrackersClippings,
- _getMainColor: barSeries._getMainColor,
- _createPointStyles: barSeries._createPointStyles,
- _createPattern: barSeries._createPattern,
- _preparePointOptions: barSeries._preparePointOptions,
- _getSpecialColor: barSeries._getSpecialColor,
- _applyMarkerClipRect: series.line._applyElementsClipRect,
- _parsePointStyle: function(style, defaultColor, defaultBorderColor) {
- var base = barSeries._parsePointStyle.call(this, style, defaultColor, defaultBorderColor);
- base.opacity = style.opacity;
- return base
- },
- _createMarkerGroup: function() {
- var markersSettings = this._getPointOptions().styles.normal,
- groupSettings;
- markersSettings["class"] = "dxc-markers";
- this._applyMarkerClipRect(markersSettings);
- groupSettings = _extend({}, markersSettings);
- delete groupSettings.opacity;
- this._createGroup("_markersGroup", this, this._group, groupSettings)
- },
- _getCreatingPointOptions: function() {
- if (!this._predefinedPointOptions) {
- var styles,
- defaultPointOptions = this._getPointOptions(),
- strokeWidth = defaultPointOptions.styles && defaultPointOptions.styles.normal && defaultPointOptions.styles.normal.strokeWidth,
- r = defaultPointOptions.styles && defaultPointOptions.styles.normal && defaultPointOptions.styles.normal.r,
- opacity = defaultPointOptions.styles && defaultPointOptions.styles.normal && defaultPointOptions.styles.normal.opacity,
- creatingPointOptions = _extend(true, {}, defaultPointOptions);
- creatingPointOptions.styles = styles = creatingPointOptions.styles || {};
- styles.normal = {
- strokeWidth: strokeWidth,
- r: r,
- opacity: opacity
- };
- this._predefinedPointOptions = creatingPointOptions
- }
- return this._predefinedPointOptions
- },
- _checkData: function(data) {
- return _isDefined(data.argument) && _isDefined(data.size) && data.value !== undefined
- },
- _getPointData: function(data, options) {
- var pointData = scatterSeries._getPointData.call(this, data, options),
- sizeField = options.sizeField || "size";
- pointData.size = data[sizeField];
- return pointData
- },
- _fusionPoints: function(fusionPoints, tick, index) {
- var medianValue = scatterSeries._calcMedianValue.call(this, fusionPoints, "value"),
- medianSize = scatterSeries._calcMedianValue.call(this, fusionPoints, "size");
- return {
- size: medianSize,
- value: medianValue,
- argument: tick,
- tag: null
- }
- },
- getValueFields: function() {
- return [this._options.valueField || "val", this._options.sizeField || "size"]
- },
- updateTeamplateFieldNames: function() {
- var that = this,
- options = that._options,
- valueFields = that.getValueFields(),
- name = that.name;
- options.valueField = valueFields[0] + name;
- options.sizeField = valueFields[1] + name;
- options.tagField = that.getTagField() + name
- },
- _clearingAnimation: function(translators, drawComplete) {
- var that = this,
- settings = {r: 0},
- partitionDuration = 0.5,
- lastPointIndex = that._drawedPoints.length - 1;
- that._labelsGroup && that._labelsGroup.animate({opacity: 0.001}, {
- duration: that._defaultDuration,
- partitionDuration: partitionDuration
- }, function() {
- _each(that._drawedPoints || [], function(i, p) {
- p.animate(i === lastPointIndex ? drawComplete : undefined, settings, partitionDuration)
- })
- })
- },
- _animate: function(firstDrawing) {
- var that = this,
- lastPointIndex = that._drawedPoints.length - 1,
- labelAnimFunc = function() {
- that._labelsGroup && that._labelsGroup.animate({opacity: 1}, {duration: that._defaultDuration})
- };
- _each(that._drawedPoints || [], function(i, p) {
- p.animate(i === lastPointIndex ? labelAnimFunc : undefined, {
- r: p.bubbleSize,
- translate: {
- x: p.x,
- y: p.y
- }
- })
- })
- }
- })
- })(jQuery, DevExpress);
- /*! Module viz-core, file pieSeries.js */
- (function($, DX) {
- var viz = DX.viz,
- mixins = viz.core.series.mixins,
- pieSeries = mixins.pieChart,
- utils = DX.utils,
- scatterSeries = mixins.chart.scatter,
- barSeries = mixins.chart.bar,
- _extend = $.extend,
- _each = $.each,
- _noop = $.noop,
- _map = $.map,
- _isFinite = isFinite,
- _max = Math.max;
- pieSeries.pie = _extend({}, barSeries, {
- _createLabelGroup: scatterSeries._createLabelGroup,
- _createGroups: scatterSeries._createGroups,
- _drawPoint: function(point) {
- scatterSeries._drawPoint.apply(this, arguments);
- !point.isVisible() && point.setInvisibility()
- },
- _applyTrackersClippings: _noop,
- _processRange: _noop,
- _applyElementsClipRect: _noop,
- _updateDataType: _noop,
- getColor: _noop,
- _prepareSeriesToDrawing: _noop,
- _endUpdateData: scatterSeries._prepareSeriesToDrawing,
- resetLabelEllipsis: function() {
- _each(this._points || [], function(_, point) {
- point._label.setLabelEllipsis = false
- })
- },
- _adjustLabels: function(firstDrawing) {
- var that = this,
- options = that._options,
- canvas = that.canvas,
- points = that._points || [],
- labelsBBoxes = [],
- labelsSpaces = [],
- labelSpace = 0,
- maxLabelLength,
- paneSpaceHeight,
- paneSpaceWidth,
- min;
- if (options.label.position !== "inside") {
- _each(points, function(_, point) {
- if (point._label.hasText())
- labelsBBoxes.push(point._label.getTextCoords().width)
- });
- if (labelsBBoxes.length) {
- maxLabelLength = _max.apply(null, labelsBBoxes);
- _each(points, function(_, point) {
- if (point._label.hasText()) {
- point._label.updatePosition(maxLabelLength);
- point._label.setLabelEllipsis = true
- }
- });
- that._firstDrawing = !that.redraw && firstDrawing;
- that.redraw = true
- }
- }
- else
- _each(points, function(i, point) {
- if (point._label.hasText()) {
- point._label.setLabelEllipsis = true;
- point._label.updatePosition()
- }
- })
- },
- _getCreatingPointOptions: function() {
- return this._getPointOptions()
- },
- _updateOptions: function(options) {
- this.labelSpace = 0;
- this.innerRadius = this.type === "pie" ? 0 : options.innerRadius;
- this.redraw = false
- },
- _checkData: function(data) {
- var base = barSeries._checkData(data);
- return this._options.paintNullPoints ? base : base && data.value !== null
- },
- _createMarkerGroup: function() {
- if (!this._markersGroup)
- this._markersGroup = this._renderer.createGroup({"class": "dxc-markers"}).append(this._group)
- },
- _getMainColor: function() {
- return this._options.mainSeriesColor()
- },
- _getPointOptions: function() {
- return this._parsePointOptions(this._preparePointOptions(), this._options.label)
- },
- _getRangeData: function() {
- return this._rangeData
- },
- _getArrangeTotal: function(points) {
- var total = 0;
- _each(points, function(_, point) {
- if (point.isVisible())
- total += point.initialValue
- });
- return total
- },
- _createPointStyles: function(pointOptions) {
- var mainColor = pointOptions.color || this._getMainColor(),
- specialMainColor = this._getSpecialColor(mainColor);
- return {
- normal: this._parsePointStyle(pointOptions, mainColor, mainColor),
- hover: this._parsePointStyle(pointOptions.hoverStyle, specialMainColor, mainColor),
- selection: this._parsePointStyle(pointOptions.selectionStyle, specialMainColor, mainColor),
- legendStyles: {
- normal: this._createLegendState(pointOptions, mainColor),
- hover: this._createLegendState(pointOptions.hoverStyle, specialMainColor),
- selection: this._createLegendState(pointOptions.selectionStyle, specialMainColor)
- }
- }
- },
- _getArrangeMinShownValue: function(points, total) {
- var minSegmentSize = this._options.minSegmentSize,
- totalMinSegmentSize = 0,
- totalNotMinValues = 0;
- total = total || points.length;
- _each(points, function(_, point) {
- if (point.isVisible())
- if (point.initialValue < minSegmentSize * total / 360)
- totalMinSegmentSize += minSegmentSize;
- else
- totalNotMinValues += point.initialValue
- });
- return totalMinSegmentSize < 360 ? minSegmentSize * totalNotMinValues / (360 - totalMinSegmentSize) : 0
- },
- _applyArrangeCorrection: function(points, minShownValue, total) {
- var options = this._options,
- isClockWise = options.segmentsDirection !== "anticlockwise",
- shiftedAngle = _isFinite(options.startAngle) ? utils.normalizeAngle(options.startAngle) : 0,
- minSegmentSize = options.minSegmentSize,
- percent,
- correction = 0,
- zeroTotalCorrection = 0;
- if (total === 0) {
- total = points.length;
- zeroTotalCorrection = 1
- }
- _each(isClockWise ? points : points.concat([]).reverse(), function(_, point) {
- var val = point.isVisible() ? zeroTotalCorrection || point.initialValue : 0,
- updatedZeroValue;
- if (minSegmentSize && point.isVisible() && val < minShownValue)
- updatedZeroValue = minShownValue;
- percent = val / total;
- point.correctValue(correction, percent, zeroTotalCorrection + (updatedZeroValue || 0));
- point.shiftedAngle = shiftedAngle;
- correction = correction + (updatedZeroValue || val)
- });
- this._rangeData = {val: {
- min: 0,
- max: correction
- }}
- },
- arrangePoints: function() {
- var that = this,
- minSegmentSize = that._options.minSegmentSize,
- minShownValue,
- pointIndex = 0,
- total,
- points = that._originalPoints = that._points = _map(that._originalPoints || [], function(point) {
- if (point.value === null || point.value < 0 || point.value === 0 && !minSegmentSize) {
- point.dispose();
- return null
- }
- else {
- point.index = pointIndex++;
- return point
- }
- });
- total = that._getArrangeTotal(points);
- if (minSegmentSize)
- minShownValue = this._getArrangeMinShownValue(points, total);
- that._applyArrangeCorrection(points, minShownValue, total)
- },
- correctPosition: function(correction) {
- var debug = DX.utils.debug;
- debug.assert(correction, "correction was not passed");
- debug.assertParam(correction.centerX, "correction.centerX was not passed");
- debug.assertParam(correction.centerY, "correction.centerY was not passed");
- debug.assertParam(correction.radiusInner, "correction.radiusInner was not passed");
- debug.assertParam(correction.radiusOuter, "correction.radiusOuter was not passed");
- _each(this._points, function(_, point) {
- point.correctPosition(correction)
- })
- },
- _animate: function(firstDrawing) {
- var that = this,
- index = 0,
- timeThreshold = 0.2,
- points = that._points,
- pointsCount = points && points.length,
- duration = 1 / (timeThreshold * (pointsCount - 1) + 1),
- animateP = function() {
- points[index] && points[index++].animate(index === pointsCount ? completeFunc : undefined, duration, stepFunc)
- },
- stepFunc = function(_, progress) {
- if (progress >= timeThreshold) {
- this.step = null;
- animateP()
- }
- },
- completeFunc = function() {
- that._labelsGroup && that._labelsGroup.animate({opacity: 1}, {duration: 400})
- };
- if (firstDrawing)
- animateP();
- else
- $.each(points, function(i, p) {
- p.animate(i == pointsCount - 1 ? completeFunc : undefined)
- })
- },
- getVisiblePoints: function() {
- return _map(this._points, function(p) {
- return p.isVisible() ? p : null
- })
- },
- _beginUpdateData: function() {
- this._deletePatterns();
- this._patterns = []
- }
- });
- pieSeries.doughnut = pieSeries.donut = pieSeries.pie
- })(jQuery, DevExpress);
- /*! Module viz-core, file financialSeries.js */
- (function($, DX) {
- var viz = DX.viz,
- series = viz.core.series.mixins.chart,
- scatterSeries = series.scatter,
- barSeries = series.bar,
- rangeCalculator = viz.core.series.helpers.rangeDataCalculator(),
- _isDefined = DX.utils.isDefined,
- _extend = $.extend,
- _each = $.each,
- _noop = $.noop,
- DEFAULT_FINANCIAL_POINT_SIZE = 10;
- series.stock = _extend({}, scatterSeries, {
- _animate: _noop,
- _applyMarkerClipRect: series.line._applyElementsClipRect,
- _applyTrackersClippings: barSeries._applyTrackersClippings,
- _createPattern: barSeries._createPattern,
- _preparePointOptions: barSeries._preparePointOptions,
- _createMarkerGroup: function() {
- var that = this,
- markersGroup,
- styles = that._getPointOptions().styles,
- defaultStyle = styles.normal,
- defaultPositiveStyle = styles.positive.normal,
- reductionStyle = styles.reduction.normal,
- reductionPositiveStyle = styles.reductionPositive.normal,
- markerSettings = {"class": "dxc-markers"};
- that._applyMarkerClipRect(markerSettings);
- defaultStyle["class"] = "default-markers";
- defaultPositiveStyle["class"] = "default-positive-markers";
- reductionStyle["class"] = "reduction-markers";
- reductionPositiveStyle["class"] = "reduction-positive-markers";
- that._createGroup("_markersGroup", that, that._group, markerSettings);
- markersGroup = that._markersGroup;
- that._createGroup("defaultMarkersGroup", markersGroup, markersGroup, defaultStyle);
- that._createGroup("reductionMarkersGroup", markersGroup, markersGroup, reductionStyle);
- that._createGroup("defaultPositiveMarkersGroup", markersGroup, markersGroup, defaultPositiveStyle);
- that._createGroup("reductionPositiveMarkersGroup", markersGroup, markersGroup, reductionPositiveStyle)
- },
- _createGroups: function() {
- scatterSeries._createGroups.call(this, false)
- },
- _clearingAnimation: function(translators, drawComplete) {
- drawComplete()
- },
- _getCreatingPointOptions: function() {
- if (!this._predefinedPointOptions) {
- var styles,
- defaultPointOptions = this._getPointOptions(),
- strokeWidth = defaultPointOptions.styles && defaultPointOptions.styles.normal && defaultPointOptions.styles.normal.strokeWidth,
- creatingPointOptions = _extend(true, {}, defaultPointOptions);
- creatingPointOptions.styles = styles = creatingPointOptions.styles || {};
- styles.normal = styles.positive.normal = styles.reduction.normal = styles.reductionPositive.normal = {strokeWidth: strokeWidth};
- this._predefinedPointOptions = creatingPointOptions
- }
- return this._predefinedPointOptions
- },
- _checkData: function(data) {
- return _isDefined(data.argument) && data.highValue !== undefined && data.lowValue !== undefined && data.openValue !== undefined && data.closeValue !== undefined
- },
- _processRange: function(point, prevPoint) {
- rangeCalculator.processTwoValues(this, point, prevPoint, "highValue", "lowValue")
- },
- _getRangeData: function(zoomArgs, calcIntervalFunction) {
- rangeCalculator.calculateTwoValuesRangeData(this, zoomArgs, calcIntervalFunction, "highValue", "lowValue");
- rangeCalculator.addRangeSeriesLabelPaddings(this);
- return this._rangeData
- },
- _getPointData: function(data, options) {
- var that = this,
- level,
- argumentField = options.argumentField || "date",
- tagField = options.tagField || "tag",
- openValueField = options.openValueField || "open",
- closeValueField = options.closeValueField || "close",
- highValueField = options.highValueField || "high",
- lowValueField = options.lowValueField || "low",
- reductionValue;
- that.level = options.reduction.level;
- switch ((that.level || "").toLowerCase()) {
- case"open":
- level = openValueField;
- break;
- case"high":
- level = highValueField;
- break;
- case"low":
- level = lowValueField;
- break;
- default:
- level = closeValueField;
- that.level = "close";
- break
- }
- reductionValue = data[level];
- return {
- argument: data[argumentField],
- highValue: data[highValueField],
- lowValue: data[lowValueField],
- closeValue: data[closeValueField],
- openValue: data[openValueField],
- reductionValue: reductionValue,
- tag: data[tagField],
- isReduction: this._checkReduction(reductionValue)
- }
- },
- _parsePointStyle: function(style, defaultColor, innerColor) {
- return {
- stroke: style.color || defaultColor,
- strokeWidth: style.width,
- fill: style.color || innerColor
- }
- },
- updateTeamplateFieldNames: function() {
- var that = this,
- options = that._options,
- valueFields = that.getValueFields(),
- name = that.name;
- options.openValueField = valueFields[0] + name;
- options.highValueField = valueFields[1] + name;
- options.lowValueField = valueFields[2] + name;
- options.closeValueField = valueFields[3] + name;
- options.tagField = that.getTagField() + name
- },
- _getDefaultStyle: function(options) {
- var mainPointColor = options.color || this._options.mainSeriesColor;
- return {
- normal: this._parsePointStyle(options, mainPointColor, mainPointColor),
- hover: this._parsePointStyle(options.hoverStyle, mainPointColor, mainPointColor),
- selection: this._parsePointStyle(options.selectionStyle, mainPointColor, mainPointColor)
- }
- },
- _getReductionStyle: function(options) {
- var reductionColor = options.reduction.color,
- normalStyle = this._parsePointStyle({
- color: reductionColor,
- width: options.width,
- hatching: options.hatching
- }, reductionColor, reductionColor);
- return {
- normal: normalStyle,
- hover: this._parsePointStyle(options.hoverStyle, reductionColor, reductionColor),
- selection: this._parsePointStyle(options.selectionStyle, reductionColor, reductionColor)
- }
- },
- _createPointStyles: function(pointOptions) {
- var that = this,
- innerColor = that._options.innerColor,
- styles = that._getDefaultStyle(pointOptions),
- positiveStyle,
- reductionStyle,
- reductionPositiveStyle;
- positiveStyle = _extend(true, {}, styles);
- reductionStyle = that._getReductionStyle(pointOptions);
- reductionPositiveStyle = _extend(true, {}, reductionStyle);
- positiveStyle.normal.fill = positiveStyle.hover.fill = positiveStyle.selection.fill = innerColor;
- reductionPositiveStyle.normal.fill = reductionPositiveStyle.hover.fill = reductionPositiveStyle.selection.fill = innerColor;
- styles.positive = positiveStyle;
- styles.reduction = reductionStyle;
- styles.reductionPositive = reductionPositiveStyle;
- return styles
- },
- _endUpdateData: function() {
- delete this.prevLevelValue;
- delete this._predefinedPointOptions
- },
- _checkReduction: function(value) {
- var result = false;
- if (value != null) {
- if (_isDefined(this.prevLevelValue))
- result = value < this.prevLevelValue;
- this.prevLevelValue = value
- }
- return result
- },
- _fusionPoints: function(fusionPoints, tick, nowIndexTicks) {
- var fusedPointData = {},
- reductionLevel,
- highValue = -Infinity,
- lowValue = +Infinity,
- openValue,
- closeValue;
- if (!fusionPoints.length)
- return {};
- _each(fusionPoints, function(_, point) {
- if (!point.hasValue())
- return;
- highValue = Math.max(highValue, point.highValue);
- lowValue = Math.min(lowValue, point.lowValue);
- openValue = openValue !== undefined ? openValue : point.openValue;
- closeValue = point.closeValue !== undefined ? point.closeValue : closeValue
- });
- fusedPointData.argument = tick;
- fusedPointData.openValue = openValue;
- fusedPointData.closeValue = closeValue;
- fusedPointData.highValue = highValue;
- fusedPointData.lowValue = lowValue;
- fusedPointData.tag = null;
- switch ((this.level || "").toLowerCase()) {
- case"open":
- reductionLevel = openValue;
- break;
- case"high":
- reductionLevel = highValue;
- break;
- case"low":
- reductionLevel = lowValue;
- break;
- default:
- reductionLevel = closeValue;
- break
- }
- fusedPointData.reductionValue = reductionLevel;
- fusedPointData.isReduction = this._checkReduction(reductionLevel);
- return fusedPointData
- },
- _getPointSize: function() {
- return DEFAULT_FINANCIAL_POINT_SIZE
- },
- getValueFields: function() {
- var options = this._options;
- return [options.openValueField || "open", options.highValueField || "high", options.lowValueField || "low", options.closeValueField || "close"]
- },
- getArgumentField: function() {
- return this._options.argumentField || "date"
- }
- });
- series.candlestick = _extend({}, series.stock, {_parsePointStyle: function(style, defaultColor, innerColor) {
- var color = this._createPattern(style.color || innerColor, style.hatching),
- base = series.stock._parsePointStyle.call(this, style, defaultColor, color);
- base.fill = color;
- return base
- }})
- })(jQuery, DevExpress);
- /*! Module viz-core, file stackedSeries.js */
- (function($, DX) {
- var viz = DX.viz,
- series = viz.core.series.mixins.chart,
- areaSeries = series.area,
- barSeries = series.bar,
- lineSeries = series.line,
- rangeCalculator = viz.core.series.helpers.rangeDataCalculator(),
- _extend = $.extend,
- _noop = $.noop,
- baseStackedSeries = {
- _processRange: _noop,
- _processStackedRange: function() {
- var that = this,
- prevPoint;
- $.each(that.getAllPoints(), function(i, p) {
- rangeCalculator.processRange(that, p, prevPoint);
- prevPoint = p
- })
- },
- _getRangeData: function() {
- this._processStackedRange();
- return areaSeries._getRangeData.apply(this, arguments)
- }
- },
- baseFullStackedSeries = _extend({}, baseStackedSeries, {
- _getRangeData: function(zoomArgs, calcIntervalFunction) {
- this._processStackedRange();
- rangeCalculator.calculateRangeData(this, zoomArgs, calcIntervalFunction);
- rangeCalculator.addLabelPaddings(this);
- rangeCalculator.processFullStackedRange(this);
- rangeCalculator.calculateRangeMinValue(this, zoomArgs);
- return this._rangeData
- },
- isFullStackedSeries: function() {
- return true
- }
- });
- series.stackedline = _extend({}, lineSeries, baseStackedSeries, {_getRangeData: function() {
- this._processStackedRange();
- return lineSeries._getRangeData.apply(this, arguments)
- }});
- series.fullstackedline = _extend({}, lineSeries, baseFullStackedSeries, {_getRangeData: function(zoomArgs, calcIntervalFunction) {
- this._processStackedRange();
- var rangeCalculator = viz.core.series.helpers.rangeDataCalculator();
- rangeCalculator.calculateRangeData(this, zoomArgs, calcIntervalFunction);
- rangeCalculator.addLabelPaddings(this);
- rangeCalculator.processFullStackedRange(this);
- return this._rangeData
- }});
- series.stackedbar = _extend({}, barSeries, baseStackedSeries, {_getRangeData: function() {
- this._processStackedRange();
- return barSeries._getRangeData.apply(this, arguments)
- }});
- series.fullstackedbar = _extend({}, barSeries, baseFullStackedSeries, {_getRangeData: function(zoomArgs, calcIntervalFunction) {
- var rangeData = baseFullStackedSeries._getRangeData.apply(this, arguments);
- rangeData.arg.stick = false;
- return rangeData
- }});
- series.stackedarea = _extend({}, areaSeries, baseStackedSeries);
- series.fullstackedarea = _extend({}, areaSeries, baseFullStackedSeries)
- })(jQuery, DevExpress);
- /*! Module viz-core, file basePoint.js */
- (function($, DX) {
- var viz = DX.viz,
- statesConsts = viz.core.series.helpers.consts.states,
- _each = $.each,
- _extend = $.extend,
- _isDefined = DX.utils.isDefined,
- _noop = $.noop,
- pointTypes = {
- scatter: "symbolPoint",
- line: "symbolPoint",
- spline: "symbolPoint",
- stepline: "symbolPoint",
- stackedline: "symbolPoint",
- fullstackedline: "symbolPoint",
- area: "symbolPoint",
- splinearea: "symbolPoint",
- steparea: "symbolPoint",
- stackedarea: "symbolPoint",
- fullstackedarea: "symbolPoint",
- rangearea: "rangeSymbolPoint",
- bar: "barPoint",
- stackedbar: "barPoint",
- fullstackedbar: "barPoint",
- rangebar: "rangeBarPoint",
- bubble: "bubblePoint",
- pie: "piePoint",
- doughnut: "piePoint",
- donut: "piePoint",
- stock: "stockPoint",
- candlestick: "candlestickPoint"
- };
- viz.core.series.points = {};
- viz.core.series.points.Point = DX.Class.inherit({
- ctor: function(dataItem, options) {
- this.update(dataItem, options);
- this._emptySettings = {
- fill: null,
- stroke: null,
- dashStyle: null
- }
- },
- getColor: function() {
- return this._styles.normal.fill || this.series.getColor()
- },
- _getStyle: function() {
- var styles = this._styles,
- style;
- if (this.isSelected())
- style = styles.selection;
- else if (this.isHovered())
- style = styles.hover;
- else {
- this.fullState = statesConsts.normalMark;
- style = styles.normal
- }
- return style
- },
- update: function(dataItem, options) {
- this.updateOptions(options);
- this.updateData(dataItem)
- },
- updateData: function(dataItem) {
- this._updateData(dataItem);
- if (!this.hasValue())
- this.setInvisibility();
- else {
- this._updateLabelData();
- this._fillStyle()
- }
- },
- deleteMarker: function() {
- this.graphic && this.graphic.detach();
- this.graphic = null
- },
- deleteTrackerMarker: function() {
- this.trackerGraphic && this.trackerGraphic.remove();
- this.trackerGraphic = null
- },
- draw: function(renderer, markersGroup, labelsGroup, animationEnabled, firstDrawing) {
- if (this._needDeletingOnDraw) {
- this.deleteMarker();
- this.deleteTrackerMarker();
- this._needDeletingOnDraw = false
- }
- if (this._needClearingOnDraw) {
- this.clearMarker();
- this._needClearingOnDraw = false
- }
- if (!this._hasGraphic())
- this._options.visible && this._drawMarker(renderer, markersGroup, animationEnabled, firstDrawing);
- else
- this._updateMarker(animationEnabled, undefined, markersGroup);
- this._drawLabel(renderer, labelsGroup)
- },
- applyStyle: function(style) {
- if (this.graphic) {
- if (style === "normal")
- this.clearMarker();
- else
- this.graphic.toForeground();
- this._updateMarker(true, this._styles[style])
- }
- },
- setHoverState: function() {
- this.series.setPointHoverState(this)
- },
- releaseHoverState: function(callback) {
- this.series.releasePointHoverState(this, callback);
- if (this.graphic)
- !this.isSelected() && this.graphic.toBackground()
- },
- setSelectedState: function() {
- this.series.setPointSelectedState(this)
- },
- releaseSelectedState: function() {
- this.series.releasePointSelectedState(this)
- },
- select: function() {
- this.series.selectPoint(this)
- },
- clearSelection: function() {
- this.series.deselectPoint(this)
- },
- showTooltip: function() {
- this.series.showPointTooltip(this)
- },
- hideTooltip: function() {
- this.series.hidePointTooltip(this)
- },
- _checkLabelsChanging: function(oldType, newType) {
- if (oldType) {
- var isNewRange = ~newType.indexOf("range"),
- isOldRange = ~oldType.indexOf("range");
- return isOldRange && !isNewRange || !isOldRange && isNewRange
- }
- else
- return false
- },
- updateOptions: function(newOptions) {
- if (!_isDefined(newOptions))
- return;
- var that = this,
- oldOptions = that._options,
- oldType = oldOptions && oldOptions.type,
- newType = newOptions.type;
- if (pointTypes[oldType] !== pointTypes[newType]) {
- that._needDeletingOnDraw = true;
- that._needClearingOnDraw = false;
- that._checkLabelsChanging(oldType, newType) && that.deleteLabel();
- that._resetType(oldType);
- that._setType(newType)
- }
- else {
- that._needDeletingOnDraw = that._checkSymbol(oldOptions, newOptions);
- that._needClearingOnDraw = that._checkCustomize(oldOptions, newOptions)
- }
- that.series = newOptions.series;
- that._options = newOptions;
- that._fillStyle();
- that._updateLabelOptions(pointTypes[newType])
- },
- translate: function(translators) {
- this.translators = translators || this.translators;
- this.translators && this.hasValue() && this._translate(this.translators)
- },
- drawTracker: function(renderer, group) {
- if (!this.trackerGraphic)
- this._drawTrackerMarker(renderer, group);
- else
- this._updateTracker()
- },
- _checkCustomize: function(oldOptions, newOptions) {
- return oldOptions.styles.usePointCustomOptions && !newOptions.styles.usePointCustomOptions
- },
- _getCustomLabelVisibility: function() {
- if (this._styles.useLabelCustomOptions)
- return this._options.label.visible ? "visible" : "hidden"
- },
- _getGraphicSettings: function() {
- return {
- x: this.graphic.settings.x || 0,
- y: this.graphic.settings.y || 0,
- height: this.graphic.settings.height || 0,
- width: this.graphic.settings.width || 0
- }
- },
- _resetType: function(type) {
- var that = this;
- if (type)
- _each(viz.core.series.points.mixins[pointTypes[type]], function(methodName) {
- delete that[methodName]
- })
- },
- _setType: function(type) {
- var that = this;
- _each(viz.core.series.points.mixins[pointTypes[type]], function(methodName, method) {
- that[methodName] = method
- })
- },
- _prepareStatesOptions: function() {
- var that = this;
- if (that._options.states && that._options.states.normal)
- that._populatePointShape(that._options.states.normal.r)
- },
- isInVisibleArea: function() {
- return this.inVisibleArea
- },
- isSelected: function() {
- return !!(this.fullState & statesConsts.selectedMark)
- },
- isHovered: function() {
- return !!(this.fullState & statesConsts.hoverMark)
- },
- getOptions: function() {
- return this._options
- },
- animate: function(complete, settings, partitionDuration) {
- if (!this.graphic) {
- complete && complete();
- return
- }
- this.graphic.animate(settings, {partitionDuration: partitionDuration}, complete)
- },
- getCoords: function(min) {
- if (!min)
- return {
- x: this.x,
- y: this.y
- };
- if (!this._options.rotated)
- return {
- x: this.x,
- y: this.minY
- };
- return {
- x: this.minX,
- y: this.y
- }
- },
- getDefaultCoords: function() {
- return !this._options.rotated ? {
- x: this.x,
- y: this.defaultY
- } : {
- x: this.defaultX,
- y: this.y
- }
- },
- _calculateVisibility: function(x, y, width, height) {
- var that = this,
- visibleAreaX,
- visibleAreaY,
- rotated = that._options.rotated;
- if (that.translators) {
- visibleAreaX = that.translators.x.getCanvasVisibleArea();
- visibleAreaY = that.translators.y.getCanvasVisibleArea();
- if (visibleAreaX.min > x + (width || 0) || visibleAreaX.max < x || visibleAreaY.min > y + (height || 0) || visibleAreaY.max < y || rotated && _isDefined(width) && width !== 0 && (visibleAreaX.min === x + width || visibleAreaX.max === x) || !rotated && _isDefined(height) && height !== 0 && (visibleAreaY.min === y + height || visibleAreaY.max === y))
- that.inVisibleArea = false;
- else
- that.inVisibleArea = true
- }
- },
- correctPosition: _noop,
- hasValue: function() {
- return this.value !== null && this.minValue !== null
- },
- _populatePointShape: _noop,
- _checkSymbol: _noop,
- hide: _noop,
- show: _noop,
- hideMarker: _noop,
- setInvisibility: _noop,
- clearVisibility: _noop,
- isVisible: _noop,
- resetCorrection: _noop,
- correctValue: _noop,
- setPercentValue: _noop,
- correctCoordinates: _noop,
- dispose: function() {
- this.deleteMarker();
- this.deleteTrackerMarker();
- this.deleteLabel();
- this._options = null;
- this._styles = null;
- this.series = null;
- this.translators = null
- },
- getTooltipFormatObject: function(tooltip) {
- var that = this,
- tooltipFormatObject = that._getFormatObject(tooltip),
- sharedTooltipValuesArray = [],
- tooltipStackPointsFormatObject = [];
- if (that.stackPoints) {
- _each(that.stackPoints, function(_, point) {
- if (!point.isVisible())
- return;
- var formatObject = point._getFormatObject(tooltip);
- tooltipStackPointsFormatObject.push(point._getFormatObject(tooltip));
- sharedTooltipValuesArray.push(formatObject.seriesName + ": " + formatObject.valueText)
- });
- _extend(tooltipFormatObject, {
- points: tooltipStackPointsFormatObject,
- valueText: sharedTooltipValuesArray.join("\n"),
- stackName: that.stackPoints.stackName
- })
- }
- return tooltipFormatObject
- }
- })
- })(jQuery, DevExpress);
- /*! Module viz-core, file label.js */
- (function($, DX) {
- var _isDefined = DX.utils.isDefined,
- _extend = $.extend,
- _math = Math,
- _round = _math.round,
- _floor = _math.floor,
- _isEmptyObject = $.isEmptyObject,
- _noop = $.noop,
- LABEL_BACKGROUND_PADDING_X = 8,
- LABEL_BACKGROUND_PADDING_Y = 4,
- LABEL_OFFSET = 10,
- setPositionFuncCollection = {
- symbolPoint: "_setPositionForSymbol",
- barPoint: "_setPositionForBar",
- bubblePoint: "_setPositionForBubble",
- rangeSymbolPoint: "_setPositionForSymbol",
- rangeBarPoint: "_setPositionForBar",
- stockPoint: "_setPositionForFinancial",
- candlestickPoint: "_setPositionForFinancial"
- },
- checkPositionFuncCollection = {
- symbolPoint: "_checkPositionForSymbol",
- barPoint: "_checkPositionForBar",
- bubblePoint: "_checkPositionForSymbol",
- rangeSymbolPoint: "_checkPositionForSymbol",
- rangeBarPoint: "_checkPositionForBar",
- stockPoint: "_checkPositionForBar",
- candlestickPoint: "_checkPositionForBar"
- };
- DX.viz.core.series.points.Label = DX.Class.inherit({
- ctor: function(data, options) {
- this._offset = LABEL_OFFSET;
- this.updateData(data);
- this.setOptions(options)
- },
- clearVisibility: function() {
- if (this._group && this._group.settings.visibility)
- this._group.applySettings({visibility: null})
- },
- hide: function() {
- if (this._group && this._group.settings.visibility !== "hidden")
- this._group.applySettings({visibility: "hidden"})
- },
- updateData: function(data) {
- if (_isDefined(data)) {
- this._data = data.formatObject;
- this._initialValue = data.initialValue
- }
- },
- updateOptions: function(options) {
- this.setOptions(_extend(true, {}, {options: this._options}, options))
- },
- setOptions: function(newOptions) {
- var that = this,
- oldOptions = that._options,
- newOptions = newOptions || {},
- pointType = newOptions.type || "symbolPoint";
- that._options = newOptions.options;
- that._rotated = newOptions.rotated;
- that._isFullStacked = newOptions.isFullStacked;
- that._isRange = newOptions.isRange;
- that._setPosition = that[setPositionFuncCollection[pointType]];
- that._checkPosition = that[checkPositionFuncCollection[pointType]];
- if (oldOptions) {
- that._isBackgroundChanged(oldOptions.background, that._options.background) && that._deleteBackground();
- that._isConnectorChanged(oldOptions.connector, that._options.connector) && that._deleteConnector()
- }
- },
- setDataField: function(fieldName, fieldValue) {
- this._data = this._data || {};
- this._data[fieldName] = fieldValue
- },
- getData: function() {
- return this._data
- },
- setCoords: function(coords, graphicBbox, location, visibleArea) {
- this._coords = coords;
- this._graphicBbox = graphicBbox;
- this._visibleArea = visibleArea;
- this._location = location
- },
- hasText: function() {
- return !!this._text
- },
- getTextCoords: function() {
- return this._text && this._text.getBBox()
- },
- getCoords: function() {
- var coords = {},
- insideGroup = this._insideGroup;
- if (insideGroup) {
- coords = insideGroup.getBBox();
- coords.x = insideGroup.settings.translateX || 0;
- coords.y = insideGroup.settings.translateY || 0
- }
- return coords
- },
- updatePosition: function(x, y) {
- var settings = {},
- insideGroup = this._insideGroup;
- insideGroup.applySettings({
- translateX: x,
- translateY: y
- });
- this._connector && this._drawConnector()
- },
- _deleteElements: function() {
- this._deleteConnector();
- this._deleteBackground();
- this._deleteText();
- this._deleteGroups()
- },
- dispose: function() {
- this._data = null;
- this._options = null;
- this._positioningFunction = null;
- this._graphicBbox = null;
- this._visibleArea = null;
- this._coords = null;
- this._deleteElements()
- },
- _deleteText: function() {
- this._text && this._text.detach();
- this._text = null
- },
- _deleteGroups: function() {
- this._insideGroup = null;
- this._group && this._group.detach();
- this._group = null
- },
- _drawGroups: function(renderer, group) {
- if (!this._group)
- this._group = renderer.createGroup().append(group);
- if (!this._insideGroup)
- this._insideGroup = renderer.createGroup().append(this._group)
- },
- _drawText: function(renderer, text) {
- if (!this._text)
- this._text = renderer.createText(text, 0, 0, this._options.attributes).append(this._insideGroup);
- else
- this._text.applySettings({text: text}, this._options.attributes)
- },
- _drawBackground: function(renderer) {
- var that = this,
- options = that._options,
- background = options.background || {},
- settings;
- if (that._checkBackground(background)) {
- settings = _extend(that._getBackgroundSettings(), background);
- if (!that._background)
- that._background = renderer.createRect(settings.x, settings.y, settings.width, settings.height, 0, background).append(that._insideGroup);
- else
- that._background.applySettings(settings);
- that._background.toBackground()
- }
- },
- _drawConnector: function(renderer) {
- var that = this,
- connector = that._options.connector || {},
- points;
- if (that._checkConnector(connector)) {
- points = that._getConnectorPoints() || [];
- if (!that._connector)
- that._connector = renderer.createPath(points, connector).append(that._group);
- else
- that._connector.applySettings(_extend({points: points}, connector));
- that._connector.toBackground()
- }
- },
- _setVisibility: function(visibility) {
- this._group && this._group.applySettings({visibility: visibility})
- },
- draw: function(renderer, group, visibility) {
- var that = this,
- options = that._options,
- background = options.background,
- text = that._format();
- if (_isDefined(text) && text !== "") {
- that._drawGroups(renderer, group);
- that._setVisibility(visibility);
- that._drawText(renderer, text);
- that._drawBackground(renderer);
- that._rotateLabel();
- that._setPosition();
- that._drawConnector(renderer)
- }
- else
- that._setVisibility("hidden")
- },
- _deleteBackground: function() {
- this._background && this._background.detach();
- this._background = null
- },
- _isBackgroundChanged: function(oldBackground, newBackground) {
- return this._checkBackground(oldBackground || {}) !== this._checkBackground(newBackground || {})
- },
- _checkBackground: function(background) {
- var hasColor = background.fill && background.fill !== "none",
- hasBorder = background.strokeWidth && background.stroke && background.stroke !== "none";
- return hasColor || hasBorder
- },
- _getBackgroundSettings: function() {
- var bbox = this._text.getBBox();
- return {
- x: bbox.x - LABEL_BACKGROUND_PADDING_X,
- y: bbox.y - LABEL_BACKGROUND_PADDING_Y,
- width: bbox.width + 2 * LABEL_BACKGROUND_PADDING_X,
- height: bbox.height + 2 * LABEL_BACKGROUND_PADDING_Y
- }
- },
- _deleteConnector: function() {
- this._connector && this._connector.detach();
- this._connector = null
- },
- _isConnectorChanged: function(oldConnector, newConnector) {
- return this._checkConnector(oldConnector || {}) !== this._checkConnector(newConnector || {})
- },
- _checkConnector: function(connector) {
- return connector && connector.strokeWidth
- },
- _getConnectorPoints: function() {
- var that = this,
- rotated = that._rotated,
- labelBbox = that._insideGroup.getBBox(),
- graphicBbox = that._graphicBbox,
- centerLabelY,
- centerLabelX,
- rightLabelCoord,
- bottomLabelCoord,
- x1,
- x2,
- y1,
- y2;
- labelBbox.x += that._insideGroup.settings.translateX || 0;
- labelBbox.y += that._insideGroup.settings.translateY || 0;
- centerLabelY = that._background ? labelBbox.y + labelBbox.height / 2 : null;
- centerLabelX = that._background ? labelBbox.x + labelBbox.width / 2 : null,
- rightLabelCoord = labelBbox.x + labelBbox.width;
- bottomLabelCoord = labelBbox.y + labelBbox.height;
- x1 = _floor(labelBbox.x + labelBbox.width / 2);
- x2 = _floor(graphicBbox.x + graphicBbox.width / 2);
- if (bottomLabelCoord < graphicBbox.y) {
- y1 = centerLabelY || bottomLabelCoord;
- y2 = graphicBbox.y
- }
- else if (labelBbox.y > graphicBbox.y + graphicBbox.height) {
- y1 = centerLabelY || labelBbox.y;
- y2 = graphicBbox.y + graphicBbox.height
- }
- else {
- if (labelBbox.x > graphicBbox.x + graphicBbox.width) {
- x1 = centerLabelX || labelBbox.x;
- x2 = graphicBbox.x + graphicBbox.width
- }
- else if (rightLabelCoord < graphicBbox.x) {
- x1 = centerLabelX || rightLabelCoord;
- x2 = graphicBbox.x
- }
- else
- return;
- y1 = _floor(labelBbox.y + labelBbox.height / 2);
- y2 = _floor(graphicBbox.y + graphicBbox.height / 2)
- }
- return [{
- x: x1,
- y: y1
- }, {
- x: x2,
- y: y2
- }]
- },
- _rotateLabel: function() {
- var bbox = this._insideGroup.getBBox();
- this._insideGroup.rotate(this._options.rotationAngle)
- },
- _format: function() {
- var that = this,
- data = that._data,
- options = that._options,
- formatHelper = DX.formatHelper;
- data.valueText = formatHelper.format(data.value, options.format, options.precision);
- data.argumentText = formatHelper.format(data.argument, options.argumentFormat, options.argumentPrecision);
- if (data.percent !== undefined)
- data.percentText = formatHelper.format(data.percent, "percent", options.percentPrecision);
- if (data.total !== undefined)
- data.totalText = formatHelper.format(data.total, options.format, options.precision);
- if (data.openValue !== undefined)
- data.openValueText = formatHelper.format(data.openValue, options.format, options.precision);
- if (data.closeValue !== undefined)
- data.closeValueText = formatHelper.format(data.closeValue, options.format, options.precision);
- if (data.lowValue !== undefined)
- data.lowValueText = formatHelper.format(data.lowValue, options.format, options.precision);
- if (data.highValue !== undefined)
- data.highValueText = formatHelper.format(data.highValue, options.format, options.precision);
- if (data.reductionValue !== undefined)
- data.reductionValueText = formatHelper.format(data.reductionValue, options.format, options.precision);
- return options.customizeText ? options.customizeText.call(data, data) : data.valueText
- },
- _getOutsideLabelCoords: function(labelBbox) {
- var graphicBbox = this._graphicBbox,
- x = 0,
- y = 0,
- isTop = this._location === "top";
- if (!this._rotated) {
- x += graphicBbox.width / 2 + graphicBbox.x;
- if (isTop)
- y += graphicBbox.y - labelBbox.y - labelBbox.height - this._offset;
- else
- y += graphicBbox.y + graphicBbox.height - labelBbox.y + this._offset
- }
- else {
- y += graphicBbox.y - labelBbox.y - labelBbox.height / 2 + graphicBbox.height / 2;
- if (isTop)
- x += graphicBbox.x + graphicBbox.width - labelBbox.x + this._offset;
- else
- x += graphicBbox.x - labelBbox.x - labelBbox.width - this._offset
- }
- return {
- x: x,
- y: y
- }
- },
- _getInsideLabelCoords: function(labelBbox) {
- var graphicBbox = this._graphicBbox,
- isTop = this._location === "top",
- x = 0,
- y = 0;
- if (!this._isRange)
- if (!this._rotated) {
- x += graphicBbox.width / 2 + graphicBbox.x;
- y += graphicBbox.y - labelBbox.y - labelBbox.height / 2 + graphicBbox.height / 2
- }
- else {
- y += graphicBbox.y - labelBbox.y - labelBbox.height / 2 + graphicBbox.height / 2;
- x += graphicBbox.x - labelBbox.x - labelBbox.width / 2 + graphicBbox.width / 2
- }
- else if (!this._rotated) {
- x += graphicBbox.width / 2 + graphicBbox.x;
- if (isTop)
- y += graphicBbox.y - labelBbox.y - labelBbox.height + this._offset + labelBbox.height;
- else
- y += graphicBbox.y + graphicBbox.height - labelBbox.y - this._offset - labelBbox.height
- }
- else {
- y += graphicBbox.y - labelBbox.y - labelBbox.height / 2 + graphicBbox.height / 2;
- if (isTop)
- x += graphicBbox.x + graphicBbox.width - labelBbox.x - labelBbox.width - this._offset;
- else
- x += graphicBbox.x - labelBbox.x + this._offset
- }
- return {
- x: x,
- y: y
- }
- },
- _getFullstackedLabelCoords: function(labelBbox) {
- var x = 0,
- y = 0,
- graphicBbox = this._graphicBbox;
- if (!this._rotated) {
- x += graphicBbox.width / 2 + graphicBbox.x;
- y += this._coords.defaultY - labelBbox.y - labelBbox.height - this._offset
- }
- else {
- y += graphicBbox.y - labelBbox.y - labelBbox.height / 2 + graphicBbox.height / 2;
- x += this._coords.defaultX - labelBbox.x + this._offset
- }
- return {
- x: x,
- y: y
- }
- },
- _setPositionForSymbol: function() {
- var that = this,
- offset = that._offset,
- labelBBox = that._insideGroup.getBBox(),
- graphicBbox = that._graphicBbox,
- isTop = that._location === "top",
- correctionY = 0,
- correctionX = 0,
- x = 0,
- y = 0;
- if (!that._rotated) {
- correctionX = that._coords.x;
- correctionY = isTop ? -labelBBox.y - labelBBox.height - offset : graphicBbox.height - labelBBox.y + offset;
- correctionY += graphicBbox.y
- }
- else {
- correctionY = graphicBbox.y - labelBBox.y - labelBBox.height / 2 + graphicBbox.height / 2;
- correctionX = isTop ? graphicBbox.width - labelBBox.x + offset : -labelBBox.x - labelBBox.width - offset;
- correctionX += graphicBbox.x
- }
- x += correctionX + that._options.horizontalOffset;
- y += correctionY + that._options.verticalOffset;
- that._checkPosition({
- x: labelBBox.x + x,
- y: labelBBox.y + y,
- height: labelBBox.height,
- width: labelBBox.width
- }, x, y)
- },
- _checkPositionForSymbol: function(labelBbox, x, y) {
- var that = this,
- graphicBbox = that._graphicBbox,
- visibleArea = that._visibleArea,
- offset = that._offset;
- if (!that._rotated) {
- if (visibleArea.minX <= graphicBbox.x + graphicBbox.width && visibleArea.maxX >= graphicBbox.x) {
- if (visibleArea.minX > labelBbox.x && that.adjustSeriesLabels)
- x += visibleArea.minX - labelBbox.x;
- if (visibleArea.maxX < labelBbox.x + labelBbox.width && that.adjustSeriesLabels)
- x -= labelBbox.x + labelBbox.width - visibleArea.maxX;
- if (visibleArea.minY > labelBbox.y)
- y += graphicBbox.y + graphicBbox.height - labelBbox.y + offset;
- if (visibleArea.maxY < labelBbox.y + labelBbox.height)
- y -= labelBbox.y + labelBbox.height - graphicBbox.y + offset
- }
- }
- else if (visibleArea.minY <= graphicBbox.y + graphicBbox.height && visibleArea.maxY >= graphicBbox.y) {
- if (visibleArea.minX > labelBbox.x)
- x += graphicBbox.x + graphicBbox.width - labelBbox.x + offset;
- if (visibleArea.maxX < labelBbox.x + labelBbox.width)
- x -= labelBbox.x + labelBbox.width - graphicBbox.x + offset;
- if (visibleArea.minY > graphicBbox.y && that.adjustSeriesLabels)
- y += visibleArea.minY - labelBbox.y;
- if (visibleArea.maxY < labelBbox.y + labelBbox.height && that.adjustSeriesLabels)
- y -= labelBbox.y + labelBbox.height - visibleArea.maxY
- }
- that._insideGroup.applySettings({
- translateX: _round(x),
- translateY: _round(y)
- })
- },
- _setPositionForBar: function() {
- var that = this,
- offset = that._offset,
- labelPosition = that._options.position,
- labelBbox = that._insideGroup.getBBox(),
- coords;
- if (that._initialValue === 0 && that._isFullStacked)
- coords = that._getFullstackedLabelCoords(labelBbox);
- else if (labelPosition === "inside")
- coords = that._getInsideLabelCoords(labelBbox);
- else
- coords = that._getOutsideLabelCoords(labelBbox);
- coords.x += that._options.horizontalOffset;
- coords.y += that._options.verticalOffset;
- that._checkPosition({
- x: labelBbox.x + coords.x,
- y: labelBbox.y + coords.y,
- height: labelBbox.height,
- width: labelBbox.width
- }, coords.x, coords.y)
- },
- _checkPositionForBar: function(labelBbox, x, y) {
- var that = this,
- graphicBbox = that._graphicBbox,
- visibleArea = that._visibleArea;
- if (visibleArea.minX <= graphicBbox.x + graphicBbox.width && visibleArea.maxX >= graphicBbox.x && visibleArea.minY <= graphicBbox.y + graphicBbox.height && visibleArea.maxY >= graphicBbox.y)
- if (!that._rotated) {
- if (visibleArea.minX > labelBbox.x && that.adjustSeriesLabels)
- x += visibleArea.minX - labelBbox.x;
- if (visibleArea.maxX < labelBbox.x + labelBbox.width && that.adjustSeriesLabels)
- x -= labelBbox.x + labelBbox.width - visibleArea.maxX;
- if (visibleArea.minY > labelBbox.y)
- y += visibleArea.minY - labelBbox.y;
- if (visibleArea.maxY < labelBbox.y + labelBbox.height)
- y -= labelBbox.y + labelBbox.height - visibleArea.maxY
- }
- else {
- if (visibleArea.minX > labelBbox.x)
- x += visibleArea.minX - labelBbox.x;
- if (visibleArea.maxX < labelBbox.x + labelBbox.width)
- x -= labelBbox.x + labelBbox.width - visibleArea.maxX;
- if (visibleArea.minY > labelBbox.y && that.adjustSeriesLabels)
- y += visibleArea.minY - labelBbox.y;
- if (visibleArea.maxY < labelBbox.y + labelBbox.height && that.adjustSeriesLabels)
- y -= labelBbox.y + labelBbox.height - visibleArea.maxY
- }
- if (that._options.resolveLabelsOverlapping && that._options.position === "inside")
- if (that._rotated) {
- if (labelBbox.width > graphicBbox.width || labelBbox.height > graphicBbox.height) {
- that.hide();
- return
- }
- }
- else if (labelBbox.height > graphicBbox.height || labelBbox.width > graphicBbox.width) {
- that.hide();
- return
- }
- that._insideGroup.applySettings({
- translateX: _round(x),
- translateY: _round(y)
- })
- },
- _setPositionForBubble: function() {
- var that = this,
- labelBbox = that._insideGroup.getBBox(),
- graphicBbox = that._graphicBbox,
- x = 0,
- y = 0;
- if (that._options.position === "inside") {
- x = that._coords.x;
- y += graphicBbox.y + graphicBbox.height / 2 - labelBbox.y - labelBbox.height / 2;
- x += that._options.horizontalOffset;
- y += that._options.verticalOffset;
- that._checkPosition({
- x: labelBbox.x + x,
- y: labelBbox.y + y,
- height: labelBbox.height,
- width: labelBbox.width
- }, x, y)
- }
- else
- that._setPositionForSymbol()
- },
- _setPositionForFinancial: function() {
- var that = this,
- offset = that._offset,
- labelBbox = that._insideGroup.getBBox(),
- coords;
- coords = that._getOutsideLabelCoords(labelBbox);
- coords.x += that._options.horizontalOffset;
- coords.y += that._options.verticalOffset;
- that._checkPosition({
- x: labelBbox.x + coords.x,
- y: labelBbox.y + coords.y,
- height: labelBbox.height,
- width: labelBbox.width
- }, coords.x, coords.y)
- }
- })
- })(jQuery, DevExpress);
- /*! Module viz-core, file pieLabel.js */
- (function($, DX) {
- var getCosAndSin = DX.utils.getCosAndSin,
- _extend = $.extend,
- _math = Math,
- _round = _math.round,
- _max = _math.max,
- _inArray = $.inArray,
- _isDefined = DX.utils.isDefined,
- INDENT_FROM_PIE = 30,
- CONNECTOR_LENGTH = 20;
- DX.viz.core.series.points.PieLabel = DX.viz.core.series.points.Label.inherit({
- ctor: function(data, options) {
- this.setLabelEllipsis = false;
- this.indentFromPie = INDENT_FROM_PIE;
- this.updateData(data);
- this.setOptions(options)
- },
- updateData: function(data) {
- if (_isDefined(data))
- this._data = data.formatObject
- },
- setOptions: function(newOptions) {
- var that = this,
- oldOptions = that._options,
- newOptions = newOptions || {};
- that._options = newOptions.options;
- that._borderWidth = newOptions.borderWidth;
- if (oldOptions) {
- that._isBackgroundChanged(oldOptions.background, that._options.background) && that._deleteBackground();
- that._isConnectorChanged(oldOptions.connector, that._options.connector) && that._deleteConnector()
- }
- },
- setCoords: function(coords, canvas) {
- this._middleAngle = coords.middleAngle;
- this._radiusOuter = coords.radiusOuter;
- this._centerX = coords.centerX;
- this._centerY = coords.centerY;
- this._canvas = canvas
- },
- updatePosition: function(maxLabelLength) {
- this._setPosition(maxLabelLength);
- this._checkEllipsis();
- this._drawBackground();
- this._rotateLabel();
- this._checkPosition();
- this._connector && this._drawConnector()
- },
- dispose: function() {
- this._data = null;
- this._options = null;
- this._canvas = null;
- this._deleteElements()
- },
- draw: function(renderer, group, visibility) {
- var that = this,
- options = that._options,
- background = options.background,
- text = that._format();
- if (_isDefined(text) && text !== "") {
- that._drawGroups(renderer, group);
- that._setVisibility(visibility);
- that._drawText(renderer, text);
- that._setPosition();
- that._checkEllipsis();
- that._drawBackground(renderer);
- that._rotateLabel();
- that._checkPosition();
- that._drawConnector(renderer)
- }
- else
- that._setVisibility("hidden")
- },
- _getOutsideGroupLabelPosition: function() {
- this._deleteConnector();
- return this._group && this._group.getBBox()
- },
- _setPosition: function(maxLabelLength) {
- var that = this,
- bbox = that._text.getBBox(),
- options = that._options,
- angleFunctions = getCosAndSin(that._middleAngle),
- align = "center",
- rad = that._radiusOuter + options.radialOffset,
- canvas = that._canvas,
- rightBorderX = canvas.width - canvas.right,
- leftBorderX = canvas.left,
- x,
- y;
- if (options.position === 'inside') {
- rad -= that.indentFromPie;
- x = that._centerX + rad * angleFunctions.cos
- }
- else if (options.position === 'columns') {
- rad += CONNECTOR_LENGTH;
- if (angleFunctions.cos >= 0) {
- align = "right";
- x = maxLabelLength ? that._centerX + rad + maxLabelLength : rightBorderX;
- x = x > rightBorderX ? rightBorderX : x
- }
- else if (angleFunctions.cos < 0) {
- align = "left";
- x = maxLabelLength ? that._centerX - rad - maxLabelLength : leftBorderX;
- x = x < leftBorderX ? leftBorderX : x
- }
- }
- else {
- rad += that.indentFromPie;
- if (angleFunctions.cos > 0.1)
- align = "left";
- else if (angleFunctions.cos < -0.1)
- align = "right";
- x = that._centerX + rad * angleFunctions.cos
- }
- y = _round(that._text.settings.y + that._centerY - rad * angleFunctions.sin - bbox.y - bbox.height / 2);
- that._text.applySettings({
- x: x,
- y: y,
- align: align
- })
- },
- _getConnectorPoints: function() {
- var that = this,
- options = that._options,
- position = options.position,
- angleFunctions,
- rad = that._radiusOuter,
- box,
- x,
- y,
- points = [];
- if (position !== "inside") {
- angleFunctions = getCosAndSin(_round(that._middleAngle));
- points.push({
- x: _round(that._centerX + (rad - that._borderWidth) * angleFunctions.cos),
- y: _round(that._centerY - (rad - that._borderWidth) * angleFunctions.sin)
- });
- x = _round(that._centerX + (rad + options.radialOffset + CONNECTOR_LENGTH) * angleFunctions.cos);
- if (position === "columns") {
- box = that._insideGroup.getBBox();
- box.x = box.x + (that._insideGroup.settings.translateX || 0);
- box.y = box.y + (that._insideGroup.settings.translateY || 0);
- y = box.y + box.height / 2;
- points.push({
- x: x,
- y: y
- });
- if (that._background)
- x = box.x + box.width / 2;
- else if (angleFunctions.cos < 0)
- x = box.x + box.width;
- else if (angleFunctions.cos > 0)
- x = box.x;
- points.push({
- x: x,
- y: y
- })
- }
- else {
- y = _round(that._centerY - (rad + options.radialOffset + CONNECTOR_LENGTH) * angleFunctions.sin);
- points.push({
- x: x,
- y: y
- })
- }
- }
- return points
- },
- _rotateLabel: function() {
- var that = this,
- options = that._options,
- shift = that._radiusOuter + options.radialOffset * 2 + CONNECTOR_LENGTH,
- angleFunctions = getCosAndSin(that._middleAngle),
- x,
- y,
- box = that._insideGroup.getBBox();
- if (options.position === "inside" || options.position === "columns") {
- x = box.x + box.width / 2;
- y = box.y + box.height / 2
- }
- else {
- x = that._centerX + shift * angleFunctions.cos;
- y = that._centerY - shift * angleFunctions.sin
- }
- that._insideGroup.applySettings({
- x: x,
- y: y,
- rotate: options.rotationAngle
- })
- },
- _checkEllipsis: function() {
- var that = this,
- i,
- LABEL_OFFSET = 10,
- labelBox,
- text,
- textLength = 0,
- linesLength = [],
- numLastSpan = [],
- maxLength,
- numSpan,
- index,
- x,
- y,
- width,
- rotationAngleFunction = getCosAndSin(that._options.rotationAngle),
- canvas = that._canvas,
- labelOptions = that._options,
- angleFunctions = getCosAndSin(that._middleAngle),
- borderX = that._centerX + (that._radiusOuter + CONNECTOR_LENGTH) * angleFunctions.cos;
- if (!that._text.tspans || !that.setLabelEllipsis)
- return;
- labelBox = that._text.getBBox();
- x = labelBox.x + labelBox.width < that._centerX ? labelBox.x + labelBox.width : labelBox.x;
- y = labelBox.y + labelBox.height / 2;
- width = labelBox.x + labelBox.width < that._centerX ? -labelBox.width : labelBox.width;
- if (y + width * rotationAngleFunction.sin > canvas.height - canvas.bottom + LABEL_OFFSET || y + width * rotationAngleFunction.sin < canvas.top - LABEL_OFFSET || x + width * rotationAngleFunction.cos < canvas.left - LABEL_OFFSET || x + width * rotationAngleFunction.cos > canvas.width - canvas.right + LABEL_OFFSET || labelOptions.position === "columns" && (angleFunctions.cos < 0 && borderX < x || angleFunctions.cos > 0 && borderX > x))
- for (i = 0; i < that._text.tspans.length; i++) {
- textLength += that._text.tspans[i].element.getNumberOfChars();
- if (!that._text.tspans[i + 1] || that._text.tspans[i + 1].settings.dy > 0) {
- linesLength.push(textLength);
- numLastSpan.push(i);
- textLength = 0
- }
- }
- while (y + width * rotationAngleFunction.sin > canvas.height - canvas.bottom + LABEL_OFFSET || y + width * rotationAngleFunction.sin < canvas.top - LABEL_OFFSET || x + width * rotationAngleFunction.cos < canvas.left - LABEL_OFFSET || x + width * rotationAngleFunction.cos > canvas.width - canvas.right + LABEL_OFFSET || labelOptions.position === "columns" && (angleFunctions.cos < 0 && borderX < x || angleFunctions.cos > 0 && borderX > x)) {
- maxLength = _max.apply(null, linesLength);
- if (maxLength === 0)
- break;
- index = _inArray(maxLength, linesLength);
- numSpan = numLastSpan[index];
- if (that._text.tspans[numSpan].element.textContent === "...") {
- if (that._text.tspans[numSpan].settings.dy > 0 || !that._text.tspans[numSpan - 1])
- linesLength[index] = 0;
- else if (that._text.tspans[numSpan - 1]) {
- that._text.tspans[numSpan].element.textContent = "";
- numLastSpan[index] -= 1;
- that._text.tspans[numSpan - 1].element.textContent += "..."
- }
- }
- else {
- text = that._text.tspans[numSpan].element.textContent;
- text = text.substr(0, text.length - 1 - 3) + "...";
- that._text.tspans[numSpan].element.textContent = text;
- linesLength[index] -= 1
- }
- labelBox = that._text.getBBox();
- x = labelBox.x + labelBox.width < that._centerX ? labelBox.x + labelBox.width : labelBox.x;
- y = labelBox.y + labelBox.height / 2;
- width = labelBox.x + labelBox.width < that._centerX ? -labelBox.width : labelBox.width
- }
- },
- _checkPosition: function() {
- var that = this,
- group = that._insideGroup,
- box = group.getBBox(),
- canvas = that._canvas,
- x = 0,
- y = 0;
- if (box.y + box.height > canvas.height - canvas.bottom)
- y = canvas.height - box.y - box.height - canvas.bottom;
- else if (box.y < canvas.top)
- y = canvas.top - box.y;
- if (box.x + box.width > canvas.width - canvas.right)
- x = canvas.width - canvas.right - box.x - box.width;
- else if (box.x < canvas.left)
- x = canvas.left - box.x;
- group.applySettings({
- translateX: x,
- translateY: y
- })
- },
- setPosition: function(position) {
- this._options.position = position
- },
- getPosition: function() {
- return this._options.position
- }
- })
- })(jQuery, DevExpress);
- /*! Module viz-core, file symbolPoint.js */
- (function($, DX) {
- var viz = DevExpress.viz,
- core = viz.core,
- series = core.series,
- _extend = $.extend,
- _each = $.each,
- _isNumber = DX.utils.isNumber,
- _isDefined = DX.utils.isDefined,
- _isEmptyObject = $.isEmptyObject,
- _math = Math,
- _round = _math.round,
- _floor = _math.floor,
- _ceil = _math.ceil,
- DEFAULT_IMAGE_WIDTH = 20,
- DEFAULT_IMAGE_HEIGHT = 20,
- CANVAS_POSITION_DEFAULT = "canvas_position_default";
- series.points.mixins = series.points.mixins || {};
- series.points.mixins.symbolPoint = {
- deleteLabel: function() {
- this._label.dispose();
- this._label = null
- },
- _hasGraphic: function() {
- return this.graphic
- },
- _clearTrackerVisibility: function() {
- if (this.trackerGraphic && this.trackerGraphic.settings.visibility)
- this.trackerGraphic.applySettings({visibility: null})
- },
- clearVisibility: function() {
- if (this.graphic && this.graphic.settings.visibility)
- this.graphic.applySettings({visibility: null});
- this._clearTrackerVisibility();
- this._label.clearVisibility()
- },
- isVisible: function() {
- return this.inVisibleArea && this.series.isVisible()
- },
- _setTrackerInvisibility: function() {
- if (this.trackerGraphic && this.trackerGraphic.settings.visibility !== "hidden")
- this.trackerGraphic.applySettings({visibility: "hidden"})
- },
- setInvisibility: function() {
- if (this.graphic && this.graphic.settings.visibility !== "hidden")
- this.graphic.applySettings({visibility: "hidden"});
- this._setTrackerInvisibility();
- this._label.hide()
- },
- clearMarker: function() {
- this.graphic && this.graphic.applySettings(this._emptySettings)
- },
- setAdjustSeriesLabels: function(adjustSeriesLabels) {
- this._label.adjustSeriesLabels = adjustSeriesLabels
- },
- _getLabelOptions: function(type) {
- var options = this._options;
- return {
- options: options.label,
- rotated: options.rotated,
- type: type,
- isFullStacked: options.series.isFullStackedSeries(),
- isRange: options.type.indexOf("range") !== -1
- }
- },
- _createLabel: function() {
- this._label = core.CoreFactory.createLabel(this._options.type)
- },
- _updateLabelData: function() {
- this._label.updateData({
- formatObject: this._getLabelFormatObject(),
- initialValue: this.initialValue
- })
- },
- _updateLabelOptions: function(type) {
- !this._label && this._createLabel();
- this._label.setOptions(this._getLabelOptions(type))
- },
- _checkImage: function(image) {
- return _isDefined(image) && (typeof image === "string" || _isDefined(image.url))
- },
- _fillStyle: function() {
- this._styles = this._options.styles
- },
- _checkSymbol: function(oldOptions, newOptions) {
- var oldSymbol = oldOptions.symbol,
- newSymbol = newOptions.symbol,
- symbolChanged = oldSymbol === "circle" && newSymbol !== "circle" || oldSymbol !== "circle" && newSymbol === "circle",
- imageChanged = this._checkImage(oldOptions.image) !== this._checkImage(newOptions.image);
- if (symbolChanged || imageChanged)
- return true;
- return false
- },
- _getSquareMarkerCoords: function(radius) {
- return [{
- x: -radius,
- y: -radius
- }, {
- x: radius,
- y: -radius
- }, {
- x: radius,
- y: radius
- }, {
- x: -radius,
- y: radius
- }, {
- x: -radius,
- y: -radius
- }]
- },
- _getPolygonMarkerCoords: function(radius) {
- var r = _ceil(radius);
- return [{
- x: -r,
- y: 0
- }, {
- x: 0,
- y: -r
- }, {
- x: r,
- y: 0
- }, {
- x: 0,
- y: r
- }, {
- x: -r,
- y: 0
- }]
- },
- _getTriangleMarkerCoords: function(radius) {
- return [{
- x: -radius,
- y: -radius
- }, {
- x: radius,
- y: -radius
- }, {
- x: 0,
- y: radius
- }, {
- x: -radius,
- y: -radius
- }]
- },
- _getCrossMarkerCoords: function(radius) {
- var r = _ceil(radius),
- floorHalfRadius = _floor(r / 2),
- ceilHalfRadius = _ceil(r / 2);
- return [{
- x: -r,
- y: -floorHalfRadius
- }, {
- x: -floorHalfRadius,
- y: -r
- }, {
- x: 0,
- y: -ceilHalfRadius
- }, {
- x: floorHalfRadius,
- y: -r
- }, {
- x: r,
- y: -floorHalfRadius
- }, {
- x: ceilHalfRadius,
- y: 0
- }, {
- x: r,
- y: floorHalfRadius
- }, {
- x: floorHalfRadius,
- y: r
- }, {
- x: 0,
- y: ceilHalfRadius
- }, {
- x: -floorHalfRadius,
- y: r
- }, {
- x: -r,
- y: floorHalfRadius
- }, {
- x: -ceilHalfRadius,
- y: 0
- }]
- },
- _populatePointShape: function(symbol, radius) {
- switch (symbol) {
- case"square":
- return this._getSquareMarkerCoords(radius);
- case"polygon":
- return this._getPolygonMarkerCoords(radius);
- case"triangle":
- return this._getTriangleMarkerCoords(radius);
- case"cross":
- return this._getCrossMarkerCoords(radius)
- }
- },
- correctValue: function(correction) {
- if (this.hasValue()) {
- this.value = this.initialValue + correction;
- this.minValue = correction;
- this.translate()
- }
- },
- resetCorrection: function() {
- this.value = this.initialValue;
- this.minValue = CANVAS_POSITION_DEFAULT
- },
- _getTranslates: function(animationEnabled) {
- var translateX,
- translateY;
- translateX = this.x;
- translateY = this.y;
- if (animationEnabled)
- if (this._options.rotated)
- translateX = this.defaultX;
- else
- translateY = this.defaultY;
- return {
- x: translateX,
- y: translateY
- }
- },
- _createImageMarker: function(renderer, settings, options) {
- var url,
- width,
- height,
- offsetY,
- attr = {
- location: "center",
- translateX: settings.attr.translateX,
- translateY: settings.attr.translateY,
- visibility: settings.attr.visibility
- };
- url = options.url ? options.url.toString() : options.toString();
- width = options.width || DEFAULT_IMAGE_WIDTH;
- height = options.height || DEFAULT_IMAGE_HEIGHT;
- return renderer.createImage(-_round(width * 0.5), -_round(height * 0.5), width, height, url, attr)
- },
- _createSymbolMarker: function(renderer, pointSettings, animationEnabled) {
- var marker,
- options = this._options;
- switch (options.symbol) {
- case"circle":
- marker = renderer.createCircle(0, 0, pointSettings.r, pointSettings.attr);
- break;
- case"square":
- case"polygon":
- case"triangle":
- case"cross":
- marker = renderer.createArea(pointSettings.points, pointSettings.attr);
- break
- }
- return marker
- },
- _createMarker: function(renderer, group, image, settings, animationEnabled) {
- var marker = this._checkImage(image) ? this._createImageMarker(renderer, settings, image) : this._createSymbolMarker(renderer, settings, animationEnabled);
- marker && marker.append(group);
- return marker
- },
- _getSymbolBbox: function(x, y, r) {
- var bbox = {};
- bbox.x = x - r;
- bbox.y = y - r;
- bbox.width = bbox.height = r * 2;
- return bbox
- },
- _getImageBbox: function(x, y) {
- var bbox = {},
- image = this._options.image,
- width = image.width || DEFAULT_IMAGE_WIDTH,
- height = image.height || DEFAULT_IMAGE_HEIGHT;
- bbox.x = x - _round(width / 2);
- bbox.y = y - _round(height / 2);
- bbox.width = width;
- bbox.height = height;
- return bbox
- },
- _getGraphicBbox: function() {
- var options = this._options,
- x = this.x,
- y = this.y,
- bbox;
- if (options.visible)
- bbox = this._checkImage(options.image) ? this._getImageBbox(x, y) : this._getSymbolBbox(x, y, options.styles.normal.r);
- else
- bbox = {
- x: x,
- y: y,
- width: 0,
- height: 0
- };
- return bbox
- },
- _drawLabel: function(renderer, group) {
- var that = this,
- customVisibility = that._getCustomLabelVisibility(),
- visibleArea,
- translators = that.translators;
- if ((that._options.series.getLabelVisibility() || customVisibility) && that.hasValue()) {
- if (translators)
- visibleArea = {
- minX: translators.x.getCanvasVisibleArea().min,
- maxX: translators.x.getCanvasVisibleArea().max,
- minY: translators.y.getCanvasVisibleArea().min,
- maxY: translators.y.getCanvasVisibleArea().max
- };
- that._label.setCoords({
- x: that.x,
- y: that.y
- }, that._getGraphicBbox(), that._getLabelPosition(), visibleArea);
- that._label.draw(renderer, group, customVisibility)
- }
- else
- that._label.hide()
- },
- _drawMarker: function(renderer, group, animationEnabled) {
- var that = this,
- options = that._options,
- translates = that._getTranslates(animationEnabled),
- marker,
- style = that._getStyle(),
- pointAttributes = _extend({
- translateX: translates.x,
- translateY: translates.y
- }, style),
- pointSettings = {
- attr: pointAttributes,
- points: that._populatePointShape(options.symbol, style.r),
- r: style.r
- };
- marker = that._createMarker(renderer, group, options.image, pointSettings, animationEnabled);
- that.graphic = marker
- },
- _drawTrackerMarker: function(renderer, group) {
- var radius = this._options.trackerR || this.storeTrackerR();
- this.trackerGraphic = renderer.createCircle(this.x, this.y, radius).append(group);
- this.trackerGraphic.data({point: this})
- },
- getTooltipCoords: function() {
- var coords;
- if (this.graphic)
- coords = {
- x: this.x,
- y: this.y,
- offset: this.graphic.getBBox().height / 2
- };
- else
- coords = {
- x: this.x,
- y: this.y,
- offset: 0
- };
- return coords
- },
- hasValue: function() {
- return this.value !== null && this.minValue !== null
- },
- setPercentValue: function(total) {
- var valuePercent = this.value / total || 0,
- percent = valuePercent,
- minValuePercent = this.minValue / total || 0;
- percent -= _isNumber(this.minValue) ? minValuePercent : 0;
- this._label.setDataField("percent", percent);
- this._label.setDataField("total", total);
- if (this._options.series.isFullStackedSeries() && this.hasValue()) {
- this.value = valuePercent;
- this.minValue = !minValuePercent ? this.minValue : minValuePercent;
- this.translate()
- }
- },
- storeTrackerR: function() {
- var navigator = window.navigator,
- r = this._options.styles.normal.r,
- minTrackerSize;
- navigator = this.__debug_navigator || navigator;
- this.__debug_browserNavigator = navigator;
- minTrackerSize = "ontouchstart" in window || navigator.msPointerEnabled && navigator.msMaxTouchPoints || navigator.pointerEnabled && navigator.maxTouchPoints ? 20 : 6;
- this._options.trackerR = r < minTrackerSize ? minTrackerSize : r;
- return this._options.trackerR
- },
- _translate: function(translators) {
- var that = this,
- mainAxis = that._options.rotated ? "x" : "y",
- upperMainAxis = mainAxis.toUpperCase(),
- mainTranslator = translators[mainAxis],
- axis = that._options.rotated ? "y" : "x";
- that[mainAxis] = mainTranslator.translate(that.value);
- that[axis] = translators[axis].translate(that.argument);
- that["min" + upperMainAxis] = mainTranslator.translate(that.minValue);
- that["default" + upperMainAxis] = mainTranslator.translate(CANVAS_POSITION_DEFAULT);
- that._calculateVisibility(that.x, that.y);
- that._prepareStatesOptions()
- },
- _changeData: function(data) {
- this.value = this.initialValue = this.originalValue = data.value;
- this.argument = this.initialArgument = this.originalArgument = data.argument;
- this.minValue = this.initialMinValue = this.originalMinValue = _isDefined(data.minValue) ? data.minValue : CANVAS_POSITION_DEFAULT;
- this.tag = data.tag;
- this.index = data.index
- },
- _updateData: function(data) {
- if (this.argument !== data.argument || this.value !== data.value || this.tag !== data.tag)
- this._changeData(data)
- },
- _getImageSettings: function(image) {
- return {
- href: image.url || image.toString(),
- width: image.width || DEFAULT_IMAGE_WIDTH,
- height: image.height || DEFAULT_IMAGE_HEIGHT
- }
- },
- _updateMarker: function(animationEnabled, style) {
- var that = this,
- options = that._options,
- style = style || this._getStyle(),
- settings,
- image = options.image;
- if (that._checkImage(image))
- settings = _extend({}, {visibility: style.visibility}, that._getImageSettings(image));
- else
- settings = _extend({}, style, {points: that._populatePointShape(options.symbol, style.r)});
- if (!animationEnabled) {
- settings.translateX = that.x;
- settings.translateY = that.y
- }
- that.graphic.applySettings(settings)
- },
- _updateTracker: function() {
- this.trackerGraphic.applySettings({
- cx: this.x,
- cy: this.y,
- r: this.storeTrackerR()
- })
- },
- _getLabelFormatObject: function() {
- return {
- argument: this.initialArgument,
- value: this.initialValue,
- originalArgument: this.originalArgument,
- originalValue: this.originalValue,
- seriesName: this._options.series.name,
- point: this
- }
- },
- _getLabelPosition: function() {
- if (this._options.series.isFullStackedSeries() || this.initialValue > 0)
- return "top";
- else
- return "bottom"
- },
- _getFormatObject: function(tooltip) {
- var labelFormatObject = this._label.getData(),
- valueObject = {
- argumentText: tooltip.formatValue(this.initialArgument, "argument"),
- valueText: tooltip.formatValue(this.initialValue)
- },
- percentObject = _isDefined(labelFormatObject.percent) ? {percentText: tooltip.formatValue(labelFormatObject.percent, "percent")} : {},
- totalObject = _isDefined(labelFormatObject.total) ? {totalText: tooltip.formatValue(labelFormatObject.total)} : {};
- return _extend({}, labelFormatObject, valueObject, percentObject, totalObject)
- }
- }
- })(jQuery, DevExpress);
- /*! Module viz-core, file barPoint.js */
- (function($, DX) {
- var viz = DevExpress.viz,
- points = viz.core.series.points.mixins,
- _extend = $.extend,
- _math = Math,
- _round = _math.round,
- _abs = _math.abs,
- _min = _math.min,
- CANVAS_POSITION_DEFAULT = "canvas_position_default",
- DEFAULT_BAR_TRACKER_SIZE = 9,
- CORRECTING_BAR_TRACKER_VALUE = 4;
- points.barPoint = _extend({}, points.symbolPoint, {
- correctCoordinates: function(correctOptions) {
- var correction = correctOptions.offset - _round(correctOptions.width / 2),
- rotated = this._options.rotated,
- valueSelector = rotated ? "height" : "width",
- correctionSelector = (rotated ? "y" : "x") + "Correction";
- this[valueSelector] = correctOptions.width;
- this[correctionSelector] = correction
- },
- _getGraphicBbox: function() {
- var bbox = {};
- bbox.x = this.x;
- bbox.y = this.y;
- bbox.width = this.width;
- bbox.height = this.height;
- return bbox
- },
- _getLabelPosition: function() {
- var position,
- invertX = this.translators.x.getBusinessRange().invert,
- invertY = this.translators.y.getBusinessRange().invert,
- isDiscreteValue = this.series.valueAxisType === "discrete",
- isFullStacked = this.series.isFullStackedSeries(),
- notVerticalInverted = !isDiscreteValue && (this.initialValue >= 0 && !invertY || this.initialValue < 0 && invertY) || isDiscreteValue && !invertY || isFullStacked,
- notHorizontalInverted = !isDiscreteValue && (this.initialValue >= 0 && !invertX || this.initialValue < 0 && invertX) || isDiscreteValue && !invertX || isFullStacked;
- if (!this._options.rotated)
- position = notVerticalInverted ? "top" : "bottom";
- else
- position = notHorizontalInverted ? "top" : "bottom";
- return position
- },
- _drawLabel: function(renderer, group) {
- var that = this,
- options = that._options,
- coords,
- commonVisibility = options.series.getLabelVisibility(),
- customVisibility = that._getCustomLabelVisibility(),
- visibleArea,
- translators = that.translators;
- if (that.hasValue() && (options.label.showForZeroValues || that.initialValue) && (customVisibility || commonVisibility)) {
- coords = {
- x: that.x,
- y: that.y,
- defaultX: that.defaultX,
- defaultY: that.defaultY
- };
- if (translators)
- visibleArea = {
- minX: translators.x.getCanvasVisibleArea().min,
- maxX: translators.x.getCanvasVisibleArea().max,
- minY: translators.y.getCanvasVisibleArea().min,
- maxY: translators.y.getCanvasVisibleArea().max
- };
- that._label.setCoords(coords, that._getGraphicBbox(), that._getLabelPosition(), visibleArea);
- that._label.draw(renderer, group, customVisibility)
- }
- else
- that._label.hide()
- },
- _drawMarker: function(renderer, group, animationEnabled) {
- var style = this._getStyle(),
- x = this.x,
- y = this.y,
- width = this.width,
- height = this.height;
- if (animationEnabled)
- if (this._options.rotated) {
- width = 0;
- x = this.defaultX
- }
- else {
- height = 0;
- y = this.defaultY
- }
- this.graphic = renderer.createRect(x, y, width, height, this._options.cornerRadius, style).append(group)
- },
- _getSettingsForTracker: function() {
- var that = this,
- y = that.y,
- height = that.height,
- x = that.x,
- width = that.width;
- if (that._options.rotated) {
- if (width === 1) {
- width = DEFAULT_BAR_TRACKER_SIZE;
- x -= CORRECTING_BAR_TRACKER_VALUE
- }
- }
- else if (height === 1) {
- height = DEFAULT_BAR_TRACKER_SIZE;
- y -= CORRECTING_BAR_TRACKER_VALUE
- }
- return {
- x: x,
- y: y,
- width: width,
- height: height
- }
- },
- _drawTrackerMarker: function(renderer, group) {
- var settings = this._getSettingsForTracker();
- this.trackerGraphic = renderer.createRect(settings.x, settings.y, settings.width, settings.height, this._options.cornerRadius).append(group);
- this.trackerGraphic.data({point: this})
- },
- getGraphicSettings: function() {
- return {
- x: this.graphic.settings.x || 0,
- y: this.graphic.settings.y || 0,
- height: this.graphic.settings.height || 0,
- width: this.graphic.settings.width || 0
- }
- },
- getTooltipCoords: function() {
- var x = this.x + this.width / 2,
- y = this.y + this.height / 2;
- return {
- x: x,
- y: y,
- offset: 0
- }
- },
- _truncateCoord: function(coord, minBounce, maxBounce) {
- if (coord < minBounce)
- return minBounce;
- if (coord > maxBounce)
- return maxBounce;
- return coord
- },
- _translate: function(translators) {
- var that = this,
- rotated = that._options.rotated,
- valAxis = rotated ? "x" : "y",
- argAxis = rotated ? "y" : "x",
- valIntervalName = rotated ? "width" : "height",
- argIntervalName = rotated ? "height" : "width",
- argTranslator = translators[argAxis],
- valTranslator = translators[valAxis],
- argVisibleArea = argTranslator.getCanvasVisibleArea(),
- valVisibleArea = valTranslator.getCanvasVisibleArea(),
- arg,
- minArg,
- val,
- minVal;
- arg = minArg = argTranslator.translate(that.argument) + (that[argAxis + "Correction"] || 0);
- val = valTranslator.translate(that.value);
- minVal = valTranslator.translate(that.minValue);
- that[valIntervalName] = _abs(val - minVal);
- that._calculateVisibility(rotated ? _min(val, minVal) : _min(arg, minArg), rotated ? _min(arg, minArg) : _min(val, minVal), that.width, that.height);
- val = that._truncateCoord(val, valVisibleArea.min, valVisibleArea.max);
- minVal = that._truncateCoord(minVal, valVisibleArea.min, valVisibleArea.max);
- that[argAxis] = arg;
- that["min" + argAxis.toUpperCase()] = minArg;
- that[valIntervalName] = _abs(val - minVal);
- that[valAxis] = _min(val, minVal) + (that[valAxis + "Correction"] || 0);
- that["min" + valAxis.toUpperCase()] = minVal + (that[valAxis + "Correction"] || 0);
- that["default" + valAxis.toUpperCase()] = valTranslator.translate(CANVAS_POSITION_DEFAULT);
- if (that.inVisibleArea) {
- if (that[argAxis] < argVisibleArea.min) {
- that[argIntervalName] = that[argIntervalName] - (argVisibleArea.min - that[argAxis]);
- that[argAxis] = argVisibleArea.min;
- that["min" + argAxis.toUpperCase()] = argVisibleArea.min
- }
- if (that[argAxis] + that[argIntervalName] > argVisibleArea.max)
- that[argIntervalName] = argVisibleArea.max - that[argAxis]
- }
- },
- _updateMarker: function(animationEnabled, style) {
- var style = style || this._getStyle(),
- attributes = _extend({}, style);
- if (!animationEnabled) {
- attributes.x = this.x;
- attributes.y = this.y;
- attributes.width = this.width;
- attributes.height = this.height
- }
- else
- attributes.sharpEdges = false;
- this.graphic.applySettings(attributes)
- },
- _updateTracker: function() {
- this.trackerGraphic.applySettings(this._getSettingsForTracker())
- }
- })
- })(jQuery, DevExpress);
- /*! Module viz-core, file bubblePoint.js */
- (function($, DX) {
- var viz = DX.viz,
- points = viz.core.series.points.mixins,
- _extend = $.extend,
- MIN_BUBBLE_HEIGHT = 20;
- points.bubblePoint = _extend({}, points.symbolPoint, {
- correctCoordinates: function(diameter) {
- this.bubbleSize = diameter / 2
- },
- _drawMarker: function(renderer, group, animationEnabled) {
- var style = this._getStyle(),
- attr = _extend({
- translateX: this.x,
- translateY: this.y
- }, style),
- marker = renderer.createCircle(0, 0, animationEnabled ? 0 : this.bubbleSize, attr).append(group);
- this.graphic = marker
- },
- _drawTrackerMarker: function(renderer, group) {
- this.trackerGraphic = renderer.createCircle(this.x, this.y, this.bubbleSize).append(group);
- this.trackerGraphic.data({point: this})
- },
- getTooltipCoords: function() {
- if (this.graphic) {
- var height = this.graphic.getBBox().height;
- return {
- x: this.x,
- y: this.y,
- offset: height < MIN_BUBBLE_HEIGHT ? height / 2 : 0
- }
- }
- },
- _getLabelFormatObject: function() {
- var symbolMethods = points.symbolPoint,
- formatObject = symbolMethods._getLabelFormatObject.call(this);
- formatObject.size = this.initialSize;
- return formatObject
- },
- _updateData: function(data) {
- var symbolMethods = points.symbolPoint;
- if (this.argument !== data.argument || this.value !== data.value || this.size !== data.size || this.tag !== data.tag) {
- symbolMethods._changeData.call(this, data);
- this.size = this.initialSize = data.size
- }
- },
- _getGraphicBbox: function() {
- return this._getSymbolBbox(this.x, this.y, this.bubbleSize)
- },
- _updateMarker: function(animationEnabled, style) {
- var style = style || this._getStyle();
- if (!animationEnabled)
- style = $.extend({
- r: this.bubbleSize,
- translateX: this.x,
- translateY: this.y
- }, style);
- this.graphic.applySettings(style)
- },
- _updateTracker: function() {
- this.trackerGraphic.applySettings({
- cx: this.x,
- cy: this.y,
- r: this.bubbleSize
- })
- },
- _getFormatObject: function(tooltip) {
- var symbolMethods = points.symbolPoint,
- formatObject = symbolMethods._getFormatObject.call(this, tooltip);
- formatObject.sizeText = tooltip.formatValue(this.initialSize);
- return formatObject
- }
- })
- })(jQuery, DevExpress);
- /*! Module viz-core, file piePoint.js */
- (function($, DX) {
- var viz = DevExpress.viz,
- points = viz.core.series.points.mixins,
- _extend = $.extend,
- _round = Math.round,
- _getCosAndSin = DX.utils.getCosAndSin;
- points.piePoint = _extend({}, points.symbolPoint, {
- _populatePointShape: function(target, deltaRadius) {
- var angleFunctions = _getCosAndSin(point.middleAngle);
- target.x = point.centerX - ~~(deltaRadius * angleFunctions.cos);
- target.y = point.centerY + ~~(deltaRadius * angleFunctions.sin);
- target.outerRadius = this.radiusOuter + deltaRadius;
- target.innerRadius = this.radiusInner;
- target.startAngle = this.toAngle;
- target.endAngle = this.fromAngle
- },
- _changeData: function(data) {
- var that = this;
- that.value = that.initialValue = that.originalValue = data.value;
- that.argument = that.initialArgument = that.originalArgument = data.argument;
- that.minValue = that.initialMinValue = that.originalMinValue = DevExpress.utils.isDefined(data.minValue) ? data.minValue : 0;
- that.tag = data.tag;
- that._visible = true;
- that.index = data.index
- },
- animate: function(complete, duration, step) {
- this.graphic.animate({
- x: this.centerX,
- y: this.centerY,
- outerRadius: this.radiusOuter,
- innerRadius: this.radiusInner,
- startAngle: this.toAngle,
- endAngle: this.fromAngle
- }, {
- partitionDuration: duration,
- step: step
- }, complete)
- },
- correctPosition: function(correction) {
- this.radiusInner = correction.radiusInner;
- this.radiusOuter = correction.radiusOuter;
- this.centerX = correction.centerX;
- this.centerY = correction.centerY
- },
- correctValue: function(correction, percent, base) {
- this.value = (base || this.initialValue) + correction;
- this.minValue = correction;
- this.percent = percent;
- this._label.setDataField("percent", percent)
- },
- _getLabelOptions: function() {
- var options = this._options,
- series = options.series,
- seriesStyle = this._options.styles.normal,
- borderWidth = series._options.containerBackgroundColor === seriesStyle.stroke ? _round(seriesStyle.strokeWidth / 2) : _round(-seriesStyle.strokeWidth / 2);
- return {
- options: options.label,
- borderWidth: borderWidth
- }
- },
- _updateLabelData: function() {
- this._label.updateData({formatObject: this._getLabelFormatObject()})
- },
- _updateLabelOptions: function() {
- !this._label && this._createLabel();
- this._label.setOptions(this._getLabelOptions())
- },
- _drawLabel: function(renderer, group) {
- var commonVisibility = this._options.series.getLabelVisibility(),
- customVisibility = this._getCustomLabelVisibility();
- if ((commonVisibility || customVisibility) && this.hasValue()) {
- this._label.setCoords({
- middleAngle: this.middleAngle,
- radiusOuter: this.radiusOuter,
- centerX: this.centerX,
- centerY: this.centerY
- }, this._options.series.canvas);
- this._label.draw(renderer, group, customVisibility)
- }
- else
- this._label.hide()
- },
- _drawMarker: function(renderer, group, animationEnabled, firstDrawing) {
- var styles = this._getStyle(),
- radiusOuter = this.radiusOuter,
- radiusInner = this.radiusInner,
- fromAngle = this.fromAngle,
- toAngle = this.toAngle;
- if (animationEnabled) {
- radiusInner = radiusOuter = 0;
- if (!firstDrawing)
- fromAngle = toAngle = this.shiftedAngle
- }
- this.graphic = renderer.createArc(this.centerX, this.centerY, radiusOuter, radiusInner, toAngle, fromAngle, styles).append(group)
- },
- _drawTrackerMarker: function(renderer, group) {
- this.trackerGraphic = renderer.createArc(this.centerX, this.centerY, this.radiusOuter, this.radiusInner, this.toAngle, this.fromAngle).append(group);
- this.trackerGraphic.data({point: this})
- },
- getTooltipCoords: function() {
- var angleFunctions = _getCosAndSin(this.middleAngle);
- return {
- x: this.centerX + (this.radiusInner + (this.radiusOuter - this.radiusInner) / 2) * angleFunctions.cos,
- y: this.centerY - (this.radiusInner + (this.radiusOuter - this.radiusInner) / 2) * angleFunctions.sin,
- offset: 0
- }
- },
- _translate: function(translator) {
- var angle = this.shiftedAngle || 0;
- this.fromAngle = translator.translate(this.minValue) + angle;
- this.toAngle = translator.translate(this.value) + angle;
- this.middleAngle = translator.translate((this.value - this.minValue) / 2 + this.minValue) + angle;
- if (!this.isVisible())
- this.middleAngle = this.toAngle = this.fromAngle = this.fromAngle || angle
- },
- _updateMarker: function(animationEnabled, style) {
- style = style || this._getStyle();
- if (!animationEnabled)
- style = _extend({
- x: this.centerX,
- y: this.centerY,
- outerRadius: this.radiusOuter,
- innerRadius: this.radiusInner,
- startAngle: this.toAngle,
- endAngle: this.fromAngle
- }, style);
- this.graphic.applySettings(style)
- },
- _updateTracker: function() {
- this.trackerGraphic.applySettings({
- x: this.centerX,
- y: this.centerY,
- outerRadius: this.radiusOuter,
- innerRadius: this.radiusInner,
- startAngle: this.toAngle,
- endAngle: this.fromAngle
- })
- },
- getLegendStyles: function() {
- return this._styles.legendStyles
- },
- isInVisibleArea: function() {
- return true
- },
- hide: function() {
- if (this._visible) {
- this._visible = false;
- this.hideTooltip();
- this._options.visibilityChanged(this)
- }
- },
- show: function() {
- if (!this._visible) {
- this._visible = true;
- this._options.visibilityChanged(this)
- }
- },
- setInvisibility: function() {
- this._setTrackerInvisibility();
- this._label.hide()
- },
- isVisible: function() {
- return this._visible
- },
- _getFormatObject: function(tooltip) {
- var symbolMethods = points.symbolPoint,
- formatObject = symbolMethods._getFormatObject.call(this, tooltip);
- formatObject.percent = this.percent;
- formatObject.percentText = tooltip.formatValue(this.percent, "percent");
- return formatObject
- },
- getColor: function() {
- return this._styles.normal.fill
- }
- })
- })(jQuery, DevExpress);
- /*! Module viz-core, file rangeSymbolPoint.js */
- (function($, DX) {
- var viz = DevExpress.viz,
- points = viz.core.series.points.mixins,
- _extend = $.extend,
- _isDefined = DX.utils.isDefined,
- _math = Math,
- _abs = _math.abs,
- _min = _math.min,
- _max = _math.max,
- _round = _math.round,
- DEFAULT_IMAGE_WIDTH = 20,
- DEFAULT_IMAGE_HEIGHT = 20;
- points.rangeSymbolPoint = _extend({}, points.symbolPoint, {
- deleteLabel: function() {
- this._topLabel.dispose();
- this._topLabel = null;
- this._bottomLabel.dispose();
- this._bottomLabel = null
- },
- hideMarker: function(type) {
- var marker = this.graphic && this.graphic[type + "Marker"],
- label = this["_" + type + "Label"];
- if (marker && marker.settings.visibility !== "hidden")
- marker.applySettings({visibility: "hidden"});
- label.hide()
- },
- setInvisibility: function() {
- this.hideMarker("top");
- this.hideMarker("bottom");
- this._setTrackerInvisibility()
- },
- clearVisibility: function() {
- var graphic = this.graphic;
- if (graphic) {
- if (graphic.topMarker && graphic.topMarker.settings.visibility)
- graphic.topMarker.applySettings({visibility: null});
- if (graphic.bottomMarker && graphic.bottomMarker.settings.visibility)
- graphic.bottomMarker.applySettings({visibility: null})
- }
- this._clearTrackerVisibility();
- this._topLabel.clearVisibility();
- this._bottomLabel.clearVisibility()
- },
- clearMarker: function() {
- if (this.graphic) {
- this.graphic.topMarker && this.graphic.topMarker.applySettings(this._emptySettings);
- this.graphic.bottomMarker && this.graphic.bottomMarker.applySettings(this._emptySettings)
- }
- },
- _getLabelPosition: function(markerType) {
- var position,
- rotated = this._options.rotated,
- invertY = this.translators.y.getBusinessRange().invert,
- invertX = this.translators.x.getBusinessRange().invert,
- isDiscreteValue = this._options.series._options.valueAxisType === "discrete",
- notInverted = isDiscreteValue && (!invertY && !rotated || invertX && rotated) || !isDiscreteValue && this.value > this.minValue && (!invertY && !rotated || !invertX && rotated);
- if (markerType === "top")
- position = notInverted ? "top" : "bottom";
- else
- position = notInverted ? "bottom" : "top";
- return position
- },
- _getLabelMinFormatObject: function() {
- return {
- index: 0,
- argument: this.initialArgument,
- value: this.initialMinValue,
- seriesName: this._options.series.name,
- originalValue: this.originalMinValue,
- originalArgument: this.originalArgument,
- point: this
- }
- },
- _updateLabelData: function() {
- var maxFormatObject = this._getLabelFormatObject();
- maxFormatObject.index = 1;
- this._topLabel.updateData({
- formatObject: maxFormatObject,
- initialValue: this.initialValue
- });
- this._bottomLabel.updateData({
- formatObject: this._getLabelMinFormatObject(),
- initialValue: this.initialMinValue
- })
- },
- _updateLabelOptions: function(type) {
- var options = this._getLabelOptions(type);
- (!this._topLabel || !this._bottomLabel) && this._createLabel();
- this._topLabel.setOptions(options);
- this._bottomLabel.setOptions(options)
- },
- setAdjustSeriesLabels: function(adjustSeriesLabels) {
- this._topLabel.adjustSeriesLabels = adjustSeriesLabels;
- this._bottomLabel.adjustSeriesLabels = adjustSeriesLabels
- },
- _createLabel: function() {
- this._topLabel = viz.core.CoreFactory.createLabel();
- this._bottomLabel = viz.core.CoreFactory.createLabel()
- },
- _getLabelCoords: function(location) {
- var coords = {},
- isTop = location === "top";
- if (!this._options.rotated) {
- coords.x = this.x;
- coords.y = isTop ? _min(this.y, this.minY) : _max(this.y, this.minY)
- }
- else {
- coords.x = isTop ? _max(this.x, this.minX) : _min(this.x, this.minX);
- coords.y = this.y
- }
- return coords
- },
- _getGraphicBbox: function(location) {
- var options = this._options,
- rotated = options.rotated,
- isTop = location === "top",
- images = this._getImage(options.image),
- image = isTop ? this._checkImage(images.top) : this._checkImage(images.bottom),
- bbox,
- x,
- y;
- if (!rotated) {
- x = this.x;
- y = isTop ? _min(this.y, this.minY) : _max(this.y, this.minY)
- }
- else {
- x = isTop ? _max(this.x, this.minX) : _min(this.x, this.minX);
- y = this.y
- }
- if (options.visible)
- bbox = image ? this._getImageBbox(x, y) : this._getSymbolBbox(x, y, options.styles.normal.r);
- else
- bbox = {
- x: x,
- y: y,
- width: 0,
- height: 0
- };
- return bbox
- },
- _checkOverlay: function(bottomCoord, topCoord, topValue) {
- return bottomCoord < topCoord + topValue
- },
- _getOverlayCorrections: function(type, topCoords, bottomCoords) {
- var isVertical = type === "vertical",
- coordSelector = isVertical ? "y" : "x",
- valueSelector = isVertical ? "height" : "width",
- visibleArea = this.translators[coordSelector].getCanvasVisibleArea(),
- minBound = visibleArea.min,
- maxBound = visibleArea.max,
- delta = _round((topCoords[coordSelector] + topCoords[valueSelector] - bottomCoords[coordSelector]) / 2),
- coord1 = topCoords[coordSelector] - delta,
- coord2 = bottomCoords[coordSelector] + delta;
- if (coord1 < minBound) {
- delta = minBound - topCoords[coordSelector];
- coord1 += delta;
- coord2 += delta
- }
- else if (coord2 + bottomCoords[valueSelector] > maxBound) {
- delta = -(bottomCoords[coordSelector] + bottomCoords[valueSelector] - maxBound);
- coord1 += delta;
- coord2 += delta
- }
- return {
- coord1: coord1,
- coord2: coord2
- }
- },
- _checkLabelsOverlay: function(topLocation) {
- var that = this,
- topCoords = that._topLabel.getCoords(),
- bottomCoords = that._bottomLabel.getCoords(),
- corrections = {};
- if (!that._options.rotated) {
- if (topLocation === "top") {
- if (this._checkOverlay(bottomCoords.y, topCoords.y, topCoords.height)) {
- corrections = this._getOverlayCorrections("vertical", topCoords, bottomCoords);
- that._topLabel.updatePosition(undefined, corrections.coord1);
- that._bottomLabel.updatePosition(undefined, corrections.coord2)
- }
- }
- else if (this._checkOverlay(topCoords.y, bottomCoords.y, bottomCoords.height)) {
- corrections = this._getOverlayCorrections("vertical", bottomCoords, topCoords);
- that._topLabel.updatePosition(undefined, corrections.coord2);
- that._bottomLabel.updatePosition(undefined, corrections.coord1)
- }
- }
- else if (topLocation === "top") {
- if (this._checkOverlay(topCoords.x, bottomCoords.x, bottomCoords.width)) {
- corrections = this._getOverlayCorrections("horizontal", bottomCoords, topCoords);
- that._topLabel.updatePosition(corrections.coord2);
- that._bottomLabel.updatePosition(corrections.coord1)
- }
- }
- else if (this._checkOverlay(bottomCoords.x, topCoords.x, topCoords.width)) {
- corrections = this._getOverlayCorrections("horizontal", topCoords, bottomCoords);
- that._topLabel.updatePosition(corrections.coord1);
- that._bottomLabel.updatePosition(corrections.coord2)
- }
- },
- _drawLabel: function(renderer, group) {
- var topCoords,
- bottomCoords,
- rotated = this._options.rotated,
- topLocation = this._getLabelPosition("top"),
- bottomLocation = this._getLabelPosition("bottom"),
- isInside = this._options.label.position === "inside",
- topPosition = isInside ? bottomLocation : topLocation,
- bottomPosition = isInside ? topLocation : bottomLocation,
- translators = this.translators,
- visibleArea,
- customVisibility = this._getCustomLabelVisibility(),
- commonVisibility = this._options.series.getLabelVisibility();
- if ((commonVisibility || customVisibility) && this.hasValue()) {
- if (translators)
- visibleArea = {
- minX: translators.x.getCanvasVisibleArea().min,
- maxX: translators.x.getCanvasVisibleArea().max,
- minY: translators.y.getCanvasVisibleArea().min,
- maxY: translators.y.getCanvasVisibleArea().max
- };
- this._topLabel.setCoords(this._getLabelCoords(topLocation), this._getGraphicBbox(topLocation), topPosition, visibleArea);
- this._bottomLabel.setCoords(this._getLabelCoords(bottomLocation), this._getGraphicBbox(bottomLocation), bottomPosition, visibleArea);
- this.visibleTopMarker && this._topLabel.draw(renderer, group, customVisibility);
- this.visibleBottomMarker && this._bottomLabel.draw(renderer, group, customVisibility);
- this._checkLabelsOverlay(topLocation)
- }
- else {
- this._topLabel.hide();
- this._bottomLabel.hide()
- }
- },
- _getImage: function(imageOption) {
- var image = {};
- if (_isDefined(imageOption))
- if (typeof imageOption === "string")
- image.top = image.bottom = imageOption;
- else {
- image.top = {
- url: typeof imageOption.url === "string" ? imageOption.url : imageOption.url && imageOption.url.rangeMaxPoint,
- width: typeof imageOption.width === "number" ? imageOption.width : imageOption.width && imageOption.width.rangeMaxPoint,
- height: typeof imageOption.height === "number" ? imageOption.height : imageOption.height && imageOption.height.rangeMaxPoint
- };
- image.bottom = {
- url: typeof imageOption.url === "string" ? imageOption.url : imageOption.url && imageOption.url.rangeMinPoint,
- width: typeof imageOption.width === "number" ? imageOption.width : imageOption.width && imageOption.width.rangeMinPoint,
- height: typeof imageOption.height === "number" ? imageOption.height : imageOption.height && imageOption.height.rangeMinPoint
- }
- }
- return image
- },
- _checkSymbol: function(oldOptions, newOptions) {
- var oldSymbol = oldOptions.symbol,
- newSymbol = newOptions.symbol,
- symbolChanged = oldSymbol === "circle" && newSymbol !== "circle" || oldSymbol !== "circle" && newSymbol === "circle",
- oldImages = this._getImage(oldOptions.image),
- newImages = this._getImage(newOptions.image),
- topImageChanged = this._checkImage(oldImages.top) !== this._checkImage(newImages.top),
- bottomImageChanged = this._checkImage(oldImages.bottom) !== this._checkImage(newImages.bottom);
- return symbolChanged || topImageChanged || bottomImageChanged
- },
- _getSettingsForTwoMarkers: function(style) {
- var that = this,
- options = that._options,
- settings = {},
- x = options.rotated ? _min(that.x, that.minX) : that.x,
- y = options.rotated ? that.y : _min(that.y, that.minY),
- radius = style.r,
- points = that._populatePointShape(options.symbol, radius);
- settings.top = {
- r: radius,
- points: points,
- attr: _extend({
- translateX: x + that.width,
- translateY: y
- }, style)
- };
- settings.bottom = {
- r: radius,
- points: points,
- attr: _extend({
- translateX: x,
- translateY: y + that.height
- }, style)
- };
- return settings
- },
- _hasGraphic: function() {
- return this.graphic && this.graphic.topMarker && this.graphic.bottomMarker
- },
- _drawOneMarker: function(renderer, markerType, imageSettings, settings) {
- if (this.graphic[markerType])
- this._updateOneMarker(markerType, settings);
- else
- this.graphic[markerType] = this._createMarker(renderer, this.graphic, imageSettings, settings)
- },
- _drawMarker: function(renderer, group, animationEnabled, style) {
- var that = this,
- style = style || that._getStyle(),
- settings = that._getSettingsForTwoMarkers(style),
- image = that._getImage(that._options.image);
- if (that._checkImage(image.top))
- settings.top = that._getImageSettings(settings.top, image.top);
- if (that._checkImage(image.bottom))
- settings.bottom = that._getImageSettings(settings.bottom, image.bottom);
- that.graphic = that.graphic || renderer.createGroup().append(group);
- that.visibleTopMarker && that._drawOneMarker(renderer, 'topMarker', image.top, settings.top);
- that.visibleBottomMarker && that._drawOneMarker(renderer, 'bottomMarker', image.bottom, settings.bottom)
- },
- _getSettingsForTracker: function(radius) {
- var that = this,
- options = that._options,
- x = options.rotated ? _min(that.x, that.minX) - radius : that.x - radius,
- y = options.rotated ? that.y - radius : _min(that.y, that.minY) - radius,
- width = that.width + 2 * radius,
- height = that.height + 2 * radius;
- return {
- translateX: x,
- translateY: y,
- width: width,
- height: height
- }
- },
- _drawTrackerMarker: function(renderer, group) {
- var that = this,
- options = that._options,
- radius = options.trackerR || that.storeTrackerR(),
- settings = that._getSettingsForTracker(radius),
- attr = {
- translateX: settings.translateX,
- translateY: settings.translateY
- };
- that.trackerGraphic = renderer.createRect(0, 0, settings.width, settings.height, 0, attr).append(group);
- that.trackerGraphic.data({point: that})
- },
- isInVisibleArea: function() {
- var that = this,
- minArgument = _min(that.minX, that.x) || that.x,
- maxArgument = _max(that.minX, that.x) || that.x,
- maxValue = _max(that.minY, that.y) || that.y,
- minValue = _min(that.minY, that.y) || that.y,
- notVisibleBothMarkersRight,
- notVisibleBothMarkersLeft,
- notVisibleBothMarkersBottom,
- notVisibleBothMarkersTop,
- visibleTopMarker = true,
- visibleBottomMarker = true,
- visibleRangeArea = true,
- visibleAreaX,
- visibleAreaY;
- if (that.translators) {
- visibleAreaX = that.translators.x.getCanvasVisibleArea();
- visibleAreaY = that.translators.y.getCanvasVisibleArea();
- notVisibleBothMarkersRight = visibleAreaX.max < minArgument && visibleAreaX.max < maxArgument;
- notVisibleBothMarkersLeft = visibleAreaX.min > minArgument && visibleAreaX.min > maxArgument;
- notVisibleBothMarkersTop = visibleAreaY.min > minValue && visibleAreaY.min > maxValue;
- notVisibleBothMarkersBottom = visibleAreaY.max < minValue && visibleAreaY.max < maxValue;
- if (notVisibleBothMarkersTop || notVisibleBothMarkersBottom || notVisibleBothMarkersRight || notVisibleBothMarkersLeft)
- visibleTopMarker = visibleBottomMarker = visibleRangeArea = false;
- else if (!that._options.rotated) {
- visibleTopMarker = visibleAreaY.min < minValue && visibleAreaY.max > minValue;
- visibleBottomMarker = visibleAreaY.min < maxValue && visibleAreaY.max > maxValue
- }
- else {
- visibleBottomMarker = visibleAreaX.min < minArgument && visibleAreaX.max > minArgument;
- visibleTopMarker = visibleAreaX.min < maxArgument && visibleAreaX.max > maxArgument
- }
- }
- that.visibleTopMarker = visibleTopMarker;
- that.visibleBottomMarker = visibleBottomMarker;
- that.visibleRangeArea = visibleRangeArea;
- return visibleRangeArea
- },
- getTooltipCoords: function() {
- var that = this,
- x,
- y,
- min,
- max,
- minValue,
- visibleAreaX = that.translators.x.getCanvasVisibleArea(),
- visibleAreaY = that.translators.y.getCanvasVisibleArea();
- if (!that._options.rotated) {
- minValue = _min(that.y, that.minY);
- x = that.x;
- min = visibleAreaY.min > minValue ? visibleAreaY.min : minValue;
- max = visibleAreaY.max < minValue + that.height ? visibleAreaY.max : minValue + that.height;
- y = min + (max - min) / 2
- }
- else {
- minValue = _min(that.x, that.minX);
- y = that.y;
- min = visibleAreaX.min > minValue ? visibleAreaX.min : minValue;
- max = visibleAreaX.max < minValue + that.width ? visibleAreaX.max : minValue + that.width;
- x = min + (max - min) / 2
- }
- return {
- x: x,
- y: y,
- offset: 0
- }
- },
- _translate: function(translators) {
- var symbolMethods = points.symbolPoint;
- this.minX = this.minY = translators.y.translate(this.minValue);
- symbolMethods._translate.call(this, translators);
- this.height = this._options.rotated ? 0 : _abs(this.minY - this.y);
- this.width = this._options.rotated ? _abs(this.x - this.minX) : 0
- },
- _updateData: function(data) {
- if (this.argument !== data.argument || this.value !== data.value || this.minValue !== data.minValue || this.tag !== data.tag) {
- this._changeData(data);
- this.minValue = this.initialMinValue = this.originalMinValue = data.minValue
- }
- },
- _getImageSettings: function(settings, image) {
- var x = settings.attr.translateX,
- y = settings.attr.translateY;
- return {
- href: image.url || image.toString(),
- width: image.width || DEFAULT_IMAGE_WIDTH,
- height: image.height || DEFAULT_IMAGE_HEIGHT,
- attr: {
- translateX: x,
- translateY: y
- }
- }
- },
- _updateOneMarker: function(markerType, settings) {
- this.graphic && this.graphic[markerType] && this.graphic[markerType].applySettings(_extend({}, settings, settings.attr))
- },
- _updateMarker: function(animationEnabled, style) {
- this._drawMarker(undefined, undefined, undefined, style)
- },
- _updateTracker: function() {
- var radius = this.storeTrackerR(),
- settings = this._getSettingsForTracker(radius);
- this.trackerGraphic.applySettings(settings)
- },
- _getFormatObject: function(tooltip) {
- var minValue = tooltip.formatValue(this.initialMinValue),
- value = tooltip.formatValue(this.initialValue);
- return {
- argument: this.initialArgument,
- argumentText: tooltip.formatValue(this.initialArgument, "argument"),
- valueText: minValue + " - " + value,
- rangeValue1Text: minValue,
- rangeValue2Text: value,
- rangeValue1: this.initialMinValue,
- rangeValue2: this.initialValue,
- seriesName: this.series.name,
- point: this,
- originalMinValue: this.originalMinValue,
- originalValue: this.originalValue,
- originalArgument: this.originalArgument
- }
- }
- })
- })(jQuery, DevExpress);
- /*! Module viz-core, file rangeBarPoint.js */
- (function($, DX) {
- var viz = DevExpress.viz,
- points = viz.core.series.points.mixins,
- _isDefined = DX.utils.isDefined,
- rangeSymbolPointMethods = points.rangeSymbolPoint,
- _extend = $.extend;
- points.rangeBarPoint = _extend({}, points.barPoint, {
- deleteLabel: rangeSymbolPointMethods.deleteLabel,
- _getFormatObject: rangeSymbolPointMethods._getFormatObject,
- setAdjustSeriesLabels: rangeSymbolPointMethods.setAdjustSeriesLabels,
- clearVisibility: function() {
- if (this.graphic && this.graphic.settings.visibility)
- this.graphic.applySettings({visibility: null});
- this._topLabel.clearVisibility();
- this._bottomLabel.clearVisibility()
- },
- setInvisibility: function() {
- if (this.graphic && this.graphic.settings.visibility !== "hidden")
- this.graphic.applySettings({visibility: "hidden"});
- this._topLabel.hide();
- this._bottomLabel.hide()
- },
- _translate: function(translator) {
- var barMethods = points.barPoint;
- barMethods._translate.call(this, translator);
- if (this._options.rotated)
- this.width = this.width || 1;
- else
- this.height = this.height || 1
- },
- _updateData: rangeSymbolPointMethods._updateData,
- _getLabelPosition: rangeSymbolPointMethods._getLabelPosition,
- _getLabelMinFormatObject: rangeSymbolPointMethods._getLabelMinFormatObject,
- _updateLabelData: rangeSymbolPointMethods._updateLabelData,
- _updateLabelOptions: rangeSymbolPointMethods._updateLabelOptions,
- _createLabel: rangeSymbolPointMethods._createLabel,
- _checkOverlay: rangeSymbolPointMethods._checkOverlay,
- _getOverlayCorrections: rangeSymbolPointMethods._getOverlayCorrections,
- _drawLabel: function(renderer, group) {
- var topCoords,
- bottomCoords,
- rotated = this._options.rotated,
- topLocation = this._getLabelPosition("top"),
- bottomLocation = this._getLabelPosition("bottom"),
- bbox = this._getGraphicBbox(),
- coords = {
- x: this.x,
- y: this.y,
- defaultX: this.defaultX,
- defaultY: this.defaultY
- },
- translators = this.translators,
- visibleArea,
- customVisibility = this._getCustomLabelVisibility(),
- commonVisibility = this._options.series.getLabelVisibility();
- if ((customVisibility || commonVisibility) && this.hasValue()) {
- if (translators)
- visibleArea = {
- minX: translators.x.getCanvasVisibleArea().min,
- maxX: translators.x.getCanvasVisibleArea().max,
- minY: translators.y.getCanvasVisibleArea().min,
- maxY: translators.y.getCanvasVisibleArea().max
- };
- this._topLabel.setCoords(coords, bbox, topLocation, visibleArea);
- this._bottomLabel.setCoords(coords, bbox, bottomLocation, visibleArea);
- this._topLabel.draw(renderer, group, customVisibility);
- this._bottomLabel.draw(renderer, group, customVisibility);
- rangeSymbolPointMethods._checkLabelsOverlay.call(this, topLocation)
- }
- else {
- this._topLabel.hide();
- this._bottomLabel.hide()
- }
- }
- })
- })(jQuery, DevExpress);
- /*! Module viz-core, file candlestickPoint.js */
- (function($, DX) {
- var viz = DevExpress.viz,
- points = viz.core.series.points.mixins,
- _isNumeric = $.isNumeric,
- _extend = $.extend,
- _math = Math,
- _abs = _math.abs,
- _min = _math.min,
- _max = _math.max,
- _round = _math.round,
- DEFAULT_FINANCIAL_TRACKER_MARGIN = 2;
- points.candlestickPoint = _extend({}, points.barPoint, {
- _getContinuousPoints: function(minValueName, maxValueName) {
- var that = this,
- x = that.x,
- createPoint = that._options.rotated ? function(x, y) {
- return {
- x: y,
- y: x
- }
- } : function(x, y) {
- return {
- x: x,
- y: y
- }
- },
- width = that.width,
- min = that[minValueName],
- max = that[maxValueName],
- points;
- if (min === max)
- points = [createPoint(x, that.highY), createPoint(x, that.lowY), createPoint(x, that.closeY), createPoint(x - width / 2, that.closeY), createPoint(x + width / 2, that.closeY), createPoint(x, that.closeY)];
- else
- points = [createPoint(x, that.highY), createPoint(x, max), createPoint(x + width / 2, max), createPoint(x + width / 2, min), createPoint(x, min), createPoint(x, that.lowY), createPoint(x, min), createPoint(x - width / 2, min), createPoint(x - width / 2, max), createPoint(x, max)];
- return points
- },
- _getCategoryPoints: function(y) {
- var that = this,
- x = that.x,
- createPoint = that._options.rotated ? function(x, y) {
- return {
- x: y,
- y: x
- }
- } : function(x, y) {
- return {
- x: x,
- y: y
- }
- };
- return [createPoint(x, that.highY), createPoint(x, that.lowY), createPoint(x, y), createPoint(x - that.width / 2, y), createPoint(x + that.width / 2, y), createPoint(x, y)]
- },
- _getPoints: function() {
- var that = this,
- points,
- minValueName,
- maxValueName,
- openValue = that.openValue,
- closeValue = that.closeValue;
- if (_isNumeric(openValue) && _isNumeric(closeValue)) {
- minValueName = openValue > closeValue ? "closeY" : "openY";
- maxValueName = openValue > closeValue ? "openY" : "closeY";
- points = that._getContinuousPoints(minValueName, maxValueName)
- }
- else if (openValue === closeValue)
- points = [{
- x: that.x,
- y: that.highY
- }, {
- x: that.x,
- y: that.lowY
- }];
- else
- points = that._getCategoryPoints(_isNumeric(openValue) ? that.openY : that.closeY);
- return points
- },
- getColor: function() {
- return this._isReduction ? this._options.reduction.color : this._styles.normal.stroke || this.series.getColor()
- },
- _drawMarkerInGroup: function(group, attributes, renderer) {
- this.graphic = renderer.createArea(this._getPoints(), attributes).append(group)
- },
- _fillStyle: function() {
- var styles = this._options.styles;
- if (this._isReduction && this._isPositive)
- this._styles = styles.reductionPositive;
- else if (this._isReduction)
- this._styles = styles.reduction;
- else if (this._isPositive)
- this._styles = styles.positive;
- else
- this._styles = styles
- },
- _getMinTrackerWidth: function() {
- return 1 + 2 * this._styles.normal.strokeWidth
- },
- correctCoordinates: function(correctOptions) {
- var minWidth = this._getMinTrackerWidth(),
- maxWidth = 10;
- this.width = correctOptions.width < minWidth ? minWidth : correctOptions.width > maxWidth ? maxWidth : correctOptions.width;
- this.xCorrection = correctOptions.offset
- },
- _getMarkerGroup: function(group) {
- var markerGroup;
- if (this._isReduction && this._isPositive)
- markerGroup = group.reductionPositiveMarkersGroup;
- else if (this._isReduction)
- markerGroup = group.reductionMarkersGroup;
- else if (this._isPositive)
- markerGroup = group.defaultPositiveMarkersGroup;
- else
- markerGroup = group.defaultMarkersGroup;
- return markerGroup
- },
- _drawMarker: function(renderer, group) {
- var attributes = this._getStyle(),
- rotated = this._options.rotated,
- pointGroup = this._getMarkerGroup(group);
- this._drawMarkerInGroup(pointGroup, attributes, renderer)
- },
- _getSettingsForTracker: function() {
- var that = this,
- highY = that.highY,
- lowY = that.lowY,
- rotated = that._options.rotated,
- x,
- y,
- width,
- height;
- if (highY === lowY) {
- highY = rotated ? highY + DEFAULT_FINANCIAL_TRACKER_MARGIN : highY - DEFAULT_FINANCIAL_TRACKER_MARGIN;
- lowY = rotated ? lowY - DEFAULT_FINANCIAL_TRACKER_MARGIN : lowY + DEFAULT_FINANCIAL_TRACKER_MARGIN
- }
- if (rotated) {
- x = _min(lowY, highY);
- y = that.x - that.width / 2;
- width = _abs(lowY - highY);
- height = that.width
- }
- else {
- x = that.x - that.width / 2;
- y = _min(lowY, highY);
- width = that.width;
- height = _abs(lowY - highY)
- }
- return {
- x: x,
- y: y,
- width: width,
- height: height
- }
- },
- _drawTrackerMarker: function(renderer, group) {
- var settings = this._getSettingsForTracker();
- this.trackerGraphic = renderer.createRect(settings.x, settings.y, settings.width, settings.height, 0).append(group);
- this.trackerGraphic.data({point: this})
- },
- _getGraphicBbox: function() {
- var bbox = {},
- rotated = this._options.rotated;
- bbox.x = !rotated ? this.x - _round(this.width / 2) : this.lowY;
- bbox.y = !rotated ? this.highY : this.x - _round(this.width / 2);
- bbox.width = !rotated ? this.width : this.highY - this.lowY;
- bbox.height = !rotated ? this.lowY - this.highY : this.width;
- return bbox
- },
- _drawLabel: function(renderer, group) {
- var coords,
- commonVisibility = this._options.series.getLabelVisibility(),
- customVisibility = this._getCustomLabelVisibility(),
- visibleArea,
- reductionColor = this._options.reduction.color,
- translators = this.translators;
- if (this.hasValue() && (commonVisibility || customVisibility)) {
- visibleArea = {
- minX: translators.x.getCanvasVisibleArea().min,
- maxX: translators.x.getCanvasVisibleArea().max,
- minY: translators.y.getCanvasVisibleArea().min,
- maxY: translators.y.getCanvasVisibleArea().max
- };
- if (this._isReduction)
- this._label.updateOptions({options: {
- background: {fill: reductionColor},
- connector: {stroke: reductionColor}
- }});
- coords = this._options.rotated ? {
- x: this.highY,
- y: this.x
- } : {
- x: this.x,
- y: this.highY
- };
- this._label.setCoords(coords, this._getGraphicBbox(), "top", visibleArea);
- this._label.draw(renderer, group, customVisibility)
- }
- },
- getTooltipCoords: function() {
- var that = this;
- if (that.graphic) {
- var x,
- y,
- min,
- max,
- minValue = _min(that.lowY, that.highY),
- maxValue = _max(that.lowY, that.highY),
- visibleAreaX = that.translators.x.getCanvasVisibleArea(),
- visibleAreaY = that.translators.y.getCanvasVisibleArea();
- if (!that._options.rotated) {
- min = _max(visibleAreaY.min, minValue);
- max = _min(visibleAreaY.max, maxValue);
- x = that.x;
- y = min + (max - min) / 2
- }
- else {
- min = _max(visibleAreaX.min, minValue);
- max = _min(visibleAreaX.max, maxValue);
- y = that.x;
- x = min + (max - min) / 2
- }
- return {
- x: x,
- y: y,
- offset: 0
- }
- }
- },
- hasValue: function() {
- return this.highValue !== null && this.lowValue !== null
- },
- _translate: function(translator) {
- var that = this,
- rotated = that._options.rotated,
- argTranslator = rotated ? that.translators.y : that.translators.x,
- valTranslator = rotated ? that.translators.x : that.translators.y,
- centerValue,
- height;
- that.x = argTranslator.translate(that.argument) + (that.xCorrection || 0);
- that.openY = that.openValue !== null ? valTranslator.translate(that.openValue) : null;
- that.highY = valTranslator.translate(that.highValue);
- that.lowY = valTranslator.translate(that.lowValue);
- that.closeY = that.closeValue !== null ? valTranslator.translate(that.closeValue) : null;
- height = _abs(that.lowY - that.highY);
- centerValue = _min(that.lowY, that.highY) + _abs(that.lowY - that.highY) / 2;
- that._calculateVisibility(!rotated ? that.x : centerValue, !rotated ? centerValue : that.x)
- },
- _updateData: function(data) {
- var that = this;
- if (that.argument !== data.argument || that.reductionValue !== data.reductionValue || that.highValue !== data.highValue || that.lowValue !== data.lowValue || that.openValue !== data.openValue || that.closeValue !== data.closeValue || that.tag !== data.tag) {
- that.value = that.initialValue = data.reductionValue;
- that.originalValue = data.value;
- that.argument = that.initialArgument = data.argument;
- that.originalArgument = data.argument;
- that.lowValue = data.lowValue;
- that.originalLowValue = data.lowValue;
- that.highValue = data.highValue;
- that.originalHighValue = data.highValue;
- that.openValue = data.openValue;
- that.originalOpenValue = data.openValue;
- that.closeValue = data.closeValue;
- that.originalCloseValue = data.closeValue;
- that.tag = data.tag;
- that.pointClassName = data.pointClassName;
- that._isPositive = data.openValue < data.closeValue;
- that._isReduction = data.isReduction
- }
- },
- _updateMarker: function(animationEnabled, style, group) {
- var style = style || this._getStyle();
- this.graphic.applySettings(_extend({points: this._getPoints()}, style));
- group && this.graphic.append(this._getMarkerGroup(group))
- },
- _updateTracker: function() {
- this.trackerGraphic.applySettings(this._getSettingsForTracker())
- },
- _getLabelFormatObject: function() {
- return {
- openValue: this.openValue,
- highValue: this.highValue,
- lowValue: this.lowValue,
- closeValue: this.closeValue,
- reductionValue: this.initialValue,
- argument: this.initialArgument,
- value: this.initialValue,
- seriesName: this._options.series.name,
- originalOpenValue: this.originalOpenValue,
- originalCloseValue: this.originalCloseValue,
- originalLowValue: this.originalLowValue,
- originalHighValue: this.originalHighValue,
- originalArgument: this.originalArgument,
- point: this
- }
- },
- _getFormatObject: function(tooltip) {
- var highValue = tooltip.formatValue(this.highValue),
- openValue = tooltip.formatValue(this.openValue),
- closeValue = tooltip.formatValue(this.closeValue),
- lowValue = tooltip.formatValue(this.lowValue),
- symbolMethods = points.symbolPoint,
- formatObject = symbolMethods._getFormatObject.call(this, tooltip);
- return _extend({}, formatObject, {
- valueText: "h: " + highValue + (openValue !== "" ? " o: " + openValue : "") + (closeValue !== "" ? " c: " + closeValue : "") + " l: " + lowValue,
- highValueText: highValue,
- openValueText: openValue,
- closeValueText: closeValue,
- lowValueText: lowValue
- })
- }
- })
- })(jQuery, DevExpress);
- /*! Module viz-core, file stockPoint.js */
- (function($, DX) {
- var viz = DevExpress.viz,
- points = viz.core.series.points.mixins,
- _extend = $.extend,
- _isNumeric = $.isNumeric;
- points.stockPoint = _extend({}, points.candlestickPoint, {
- _getPoints: function() {
- var that = this,
- createPoint = that._options.rotated ? function(x, y) {
- return {
- x: y,
- y: x
- }
- } : function(x, y) {
- return {
- x: x,
- y: y
- }
- },
- openYExist = _isNumeric(that.openY),
- closeYExist = _isNumeric(that.closeY),
- x = that.x,
- width = that.width,
- points = [createPoint(x, that.highY), openYExist && createPoint(x, that.openY), openYExist && createPoint(x - width / 2, that.openY), openYExist && createPoint(x, that.openY), closeYExist && createPoint(x, that.closeY), closeYExist && createPoint(x + width / 2, that.closeY), closeYExist && createPoint(x, that.closeY), createPoint(x, that.lowY)];
- return points
- },
- _drawMarkerInGroup: function(group, attributes, renderer) {
- this.graphic = renderer.createPath(this._getPoints(), attributes).append(group)
- },
- _getMinTrackerWidth: function() {
- return 2 + this._styles.normal.strokeWidth
- }
- })
- })(jQuery, DevExpress);
- /*! Module viz-core, file default.js */
- (function($, DX, undefined) {
- DX.viz.themes = DX.viz.themes || [];
- var fontFamilyDefault = "'Segoe UI', 'Helvetica Neue', 'Trebuchet MS', Verdana",
- fontFamilyLight = "'Segoe UI Light', 'Helvetica Neue Light', 'Segoe UI', 'Helvetica Neue', 'Trebuchet MS', Verdana",
- baseChartTheme = {
- containerBackgroundColor: '#ffffff',
- animation: {
- enabled: true,
- duration: 1000,
- easing: 'easeOutCubic',
- maxPointCountSupported: 300
- },
- commonSeriesSettings: {
- border: {
- visible: false,
- width: 2
- },
- showInLegend: true,
- visible: true,
- hoverMode: 'excludePoints',
- selectionMode: 'includePoints',
- hoverStyle: {
- hatching: {
- direction: 'right',
- width: 2,
- step: 6,
- opacity: 0.75
- },
- border: {
- visible: false,
- width: 3
- }
- },
- selectionStyle: {
- hatching: {
- direction: 'right',
- width: 2,
- step: 6,
- opacity: 0.5
- },
- border: {
- visible: false,
- width: 3
- }
- },
- label: {
- visible: false,
- alignment: 'center',
- rotationAngle: 0,
- horizontalOffset: 0,
- verticalOffset: 0,
- radialOffset: 0,
- format: '',
- argumentFormat: '',
- precision: 0,
- argumentPrecision: 0,
- percentPrecision: 0,
- showForZeroValues: true,
- customizeText: undefined,
- maxLabelCount: undefined,
- position: 'outside',
- font: {color: '#ffffff'},
- border: {
- visible: false,
- width: 1,
- color: '#d3d3d3',
- dashStyle: 'solid'
- },
- connector: {
- visible: false,
- width: 1
- }
- }
- },
- redrawOnResize: true,
- margin: {
- left: 0,
- top: 0,
- right: 0,
- bottom: 0
- },
- seriesSelectionMode: 'single',
- pointSelectionMode: 'single',
- legend: {
- hoverMode: 'includePoints',
- verticalAlignment: 'top',
- horizontalAlignment: 'right',
- position: 'outside',
- visible: true,
- customizeText: undefined,
- itemTextPosition: undefined,
- margin: 10,
- equalColumnWidth: false,
- markerSize: 12,
- backgroundColor: undefined,
- backgroundOpacity: undefined,
- border: {
- visible: false,
- width: 1,
- color: '#d3d3d3',
- cornerRadius: 0,
- dashStyle: 'solid'
- },
- paddingLeftRight: 20,
- paddingTopBottom: 15,
- columnCount: 0,
- rowCount: 0,
- columnItemSpacing: 20,
- rowItemSpacing: 8
- },
- tooltip: {
- enabled: false,
- border: {
- width: 1,
- color: '#d3d3d3',
- dashStyle: 'solid',
- visible: true
- },
- font: {
- family: fontFamilyDefault,
- weight: 400,
- size: 12,
- color: '#232323'
- },
- color: '#ffffff',
- arrowLength: 10,
- paddingLeftRight: 18,
- paddingTopBottom: 15,
- shared: false,
- format: '',
- argumentFormat: '',
- precision: 0,
- argumentPrecision: 0,
- percentPrecision: 0,
- customizeText: undefined,
- customizeTooltip: undefined,
- shadow: {
- opacity: 0.4,
- offsetX: 0,
- offsetY: 4,
- blur: 2,
- color: '#000000'
- }
- },
- size: {
- width: undefined,
- height: undefined
- },
- loadingIndicator: {
- font: {},
- backgroundColor: '#ffffff',
- text: 'Loading...'
- },
- dataPrepareSettings: {
- checkTypeForAllData: false,
- convertToAxisDataType: true,
- sortingMethod: true
- },
- title: {
- font: {
- family: fontFamilyLight,
- weight: 200,
- color: '#232323',
- size: 28
- },
- margin: 10
- },
- adaptiveLayout: {
- width: 80,
- height: 80,
- keepLabels: true
- },
- _rtl: {legend: {itemTextPosition: 'left'}}
- },
- baseDarkChartTheme = {
- containerBackgroundColor: '#2b2b2b',
- commonSeriesSettings: {label: {border: {color: '#494949'}}},
- legend: {border: {color: '#494949'}},
- loadingIndicator: {backgroundColor: '#2b2b2b'},
- title: {font: {color: '#929292'}},
- tooltip: {
- color: '#2b2b2b',
- border: {color: '#494949'},
- font: {color: '#929292'}
- }
- };
- DX.viz.themes.push({
- name: 'desktop',
- font: {
- color: '#767676',
- family: fontFamilyDefault,
- weight: 400,
- size: 12,
- cursor: 'default'
- },
- chart: $.extend(true, {}, baseChartTheme, {
- commonSeriesSettings: {
- type: 'line',
- stack: 'default',
- point: {
- visible: true,
- symbol: 'circle',
- size: 12,
- border: {
- visible: false,
- width: 1
- },
- hoverMode: 'onlyPoint',
- selectionMode: 'onlyPoint',
- hoverStyle: {
- border: {
- visible: true,
- width: 4
- },
- size: 12
- },
- selectionStyle: {
- border: {
- visible: true,
- width: 4
- },
- size: 12
- }
- },
- scatter: {},
- line: {
- width: 2,
- dashStyle: 'solid',
- hoverStyle: {
- width: 3,
- hatching: {direction: 'none'}
- },
- selectionStyle: {width: 3}
- },
- stackedline: {
- width: 2,
- dashStyle: 'solid',
- hoverStyle: {
- width: 3,
- hatching: {direction: 'none'}
- },
- selectionStyle: {width: 3}
- },
- fullstackedline: {
- width: 2,
- dashStyle: 'solid',
- hoverStyle: {
- width: 3,
- hatching: {direction: 'none'}
- },
- selectionStyle: {width: 3}
- },
- stepline: {
- width: 2,
- dashStyle: 'solid',
- hoverStyle: {
- width: 3,
- hatching: {direction: 'none'}
- },
- selectionStyle: {width: 3}
- },
- area: {
- point: {visible: false},
- opacity: 0.5
- },
- stackedarea: {
- point: {visible: false},
- opacity: 0.5
- },
- fullstackedarea: {
- point: {visible: false},
- opacity: 0.5
- },
- steparea: {
- border: {
- visible: true,
- width: 2
- },
- point: {visible: false},
- hoverStyle: {border: {
- visible: true,
- width: 3
- }},
- selectionStyle: {border: {
- visible: true,
- width: 3
- }},
- opacity: 0.5
- },
- spline: {
- width: 2,
- hoverStyle: {
- width: 3,
- hatching: {direction: 'none'}
- },
- selectionStyle: {width: 3}
- },
- splinearea: {
- point: {visible: false},
- opacity: 0.5
- },
- bar: {
- cornerRadius: 0,
- point: {
- hoverStyle: {border: {visible: false}},
- selectionStyle: {border: {visible: false}}
- }
- },
- stackedbar: {
- cornerRadius: 0,
- point: {
- hoverStyle: {border: {visible: false}},
- selectionStyle: {border: {visible: false}}
- },
- label: {position: "inside"}
- },
- fullstackedbar: {
- cornerRadius: 0,
- point: {
- hoverStyle: {border: {visible: false}},
- selectionStyle: {border: {visible: false}}
- },
- label: {position: "inside"}
- },
- rangebar: {
- cornerRadius: 0,
- point: {
- hoverStyle: {border: {visible: false}},
- selectionStyle: {border: {visible: false}}
- }
- },
- rangearea: {
- point: {visible: false},
- opacity: 0.5
- },
- rangesplinearea: {
- point: {visible: false},
- opacity: 0.5
- },
- bubble: {
- opacity: 0.5,
- point: {
- hoverStyle: {border: {visible: false}},
- selectionStyle: {border: {visible: false}}
- }
- },
- candlestick: {
- width: 1,
- innerColor: '#ffffff',
- reduction: {color: '#ff0000'},
- hoverStyle: {
- width: 3,
- hatching: {direction: 'none'}
- },
- selectionStyle: {width: 3},
- point: {border: {visible: true}}
- },
- stock: {
- width: 1,
- reduction: {color: '#ff0000'},
- hoverStyle: {
- width: 3,
- hatching: {direction: 'none'}
- },
- selectionStyle: {width: 3},
- point: {border: {visible: true}}
- }
- },
- crosshair: {
- enabled: false,
- color: '#c6c6c6',
- width: 1,
- dashStyle: 'solid',
- verticalLine: {visible: true},
- horizontalLine: {visible: true}
- },
- commonAxisSettings: {
- tickInterval: undefined,
- setTicksAtUnitBeginning: true,
- valueMarginsEnabled: true,
- placeholderSize: null,
- logarithmBase: 10,
- discreteAxisDivisionMode: 'betweenLabels',
- visible: false,
- color: '#d3d3d3',
- width: 1,
- multipleAxesSpacing: 5,
- label: {
- visible: true,
- overlappingBehavior: {
- mode: 'auto',
- rotationAngle: 90,
- staggeringSpacing: 5
- },
- precision: 0,
- format: '',
- customizeText: undefined,
- indentFromAxis: 10
- },
- grid: {
- visible: false,
- color: '#d3d3d3',
- width: 1
- },
- tick: {
- visible: false,
- color: '#d3d3d3'
- },
- title: {
- font: {size: 16},
- margin: 10
- },
- stripStyle: {
- paddingLeftRight: 10,
- paddingTopBottom: 5
- },
- constantLineStyle: {
- paddingLeftRight: 10,
- paddingTopBottom: 10,
- width: 1,
- color: '#000000',
- dashStyle: 'solid',
- label: {
- visible: true,
- position: 'inside'
- }
- }
- },
- horizontalAxis: {
- isHorizontal: true,
- position: 'bottom',
- axisDivisionFactor: 50,
- label: {alignment: "center"},
- stripStyle: {label: {
- horizontalAlignment: 'center',
- verticalAlignment: 'top'
- }},
- constantLineStyle: {label: {
- horizontalAlignment: 'right',
- verticalAlignment: 'top'
- }},
- constantLines: {}
- },
- verticalAxis: {
- isHorizontal: false,
- position: 'left',
- axisDivisionFactor: 30,
- label: {
- alignment: 'right',
- overlappingBehavior: {mode: 'enlargeTickInterval'}
- },
- stripStyle: {label: {
- horizontalAlignment: 'left',
- verticalAlignment: 'center'
- }},
- constantLineStyle: {label: {
- horizontalAlignment: 'left',
- verticalAlignment: 'top'
- }},
- constantLines: {}
- },
- argumentAxis: {},
- valueAxis: {grid: {visible: true}},
- commonPaneSettings: {
- backgroundColor: 'none',
- border: {
- color: '#d3d3d3',
- width: 1,
- visible: false,
- top: true,
- bottom: true,
- left: true,
- right: true,
- dashStyle: 'solid'
- }
- },
- useAggregation: false,
- adjustOnZoom: true,
- rotated: false,
- synchronizeMultiAxes: true,
- equalBarWidth: true,
- minBubbleSize: 12,
- maxBubbleSize: 0.2
- }),
- pie: $.extend(true, {}, baseChartTheme, {
- commonSeriesSettings: {
- type: 'pie',
- pie: {
- border: {
- visible: false,
- width: 2,
- color: '#ffffff'
- },
- hoverStyle: {
- hatching: {
- direction: 'right',
- width: 4,
- step: 10,
- opacity: 0.75
- },
- border: {
- visible: false,
- width: 2
- }
- },
- selectionStyle: {
- hatching: {
- direction: 'right',
- width: 4,
- step: 10,
- opacity: 0.5
- },
- border: {
- visible: false,
- width: 2
- }
- }
- },
- doughnut: {
- innerRadius: 0.5,
- border: {
- visible: false,
- width: 2,
- color: '#ffffff'
- },
- hoverStyle: {
- hatching: {
- direction: 'right',
- width: 4,
- step: 10,
- opacity: 0.75
- },
- border: {
- visible: false,
- width: 2
- }
- },
- selectionStyle: {
- hatching: {
- direction: 'right',
- width: 4,
- step: 10,
- opacity: 0.5
- },
- border: {
- visible: false,
- width: 2
- }
- }
- },
- donut: {
- innerRadius: 0.5,
- border: {
- visible: false,
- width: 2,
- color: '#ffffff'
- },
- hoverStyle: {
- hatching: {
- direction: 'right',
- width: 4,
- step: 10,
- opacity: 0.75
- },
- border: {
- visible: false,
- width: 2
- }
- },
- selectionStyle: {
- hatching: {
- direction: 'right',
- width: 4,
- step: 10,
- opacity: 0.5
- },
- border: {
- visible: false,
- width: 2
- }
- }
- }
- },
- legend: {hoverMode: 'markPoint'},
- adaptiveLayout: {keepLabels: false}
- }),
- pieIE8: {commonSeriesSettings: {
- pie: {
- hoverStyle: {border: {
- visible: true,
- color: '#ffffff'
- }},
- selectionStyle: {border: {
- visible: true,
- color: '#ffffff'
- }}
- },
- donut: {
- hoverStyle: {border: {
- visible: true,
- color: '#ffffff'
- }},
- selectionStyle: {border: {
- visible: true,
- color: '#ffffff'
- }}
- },
- doughnut: {
- hoverStyle: {border: {
- visible: true,
- color: '#ffffff'
- }},
- selectionStyle: {border: {
- visible: true,
- color: '#ffffff'
- }}
- }
- }},
- gauge: {
- containerBackgroundColor: '#ffffff',
- scale: {
- majorTick: {
- visible: true,
- length: 5,
- width: 2,
- showCalculatedTicks: true,
- useTicksAutoArrangement: true,
- color: '#ffffff'
- },
- minorTick: {
- visible: false,
- length: 3,
- width: 1,
- showCalculatedTicks: true,
- color: '#ffffff'
- },
- label: {
- visible: true,
- font: {}
- }
- },
- rangeContainer: {
- offset: 0,
- width: 5,
- backgroundColor: '#808080'
- },
- valueIndicator: {
- _default: {color: '#c2c2c2'},
- rangebar: {
- space: 2,
- size: 10,
- color: '#cbc5cf',
- backgroundColor: 'none',
- text: {
- indent: 0,
- font: {
- size: 14,
- color: null
- }
- }
- },
- twocolorneedle: {secondColor: '#e18e92'},
- twocolorrectangle: {secondColor: '#e18e92'}
- },
- subvalueIndicator: {
- _default: {color: '#8798a5'},
- trianglemarker: {
- space: 2,
- length: 14,
- width: 13,
- color: '#8798a5'
- },
- triangle: {
- space: 2,
- length: 14,
- width: 13,
- color: '#8798a5'
- },
- textcloud: {
- arrowLength: 5,
- horizontalOffset: 6,
- verticalOffset: 3,
- color: '#679ec5',
- text: {font: {
- color: '#ffffff',
- size: 18
- }}
- }
- },
- valueIndicators: {
- _default: {color: '#c2c2c2'},
- rangebar: {
- space: 2,
- size: 10,
- color: '#cbc5cf',
- backgroundColor: 'none',
- text: {
- indent: 0,
- font: {
- size: 14,
- color: null
- }
- }
- },
- twocolorneedle: {secondColor: '#e18e92'},
- trianglemarker: {
- space: 2,
- length: 14,
- width: 13,
- color: '#8798a5'
- },
- textcloud: {
- arrowLength: 5,
- horizontalOffset: 6,
- verticalOffset: 3,
- color: '#679ec5',
- text: {font: {
- color: '#ffffff',
- size: 18
- }}
- }
- },
- title: {
- layout: {
- horizontalAlignment: 'center',
- verticalAlignment: 'top',
- overlay: 0
- },
- font: {
- size: 16,
- color: '#232323',
- family: fontFamilyDefault,
- weight: 400
- }
- },
- subtitle: {font: {
- size: 14,
- color: '#232323',
- family: fontFamilyDefault,
- weight: 400
- }},
- indicator: {
- hasPositiveMeaning: true,
- layout: {
- horizontalAlignment: 'center',
- verticalAlignment: 'bottom',
- overlay: 0
- },
- text: {font: {size: 18}}
- },
- tooltip: {
- arrowLength: 10,
- paddingLeftRight: 18,
- paddingTopBottom: 15,
- enabled: false,
- border: {
- width: 1,
- color: '#d3d3d3',
- dashStyle: 'solid',
- visible: true
- },
- color: '#ffffff',
- font: {
- color: '#232323',
- size: 12,
- family: fontFamilyDefault,
- weight: 400
- },
- shadow: {
- opacity: 0.4,
- offsetX: 0,
- offsetY: 4,
- blur: 2,
- color: '#000000'
- }
- },
- loadingIndicator: {
- font: {},
- backgroundColor: '#ffffff',
- text: 'Loading...'
- },
- _circular: {
- scale: {
- orientation: 'outside',
- label: {indentFromTick: 10}
- },
- rangeContainer: {orientation: 'outside'},
- valueIndicator: {
- type: 'rectangleneedle',
- _default: {
- offset: 20,
- indentFromCenter: 0,
- width: 2,
- spindleSize: 14,
- spindleGapSize: 10
- },
- triangleneedle: {width: 4},
- triangle: {width: 4},
- twocolorneedle: {
- space: 2,
- secondFraction: 0.4
- },
- twocolorrectangle: {
- space: 2,
- secondFraction: 0.4
- },
- rangebar: {offset: 30}
- },
- subvalueIndicator: {
- type: 'trianglemarker',
- trianglemarker: {offset: 6},
- triangle: {offset: 6},
- textcloud: {offset: -6}
- },
- valueIndicators: {
- _type: 'rectangleneedle',
- _default: {
- offset: 20,
- indentFromCenter: 0,
- width: 2,
- spindleSize: 14,
- spindleGapSize: 10
- },
- triangleneedle: {width: 4},
- twocolorneedle: {
- space: 2,
- secondFraction: 0.4
- },
- rangebar: {offset: 30},
- trianglemarker: {offset: 6},
- textcloud: {offset: -6}
- }
- },
- _linear: {
- scale: {
- horizontalOrientation: 'right',
- verticalOrientation: 'bottom',
- label: {indentFromTick: -10}
- },
- rangeContainer: {
- horizontalOrientation: 'right',
- verticalOrientation: 'bottom'
- },
- valueIndicator: {
- type: 'rangebar',
- _default: {
- offset: 2.5,
- length: 15,
- width: 15
- },
- rectangle: {width: 10},
- rangebar: {
- offset: 10,
- horizontalOrientation: 'right',
- verticalOrientation: 'bottom'
- }
- },
- subvalueIndicator: {
- type: 'trianglemarker',
- _default: {
- offset: -1,
- horizontalOrientation: 'left',
- verticalOrientation: 'top'
- }
- },
- valueIndicators: {
- _type: 'rectangle',
- _default: {
- offset: 2.5,
- length: 15,
- width: 15
- },
- rectangle: {width: 10},
- rangebar: {
- offset: 10,
- horizontalOrientation: 'right',
- verticalOrientation: 'bottom'
- },
- trianglemarker: {
- offset: -1,
- horizontalOrientation: 'left',
- verticalOrientation: 'top'
- },
- textcloud: {
- offset: -1,
- horizontalOrientation: 'left',
- verticalOrientation: 'top'
- }
- }
- }
- },
- barGauge: {
- backgroundColor: '#e0e0e0',
- relativeInnerRadius: 0.3,
- barSpacing: 4,
- label: {
- indent: 20,
- connectorWidth: 2,
- font: {size: 16}
- },
- title: {
- layout: {
- horizontalAlignment: 'center',
- verticalAlignment: 'top',
- overlay: 0
- },
- font: {
- size: 16,
- color: '#232323',
- family: fontFamilyDefault,
- weight: 400
- }
- },
- subtitle: {font: {
- size: 14,
- color: '#232323',
- family: fontFamilyDefault,
- weight: 400
- }},
- indicator: {
- hasPositiveMeaning: true,
- layout: {
- horizontalAlignment: 'center',
- verticalAlignment: 'bottom',
- overlay: 0
- },
- text: {font: {size: 18}}
- },
- tooltip: {
- arrowLength: 10,
- paddingLeftRight: 18,
- paddingTopBottom: 15,
- enabled: false,
- border: {
- width: 1,
- color: '#d3d3d3',
- dashStyle: 'solid',
- visible: true
- },
- color: '#ffffff',
- font: {
- size: 12,
- color: '#232323',
- family: fontFamilyDefault,
- weight: 400
- },
- shadow: {
- opacity: 0.4,
- offsetX: 0,
- offsetY: 4,
- blur: 2,
- color: '#000000'
- }
- },
- loadingIndicator: {
- font: {},
- backgroundColor: '#ffffff',
- text: 'Loading...'
- }
- },
- rangeSelector: {
- containerBackgroundColor: '#ffffff',
- scale: {
- label: {
- topIndent: 7,
- font: {size: 11}
- },
- tick: {
- width: 1,
- color: '#000000',
- opacity: 0.1
- },
- marker: {
- separatorHeight: 33,
- topIndent: 10,
- textLeftIndent: 7,
- textTopIndent: 11
- }
- },
- loadingIndicator: {
- font: {},
- backgroundColor: '#ffffff',
- text: 'Loading...'
- },
- sliderMarker: {
- padding: 7,
- pointerSize: 6,
- color: '#9b9b9b',
- invalidRangeColor: '#ff0000',
- font: {
- color: '#ffffff',
- size: 11
- }
- },
- sliderHandle: {
- width: 1,
- color: '#000000',
- opacity: 0.2
- },
- shutter: {
- color: undefined,
- opacity: 0.75
- },
- background: {color: "#c0bae1"},
- chart: {
- containerBackgroundColor: undefined,
- commonSeriesSettings: {
- label: baseChartTheme.commonSeriesSettings.label,
- border: {
- visible: false,
- width: 1
- },
- visible: true,
- type: 'area',
- hoverMode: 'none',
- hoverStyle: {border: {}},
- selectionStyle: {border: {}},
- point: {
- visible: false,
- symbol: 'circle',
- border: {
- visible: false,
- width: 1
- },
- size: 12,
- hoverStyle: {border: {}},
- selectionStyle: {border: {}}
- },
- line: {width: 2},
- stepline: {width: 2},
- scatter: {point: {visible: true}},
- stackedline: {width: 2},
- fullstackedline: {width: 2},
- area: {opacity: 0.5},
- stackedarea: {opacity: 0.5},
- fullstackedarea: {opacity: 0.5},
- spline: {width: 2},
- splinearea: {opacity: 0.5},
- steparea: {
- border: {
- visible: true,
- width: 2
- },
- opacity: 0.5
- },
- bubble: {
- opacity: 0.5,
- point: {visible: true}
- },
- bar: {
- cornerRadius: 0,
- point: {visible: true}
- },
- stackedbar: {
- cornerRadius: 0,
- point: {visible: true}
- },
- fullstackedbar: {
- cornerRadius: 0,
- point: {visible: true}
- },
- rangebar: {
- cornerRadius: 0,
- point: {visible: true}
- },
- rangearea: {opacity: 0.5},
- rangesplinearea: {opacity: 0.5},
- candlestick: {
- width: 1,
- innerColor: '#ffffff',
- reduction: {color: '#ff0000'}
- },
- stock: {
- width: 1,
- reduction: {color: '#ff0000'}
- }
- },
- dataPrepareSettings: {
- checkTypeForAllData: false,
- convertToAxisDataType: true,
- sortingMethod: true
- },
- useAggregation: false,
- equalBarWidth: true,
- minBubbleSize: 12,
- maxBubbleSize: 0.2,
- topIndent: 0.1,
- bottomIndent: 0,
- valueAxis: {
- min: undefined,
- max: undefined,
- inverted: false,
- logarithmBase: 10
- }
- }
- },
- map: {
- background: {
- borderWidth: 1,
- borderColor: '#cacaca',
- color: '#ffffff'
- },
- area: {
- borderWidth: 1,
- borderColor: '#ffffff',
- color: '#d2d2d2',
- hoveredBorderColor: '#303030',
- selectedBorderWidth: 2,
- selectedBorderColor: '#303030'
- },
- marker: {
- font: {
- color: '#2b2b2b',
- size: 12
- },
- _dot: {
- borderWidth: 2,
- borderColor: '#ffffff',
- color: '#ba4d51',
- size: 8,
- selectedStep: 2,
- backStep: 18,
- backColor: '#ffffff',
- backOpacity: 0.32,
- shadow: true
- },
- _bubble: {
- minSize: 20,
- maxSize: 50,
- color: '#ba4d51',
- hoveredBorderWidth: 1,
- hoveredBorderColor: '#303030',
- selectedBorderWidth: 2,
- selectedBorderColor: '#303030'
- },
- _pie: {
- size: 50,
- hoveredBorderWidth: 1,
- hoveredBorderColor: '#303030',
- selectedBorderWidth: 2,
- selectedBorderColor: '#303030'
- },
- _image: {size: 20}
- },
- controlBar: {
- borderColor: '#5d5d5d',
- borderWidth: 3,
- color: '#ffffff'
- },
- tooltip: {
- borderWidth: 1,
- borderColor: '#d7d7d7',
- arrowLength: 10,
- paddingLeftRight: 18,
- paddingTopBottom: 15,
- border: {
- width: 1,
- color: '#d3d3d3',
- dashStyle: 'solid',
- visible: true
- },
- color: '#ffffff',
- font: {
- color: '#232323',
- size: 12,
- family: fontFamilyDefault,
- weight: 400
- },
- shadow: {
- opacity: 0.4,
- offsetX: 0,
- offsetY: 4,
- blur: 2,
- color: '#000000'
- }
- },
- legend: {
- verticalAlignment: 'bottom',
- horizontalAlignment: 'right',
- position: 'inside',
- visible: true,
- margin: 10,
- equalColumnWidth: false,
- markerSize: 12,
- backgroundColor: '#ffffff',
- backgroundOpacity: 0.65,
- border: {
- visible: true,
- width: 1,
- color: '#cacaca',
- cornerRadius: 0,
- dashStyle: 'solid'
- },
- paddingLeftRight: 16,
- paddingTopBottom: 12,
- columnItemSpacing: 20,
- rowItemSpacing: 8,
- font: {
- color: '#2b2b2b',
- size: 12
- }
- },
- loadingIndicator: {
- backgroundColor: '#ffffff',
- font: {},
- text: 'Loading...'
- },
- _rtl: {legend: {itemTextPosition: 'left'}}
- },
- sparkline: {
- lineColor: '#666666',
- lineWidth: 2,
- areaOpacity: 0.2,
- minColor: '#e8c267',
- maxColor: '#e55253',
- barPositiveColor: '#a9a9a9',
- barNegativeColor: '#d7d7d7',
- winColor: '#a9a9a9',
- lossColor: '#d7d7d7',
- firstLastColor: '#666666',
- pointSymbol: 'circle',
- pointColor: '#ffffff',
- pointSize: 4,
- tooltip: {
- enabled: true,
- allowContainerResizing: true,
- verticalAlignment: 'top',
- horizontalAlignment: 'center',
- format: '',
- paddingLeftRight: 18,
- paddingTopBottom: 15,
- arrowLength: 10,
- precision: 0,
- color: '#ffffff',
- border: {
- width: 1,
- color: '#d3d3d3',
- dashStyle: 'solid',
- visible: true
- },
- font: {
- color: '#232323',
- family: fontFamilyDefault,
- size: 12,
- weight: 400
- },
- shadow: {
- opacity: 0.4,
- offsetX: 0,
- offsetY: 4,
- blur: 2,
- color: '#000000'
- }
- }
- },
- bullet: {
- color: '#e8c267',
- targetColor: '#666666',
- targetWidth: 4,
- showTarget: true,
- showZeroLevel: true,
- tooltip: {
- enabled: true,
- allowContainerResizing: true,
- verticalAlignment: 'top',
- horizontalAlignment: 'center',
- format: '',
- precision: 0,
- paddingLeftRight: 18,
- paddingTopBottom: 15,
- arrowLength: 10,
- color: '#ffffff',
- border: {
- width: 1,
- color: '#d3d3d3',
- dashStyle: 'solid',
- visible: true
- },
- font: {
- color: '#232323',
- family: fontFamilyDefault,
- size: 12,
- weight: 400
- },
- shadow: {
- opacity: 0.4,
- offsetX: 0,
- offsetY: 4,
- blur: 2,
- color: '#000000'
- }
- }
- }
- });
- DX.viz.core.registerTheme({
- name: 'desktop-dark',
- font: {color: '#808080'},
- chart: $.extend(true, {}, baseDarkChartTheme, {
- commonSeriesSettings: {candlestick: {innerColor: '#2b2b2b'}},
- crosshair: {color: '#515151'},
- commonAxisSettings: {
- color: '#494949',
- grid: {color: '#494949'},
- tick: {color: '#494949'},
- constantLineStyle: {color: '#ffffff'}
- },
- commonPaneSettings: {border: {color: '#494949'}}
- }),
- pie: $.extend(true, {}, baseDarkChartTheme),
- pieIE8: {commonSeriesSettings: {
- pie: {
- hoverStyle: {border: {color: '#2b2b2b'}},
- selectionStyle: {border: {color: '#2b2b2b'}}
- },
- donut: {
- hoverStyle: {border: {color: '#2b2b2b'}},
- selectionStyle: {border: {color: '#2b2b2b'}}
- },
- doughnut: {
- hoverStyle: {border: {color: '#2b2b2b'}},
- selectionStyle: {border: {color: '#2b2b2b'}}
- }
- }},
- gauge: {
- containerBackgroundColor: '#2b2b2b',
- scale: {
- majorTick: {color: '#303030'},
- minorTick: {color: '#303030'}
- },
- rangeContainer: {backgroundColor: '#b5b5b5'},
- valueIndicator: {
- _default: {color: '#b5b5b5'},
- rangebar: {color: '#84788b'},
- twocolorneedle: {secondColor: '#ba544d'},
- twocolorrectangle: {secondColor: '#ba544d'}
- },
- subvalueIndicator: {_default: {color: '#b7918f'}},
- valueIndicators: {
- _default: {color: '#b5b5b5'},
- rangebar: {color: '#84788b'},
- twocolorneedle: {secondColor: '#ba544d'},
- trianglemarker: {color: '#b7918f'},
- textcloud: {color: '#ba544d'}
- },
- title: {font: {color: '#929292'}},
- subtitle: {font: {color: '#929292'}},
- loadingIndicator: {backgroundColor: '#2b2b2b'},
- tooltip: {
- color: '#2b2b2b',
- border: {color: '#494949'},
- font: {color: '#929292'}
- }
- },
- barGauge: {
- title: {font: {color: '#929292'}},
- subtitle: {font: {color: '#929292'}},
- tooltip: {
- color: '#2b2b2b',
- border: {color: '#494949'},
- font: {color: '#929292'}
- },
- loadingIndicator: {backgroundColor: '#2b2b2b'}
- },
- rangeSelector: {
- containerBackgroundColor: '#2b2b2b',
- scale: {tick: {
- color: '#ffffff',
- opacity: 0.05
- }},
- loadingIndicator: {backgroundColor: '#2b2b2b'},
- sliderMarker: {
- color: '#b5b5b5',
- font: {color: '#303030'}
- },
- sliderHandle: {
- color: '#ffffff',
- opacity: 0.35
- },
- shutter: {
- color: '#2b2b2b',
- opacity: 0.9
- }
- },
- map: {
- background: {
- borderColor: '#3f3f3f',
- color: '#303030'
- },
- area: {
- borderColor: '#303030',
- color: '#686868',
- hoveredBorderColor: '#ffffff',
- selectedBorderColor: '#ffffff'
- },
- marker: {
- font: {color: '#ffffff'},
- _bubble: {
- hoveredBorderColor: '#ffffff',
- selectedBorderColor: '#ffffff'
- },
- _pie: {
- hoveredBorderColor: '#ffffff',
- selectedBorderColor: '#ffffff'
- }
- },
- controlBar: {
- borderColor: '#c7c7c7',
- color: '#303030'
- },
- legend: {
- border: {color: '#3f3f3f'},
- backgroundColor: '#303030',
- font: {color: '#ffffff'}
- },
- tooltip: {
- color: '#2b2b2b',
- border: {color: '#494949'},
- font: {color: '#929292'}
- },
- loadingIndicator: {backgroundColor: '#2b2b2b'}
- },
- sparkline: {
- lineColor: '#c7c7c7',
- firstLastColor: '#c7c7c7',
- barPositiveColor: '#b8b8b8',
- barNegativeColor: '#8e8e8e',
- winColor: '#b8b8b8',
- lossColor: '#8e8e8e',
- pointColor: '#303030',
- tooltip: {
- color: '#2b2b2b',
- border: {color: '#494949'},
- font: {color: '#929292'}
- }
- },
- bullet: {
- targetColor: '#8e8e8e',
- tooltip: {
- color: '#2b2b2b',
- border: {color: '#494949'},
- font: {color: '#929292'}
- }
- }
- }, 'desktop')
- })(jQuery, DevExpress);
- /*! Module viz-core, file android.js */
- (function($, DX, undefined) {
- var baseChartTheme = {
- containerBackgroundColor: '#050506',
- title: {font: {color: '#ffffff'}},
- commonSeriesSettings: {label: {border: {color: '#4c4c4c'}}},
- legend: {
- font: {
- color: '#ffffff',
- size: 11
- },
- border: {color: '#4c4c4c'}
- },
- loadingIndicator: {backgroundColor: '#050506'},
- tooltip: {
- color: '#050506',
- border: {color: '#4c4c4c'},
- font: {color: '#ffffff'}
- }
- },
- baseLightChartTheme = {
- containerBackgroundColor: '#e8e8e8',
- title: {font: {color: '#808080'}},
- legend: {font: {
- color: '#000000',
- size: 11
- }},
- loadingIndicator: {backgroundColor: '#e8e8e8'},
- tooltip: {
- color: '#e8e8e8',
- font: {color: '#808080'}
- }
- };
- DX.viz.core.registerTheme({
- name: 'android',
- chart: $.extend(true, {}, baseChartTheme, {
- commonSeriesSettings: {candlestick: {innerColor: '#050506'}},
- commonAxisSettings: {
- color: '#4c4c4c',
- grid: {color: '#4c4c4c'},
- tick: {color: '#4c4c4c'},
- title: {font: {color: '#545455'}},
- label: {font: {
- color: '#ffffff',
- size: 11
- }}
- },
- commonPaneSettings: {border: {color: '#4c4c4c'}}
- }),
- pie: $.extend(true, {}, baseChartTheme),
- pieIE8: {commonSeriesSettings: {
- pie: {
- hoverStyle: {border: {color: '#050506'}},
- selectionStyle: {border: {color: '#050506'}}
- },
- donut: {
- hoverStyle: {border: {color: '#050506'}},
- selectionStyle: {border: {color: '#050506'}}
- },
- doughnut: {
- hoverStyle: {border: {color: '#050506'}},
- selectionStyle: {border: {color: '#050506'}}
- }
- }},
- gauge: {
- containerBackgroundColor: '#050506',
- title: {font: {color: '#ffffff'}},
- subtitle: {font: {color: '#ffffff'}},
- loadingIndicator: {backgroundColor: '#050506'},
- tooltip: {
- color: '#050506',
- border: {color: '#4c4c4c'},
- font: {color: '#ffffff'}
- }
- },
- barGauge: {
- title: {font: {color: '#ffffff'}},
- subtitle: {font: {color: '#ffffff'}},
- tooltip: {
- color: '#050506',
- border: {color: '#4c4c4c'},
- font: {color: '#ffffff'}
- },
- loadingIndicator: {backgroundColor: '#050506'}
- },
- rangeSelector: {
- containerBackgroundColor: '#050506',
- loadingIndicator: {backgroundColor: '#050506'}
- },
- map: {
- loadingIndicator: {backgroundColor: '#050506'},
- tooltip: {
- color: '#050506',
- border: {color: '#4c4c4c'},
- font: {color: '#ffffff'}
- }
- },
- sparkline: {tooltip: {
- color: '#050506',
- border: {color: '#4c4c4c'},
- font: {color: '#ffffff'}
- }},
- bullet: {tooltip: {
- color: '#050506',
- border: {color: '#4c4c4c'},
- font: {color: '#ffffff'}
- }}
- }, 'desktop-dark');
- DX.viz.core.registerTheme({
- name: 'android-holo-light',
- chart: $.extend(true, {}, baseLightChartTheme, {
- commonSeriesSettings: {candlestick: {innerColor: '#e8e8e8'}},
- commonAxisSettings: {
- title: {font: {color: '#939393'}},
- label: {font: {
- color: '#404040',
- size: 11
- }}
- }
- }),
- pie: $.extend(true, {}, baseLightChartTheme),
- pieIE8: {commonSeriesSettings: {
- pie: {
- hoverStyle: {border: {color: '#e8e8e8'}},
- selectionStyle: {border: {color: '#e8e8e8'}}
- },
- donut: {
- hoverStyle: {border: {color: '#e8e8e8'}},
- selectionStyle: {border: {color: '#e8e8e8'}}
- },
- doughnut: {
- hoverStyle: {border: {color: '#e8e8e8'}},
- selectionStyle: {border: {color: '#e8e8e8'}}
- }
- }},
- gauge: {
- containerBackgroundColor: '#e8e8e8',
- title: {font: {color: '#808080'}},
- subtitle: {font: {color: '#808080'}},
- loadingIndicator: {backgroundColor: '#e8e8e8'},
- tooltip: {
- color: '#e8e8e8',
- font: {color: '#808080'}
- }
- },
- barGauge: {
- title: {font: {color: '#808080'}},
- subtitle: {font: {color: '#808080'}},
- tooltip: {
- color: '#e8e8e8',
- font: {color: '#808080'}
- },
- loadingIndicator: {backgroundColor: '#e8e8e8'}
- },
- rangeSelector: {
- containerBackgroundColor: '#e8e8e8',
- loadingIndicator: {backgroundColor: '#e8e8e8'}
- },
- map: {
- loadingIndicator: {backgroundColor: '#e8e8e8'},
- tooltip: {
- color: '#e8e8e8',
- font: {color: '#808080'}
- }
- },
- sparkline: {tooltip: {
- color: '#e8e8e8',
- font: {color: '#808080'}
- }},
- bullet: {tooltip: {
- color: '#e8e8e8',
- font: {color: '#808080'}
- }}
- }, 'desktop')
- })(jQuery, DevExpress);
- /*! Module viz-core, file ios.js */
- (function($, DX, undefined) {
- var baseChartTheme = {
- containerBackgroundColor: '#cbd0da',
- title: {font: {color: '#808080'}},
- commonSeriesSettings: {label: {border: {color: '#b0b3ba'}}},
- legend: {
- font: {
- color: '#000000',
- size: 11
- },
- border: {color: '#b0b3ba'}
- },
- loadingIndicator: {backgroundColor: '#cbd0da'},
- tooltip: {font: {color: '#808080'}}
- },
- baseIos7ChartTheme = {
- containerBackgroundColor: '#ffffff',
- title: {font: {color: '#808080'}},
- commonSeriesSettings: {label: {border: {color: '#d3d3d3'}}},
- legend: {
- font: {
- color: '#000000',
- size: 11
- },
- border: {color: '#d3d3d3'}
- },
- loadingIndicator: {backgroundColor: '#ffffff'},
- tooltip: {font: {color: '#808080'}}
- };
- DX.viz.core.registerTheme({
- name: 'ios',
- chart: $.extend(true, {}, baseChartTheme, {
- commonSeriesSettings: {candlestick: {innerColor: '#cbd0da'}},
- commonAxisSettings: {
- color: '#b0b3ba',
- grid: {color: '#b0b3ba'},
- tick: {color: '#b0b3ba'},
- title: {font: {color: '#939393'}},
- label: {font: {
- color: '#000000',
- size: 11
- }}
- },
- commonPaneSettings: {border: {color: '#b0b3ba'}}
- }),
- pie: $.extend(true, {}, baseChartTheme),
- pieIE8: {commonSeriesSettings: {
- pie: {
- hoverStyle: {border: {color: '#cbd0da'}},
- selectionStyle: {border: {color: '#cbd0da'}}
- },
- donut: {
- hoverStyle: {border: {color: '#cbd0da'}},
- selectionStyle: {border: {color: '#cbd0da'}}
- },
- doughnut: {
- hoverStyle: {border: {color: '#cbd0da'}},
- selectionStyle: {border: {color: '#cbd0da'}}
- }
- }},
- gauge: {
- title: {font: {color: '#808080'}},
- subtitle: {font: {color: '#808080'}},
- tooltip: {font: {color: '#808080'}}
- },
- barGauge: {
- title: {font: {color: '#808080'}},
- subtitle: {font: {color: '#808080'}},
- tooltip: {font: {color: '#808080'}}
- },
- map: {tooltip: {font: {color: '#808080'}}},
- sparkline: {tooltip: {font: {color: '#808080'}}},
- bullet: {tooltip: {font: {color: '#808080'}}}
- }, 'desktop');
- DX.viz.core.registerTheme({
- name: 'ios:7',
- chart: $.extend(true, {}, baseIos7ChartTheme, {
- commonAxisSettings: {
- color: '#d3d3d3',
- grid: {color: '#d3d3d3'},
- tick: {color: '#d3d3d3'},
- title: {font: {color: '#939393'}},
- label: {font: {
- color: '#000000',
- size: 11
- }}
- },
- commonPaneSettings: {border: {color: '#d3d3d3'}}
- }),
- pie: $.extend(true, {}, baseIos7ChartTheme),
- gauge: {
- title: {font: {color: '#808080'}},
- subtitle: {font: {color: '#808080'}},
- tooltip: {font: {color: '#808080'}}
- },
- barGauge: {
- title: {font: {color: '#808080'}},
- subtitle: {font: {color: '#808080'}},
- tooltip: {font: {color: '#808080'}}
- },
- map: {tooltip: {font: {color: '#808080'}}},
- sparkline: {tooltip: {font: {color: '#808080'}}},
- bullet: {tooltip: {font: {color: '#808080'}}}
- }, 'desktop')
- })(jQuery, DevExpress);
- /*! Module viz-core, file win8.js */
- (function($, DX) {
- var baseChartTheme = {
- containerBackgroundColor: '#000000',
- title: {font: {color: '#ffffff'}},
- commonSeriesSettings: {label: {border: {color: '#454545'}}},
- legend: {
- font: {
- color: '#ffffff',
- size: 11
- },
- border: {color: '#454545'}
- },
- loadingIndicator: {backgroundColor: '#000000'},
- tooltip: {
- color: '#000000',
- font: {color: '#ffffff'}
- }
- },
- baseWhiteChartTheme = {
- title: {font: {color: '#808080'}},
- legend: {font: {
- color: '#000000',
- size: 11
- }},
- tooltip: {font: {color: '#808080'}}
- };
- DX.viz.core.registerTheme({
- name: 'win8',
- chart: $.extend(true, {}, baseChartTheme, {
- commonSeriesSettings: {candlestick: {innerColor: '#000000'}},
- commonAxisSettings: {
- color: '#454545',
- grid: {color: '#454545'},
- tick: {color: '#454545'},
- title: {font: {color: '#535353'}},
- label: {font: {
- color: '#ffffff',
- size: 11
- }}
- },
- commonPaneSettings: {border: {color: '#454545'}}
- }),
- pie: $.extend(true, {}, baseChartTheme),
- pieIE8: {commonSeriesSettings: {
- pie: {
- hoverStyle: {border: {color: '#000000'}},
- selectionStyle: {border: {color: '#000000'}}
- },
- donut: {
- hoverStyle: {border: {color: '#000000'}},
- selectionStyle: {border: {color: '#000000'}}
- },
- doughnut: {
- hoverStyle: {border: {color: '#000000'}},
- selectionStyle: {border: {color: '#000000'}}
- }
- }},
- gauge: {
- containerBackgroundColor: '#000000',
- title: {font: {color: '#ffffff'}},
- subtitle: {font: {color: '#ffffff'}},
- loadingIndicator: {backgroundColor: '#000000'},
- tooltip: {
- color: '#000000',
- font: {color: '#ffffff'}
- }
- },
- barGauge: {
- title: {font: {color: '#ffffff'}},
- subtitle: {font: {color: '#ffffff'}},
- tooltip: {
- color: '#000000',
- font: {color: '#ffffff'}
- },
- loadingIndicator: {backgroundColor: '#000000'}
- },
- rangeSelector: {
- containerBackgroundColor: '#000000',
- loadingIndicator: {backgroundColor: '#000000'}
- },
- map: {
- loadingIndicator: {backgroundColor: '#000000'},
- tooltip: {
- color: '#000000',
- font: {color: '#ffffff'}
- }
- },
- sparkline: {tooltip: {
- color: '#000000',
- font: {color: '#ffffff'}
- }},
- bullet: {tooltip: {
- color: '#000000',
- font: {color: '#ffffff'}
- }}
- }, 'desktop-dark');
- DX.viz.core.registerTheme({
- name: 'win8-white',
- chart: $.extend(true, {}, baseWhiteChartTheme, {commonAxisSettings: {
- title: {font: {color: '#939393'}},
- label: {font: {
- color: '#404040',
- size: 11
- }}
- }}),
- pie: $.extend(true, {}, baseWhiteChartTheme),
- gauge: {
- title: {font: {color: '#808080'}},
- subtitle: {font: {color: '#808080'}},
- tooltip: {font: {color: '#808080'}}
- },
- barGauge: {
- title: {font: {color: '#808080'}},
- subtitle: {font: {color: '#808080'}},
- tooltip: {font: {color: '#808080'}}
- },
- map: {tooltip: {font: {color: '#808080'}}},
- sparkline: {tooltip: {font: {color: '#808080'}}},
- bullet: {tooltip: {font: {color: '#808080'}}}
- }, 'desktop')
- })(jQuery, DevExpress);
- /*! Module viz-core, file others.js */
- (function($, DX) {
- DX.viz.core.registerTheme({name: 'generic'}, 'desktop');
- DX.viz.core.registerTheme({name: 'generic-dark'}, 'desktop-dark');
- DX.viz.core.registerTheme({name: 'tizen'}, 'desktop');
- DX.viz.core.registerTheme({name: 'tizen-black'}, 'desktop-dark')
- })(jQuery, DevExpress);
- /*! Module viz-core, file namespaces.js */
- (function(DevExpress) {
- DevExpress.viz.renderers = {}
- })(DevExpress);
- /*! Module viz-core, file svgRenderer.js */
- (function($, DX) {
- var renderers = DX.viz.renderers,
- utils = DX.utils,
- Class = DX.Class,
- doc = document,
- MAX_PIXEL_COUNT = 10000000000;
- function createElement(name) {
- return doc.createElementNS('http://www.w3.org/2000/svg', name)
- }
- function getPatternUrl(id, pathModified) {
- return id !== null ? 'url(' + (pathModified ? window.location.href : '') + '#' + id + ')' : null
- }
- var BaseSvgElement = Class.inherit({
- ctor: function baseSvgElementCtor(renderer, name, params) {
- this.renderer = renderer;
- this.element = this.createElement(name);
- this.$element = $(this.element);
- this.applySettings($.extend({}, this.defaultSettings(), params));
- this.__passedParams = params
- },
- defaultSettings: $.noop,
- createElement: function(nodeName) {
- this._nodeName = nodeName;
- return createElement(nodeName)
- },
- dispose: function() {
- this.off();
- this.remove();
- this.renderer = null;
- this.element = null;
- this.settings = null;
- this.$element = null;
- this.transformation = null;
- this.__passedParams = null;
- this.__appliedSettings = null;
- this.__appliedStyle = null
- },
- append: function(svgElement) {
- var toElement = svgElement || this.renderer.getRoot();
- toElement.element.appendChild(this.element);
- return this
- },
- insertBefore: function(target) {
- target.element.parentNode.insertBefore(this.element, target.element);
- return this
- },
- toBackground: function() {
- this.element.parentNode && this.element.parentNode.insertBefore(this.element, this.element.parentNode.firstChild);
- return this
- },
- toForeground: function() {
- this.element.parentNode && this.element.parentNode.appendChild(this.element);
- return this
- },
- addClass: function(className) {
- var classAttribute = this.$element.attr('class'),
- classNameIndex,
- classNames;
- if (className) {
- if (classAttribute) {
- classNames = classAttribute.split(' ');
- classNameIndex = $.inArray(className, classNames);
- if (classNameIndex === -1)
- classAttribute += ' ' + className
- }
- else
- classAttribute = className;
- this.$element.attr('class', classAttribute)
- }
- return this.$element
- },
- removeClass: function(className) {
- var classAttribute = this.$element.attr('class'),
- classNames,
- indexDeleteElement,
- resultClassNames = '',
- i;
- if (classAttribute && className) {
- classNames = classAttribute.split(' ');
- indexDeleteElement = $.inArray(className, classNames);
- if (indexDeleteElement !== -1) {
- for (i = 0; i < classNames.length; i++)
- if (i !== indexDeleteElement)
- resultClassNames += classNames[i] + ' ';
- this.$element.attr('class', resultClassNames.replace(/ $/, ''))
- }
- }
- return this.$element
- },
- applySettings: function(settings) {
- var normalized;
- this.settings = $.extend(this.settings || {}, settings || {});
- this.adjustSettings();
- normalized = this._normalizeSettings(this.settings);
- this.applyStyle(this._style);
- this._applyAttributes(normalized);
- return this
- },
- _applyAttributes: function(settings) {
- this.$element.attr(settings);
- this.__appliedSettings = settings
- },
- adjustSettings: function(){},
- applyStyle: function(style) {
- this.$element.css(style || {});
- this.__appliedStyle = style || {};
- return this
- },
- trigger: function(event, data) {
- this.$element.trigger(event, data)
- },
- on: function(events, data, handler) {
- this.$element.on.apply(this.$element, arguments);
- return this
- },
- data: function(key, value) {
- this.$element.data(key, value);
- return this
- },
- removeData: function() {
- this.$element.removeData();
- return this
- },
- off: function(events) {
- this.$element.off(events);
- return this
- },
- getBBox: function() {
- var that = this,
- bBox,
- element = this.element,
- transformation = that.transformation,
- rotateAngle = transformation.rotateAngle || 0,
- rotateX = transformation.rotateX || 0,
- rotateY = transformation.rotateY || 0,
- mabs = Math.abs,
- mmin = Math.min;
- function bBox(el) {
- var ret = {};
- try {
- if (!$.isFunction(el.getBBox))
- throw{};
- else
- ret = el.getBBox()
- }
- catch(e) {
- ret = {
- x: 0,
- y: 0,
- width: el.offsetWidth || 0,
- height: el.offsetHeight || 0
- }
- }
- return ret
- }
- bBox = $.extend({}, bBox(element));
- if (rotateAngle) {
- var cossin = utils.getCosAndSin(rotateAngle),
- sin = cossin.sin.toFixed(3),
- cos = cossin.cos.toFixed(3),
- ltx = bBox.x - rotateX,
- lty = bBox.y - rotateY,
- rtx = bBox.x + bBox.width - rotateX,
- rty = bBox.y - rotateY,
- lbx = bBox.x - rotateX,
- lby = bBox.y + bBox.height - rotateY,
- rbx = bBox.x + bBox.width - rotateX,
- rby = bBox.y + bBox.height - rotateY,
- w,
- h;
- w = mabs(bBox.height * sin) + mabs(bBox.width * cos);
- h = mabs(bBox.height * cos) + mabs(bBox.width * sin);
- bBox.x = mmin(ltx * cos - lty * sin + rotateX, rtx * cos - rty * sin + rotateX, lbx * cos - lby * sin + rotateX, rbx * cos - rby * sin + rotateX);
- bBox.y = mmin(ltx * sin + lty * cos + rotateY, rtx * sin + rty * cos + rotateY, lbx * sin + lby * cos + rotateY, rbx * sin + rby * cos + rotateY);
- bBox.width = w;
- bBox.height = h
- }
- return that._normalizeBBox(bBox)
- },
- _normalizeBBox: function(bBox) {
- var ceil = Math.ceil,
- floor = Math.floor,
- $isNumeric = $.isNumeric,
- rxl = floor(bBox.x),
- ryt = floor(bBox.y),
- rxr = ceil(bBox.width + bBox.x),
- ryb = ceil(bBox.height + bBox.y),
- width,
- height;
- bBox.x = $isNumeric(rxl) && rxl < MAX_PIXEL_COUNT && rxl > -MAX_PIXEL_COUNT ? rxl : 0;
- bBox.y = $isNumeric(ryt) && ryt < MAX_PIXEL_COUNT && ryt > -MAX_PIXEL_COUNT ? ryt : 0;
- width = rxr - rxl;
- height = ryb - ryt;
- bBox.width = $isNumeric(width) && width < MAX_PIXEL_COUNT && width > -MAX_PIXEL_COUNT ? width : 0;
- bBox.height = $isNumeric(height) && height < MAX_PIXEL_COUNT && height > -MAX_PIXEL_COUNT ? height : 0;
- bBox.isEmpty = !bBox.x && !bBox.y && !bBox.width && !bBox.height;
- return bBox
- },
- clear: function(selector) {
- selector ? this.$element.find(selector).remove() : this.$element.empty();
- return this
- },
- detach: function() {
- this.$element.detach();
- return this
- },
- animate: function(params, options, complete) {
- options = options || {};
- var that = this,
- animationParams = {};
- if (complete)
- $.extend(options, {complete: complete});
- if (this.renderer.animOptions.enabled) {
- $.each(params, function(name, to) {
- switch (name) {
- case'scale':
- animationParams['transform'] = animationParams['transform'] || {};
- var scale = that.transformation.scale || {};
- animationParams['transform'].scale = {
- x: {
- from: utils.isDefined(scale.x) ? scale.x : 1,
- to: utils.isDefined(to.x) ? to.x : 1
- },
- y: {
- from: utils.isDefined(scale.y) ? scale.y : 1,
- to: utils.isDefined(to.y) ? to.y : 1
- }
- };
- break;
- case'rotate':
- animationParams['transform'] = animationParams['transform'] || {};
- animationParams['transform'].rotate = {
- angle: {
- from: that.transformation.rotateAngle || 0,
- to: to.angle
- },
- y: to.y || 0,
- x: to.x || 0
- };
- break;
- case'translate':
- animationParams['transform'] = animationParams['transform'] || {};
- animationParams['transform'].translate = {
- x: {
- from: that.transformation.translateX || 0,
- to: to.x || 0
- },
- y: {
- from: that.transformation.translateY || 0,
- to: to.y || 0
- }
- };
- break;
- case'arc':
- case'points':
- animationParams[name] = to;
- break;
- default:
- animationParams[name] = {
- from: that.settings[name] || 0,
- to: to
- }
- }
- });
- that.renderer.animateElement(that, animationParams, $.extend({}, this.renderer.animOptions, options))
- }
- else {
- if (params.translate) {
- if ('x' in params.translate)
- params.translateX = params.translate.x;
- if ('y' in params.translate)
- params.translateY = params.translate.y;
- delete params.translate
- }
- if (options) {
- options.step && options.step.call(that, 1, 1);
- options.complete && options.complete.call(that)
- }
- this.applySettings(params)
- }
- },
- stopAnimation: function(disableComplete) {
- var that = this;
- that.animation && that.animation.stop(true, disableComplete);
- return that
- },
- move: function(x, y, animate, animOptions) {
- x = x || 0,
- y = y || 0;
- animOptions = animOptions || {};
- if (!animate)
- this.applySettings({
- translateX: x,
- translateY: y
- });
- else
- this.animate({translate: {
- x: x,
- y: y
- }}, animOptions);
- return this
- },
- rotate: function(angle, x, y, animate, animOptions) {
- angle = angle || 0;
- x = x || 0;
- y = y || 0;
- animOptions = animOptions || {};
- if (!animate)
- this.applySettings({rotate: [angle, x, y]});
- else
- this.animate({rotate: {
- angle: angle,
- x: x,
- y: y
- }}, animOptions)
- },
- remove: function() {
- this.$element.remove()
- },
- _normalizeSettings: function(settings) {
- var key,
- style,
- firstChar,
- styleName,
- prop,
- value,
- normalized = {},
- fontSetting,
- rtl = this.renderer.rtl;
- for (key in settings) {
- prop = key,
- value = settings[prop];
- if (prop === 'align') {
- prop = 'text-anchor';
- value = {
- left: rtl ? 'end' : 'start',
- center: 'middle',
- right: rtl ? 'start' : 'end'
- }[value]
- }
- else if (prop === 'font') {
- style = this['_style'] = this['_style'] || {};
- if (!$.isPlainObject(value))
- continue;
- $.each(value, function(fontSetting) {
- switch (fontSetting) {
- case'color':
- styleName = 'fill';
- break;
- case'opacity':
- styleName = 'fillOpacity';
- break;
- case'cursor':
- styleName = fontSetting;
- break;
- default:
- firstChar = fontSetting.charAt(0);
- styleName = 'font' + fontSetting.replace(firstChar, firstChar.toUpperCase())
- }
- style[styleName] = value[fontSetting]
- });
- continue
- }
- else if (prop === 'dashStyle') {
- prop = 'stroke-dasharray';
- value = (value || 'none').toLowerCase();
- if (value === 'solid' || value === 'none')
- value = null;
- else {
- value = value.replace(/longdash/g, '8,3,').replace(/dash/g, '4,3,').replace(/dot/g, '1,3,').replace(/,$/, '').split(',');
- value = $.map(value, function(p) {
- return +p * (settings.strokeWidth || 1)
- }).join(',')
- }
- }
- else if (/^(linecap|linejoin)$/i.test(prop))
- prop = 'stroke-' + prop;
- else if (/^(translateX|translateY|rotate|scale)$/i.test(prop)) {
- this['_' + prop] = value;
- continue
- }
- else if (prop === 'clipId') {
- prop = 'clip-path';
- value = getPatternUrl(value, this.renderer.pathModified)
- }
- else if (prop === 'style') {
- this['_style'] = this['_style'] || {};
- $.extend(true, this['_style'], value);
- continue
- }
- else if (prop === 'sharpEdges')
- continue;
- else if (prop === 'text')
- continue;
- else if (prop === 'segments')
- continue;
- else
- prop = DX.inflector.dasherize(prop);
- normalized[prop] = value
- }
- return this._applyTransformation(normalized)
- },
- _applyTransformation: function(settings) {
- this.transformation = {
- translateX: this._translateX,
- translateY: this._translateY,
- rotateAngle: 0,
- rotateX: 0,
- rotateY: 0
- };
- var tr = this.transformation,
- rotate = this._rotate,
- scale = this._scale,
- transformations = [];
- if (utils.isDefined(tr.translateX) || utils.isDefined(tr.translateY))
- transformations.push('translate(' + (tr.translateX || 0) + ',' + (tr.translateY || 0) + ')');
- if (utils.isDefined(rotate)) {
- if (utils.isNumber(rotate)) {
- tr.rotateAngle = rotate;
- tr.rotateX = settings.x || 0;
- tr.rotateY = settings.y || 0
- }
- else if ($.isArray(rotate)) {
- tr.rotateAngle = rotate[0] || 0;
- tr.rotateX = rotate[1] || 0;
- tr.rotateY = rotate[2] || 0
- }
- else if (utils.isObject(rotate)) {
- tr.rotateAngle = rotate.angle || 0;
- tr.rotateX = rotate.x || 0;
- tr.rotateY = rotate.y || 0
- }
- transformations.push('rotate(' + tr.rotateAngle + ',' + tr.rotateX + ',' + tr.rotateY + ')')
- }
- if (utils.isNumber(scale)) {
- var value = utils.isDefined(scale) ? scale : 1;
- transformations.push('scale(' + value + ',' + value + ')');
- tr.scale = {
- x: value,
- y: value
- }
- }
- else if (utils.isObject(scale)) {
- var valueX = utils.isDefined(scale.x) ? scale.x : 1;
- var valueY = utils.isDefined(scale.y) ? scale.y : 1;
- transformations.push('scale(' + valueX + ',' + valueY + ')');
- tr.scale = {
- x: valueX,
- y: valueY
- }
- }
- if (transformations.length)
- settings.transform = transformations.join(' ');
- return settings
- }
- });
- var RootSvgElement = BaseSvgElement.inherit({
- defaultSettings: function() {
- return {
- width: 0,
- height: 0,
- style: {
- '-webkit-tap-highlight-color': 'rgba(0, 0, 0, 0)',
- display: 'block',
- overflow: 'hidden'
- },
- xmlns: 'http://www.w3.org/2000/svg',
- 'xmlns:xlink': 'http://www.w3.org/1999/xlink',
- version: '1.1',
- stroke: 'none',
- strokeWidth: 0,
- fill: 'none'
- }
- },
- ctor: function(renderer, params) {
- this.callBase(renderer, 'svg', params)
- }
- });
- var RectSvgBaseElement = {
- defaultSettings: function() {
- return {
- x: 0,
- y: 0,
- width: 0,
- height: 0
- }
- },
- adjustSettings: function() {
- if (!utils.isDefined(this.settings.sharpEdges) || this.settings.sharpEdges) {
- this.sharpEdges();
- delete this.settings.sharpEdges
- }
- },
- prepareSettings: function(settings) {
- var prevStrokeWidth = this.settings ? Number(this.settings.strokeWidth) || 0 : 0,
- newStrokeWidth,
- maxStrokeWidth,
- strokeWidthChanged = false;
- if (utils.isDefined(settings.width))
- this._realWidth = Number(settings.width);
- if (utils.isDefined(settings.height))
- this._realHeight = Number(settings.height);
- if (utils.isDefined(settings.x))
- this._realX = Number(settings.x);
- if (utils.isDefined(settings.y))
- this._realY = Number(settings.y);
- if (utils.isDefined(settings.strokeWidth))
- this._realStrokeWidth = Number(settings.strokeWidth);
- this._realStrokeWidth = this._realStrokeWidth || this.defaultSettings().strokeWidth || 0;
- maxStrokeWidth = ~~((this._realWidth < this._realHeight ? this._realWidth : this._realHeight) / 2);
- newStrokeWidth = this._realStrokeWidth < maxStrokeWidth ? this._realStrokeWidth : maxStrokeWidth;
- if (newStrokeWidth !== prevStrokeWidth) {
- strokeWidthChanged = true;
- settings.sharpEdges = true;
- newStrokeWidth > 0 && (settings.strokeWidth = newStrokeWidth)
- }
- (utils.isDefined(settings.x) || strokeWidthChanged) && (settings.x = this._realX + newStrokeWidth / 2);
- (utils.isDefined(settings.y) || strokeWidthChanged) && (settings.y = this._realY + newStrokeWidth / 2);
- (utils.isDefined(settings.width) || strokeWidthChanged) && (settings.width = this._realWidth - newStrokeWidth);
- (utils.isDefined(settings.height) || strokeWidthChanged) && (settings.height = this._realHeight - newStrokeWidth)
- },
- applySettings: function(settings) {
- var settings = $.extend(true, {}, settings);
- this.prepareSettings(settings);
- return this.callBase(settings)
- },
- sharpEdges: function() {
- var strokeWidth = Math.round(this.settings.strokeWidth || 0),
- correction = strokeWidth % 2 / 2;
- this.settings.x = Math.floor(this.settings.x - correction || 0) + correction;
- this.settings.y = Math.floor(this.settings.y - correction || 0) + correction;
- this.settings.width = Math.floor(this.settings.width || 0);
- this.settings.height = Math.floor(this.settings.height || 0);
- this.settings.strokeWidth > 0 && (this.settings.strokeWidth = strokeWidth)
- }
- };
- var ImageSvgElement = BaseSvgElement.inherit(RectSvgBaseElement).inherit({
- ctor: function(renderer, params, href, location) {
- var locationToPreserveAspectRatioMap = {
- full: 'none',
- lefttop: 'xMinYMin',
- leftcenter: 'xMinYMid',
- leftbottom: 'xMinYMax',
- centertop: 'xMidYMin',
- center: 'xMidYMid',
- centerbottom: 'xMidYMax',
- righttop: 'xMaxYMin',
- rightcenter: 'xMaxYMid',
- rightbottom: 'xMaxYMax'
- };
- this.href = utils.isDefined(href) ? href : '';
- this.preserveAspectRatio = locationToPreserveAspectRatioMap[(location || '').toLowerCase()];
- this.preserveAspectRatio = this.preserveAspectRatio || 'none';
- this.callBase(renderer, 'image', params)
- },
- adjustSettings: function() {
- this.callBase();
- this.element.setAttributeNS('http://www.w3.org/1999/xlink', 'href', this.href);
- if (this.preserveAspectRatio)
- this.element.setAttribute('preserveAspectRatio', this.preserveAspectRatio)
- }
- });
- var RectSvgElement = BaseSvgElement.inherit(RectSvgBaseElement).inherit({
- defaultSettings: function() {
- return {
- x: 0,
- y: 0,
- width: 0,
- height: 0,
- rx: 0,
- ry: 0
- }
- },
- ctor: function(renderer, params) {
- this.callBase(renderer, 'rect', params)
- }
- });
- var PathSvgElement = BaseSvgElement.inherit({
- defaultSettings: function() {
- return {points: {
- x: 0,
- y: 0
- }}
- },
- getNodeName: function() {
- return 'path'
- },
- getPathAttributeName: function() {
- return 'd'
- },
- ctor: function(renderer, params) {
- this.callBase(renderer, this.getNodeName(), params)
- },
- dispose: function() {
- this.segments = null;
- this.fromSegments = null;
- this.callBase()
- },
- adjustSettings: function() {
- this.prepareSegments(this.settings)
- },
- applySettings: function(settings) {
- var settings = settings || {};
- if (this.settings && settings.strokeWidth && this.settings.strokeWidth !== settings.strokeWidth)
- settings.sharpEdges = true;
- return this.callBase(settings)
- },
- prepareSegments: function(params) {
- if ('points' in params) {
- var points = params.points,
- firstElem = points[0],
- close = this.closePath || params.closePath,
- segments = [],
- i;
- if (utils.isObject(firstElem))
- segments = $.map(points, function(pt, i) {
- if (!pt)
- return null;
- if (!i)
- return [['M', pt.x, pt.y]];
- return [['L', pt.x, pt.y]]
- });
- else if (utils.isNumber(firstElem))
- for (i = 0; i < points.length; i += 2) {
- if (!i) {
- segments = [['M', points[i] || 0, points[i + 1] || 0]];
- continue
- }
- segments.push(['L', points[i] || 0, points[i + 1] || 0])
- }
- else
- segments = [['M', 0, 0]];
- if (close)
- segments.push(['Z']);
- this.segments = segments;
- delete params.points;
- delete params.closePath;
- params.sharpEdges = true
- }
- if (params.sharpEdges) {
- this.sharpEdges();
- this.combinePathParams(params);
- delete params.sharpEdges
- }
- },
- customizeSegments: function(segments) {
- return segments
- },
- combinePathParams: function(params) {
- var path;
- this.segments = this.customizeSegments(this.segments);
- if (this.segments) {
- path = $.map(this.segments, function(seg, i) {
- return seg.join(' ')
- });
- path = path.join(' ');
- params[this.getPathAttributeName()] = path
- }
- },
- _prepareDifferrentPath: function(from, to) {
- var end = {},
- constsSeg;
- if (to.length > from.length)
- this._makeEqualPath(from, to);
- else {
- this.combinePathParams(end);
- this._makeEqualPath(to, from)
- }
- return end.d
- },
- _prepareConstSegment: function(seg) {
- seg[0] = "L"
- },
- _makeEqualPath: function(short, long) {
- var constSeg = short[short.length - 1].slice();
- this._prepareConstSegment(constSeg);
- for (var i = short.length; i < long.length; i++)
- short[i] = constSeg
- },
- animate: function(params, options, complete) {
- var that = this;
- if (!('points' in params) || !that.renderer.animOptions.enabled)
- return that.callBase(params, options, complete);
- var fromPath = that.segments,
- end;
- that.prepareSegments(params);
- delete params.d;
- if (fromPath.length === that.segments.length)
- params.points = {
- from: fromPath,
- to: that.segments
- };
- else
- end = that._prepareDifferrentPath(fromPath, that.segments);
- params.points = {
- from: fromPath,
- to: that.segments,
- end: end
- };
- that.callBase(params, options, complete)
- },
- sharpEdges: function() {
- var that = this,
- segLength = that.segments.length,
- i = 0,
- curSeg,
- nextSeg,
- curX,
- curY,
- nextX,
- nextY,
- curXIdx,
- curYIdx,
- nextXIdx,
- nextYIdx,
- strokeWidth = Math.round(that.settings.strokeWidth || 0),
- correction = strokeWidth % 2 / 2;
- for (i; i < segLength - 1; i++) {
- curSeg = that.segments[i];
- nextSeg = that.segments[i + 1];
- if (nextSeg[0] === 'Z' && i)
- nextSeg = that.segments[0];
- switch (curSeg[0]) {
- case'M':
- case'L':
- curXIdx = 1;
- curYIdx = 2;
- break;
- case'C':
- curXIdx = 5;
- curYIdx = 6;
- break;
- case'A':
- curXIdx = 6;
- curYIdx = 7;
- break;
- case'Z':
- continue
- }
- switch (nextSeg[0]) {
- case'M':
- case'L':
- nextXIdx = 1;
- nextYIdx = 2;
- break;
- case'C':
- nextXIdx = 5;
- nextYIdx = 6;
- break;
- case'A':
- nextXIdx = 6;
- nextYIdx = 7;
- break;
- case'Z':
- continue
- }
- curX = Math.floor(curSeg[curXIdx]);
- curY = Math.floor(curSeg[curYIdx]);
- nextX = nextSeg[nextXIdx] = Math.floor(nextSeg[nextXIdx]);
- nextY = nextSeg[nextYIdx] = Math.floor(nextSeg[nextYIdx]);
- curSeg[curXIdx] = i == 0 ? curX : curSeg[curXIdx];
- curSeg[curYIdx] = i == 0 ? curY : curSeg[curYIdx];
- if (curX == nextX) {
- curSeg[curXIdx] = curX + correction;
- nextSeg[nextXIdx] = nextX + correction
- }
- if (curY == nextY) {
- curSeg[curYIdx] = curY + correction;
- nextSeg[nextYIdx] = nextY + correction
- }
- }
- }
- });
- var SegmentRectSvgElement = PathSvgElement.inherit(RectSvgBaseElement).inherit({
- defaultSettings: function() {
- return $.extend(true, {}, this.callBase(), {segments: {
- top: true,
- bottom: true,
- left: true,
- right: true
- }})
- },
- prepareSegments: function() {
- var that = this,
- settings = that.settings,
- left = settings.x,
- right = left + settings.width,
- top = settings.y,
- bottom = top + settings.height,
- segments = [],
- segmentSequence,
- visiblyOpt = 0,
- prevSegmentVisibility = 0;
- var allSegment = {
- top: [['M', left, top], ['L', right, top]],
- right: [['M', right, top], ['L', right, bottom]],
- bottom: [['M', right, bottom], ['L', left, bottom]],
- left: [['M', left, bottom], ['L', left, top]]
- };
- $.each(allSegment, function(seg, _) {
- var visibility = !!that.settings.segments[seg];
- visiblyOpt = visiblyOpt * 2 + ~~visibility
- });
- switch (visiblyOpt) {
- case(13):
- case(9):
- segmentSequence = ['left', 'top', 'right', 'bottom'];
- break;
- case(11):
- segmentSequence = ['bottom', 'left', 'top', 'right'];
- break;
- default:
- segmentSequence = ['top', 'right', 'bottom', 'left']
- }
- $.each(segmentSequence, function(_, seg) {
- var segmentVisibility = !!that.settings.segments[seg];
- if (segmentVisibility)
- $.each(allSegment[seg].slice(prevSegmentVisibility), function(_, segment) {
- segments.push(segment)
- });
- prevSegmentVisibility = ~~segmentVisibility
- });
- visiblyOpt == 15 && segments.push(['Z']);
- this.segments = segments.length ? segments : [['M', 0, 0], ['Z']];
- this.combinePathParams(settings)
- },
- adjustSettings: function() {
- this.callBase();
- this.prepareSegments()
- },
- applySettings: function(settings) {
- var segments = this.settings && this.settings.segments || this.defaultSettings().segments;
- settings.segments = $.extend(true, {}, segments || {}, settings.segments);
- return this.callBase(settings)
- }
- });
- var baseAreaElement = {
- defaultSettings: function() {
- return {points: {
- x: 0,
- y: 0
- }}
- },
- ctor: function(renderer, params) {
- this.closePath = true;
- this.callBase(renderer, params)
- },
- _tailIndex: 0,
- _makeEqualPath: function(short, long) {
- var i,
- tail,
- head,
- constsSeg1,
- constsSeg2,
- newTail = [];
- if ((short.length - 1) % 2 == 0 && (long.length - 1) % 2 == 0) {
- i = (short.length - 1) / 2 - 1;
- tail = short.slice(i + 1);
- head = short.slice(0, i + 1);
- constsSeg1 = head[head.length - 1];
- constsSeg2 = tail[this._tailIndex];
- this._prepareConstSegment(constsSeg1);
- for (var j = i; j < (long.length - 1) / 2 - 1; j++) {
- head.push(constsSeg1);
- newTail.push(constsSeg2)
- }
- head = this._concatAnimationSegment(head, newTail, tail);
- for (i = 0; i < head.length; i++)
- short[i] = head[i]
- }
- },
- _concatAnimationSegment: function(head, newTail, tail) {
- return head.concat(newTail, tail)
- }
- };
- var AreaSvgElement = PathSvgElement.inherit(baseAreaElement);
- var BezierSvgElement = PathSvgElement.inherit({
- defaultSettings: function() {
- return {points: {
- x: 0,
- y: 0
- }}
- },
- _prepareConstSegment: function(seg) {
- var x = seg[seg.length - 2],
- y = seg[seg.length - 1];
- seg[0] = "C";
- seg[5] = seg[3] = seg[1] = x;
- seg[6] = seg[4] = seg[2] = y
- },
- prepareSegments: function(params) {
- if (!('points' in params))
- return;
- var points = params.points,
- firstElem = points[0],
- close = this.closePath || params.closePath,
- segments = [],
- seg = [],
- i,
- x,
- y;
- var cnt = 0;
- if (utils.isObject(firstElem)) {
- for (i = 0; i < points.length; i++) {
- x = points[i].x;
- y = points[i].y;
- if (!i) {
- segments = [['M', x, y]];
- continue
- }
- if ((i - 1) % 3 == 0) {
- if (seg.length > 0)
- segments.push(seg);
- seg = ['C', x, y];
- continue
- }
- seg.push(x);
- seg.push(y)
- }
- if (seg.length > 0)
- segments.push(seg)
- }
- else if (utils.isNumber(firstElem)) {
- for (i = 0; i < points.length; i += 2) {
- x = points[i];
- y = points[i + 1];
- if (!i) {
- segments = [['M', x, y || 0]];
- continue
- }
- if ((i - 2) % 6 == 0) {
- if (seg.length > 0)
- segments.push(seg);
- seg = ['C', x, y || 0];
- continue
- }
- seg.push(x);
- seg.push(y || 0)
- }
- if (seg.length > 0)
- segments.push(seg)
- }
- else
- segments = [['M', 0, 0]];
- if (close)
- segments.push(['Z']);
- this.segments = segments;
- delete params.points;
- delete params.closePath;
- this.combinePathParams(params)
- }
- });
- var BezierAreaSvgElement = BezierSvgElement.inherit(baseAreaElement).inherit({
- _concatAnimationSegment: function(head, newTail, tail) {
- var point = tail.splice(0, 1);
- return head.concat(point.concat(newTail), tail)
- },
- _tailIndex: 1
- });
- var ArcSvgElement = PathSvgElement.inherit({
- defaultSettings: function() {
- return {
- x: 0,
- y: 0,
- linejoin: 'round'
- }
- },
- createArcSegments: function(x, y, innerR, outerR, startAngle, endAngle, isCircle) {
- var longFlag = Math.floor(Math.abs(endAngle - startAngle) / Math.PI) % 2 ? '1' : '0',
- xOuterStart = x + outerR * Math.cos(startAngle),
- yOuterStart = y - outerR * Math.sin(startAngle),
- xOuterEnd = x + outerR * Math.cos(endAngle),
- yOuterEnd = y - outerR * Math.sin(endAngle),
- xInnerStart = x + innerR * Math.cos(endAngle),
- yInnerStart = y - innerR * Math.sin(endAngle),
- xInnerEnd = x + innerR * Math.cos(startAngle),
- yInnerEnd = y - innerR * Math.sin(startAngle);
- return [['M', xOuterStart, yOuterStart], ['A', outerR, outerR, 0, longFlag, 0, xOuterEnd, yOuterEnd], [isCircle ? 'M' : 'L', xInnerStart, yInnerStart], ['A', innerR, innerR, 0, longFlag, 1, xInnerEnd, yInnerEnd], ['Z']]
- },
- prepareSegments: function(params) {
- if (!('x' in params) && !('y' in params) && !('outerRadius' in params) && !('innerRadius' in params) && !('startAngle' in params) && !('endAngle' in params))
- return;
- var x = utils.isNumber(params.x) ? Number(params.x) : 0,
- y = utils.isNumber(params.y) ? Number(params.y) : 0,
- outerR = utils.isNumber(params.outerRadius) ? Number(params.outerRadius) : 0,
- innerR = utils.isNumber(params.innerRadius) ? Number(params.innerRadius) : 0,
- startAngle = utils.isNumber(params.startAngle) ? Number(params.startAngle) : 0,
- endAngle = utils.isNumber(params.endAngle) ? Number(params.endAngle) : 360,
- isCircle;
- this.segments = [['M', 0, 0], ['Z']];
- if (outerR || innerR) {
- var tmp = Math.min(outerR, innerR);
- outerR = Math.max(outerR, innerR);
- innerR = tmp;
- if (Math.round(startAngle) != Math.round(endAngle)) {
- if (Math.abs(endAngle - startAngle) % 360 == 0) {
- startAngle = 0;
- endAngle = 360;
- isCircle = true;
- endAngle -= 0.0001
- }
- if (startAngle > 360)
- startAngle = startAngle % 360;
- if (endAngle > 360)
- endAngle = endAngle % 360;
- if (startAngle > endAngle)
- startAngle -= 360;
- startAngle = startAngle * Math.PI / 180;
- endAngle = endAngle * Math.PI / 180;
- this.segments = this.createArcSegments(x, y, innerR, outerR, startAngle, endAngle, isCircle)
- }
- }
- this.x = params.x;
- this.y = params.y;
- this.outerRadius = params.outerRadius;
- this.innerRadius = params.innerRadius;
- this.startAngle = params.startAngle;
- this.endAngle = params.endAngle;
- delete params.x;
- delete params.y;
- delete params.outerRadius;
- delete params.innerRadius;
- delete params.startAngle;
- delete params.endAngle;
- this.combinePathParams(params)
- },
- animate: function(params) {
- var _this = this;
- if ('x' in params && 'y' in params && 'outerRadius' in params && 'innerRadius' in params && 'startAngle' in params && 'endAngle' in params && this.renderer.animOptions.enabled) {
- var settings = this.settings;
- params.arc = {
- from: {
- x: this.x,
- y: this.y,
- outerRadius: this.outerRadius,
- innerRadius: this.innerRadius,
- startAngle: this.startAngle,
- endAngle: this.endAngle
- },
- to: {
- x: params.x,
- y: params.y,
- outerRadius: params.outerRadius,
- innerRadius: params.innerRadius,
- startAngle: params.startAngle,
- endAngle: params.endAngle
- }
- };
- delete params.d;
- delete params.x;
- delete params.y;
- delete params.outerRadius;
- delete params.innerRadius;
- delete params.startAngle;
- delete params.endAngle
- }
- this.callBase.apply(this, arguments)
- }
- });
- var CircleSvgElement = BaseSvgElement.inherit({
- defaultSettings: function() {
- return {
- cx: 0,
- cy: 0,
- r: 0
- }
- },
- ctor: function(renderer, params) {
- this.callBase(renderer, 'circle', params)
- }
- });
- var TextSvgElement = BaseSvgElement.inherit({
- defaultSettings: function() {
- return {
- x: 0,
- y: 0
- }
- },
- ctor: function(renderer, params) {
- this.tspans = [];
- this.callBase(renderer, 'text', params)
- },
- dispose: function() {
- this.tspans = null;
- this.callBase()
- },
- updateText: function(text) {
- if (!utils.isDefined(text))
- text = '';
- this.applySettings({text: text})
- },
- adjustSettings: function() {
- if (!('text' in this.settings)) {
- this.changeX();
- return
- }
- this._createElementWithText(this.settings.text)
- },
- changeX: function() {
- for (var i = 0; i < this.tspans.length; i++)
- if (this.tspans[i].settings.x != undefined)
- this.tspans[i].applySettings({x: this.settings.x})
- },
- _createElementWithText: function(text) {
- var div,
- i;
- this.clear();
- text = text.toString().replace(/\r/g, "");
- text = text.replace(/\n/g, "<br/>");
- div = doc.createElement("div");
- div.innerHTML = text;
- div.params = {style: {}};
- this._orderText(div)
- },
- clear: function() {
- this.callBase();
- this.tspans = []
- },
- _orderText: function(node) {
- var textArray = [],
- defaultFontSize = (this.settings.font ? this.settings.font.size : 12) || 12;
- var order = function(strCount, node, textArray) {
- var params = {style: {}},
- textArray = textArray || [];
- node.params = node.params || {};
- if (node.parentNode && node.nodeName != "#text")
- if (node.parentNode.params)
- for (var i in node.parentNode.params)
- node.params[i] = node.parentNode.params[i];
- switch (node.tagName) {
- case"B" || "STRONG":
- node.params.fontWeight = "bold";
- break;
- case"I" || "EM":
- node.params.fontStyle = "italic";
- break;
- case"U":
- node.params.textDecoration = "underline";
- break;
- case"BR":
- strCount++;
- break
- }
- if (node.style) {
- if (node.style.fontSize)
- node.params.fontSize = (parseInt(node.style.fontSize) || node.params.fontSize) + "px";
- node.params.fill = node.style.color || node.params.fill;
- node.params.fontStyle = node.style.fontStyle || node.params.fontStyle;
- node.params.fontWeight = node.style.fontWeight || node.params.fontWeight;
- node.params.textDecoration = node.style.textDecoration || node.params.textDecoration
- }
- var childnum = node.childNodes.length;
- var count = 0;
- while (count != childnum)
- strCount = order(strCount, node.childNodes[count++], textArray);
- if (node.wholeText != undefined) {
- params.fill = node.parentNode.params.fill;
- params.text = node.wholeText;
- node.parentNode.params.fontSize && (params.style.fontSize = node.parentNode.params.fontSize);
- node.parentNode.params.fontStyle && (params.style.fontStyle = node.parentNode.params.fontStyle);
- node.parentNode.params.fontWeight && (params.style.fontWeight = node.parentNode.params.fontWeight);
- node.parentNode.params.textDecoration && (params.style.textDecoration = node.parentNode.params.textDecoration);
- textArray.push({
- params: params,
- line: strCount
- })
- }
- return strCount
- };
- order(0, node, textArray);
- for (var txt = 0; txt < textArray.length; txt++) {
- if (txt != 0)
- if (textArray[txt].line != textArray[txt - 1].line) {
- textArray[txt].params.dy = textArray[txt].params.style.fontSize || defaultFontSize;
- textArray[txt].params.x = this.settings.x
- }
- else {
- textArray[txt].params.dy = 0;
- textArray[txt].params.dx = 0
- }
- else {
- textArray[txt].params.x = this.settings.x;
- textArray[txt].params.dy = 0
- }
- var tspan = new TspanSvgElement(this.renderer, textArray[txt].params);
- tspan.append(this);
- this.tspans.push(tspan)
- }
- }
- });
- var TspanSvgElement = BaseSvgElement.inherit({ctor: function(renderer, params) {
- var text = params.text || '';
- delete params.text;
- this.callBase(renderer, 'tspan', params);
- this.element.appendChild(doc.createTextNode(text))
- }});
- var GroupSvgElement = BaseSvgElement.inherit({
- ctor: function(renderer, params) {
- this.callBase(renderer, 'g', params)
- },
- update: $.noop
- });
- var PatternSvgElement = BaseSvgElement.inherit({
- ctor: function(renderer, params) {
- this.__patternParams = $.extend({}, params);
- var id = utils.getNextDefsSvgId(),
- color = params.color,
- hatching = params.hatching,
- opacity = hatching.opacity,
- width = hatching.width || 1,
- step = hatching.step || 6,
- direction = hatching.direction,
- options = {
- strokeWidth: width,
- stroke: color
- };
- this.callBase(renderer, 'pattern', {
- id: id,
- width: step,
- height: step
- });
- this.element.setAttribute('patternUnits', 'userSpaceOnUse');
- this._rect = renderer.createRect(0, 0, step, step, 0, {
- fill: color,
- opacity: opacity
- }).append(this);
- this._path = renderer.createPath(0, options).append(this);
- if (direction === 'right')
- this._path.applySettings({d: "M " + step / 2 + " " + -step / 2 + " L " + -step / 2 + " " + step / 2 + "M 0 " + step + " L " + step + " 0 M " + step * 1.5 + " " + step / 2 + " L " + step / 2 + " " + step * 1.5});
- else if (direction === 'left')
- this._path.applySettings({d: "M 0 0 L " + step + ' ' + step + " M " + -step / 2 + " " + step / 2 + " L " + step / 2 + " " + step * 1.5 + " M " + step / 2 + -step / 2 + " L " + step * 1.5 + " " + step / 2});
- this.id = getPatternUrl(id, renderer.pathModified)
- },
- append: function() {
- return this.callBase(this.renderer.getDefsSvg())
- },
- clear: function() {
- this.callBase();
- this._path = null
- },
- dispose: function() {
- this._path = null;
- this.callBase()
- }
- });
- var ClipRectSvgElement = BaseSvgElement.inherit({
- ctor: function(renderer, params) {
- this.__clipRectParams = $.extend({}, params);
- var x = params.x,
- y = params.y,
- w = params.w,
- h = params.h,
- id = utils.getNextDefsSvgId();
- delete params.x;
- delete params.y;
- delete params.w;
- delete params.h;
- this.callBase(renderer, 'clipPath', {id: id});
- this.id = id;
- this._rect = renderer.createRect(x, y, w, h, 0, params);
- this._rect.append(this)
- },
- append: function() {
- return this.callBase(this.renderer.getDefsSvg())
- },
- updateRectangle: function(settings) {
- this._rect.applySettings(settings)
- },
- dispose: function() {
- this._rect = null;
- this.callBase()
- }
- });
- var BaseFilterSvgElement = BaseSvgElement.inherit({
- ctor: function(renderer) {
- this.applySettings = $.noop;
- this.callBase(renderer, 'filter');
- delete this.applySettings;
- this.ref = null;
- this._create()
- },
- append: function() {
- return this.callBase(this.renderer.getDefsSvg())
- },
- dispose: function() {
- while (this.element.firstChild)
- this.element.removeChild(this.element.firstChild);
- this.callBase();
- return this
- },
- applySettings: function(settings) {
- settings = settings || {};
- settings.id = utils.getNextDefsSvgId();
- this.$element.attr({
- id: settings.id,
- x: settings.x || null,
- y: settings.y || null,
- width: settings.width || null,
- height: settings.height || null
- });
- this.ref = settings.id ? getPatternUrl(settings.id, this.renderer.pathModified) : null;
- this._update(settings);
- return this
- }
- });
- function setAttributes(element, attr) {
- $.each(attr, function(name, value) {
- element.setAttribute(name, value)
- })
- }
- var ShadowFilterSvgElement = BaseFilterSvgElement.inherit({
- _create: function() {
- var that = this,
- gaussianBlur = that._gaussianBlur = createElement('feGaussianBlur'),
- offset = that._offset = createElement('feOffset'),
- flood = that._flood = createElement('feFlood'),
- composite = that._composite = createElement('feComposite'),
- finalComposite = createElement('feComposite');
- setAttributes(gaussianBlur, {
- 'in': 'SourceGraphic',
- result: 'gaussianBlurResult'
- });
- setAttributes(offset, {
- 'in': 'gaussianBlurResult',
- result: 'offsetResult'
- });
- setAttributes(flood, {result: 'floodResult'});
- setAttributes(composite, {
- 'in': 'floodResult',
- in2: 'offsetResult',
- operator: 'in',
- result: 'compositeResult'
- });
- setAttributes(finalComposite, {
- 'in': 'SourceGraphic',
- in2: 'compositeResult',
- operator: 'over'
- });
- that.element.appendChild(gaussianBlur);
- that.element.appendChild(offset);
- that.element.appendChild(flood);
- that.element.appendChild(composite);
- that.element.appendChild(finalComposite)
- },
- _update: function(settings) {
- setAttributes(this._gaussianBlur, {stdDeviation: settings.blur || 0});
- setAttributes(this._offset, {
- dx: settings.dx || 0,
- dy: settings.dy || 0
- });
- setAttributes(this._flood, {
- 'flood-color': settings.color,
- 'flood-opacity': settings.opacity
- })
- }
- });
- renderers.SvgRenderer = Class.inherit({
- ctor: function(options) {
- var that = this;
- options = options || {};
- that._setAnimationOptions(options.animation || {});
- that.animationController = new renderers.AnimationController;
- that.pathModified = options.pathModified;
- that.rtl = !!options.rtl;
- that.cssClass = options.cssClass || '';
- that.recreateCanvas(options.width, options.height)
- },
- dispose: function() {
- var that = this;
- that.detachContainer();
- that.svgRoot && (that.svgRoot.remove(), that.svgRoot = null);
- that.animationController.dispose();
- that.animOptions = null;
- that.animationController = null
- },
- _setAnimationOptions: function(options) {
- this.animOptions = {
- enabled: true,
- duration: 1000,
- easing: 'easeOutCubic'
- };
- if ('enabled' in options)
- this.animOptions.enabled = options.enabled;
- if ('duration' in options)
- this.animOptions.duration = options.duration;
- if ('easing' in options)
- this.animOptions.easing = options.easing
- },
- animationEnabled: function() {
- return !!this.animOptions.enabled
- },
- updateAnimationOptions: function(newOptions) {
- this._setAnimationOptions($.extend(this.animOptions || {}, newOptions))
- },
- stopAllAnimations: function(lock) {
- lock ? this.animationController.lock() : this.animationController.stop()
- },
- detachContainer: function() {
- var that = this;
- that.svgRoot && that.svgRoot.detach();
- that.defsSvg && (that.defsSvg.remove(), that.defsSvg = null);
- that.drawn = null
- },
- recreateCanvas: function(width, height, cssClass) {
- if (width >= 0 && height >= 0) {
- if (!this.svgRoot) {
- this.cssClass = cssClass || this.cssClass;
- this.svgRoot = new RootSvgElement(this, {
- width: width,
- height: height,
- 'class': this.cssClass,
- direction: this.rtl ? 'rtl' : 'ltr'
- });
- this.animationController.element = this.svgRoot.element
- }
- else
- this.svgRoot.applySettings({
- width: width,
- height: height
- });
- this.defsSvg && this.defsSvg.clear("pattern")
- }
- },
- resize: function(width, height) {
- var root = this.getRoot();
- root && width > 0 && height > 0 && root.applySettings({
- width: width,
- height: height
- })
- },
- getRoot: function() {
- return this.svgRoot
- },
- isInitialized: function() {
- return !!this.svgRoot
- },
- draw: function(container) {
- if (!container || this.drawn)
- return;
- container.appendChild(this.getRoot().element);
- this.drawn = true
- },
- updateParams: function(params, options) {
- if (options && options.strokeWidth)
- params.strokeWidth = options.strokeWidth
- },
- animateElement: function(element, params, options) {
- this.animationController.animateElement(element, params, options)
- },
- createRect: function(x, y, w, h, r, options) {
- var params = {
- x: x,
- y: y,
- width: w,
- height: h,
- rx: r,
- ry: r
- };
- if (options && !options.inh)
- $.extend(params, options);
- this.updateParams(params, options);
- return new RectSvgElement(this, params)
- },
- createSegmentRect: function(x, y, w, h, r, segments, options) {
- var params = $.extend({}, options || {}, {
- x: x,
- y: y,
- width: w,
- height: h,
- rx: r,
- ry: r,
- segments: segments
- });
- return new SegmentRectSvgElement(this, params)
- },
- createClipRect: function(x, y, w, h) {
- var attr = {
- x: x,
- y: y,
- w: w,
- h: h,
- fill: 'none',
- stroke: 'none',
- strokeWidth: 0
- };
- return new ClipRectSvgElement(this, attr)
- },
- createPattern: function(color, hatching) {
- hatching = hatching || {};
- hatching.direction = (hatching.direction || '').toLowerCase();
- if (hatching.direction !== 'right' && hatching.direction !== 'left')
- return {
- id: color,
- append: function() {
- return this
- },
- clear: function(){},
- dispose: function(){}
- };
- return new PatternSvgElement(this, {
- hatching: hatching,
- color: color
- })
- },
- createImage: function(x, y, w, h, href, options) {
- var params = $.extend({}, options || {}, {
- x: x,
- y: y,
- width: w,
- height: h
- });
- return new ImageSvgElement(this, params, href, params.location)
- },
- createLine: function(x1, y1, x2, y2, options) {
- var params = {points: [x1, y1, x2, y2]};
- if (options && !options.inh)
- $.extend(params, options);
- this.updateParams(params, options);
- return new PathSvgElement(this, params)
- },
- createPath: function(points, options) {
- var params = {points: points};
- if (options && !options.inh)
- $.extend(params, options);
- this.updateParams(params, options);
- return new PathSvgElement(this, params)
- },
- createSimplePath: function(options) {
- return new BaseSvgElement(this, 'path', options)
- },
- createBezierPath: function(points, options) {
- var params = {points: points};
- if (options && !options.inh)
- $.extend(params, options);
- this.updateParams(params, options);
- return new BezierSvgElement(this, params)
- },
- createArea: function(points, options) {
- var params = {points: points};
- if (options && !options.inh)
- $.extend(params, options);
- this.updateParams(params, options);
- return new AreaSvgElement(this, params)
- },
- createBezierArea: function(points, options) {
- var params = {points: points};
- if (options && !options.inh)
- $.extend(params, options);
- this.updateParams(params, options);
- return new BezierAreaSvgElement(this, params)
- },
- createCircle: function(x, y, r, options) {
- var params = {
- cx: x,
- cy: y,
- r: r
- };
- if (options && !options.inh)
- $.extend(params, options);
- return new CircleSvgElement(this, params)
- },
- createArc: function(x, y, outerRadius, innerRadius, startAngle, endAngle, options) {
- var params = {
- x: x,
- y: y,
- outerRadius: outerRadius,
- innerRadius: innerRadius,
- startAngle: startAngle,
- endAngle: endAngle
- };
- if (options && !options.inh)
- $.extend(params, options);
- this.updateParams(params, options);
- return new ArcSvgElement(this, params)
- },
- createText: function(text, x, y, options) {
- var params = {
- x: x,
- y: y,
- text: text
- };
- if (options && !options.inh)
- $.extend(params, options);
- return new TextSvgElement(this, params)
- },
- createGroup: function(options) {
- return new GroupSvgElement(this, options)
- },
- createFilter: function(type) {
- var filterType = type === 'shadow' ? ShadowFilterSvgElement : null;
- if (filterType)
- return new filterType(this);
- return null
- },
- getDefsSvg: function() {
- this.defsSvg = this.defsSvg || new BaseSvgElement(this, 'defs').append();
- return this.defsSvg
- },
- svg: function() {
- return this.svgRoot.$element.parent().html()
- }
- });
- function buildPath(points) {
- var i = 0,
- ii = points.length,
- list = [];
- for (; i < ii; )
- list.push('L', points[i++].toFixed(2), points[i++].toFixed(2));
- if (ii) {
- list[0] = 'M';
- list.push('Z');
- list = list.join(' ')
- }
- else
- list = '';
- return list
- }
- function processCircleSettings(x, y, size, borderWidth) {
- var correct = size + ~~borderWidth & 1;
- return {
- cx: correct ? x + 0.5 : x,
- cy: correct ? y + 0.5 : y,
- r: size / 2
- }
- }
- renderers._svgBuildPath = buildPath;
- renderers._svgProcessCircleSettings = processCircleSettings;
- renderers._svgRendererInternals = {
- BaseSvgElement: BaseSvgElement,
- RootSvgElement: RootSvgElement,
- RectSvgElement: RectSvgElement,
- ImageSvgElement: ImageSvgElement,
- PathSvgElement: PathSvgElement,
- AreaSvgElement: AreaSvgElement,
- BezierSvgElement: BezierSvgElement,
- BezierAreaSvgElement: BezierAreaSvgElement,
- CircleSvgElement: CircleSvgElement,
- TextSvgElement: TextSvgElement,
- TspanSvgElement: TspanSvgElement,
- GroupSvgElement: GroupSvgElement,
- ArcSvgElement: ArcSvgElement,
- RectSvgBaseElement: RectSvgBaseElement,
- SegmentRectSvgElement: SegmentRectSvgElement,
- ClipRectSvgElement: ClipRectSvgElement,
- PatternSvgElement: PatternSvgElement,
- ShadowFilterSvgElement: ShadowFilterSvgElement
- }
- })(jQuery, DevExpress);
- /*! Module viz-core, file vmlRenderer.js */
- (function($, DX) {
- var renderers = DX.viz.renderers,
- utils = DX.utils,
- doc = document,
- svgRendererInternals = renderers._svgRendererInternals,
- documentFragment = doc.createDocumentFragment();
- function createVmlElement(nodeName) {
- var element = doc.createElement(nodeName);
- return documentFragment.appendChild(element)
- }
- var appendTimerID;
- var vmlElementsToAppend = [];
- var CSS_PROPERTIES = ['position', 'display', 'visibility', 'filter', 'margin', 'marginTop', 'marginLeft', 'marginRight', 'marginBottom', 'whiteSpace', 'clip', 'overflow'];
- var INHERITABLE_PROPERTIES = ['stroke', 'fill', 'opacity', 'strokeWidth', 'align', 'dashStyle'];
- var defaultVmlSettings = {
- x: 0,
- y: 0,
- width: 1,
- height: 1,
- position: 'absolute',
- behavior: 'url(#default#VML)',
- display: 'inline-block',
- xmlns: "urn:schemas-microsoft-com:vml"
- };
- var CLIP_RECT_CLASS = "dx-vml-clip-rect";
- var extendDefaultVmlOptions = function(customOptions, baseOptions) {
- return $.extend(true, baseOptions || {}, defaultVmlSettings, customOptions)
- };
- var parseRotateParameter = function(rotate, defaultX, defaultY) {
- var rotateObject;
- if (utils.isDefined(rotate))
- if (utils.isNumber(rotate))
- rotateObject = {
- angle: rotate,
- x: defaultX || 0,
- y: defaultY || 0
- };
- else if ($.isArray(rotate))
- rotateObject = {
- angle: rotate[0] || 0,
- x: rotate[1] || 0,
- y: rotate[2] || 0
- };
- else if (utils.isObject(rotate))
- rotateObject = {
- angle: rotate.angle || 0,
- x: rotate.x || 0,
- y: rotate.y || 0
- };
- return rotateObject
- };
- function adjustOpacity(value) {
- return value >= 0.002 ? value : value === null ? 1 : 0.002
- }
- var applySubElementAttribute = function(vmlElement, params, name) {
- var element = vmlElement.element,
- subElement,
- value = params[name];
- if (name === 'opacity' || name === 'fillOpacity')
- if (element.fill)
- element.fill.opacity = adjustOpacity(value);
- if (name === 'joinStyle')
- if (element.stroke)
- element.stroke.joinStyle = value;
- if (name === 'opacity' || name === 'strokeOpacity')
- if (element.stroke)
- element.stroke.opacity = value >= 0.002 ? value : value === null ? 1 : 0.002;
- if (name === 'dashstyle')
- if (element.stroke)
- element.stroke.dashstyle = value
- };
- var getBoundingClientRect = function(element) {
- var i,
- resultRect,
- rect,
- tagName = element.tagName.toLowerCase(),
- points,
- value,
- halfStrokeWidth;
- if (element.className && element.className.indexOf(CLIP_RECT_CLASS) !== -1)
- return;
- if (tagName === 'div') {
- if (element.childNodes.length > 0) {
- resultRect = {};
- for (i = 0; i < element.childNodes.length; i++) {
- rect = getBoundingClientRect(element.childNodes[i]);
- if (!rect)
- continue;
- resultRect.left = resultRect.left === undefined || rect.left < resultRect.left ? rect.left : resultRect.left;
- resultRect.top = resultRect.top === undefined || rect.top < resultRect.top ? rect.top : resultRect.top;
- resultRect.right = resultRect.right === undefined || rect.right > resultRect.right ? rect.right : resultRect.right;
- resultRect.bottom = resultRect.bottom === undefined || rect.bottom > resultRect.bottom ? rect.bottom : resultRect.bottom
- }
- }
- }
- else if (tagName === 'shape' || tagName === 'vml:shape') {
- points = (element.path.value || element.path).match(/[-0-9]+/g);
- resultRect = {};
- rect = element.getBoundingClientRect();
- for (i = 0; i < points.length; i++) {
- value = parseInt(points[i]);
- if (i % 2) {
- resultRect.top = resultRect.top === undefined || value < resultRect.top ? value : resultRect.top;
- resultRect.bottom = resultRect.bottom === undefined || value > resultRect.bottom ? value : resultRect.bottom
- }
- else {
- resultRect.left = resultRect.left === undefined || value < resultRect.left ? value : resultRect.left;
- resultRect.right = resultRect.right === undefined || value > resultRect.right ? value : resultRect.right
- }
- }
- resultRect.left = resultRect.left || 0;
- resultRect.top = resultRect.top || 0;
- resultRect.right = resultRect.right || 0;
- resultRect.bottom = resultRect.bottom || 0;
- if (rect.right - rect.left <= 1 && rect.top - rect.bottom <= 1) {
- resultRect.right = resultRect.right + rect.left;
- resultRect.bottom = resultRect.bottom + rect.top;
- resultRect.left = resultRect.left + rect.left;
- resultRect.top = resultRect.top + rect.top
- }
- else {
- resultRect.right = resultRect.right - resultRect.left + rect.left;
- resultRect.bottom = resultRect.bottom - resultRect.top + rect.top;
- resultRect.left = rect.left;
- resultRect.top = rect.top
- }
- halfStrokeWidth = Math.ceil(parseFloat(element.strokeweight) / 2);
- if (halfStrokeWidth && halfStrokeWidth > 1) {
- resultRect.left -= halfStrokeWidth;
- resultRect.top -= halfStrokeWidth;
- resultRect.right += halfStrokeWidth;
- resultRect.bottom += halfStrokeWidth
- }
- }
- else
- resultRect = element.getBoundingClientRect();
- return resultRect
- };
- var BaseVmlElement = {
- isVml: function() {
- return true
- },
- dispose: function() {
- this.childElements = null;
- this._style = null;
- this._fullSettings = null;
- this.callBase()
- },
- defaultSettings: function(customOptions) {
- return extendDefaultVmlOptions(customOptions, this.callBase ? this.callBase() : {})
- },
- createElement: function(nodeName) {
- this._nodeName = nodeName;
- this.childElements = [];
- this._fullSettings = {};
- if (this.isVml()) {
- var result = createVmlElement('vml:' + nodeName);
- return result
- }
- else
- return doc.createElement(nodeName)
- },
- append: function(element) {
- var toElement = element || this.renderer.getRoot();
- if (toElement) {
- toElement.element.appendChild(this.element);
- toElement.childElements.push(this);
- if (this.parentElement)
- this.parentElement.childElements.splice($.inArray(this, this.parentElement.childElements), 1);
- this.parentElement = toElement
- }
- if (toElement === this.renderer.getRoot() || toElement._isAppended)
- this.appendComplete();
- return this
- },
- insertBefore: function(target) {
- var parent = target.parentElement;
- parent.element.insertBefore(this.element, target.element);
- this.parentElement = parent;
- parent.childElements.splice($.inArray(target, parent.childElements), 0, this);
- parent._isAppended && this.appendComplete();
- return this
- },
- remove: function() {
- this.callBase.apply(this, arguments);
- if (this.parentElement) {
- this.parentElement.childElements.splice($.inArray(this, this.parentElement.childElements), 1);
- this.parentElement = null
- }
- return this
- },
- detach: function() {
- this.callBase.apply(this, arguments);
- this._delayAttributes(['opacity']);
- this._onDetach();
- if (this.parentElement) {
- this.parentElement.childElements.splice($.inArray(this, this.parentElement.childElements), 1);
- this.parentElement = null
- }
- return this
- },
- clear: function() {
- this.callBase.apply(this, arguments);
- $.each(this.childElements, function(_, element) {
- element._delayAttributes(['opacity']);
- element._onDetach();
- element.parentElement = null
- });
- this.childElements = [];
- return this
- },
- applyStyle: function(style) {
- this.callBase(style);
- if (style.opacity)
- this.element.style.opacity = style.opacity;
- if (style.clip)
- try {
- this.element.style.clip = style.clip
- }
- catch(e) {}
- },
- _fillAttributesFromParentAndCurrentStyle: function(attributes) {
- var element = this.element,
- parent = this.parentElement,
- i,
- settingToStyleMap = {strokeWidth: 'stroke-width'},
- propertyName,
- styleName,
- settingsToApply = {};
- if (parent)
- for (i = 0; i < INHERITABLE_PROPERTIES.length; i++) {
- propertyName = INHERITABLE_PROPERTIES[i];
- if (!this.settings[propertyName] && parent._fullSettings[propertyName])
- settingsToApply[propertyName] = parent._fullSettings[propertyName]
- }
- if (element.style && element.currentStyle)
- for (i = 0; i < INHERITABLE_PROPERTIES.length; i++) {
- propertyName = INHERITABLE_PROPERTIES[i];
- styleName = settingToStyleMap[propertyName] || propertyName;
- if (element.currentStyle[styleName])
- settingsToApply[propertyName] = element.currentStyle[styleName]
- }
- $.extend(this._fullSettings, this.settings, settingsToApply);
- if (this.isVml())
- $.extend(attributes, this._normalizeSettings(settingsToApply))
- },
- _applyAttributes: function(params) {
- var name,
- value;
- if (params && params.arcsize !== undefined) {
- try {
- this.element.setAttribute('arcsize', params.arcsize)
- }
- catch(e) {}
- this.__appliedSettings = {arcsize: params.arcsize};
- delete params.arcsize
- }
- if (params && params['class']) {
- this.element.className = params['class'];
- delete params['class']
- }
- if (!this._isAppended)
- this._delayedAttributes = params;
- else {
- params = params || this._delayedAttributes;
- if (params) {
- this._fillAttributesFromParentAndCurrentStyle(params);
- if (this.isVml()) {
- for (name in params) {
- value = params[name];
- if (name === 'opacity' || name === 'fillOpacity' || name === 'strokeOpacity' || name === 'dashstyle' || name === 'joinStyle')
- applySubElementAttribute(this, params, name);
- else
- this.element[name] = value
- }
- $.each(this.element.children, function(_, e) {
- e.style.behavior = 'url(#default#VML)';
- e.style.display = 'inline-block';
- e.xmlns = "urn:schemas-microsoft-com:vml"
- })
- }
- this.__appliedSettings = this.isVml() ? params : {};
- delete this._delayedAttributes
- }
- }
- },
- _onDetach: function() {
- this._isAppended = false;
- $.each(this.childElements, function(_, child) {
- child._onDetach()
- })
- },
- appendComplete: function() {
- if (this.renderer.isElementAppendedToPage(this)) {
- this._isAppended = true;
- this._applyAttributes();
- $.each(this.childElements, function(_, child) {
- child.appendComplete()
- });
- if (this.parentElement instanceof GroupVmlElement && this.parentElement._clipRect && this.parentElement._clipRect !== this)
- if (this.parentElement._clipRect._isAppended)
- this.parentElement._clipRect.toForeground();
- else
- this.parentElement._clipRect.append(this.parentElement)
- }
- else {
- vmlElementsToAppend.push(this);
- $(this.element).data('vmlNeedAppendComplete', true);
- if (appendTimerID === undefined)
- appendTimerID = setTimeout(function() {
- appendTimerID = undefined;
- var vmlElements = vmlElementsToAppend;
- vmlElementsToAppend = [];
- $.each(vmlElements, function() {
- if ($(this.element).data('vmlNeedAppendComplete') && !this._isAppended)
- this.appendComplete()
- })
- }, 200)
- }
- },
- _delayAttributes: function(attributes) {
- var attr,
- val,
- i,
- settings = this.settings || {};
- attributes = attributes || [];
- this._delayedAttributes = this._delayedAttributes || {};
- for (i = 0; i < attributes.length; i++) {
- attr = attributes[i];
- val = settings[attr];
- if (val)
- this._delayedAttributes[attr] = val
- }
- $.each(this.childElements || [], function(_, child) {
- child._delayAttributes(attributes)
- })
- },
- _normalizeSettings: function(settings) {
- var key,
- style = {},
- normalized = {},
- clipRect,
- pos,
- prop,
- value;
- for (key in settings) {
- prop = key;
- value = settings[prop];
- if (prop === 'x' || prop === 'translateX') {
- pos = settings.x || 0;
- if (settings.translateX)
- pos += settings.translateX;
- style.left = pos + 'px'
- }
- else if (prop === 'y' || prop === 'translateY') {
- pos = settings.y || 0;
- if (settings.translateY)
- pos += settings.translateY;
- style.top = pos + 'px'
- }
- else if (prop === 'width')
- style.width = value + 'px';
- else if (prop === "behavior")
- style[prop] = value;
- else if (prop === 'height')
- style.height = value + 'px';
- else if (prop === 'align')
- continue;
- else if (prop === 'scale')
- continue;
- else if ($.inArray(prop, CSS_PROPERTIES) != -1)
- style[prop] = value !== null ? value : '';
- else if (prop === 'font') {
- if (!$.isPlainObject(value))
- continue;
- $.each(value, function(fontSetting) {
- var styleName,
- firstChar;
- switch (fontSetting) {
- case'color':
- styleName = "fill";
- break;
- case'opacity':
- styleName = "opacity";
- break;
- case'cursor':
- styleName = fontSetting;
- break;
- default:
- firstChar = fontSetting.charAt(0);
- styleName = 'font' + fontSetting.replace(firstChar, firstChar.toUpperCase())
- }
- if (styleName)
- style[styleName] = value[fontSetting]
- })
- }
- else if (prop === 'style')
- $.extend(true, style, value);
- else if (prop === 'rotate')
- this['_rotate'] = value;
- else if (prop === 'clipId') {
- clipRect = this.renderer.getClipRect(value, this);
- if (clipRect) {
- var width = clipRect.width,
- height = clipRect.height,
- x = clipRect.x,
- y = clipRect.y,
- clipWidth = width + x,
- clipHeight = height + y,
- canvasSize = this.renderer._getSize();
- style.width = canvasSize.width;
- style.height = canvasSize.height;
- style.clip = "rect(" + y + "px, " + clipWidth + "px, " + clipHeight + "px, " + x + "px)"
- }
- }
- else if (prop === 'segments')
- continue;
- else if (prop === 'fill') {
- normalized.filled = value === 'none' ? 'f' : 't';
- normalized.fillcolor = value === 'grey' ? '#808080' : value
- }
- else if (prop === 'opacity')
- normalized.opacity = value < 0.002 ? value : value;
- else if (prop === 'stroke') {
- normalized.stroked = value === 'none' ? 'f' : 't';
- normalized.strokecolor = value
- }
- else if (prop === 'strokeWidth')
- normalized.strokeweight = value + 'px';
- else if (prop === 'lineJoin')
- normalized.joinStyle = value;
- else if (prop === 'dashStyle') {
- value = (value || "").toLowerCase();
- normalized.dashstyle = value
- }
- else
- normalized[prop] = value
- }
- this['_style'] = style;
- return normalized
- },
- _getBBox: function() {
- var width,
- height,
- rect,
- parentRect,
- x = 0,
- y = 0,
- element = this.element,
- parent;
- try {
- rect = getBoundingClientRect(element);
- width = rect.right - rect.left;
- height = rect.bottom - rect.top;
- parent = this.element.parentNode || this.renderer.getRoot().element;
- parentRect = parent.getBoundingClientRect();
- x = rect.left - parentRect.left;
- y = rect.top - parentRect.top;
- if (element.tagName.toLowerCase() === 'div') {
- x = x - (parseInt(element.style.left, 10) || 0);
- y = y - (parseInt(element.style.top, 10) || 0)
- }
- }
- catch(e) {
- width = element.offsetWidth || 0;
- height = element.offsetHeight || 0
- }
- return {
- x: x,
- y: y,
- width: width,
- height: height,
- isEmpty: !x && !y && !width && !height
- }
- },
- getBBox: function() {
- return this._getBBox()
- },
- sharpEdges: function(){}
- };
- var convertSvgPathCommandToVml = function(command) {
- switch (command) {
- case'M':
- return 'm';
- case'L':
- return 'l';
- case'Z':
- return 'x e'
- }
- return command
- };
- var BasePathVmlElement = {
- defaultSettings: function() {
- return $.extend(this.callBase(), {coordsize: '1,1'})
- },
- getNodeName: function() {
- return 'shape'
- },
- getPathAttributeName: function() {
- return 'path'
- },
- customizeSegments: function(segments) {
- var result = segments;
- if (segments)
- result = $.map(segments, function(s, i) {
- var pos,
- segmentArray = [],
- command = convertSvgPathCommandToVml(s[0]);
- segmentArray.push(command);
- for (pos = 1; pos < s.length; pos++)
- segmentArray.push(Math.floor(s[pos]));
- return [segmentArray]
- });
- return result
- }
- };
- var RootVmlElement = svgRendererInternals.BaseSvgElement.inherit(BaseVmlElement).inherit({
- isVml: function() {
- return false
- },
- defaultSettings: function() {
- return {
- width: 0,
- height: 0,
- position: 'relative',
- display: 'inline-block',
- overflow: 'hidden',
- stroke: 'none',
- strokeWidth: 0,
- fill: 'none'
- }
- },
- ctor: function(renderer, params) {
- this.callBase(renderer, 'div', params)
- }
- });
- var ImageVmlElement = svgRendererInternals.BaseSvgElement.inherit(svgRendererInternals.RectSvgBaseElement).inherit(BaseVmlElement).inherit({
- ctor: function(renderer, params) {
- this.callBase(renderer, 'image', params)
- },
- defaultSettings: function() {
- return $.extend(this.callBase(), {
- strokeWidth: 0,
- fill: 'none',
- stroke: 'none'
- })
- },
- adjustSettings: function() {
- var defaultSettings = this.defaultSettings();
- this.callBase();
- if (this.settings.href) {
- this.settings.src = this.settings.href;
- delete this.settings.href
- }
- this.settings.fill = defaultSettings.fill;
- this.settings.stroke = defaultSettings.stroke;
- this.settings.strokeWidth = defaultSettings.strokeWidth
- }
- });
- var RectVmlElement = svgRendererInternals.BaseSvgElement.inherit(svgRendererInternals.RectSvgBaseElement).inherit(BaseVmlElement).inherit({
- defaultSettings: function() {
- return extendDefaultVmlOptions({
- stroked: 'f',
- strokeWidth: 0,
- rx: 0,
- ry: 0
- })
- },
- recreateElement: function(name) {
- this._nodeName = name;
- var parent = this.$element.parent()[0];
- if (parent) {
- var $oldElement = this.$element;
- this.element = this.createElement(name);
- this.$element = $(this.element);
- this.$element.insertBefore($oldElement);
- $oldElement.remove()
- }
- else {
- this.element = this.createElement(name);
- this.$element = $(this.element)
- }
- this.applySettings()
- },
- _adjustArcSize: function() {
- var settings = this.settings;
- var rx = settings.rx || 0,
- ry = settings.ry || 0,
- width = settings.width,
- height = settings.height,
- r,
- halfsize,
- arcsize;
- if (settings.rx !== undefined || settings.ry !== undefined) {
- r = Math.max(rx, ry);
- halfsize = Math.max(width, height) / 2;
- arcsize = r / halfsize;
- settings.arcsize = arcsize;
- if ($.isNumeric(arcsize) && arcsize != 0)
- this._nodeName !== 'roundrect' && this.recreateElement('roundrect');
- else
- this._nodeName === 'roundrect' && this.recreateElement('rect');
- delete settings.rx;
- delete settings.ry
- }
- },
- _adjustRotation: function() {
- var settings = this.settings;
- var rotate = this.settings.rotate,
- rotateAngle,
- radianAngle,
- cos,
- sin,
- rotateX,
- rotateY,
- marginTop,
- marginLeft,
- cx,
- cy,
- rotateObject;
- rotateObject = parseRotateParameter(rotate, settings.x, settings.y);
- if (rotateObject) {
- rotateAngle = rotateObject.angle;
- rotateX = rotateObject.x;
- rotateY = rotateObject.y;
- radianAngle = rotateAngle * Math.PI / 180.0;
- cos = Math.cos(radianAngle);
- sin = Math.sin(radianAngle);
- cx = settings.x + (settings.translateX || 0) + settings.width / 2;
- cy = settings.y + (settings.translateY || 0) + settings.height / 2;
- marginLeft = (cx - rotateX) * cos - (cy - rotateY) * sin + rotateX - cx;
- marginTop = (cx - rotateX) * sin + (cy - rotateY) * cos + rotateY - cy;
- this.settings.marginLeft = Math.round(marginLeft) + 'px';
- this.settings.marginTop = Math.round(marginTop) + 'px';
- this.settings.rotation = rotateAngle
- }
- },
- adjustSettings: function() {
- this.callBase();
- this._adjustArcSize();
- this._adjustRotation()
- },
- ctor: function(renderer, params) {
- this.callBase(renderer, 'rect', params)
- }
- });
- var PathVmlElement = svgRendererInternals.PathSvgElement.inherit(BaseVmlElement).inherit(BasePathVmlElement).inherit({prepareSegments: function(settings) {
- var that = this,
- rotate = settings.rotate,
- rotateAngle,
- rotateX,
- rotateY,
- oldSegments,
- radianAngle,
- cos,
- sin,
- x,
- y,
- rotatedX,
- rotatedY,
- rotateObject;
- this.callBase(settings);
- oldSegments = that.segments;
- rotateObject = parseRotateParameter(rotate, settings.x, settings.y);
- if (rotateObject) {
- rotateAngle = rotateObject.angle;
- rotateX = rotateObject.x;
- rotateY = rotateObject.y;
- if (that.segments) {
- radianAngle = rotateAngle * Math.PI / 180.0;
- cos = Math.cos(radianAngle);
- sin = Math.sin(radianAngle);
- that.segments = $.map(that.segments, function(s, i) {
- if (s.length === 3) {
- x = s[1],
- y = s[2];
- rotatedX = (x - rotateX) * cos - (y - rotateY) * sin + rotateX;
- rotatedY = (x - rotateX) * sin + (y - rotateY) * cos + rotateY;
- return [[s[0], Math.floor(rotatedX), Math.floor(rotatedY)]]
- }
- else
- return [s]
- });
- that.combinePathParams(settings);
- that.segments = oldSegments
- }
- }
- }});
- var SimplePathVmlElement = svgRendererInternals.BaseSvgElement.inherit(BaseVmlElement).inherit({
- ctor: function(renderer, options) {
- this.callBase(renderer, 'shape', options)
- },
- defaultSettings: function() {
- return extendDefaultVmlOptions({coordsize: '1,1'})
- },
- adjustSettings: function() {
- var settings = this.settings;
- if (settings.d !== undefined) {
- settings.path = settings.d;
- delete settings.d
- }
- }
- });
- var AreaVmlElement = PathVmlElement.inherit({
- defaultSettings: function() {
- var baseOptions = this.callBase();
- return extendDefaultVmlOptions({points: {
- x: 0,
- y: 0
- }}, baseOptions)
- },
- ctor: function(renderer, params) {
- this.closePath = true;
- this.callBase(renderer, params)
- }
- });
- var SegmentRectVmlElement = svgRendererInternals.SegmentRectSvgElement.inherit(BaseVmlElement).inherit(BasePathVmlElement).inherit({
- defaultSettings: function() {
- var settings = this.callBase();
- settings.lineJoin = 'miter';
- delete settings.fill;
- delete settings.stroke;
- delete settings.strokecolor;
- delete settings.stroked;
- return settings
- },
- prepareSegments: function() {
- this.callBase();
- this.segments = this.customizeSegments(this.segments);
- this.settings.x = 0;
- this.settings.y = 0;
- this.settings.width = 1;
- this.settings.height = 1
- },
- applySettings: function(settings) {
- var x = settings.x,
- y = settings.y,
- w = settings.width,
- h = settings.height;
- this.callBase(settings);
- this.settings.x = x;
- this.settings.y = y;
- this.settings.width = w;
- this.settings.height = h;
- return this
- }
- });
- var BezierVmlElement = svgRendererInternals.BezierSvgElement.inherit(BaseVmlElement).inherit(BasePathVmlElement);
- var BezierAreaVmlElement = BezierVmlElement.inherit({
- defaultSettings: function() {
- var baseOptions = this.callBase();
- return extendDefaultVmlOptions({points: {
- x: 0,
- y: 0
- }}, baseOptions)
- },
- ctor: function(renderer, params) {
- this.closePath = true;
- this.callBase(renderer, params)
- }
- });
- var ArcVmlElement = svgRendererInternals.ArcSvgElement.inherit(BaseVmlElement).inherit(BasePathVmlElement).inherit({createArcSegments: function(x, y, innerR, outerR, startAngle, endAngle, isCircle) {
- var xOuterStart = x + outerR * Math.cos(startAngle),
- yOuterStart = y - outerR * Math.sin(startAngle),
- xOuterEnd = x + outerR * Math.cos(endAngle),
- yOuterEnd = y - outerR * Math.sin(endAngle),
- xInnerStart = x + innerR * Math.cos(endAngle),
- yInnerStart = y - innerR * Math.sin(endAngle),
- xInnerEnd = x + innerR * Math.cos(startAngle),
- yInnerEnd = y - innerR * Math.sin(startAngle);
- return [['wr', x - innerR, y - innerR, x + innerR, y + innerR, xInnerStart, yInnerStart, xInnerEnd, yInnerEnd], [isCircle ? 'wr' : 'at', x - outerR, y - outerR, x + outerR, y + outerR, xOuterStart, yOuterStart, xOuterEnd, yOuterEnd], ['x e']]
- }});
- var CircleVmlElement = svgRendererInternals.BaseSvgElement.inherit(BaseVmlElement).inherit({
- defaultSettings: function() {
- return extendDefaultVmlOptions({
- cx: 0,
- cy: 0,
- r: 0
- })
- },
- applySettings: function(settings) {
- settings.cx = settings.cx || settings.x;
- settings.cy = settings.cy || settings.y;
- return this.callBase(settings)
- },
- adjustSettings: function() {
- var r,
- cx,
- cy;
- if (this.settings.cx !== undefined || this.settings.cy !== undefined || this.settings.r !== undefined) {
- r = 'r' in this.settings ? this.settings.r : this.settings.width / 2;
- cx = 'cx' in this.settings ? this.settings.cx : this.settings.x + this.settings.width / 2;
- cy = 'cy' in this.settings ? this.settings.cy : this.settings.y + this.settings.width / 2;
- this.settings.x = cx - r;
- this.settings.y = cy - r;
- this.settings.width = this.settings.height = r * 2;
- delete this.settings.cx;
- delete this.settings.cy;
- delete this.settings.r
- }
- },
- ctor: function(renderer, params) {
- this.callBase(renderer, 'oval', params)
- }
- });
- var TextVmlElement = svgRendererInternals.BaseSvgElement.inherit(BaseVmlElement).inherit({
- isVml: function() {
- return false
- },
- defaultSettings: function() {
- return {
- x: 0,
- y: 0,
- position: 'absolute',
- whiteSpace: 'nowrap'
- }
- },
- ctor: function(renderer, params) {
- this.callBase(renderer, 'span', params)
- },
- adjustSettings: function() {
- var text,
- settings = this.settings;
- if (settings.font) {
- settings.fill = settings.fill || settings.font.color;
- settings.opacity = settings.opacity || settings.font.opacity
- }
- if ('text' in settings) {
- text = utils.isDefined(settings.text) ? settings.text : '';
- text = text.toString().replace(/\r/g, "");
- text = text.replace(/\n/g, "<br/>");
- $(this.element).html(text);
- delete settings.text
- }
- if (this.renderer.rtl)
- $(this.element).css('direction', 'rtl')
- },
- updateText: function(text) {
- this.applySettings({text: utils.isDefined(text) ? text : ''})
- },
- _applyAttributes: function(settings) {
- this.callBase(settings);
- settings = this._fullSettings;
- var rotate = settings.rotate,
- rotateAngle = 0,
- rotateX,
- rotateY,
- cos = 1,
- sin = 0,
- osin = 0,
- ocos = 1,
- angle,
- otg,
- rad,
- y = settings.y + (settings.translateY || 0),
- x = settings.x + (settings.translateX || 0),
- align = settings.align,
- bBox = this.getBBox(),
- style = this._style || {},
- marginLeft = 0,
- marginTop = 0,
- fontHeightOffset,
- alignMultiplier,
- rotateObject,
- textWidth,
- textHeight;
- if (this._oldRotate && !bBox.isEmpty) {
- rad = this._oldRotate.angle * Math.PI / 180.0;
- osin = Math.sin(rad);
- ocos = Math.cos(rad);
- if ((this._oldRotate.angle | 0) % 90 !== 0)
- if ((this._oldRotate.angle | 0) % 45 === 0)
- textWidth = bBox.width,
- textHeight = bBox.height;
- else {
- otg = Math.abs(Math.tan(rad));
- var b = (bBox.width - bBox.height * otg) / (1 - otg * otg);
- var a = bBox.width - b;
- textHeight = Math.abs(a / osin);
- textWidth = Math.abs(b / ocos)
- }
- else {
- textHeight = Math.abs(bBox.height * ocos - bBox.width * osin);
- textWidth = Math.abs(bBox.width * ocos - bBox.height * osin)
- }
- }
- else
- textWidth = bBox.width,
- textHeight = bBox.height;
- this.__textWidth = textWidth;
- this.__textHeight = textHeight;
- if (textHeight || textWidth) {
- rotateObject = parseRotateParameter(rotate, x, y);
- this._oldRotate = rotateObject;
- if (rotateObject) {
- rotateAngle = rotateObject.angle;
- rotateX = rotateObject.x;
- rotateY = rotateObject.y;
- if (Math.abs(rotateAngle) > 360)
- rotateAngle = rotateAngle % 360;
- if (rotateAngle < 0)
- rotateAngle = rotateAngle + 360;
- if (rotateAngle) {
- rad = rotateAngle * Math.PI / 180.0;
- cos = Math.cos(rad);
- sin = Math.sin(rad);
- style.filter = 'progid:DXImageTransform.Microsoft.Matrix(sizingMethod="auto expand", M11 = ' + cos.toFixed(5) + ', M12 = ' + (-sin).toFixed(5) + ', M21 = ' + sin.toFixed(5) + ', M22 = ' + cos.toFixed(5) + ')'
- }
- else {
- style.filter = '';
- this._oldRotate = null
- }
- marginLeft = (x - rotateX) * (cos - 1) - (y - rotateY) * sin;
- marginTop = (x - rotateX) * sin + (y - rotateY) * (cos - 1)
- }
- fontHeightOffset = textHeight * (0.55 + 0.45 / 2);
- if (rotateAngle < 90) {
- marginTop -= fontHeightOffset * cos;
- marginLeft -= (textHeight - fontHeightOffset) * sin
- }
- else if (rotateAngle < 180) {
- marginTop += (textHeight - fontHeightOffset) * cos;
- marginLeft += textWidth * cos - (textHeight - fontHeightOffset) * sin
- }
- else if (rotateAngle < 270) {
- marginTop += (textHeight - fontHeightOffset) * cos + textWidth * sin;
- marginLeft += textWidth * cos + fontHeightOffset * sin
- }
- else {
- marginTop += textWidth * sin - fontHeightOffset * cos;
- marginLeft += fontHeightOffset * sin
- }
- if (rotateAngle && this.renderer.rtl)
- marginLeft -= textWidth - (textHeight * Math.abs(sin) + textWidth * Math.abs(cos));
- alignMultiplier = {
- center: 0.5,
- right: 1
- }[align];
- if (alignMultiplier) {
- marginLeft -= textWidth * alignMultiplier * cos;
- marginTop -= textWidth * alignMultiplier * sin
- }
- style.marginLeft = Math.round(marginLeft) + 'px';
- style.marginTop = Math.round(marginTop) + 'px'
- }
- if (settings.fill && settings.fill !== 'none')
- style.color = settings.fill;
- if (settings.opacity)
- this.element.style.filter = 'alpha(opacity=' + settings.opacity * 100 + ')';
- this.applyStyle(style)
- }
- });
- var GroupVmlElement = svgRendererInternals.BaseSvgElement.inherit(BaseVmlElement).inherit({
- isVml: function() {
- return false
- },
- defaultSettings: function() {
- return {
- x: 0,
- y: 0,
- position: 'absolute'
- }
- },
- ctor: function(renderer, params) {
- this.callBase(renderer, 'div', params)
- },
- adjustSettings: function() {
- if (this.settings.clipId || this._clipRect) {
- var rect = this.renderer.getClipRect(this.settings.clipId, this);
- if (this._clipRect)
- if (rect)
- this._clipRect.applySettings({
- x: rect.x,
- y: rect.y,
- width: rect.width,
- height: rect.height
- });
- else {
- this._clipRect.remove();
- this._clipRect = null
- }
- else
- this._clipRect = this.renderer.createRect(rect.x, rect.y, rect.width, rect.height, 0, {
- fill: "none",
- opacity: 0.002,
- "class": CLIP_RECT_CLASS
- });
- if (this._clipRect)
- this.childElements.length && this._clipRect.append(this)
- }
- },
- applySettings: function(settings) {
- var rotate;
- settings = settings || {};
- rotate = settings.rotate;
- if (rotate) {
- if (utils.isNumber(rotate))
- rotate = [rotate, settings.x || 0, settings.y || 0];
- $.each(this.childElements, function(_, child) {
- child.applySettings({rotate: rotate})
- })
- }
- delete settings.rotate;
- delete settings.x;
- delete settings.y;
- this.callBase(settings);
- $.each(this.childElements || [], function(_, c) {
- c.applySettings({})
- });
- return this
- },
- getBBox: function() {
- return this._getBBox()
- },
- update: function() {
- if (this.settings.clipId) {
- var bbox = this.getBBox();
- this.applyStyle({
- left: bbox.x + (this.settings.translateX || 0),
- right: bbox.y + (this.settings.translateY || 0),
- width: bbox.width,
- height: bbox.height
- })
- }
- }
- });
- renderers.VmlRenderer = renderers.SvgRenderer.inherit({
- ctor: function(options) {
- options = options || {};
- options.animation = {enabled: false};
- if (doc.namespaces && !doc.namespaces.vml) {
- doc.namespaces.add('vml', 'urn:schemas-microsoft-com:vml');
- var cssText = 'vml\\:fill, vml\\:path, vml\\:shape, vml\\:stroke, vml\\:rect, vml\\:oval' + '{ behavior:url(#default#VML); display: inline-block; };';
- try {
- doc.createStyleSheet().cssText = cssText
- }
- catch(e) {
- doc.styleSheets[0].cssText += cssText
- }
- }
- this._clipRects = {};
- this.cssClass = options.cssClass || '';
- this.callBase(options)
- },
- dispose: function() {
- this.callBase();
- this._clipRects = null;
- this._size = null
- },
- updateAnimationOptions: $.noop,
- draw: function(container) {
- var root = this.getRoot();
- this.callBase(container);
- if (root)
- root.appendComplete()
- },
- recreateCanvas: function(width, height, cssClass) {
- if (width >= 0 && height >= 0) {
- this._size = {
- width: width,
- height: height
- };
- if (!this.svgRoot) {
- this.cssClass = cssClass || this.cssClass;
- this.svgRoot = new RootVmlElement(this, {
- width: width,
- height: height,
- 'class': this.cssClass
- })
- }
- else
- this.svgRoot.applySettings({
- width: width,
- height: height
- });
- this.defsSvg && this.defsSvg.clear()
- }
- },
- _getSize: function() {
- return this._size || {}
- },
- isElementAppendedToPage: function(element) {
- return $(element.element).closest(doc.documentElement).length
- },
- createRect: function(x, y, w, h, r, options) {
- var params = $.extend(true, {}, options || {}, {
- x: x,
- y: y,
- width: w,
- height: h,
- rx: r,
- ry: r
- });
- return new RectVmlElement(this, params)
- },
- createSegmentRect: function(x, y, w, h, r, segments, options) {
- var params = $.extend({}, options || {}, {
- x: x,
- y: y,
- width: w,
- height: h,
- rx: r,
- ry: r,
- segments: segments
- });
- return new SegmentRectVmlElement(this, params)
- },
- createClipRect: function(x, y, width, height) {
- var clipId = utils.getNextDefsSvgId(),
- elements = [],
- clipRect = {
- id: clipId,
- x: x,
- y: y,
- width: width,
- height: height,
- addElement: function(element) {
- var hasElement = false;
- $.each(elements, function() {
- if (this === element) {
- hasElement = true;
- return false
- }
- });
- if (!hasElement)
- elements.push(element)
- },
- append: function() {
- return this
- },
- remove: function(){},
- dispose: function(){},
- updateRectangle: function(settings) {
- if ('x' in settings)
- this.x = settings.x;
- if ('translateX' in settings)
- this.x += settings.translateX;
- if ('y' in settings)
- this.y = settings.y;
- if ('translateY' in settings)
- this.y += settings.translateY;
- if ('width' in settings)
- this.width = settings.width;
- if ('height' in settings)
- this.height = settings.height;
- $.each(elements, function() {
- this.applySettings({clipId: clipId})
- });
- return this
- }
- };
- this._clipRects[clipId] = clipRect;
- return clipRect
- },
- getClipRect: function(clipId, element) {
- var clipRect = this._clipRects[clipId];
- if (clipRect && element)
- clipRect.addElement(element);
- return this._clipRects[clipId]
- },
- createImage: function(x, y, w, h, href, options) {
- var params = $.extend(true, {}, options && !options.inh ? options : {}, {
- x: x,
- y: y,
- width: w,
- height: h,
- href: href
- });
- return new ImageVmlElement(this, params)
- },
- createLine: function(x1, y1, x2, y2, options) {
- var params = $.extend(true, {}, options && !options.inh ? options : {}, {points: [x1, y1, x2, y2]});
- return new PathVmlElement(this, params)
- },
- createPath: function(points, options) {
- var params = $.extend(true, {}, options && !options.inh ? options : {}, {points: points});
- return new PathVmlElement(this, params)
- },
- createSimplePath: function(options) {
- return new SimplePathVmlElement(this, options)
- },
- createBezierPath: function(points, options) {
- var params = $.extend(true, {}, options && !options.inh ? options : {}, {points: points});
- return new BezierVmlElement(this, params)
- },
- createArea: function(points, options) {
- var params = $.extend(true, {}, options && !options.inh ? options : {}, {points: points});
- return new AreaVmlElement(this, params)
- },
- createBezierArea: function(points, options) {
- var params = $.extend(true, {}, options && !options.inh ? options : {}, {points: points});
- return new BezierAreaVmlElement(this, params)
- },
- createCircle: function(x, y, r, options) {
- var params = $.extend(true, {}, options && !options.inh ? options : {}, {
- cx: x,
- cy: y,
- r: r
- });
- return new CircleVmlElement(this, params)
- },
- createArc: function(x, y, outerRadius, innerRadius, startAngle, endAngle, options) {
- var params = $.extend(true, {}, options && !options.inh ? options : {}, {
- x: x,
- y: y,
- outerRadius: outerRadius,
- innerRadius: innerRadius,
- startAngle: startAngle,
- endAngle: endAngle
- });
- return new ArcVmlElement(this, params)
- },
- createText: function(text, x, y, options) {
- var params = $.extend(true, {}, options && !options.inh ? options : {}, {
- x: x,
- y: y,
- text: text
- });
- return new TextVmlElement(this, params)
- },
- createGroup: function(options) {
- return new GroupVmlElement(this, options)
- },
- createPattern: function(color, hatching) {
- return {
- id: color,
- append: function() {
- return this
- },
- clear: function(){},
- dispose: function(){}
- }
- },
- createFilter: function(type) {
- if (type === 'shadow')
- return {
- ref: null,
- append: function() {
- return this
- },
- dispose: function() {
- return this
- },
- applySettings: function() {
- return this
- }
- };
- return null
- },
- svg: function() {
- return ''
- }
- });
- function buildPath(points) {
- var i = 0,
- ii = points.length,
- list = [];
- for (; i < ii; )
- list.push('l', points[i++].toFixed(0), points[i++].toFixed(0));
- if (ii) {
- list[0] = 'm';
- list.push('x e');
- list = list.join(' ')
- }
- else
- list = '';
- return list
- }
- function processCircleSettings(x, y, size) {
- return {
- cx: x,
- cy: y,
- r: size / 2
- }
- }
- renderers._vmlBuildPath = buildPath;
- renderers._vmlProcessCircleSettings = processCircleSettings;
- renderers.__vmlRendererInternals = {
- RootVmlElement: RootVmlElement,
- RectVmlElement: RectVmlElement,
- ImageVmlElement: ImageVmlElement,
- PathVmlElement: PathVmlElement,
- AreaVmlElement: AreaVmlElement,
- BezierVmlElement: BezierVmlElement,
- BezierAreaVmlElement: BezierAreaVmlElement,
- SimplePathVmlElement: SimplePathVmlElement,
- CircleVmlElement: CircleVmlElement,
- TextVmlElement: TextVmlElement,
- GroupVmlElement: GroupVmlElement,
- ArcVmlElement: ArcVmlElement,
- SegmentRectVmlElement: SegmentRectVmlElement
- }
- })(jQuery, DevExpress);
- /*! Module viz-core, file renderer.js */
- (function($, DX) {
- var renderers = DX.viz.renderers,
- browser = DX.browser;
- function isSvg() {
- return !(browser.msie && browser.version < 9) || !!document.createElementNS && !!document.createElementNS('http://www.w3.org/2000/svg', "svg").createSVGRect
- }
- if (!isSvg()) {
- renderers.Renderer = renderers.VmlRenderer;
- renderers.buildPath = renderers._vmlBuildPath;
- renderers.processCircleSettings = renderers._vmlProcessCircleSettings
- }
- else {
- renderers.Renderer = renderers.SvgRenderer;
- renderers.buildPath = renderers._svgBuildPath;
- renderers.processCircleSettings = renderers._svgProcessCircleSettings
- }
- renderers.isSvg = isSvg
- })(jQuery, DevExpress);
- /*! Module viz-core, file animation.js */
- (function(DX) {
- var renderers = DX.viz.renderers,
- Class = DX.Class,
- noop = function(){},
- easingFunctions = {
- easeOutCubic: function(pos, start, end) {
- return pos === 1 ? end : (1 - Math.pow(1 - pos, 3)) * (end - start) + +start
- },
- linear: function(pos, start, end) {
- return pos === 1 ? end : pos * (end - start) + +start
- }
- };
- renderers.easingFunctions = easingFunctions;
- renderers.animationSvgStep = {
- points: function(elem, params, progress, easing, currentParams) {
- var from = params.from,
- to = params.to,
- path = [],
- i,
- j,
- seg,
- d;
- for (i = 0; i < from.length; i++) {
- seg = [from[i][0]];
- if (from[i].length > 1)
- for (j = 1; j < from[i].length; j++)
- seg.push(easing(progress, from[i][j], to[i][j]));
- path[i] = seg.join(' ')
- }
- d = path.join(' ');
- currentParams.d = params.end && progress === 1 ? params.end : d;
- elem.element.setAttribute('d', d)
- },
- arc: function(elem, params, progress, easing) {
- var from = params.from,
- to = params.to,
- current = {};
- for (var i in from)
- current[i] = easing(progress, from[i], to[i]);
- elem.applySettings(current)
- },
- transform: function(elem, params, progress, easing, currentParams) {
- var translate = params.translate,
- rotate = params.rotate,
- scale = params.scale,
- transformations = [],
- elemSettings = elem.settings;
- if (translate) {
- currentParams.translateX = easing(progress, translate.x.from, translate.x.to);
- currentParams.translateY = easing(progress, translate.y.from, translate.y.to);
- transformations.push('translate(' + currentParams.translateX + ',' + currentParams.translateY + ')')
- }
- else if (elemSettings.translateX || elemSettings.translateY)
- transformations.push('translate(' + (elemSettings.translateX || 0) + ',' + (elemSettings.translateY || 0) + ')');
- if (rotate) {
- currentParams.rotate = {
- angle: easing(progress, rotate.angle.from, rotate.angle.to),
- x: rotate.x,
- y: rotate.y
- };
- transformations.push('rotate(' + currentParams.rotate.angle + ',' + rotate.x + ',' + rotate.y + ')')
- }
- else if (elemSettings.rotate)
- transformations.push('rotate(' + elemSettings.rotate.angle + ',' + (elemSettings.rotate.x || 0) + ',' + (elemSettings.rotate.y || 0) + ')');
- if (scale) {
- currentParams.scale = {
- x: easing(progress, scale.x.from, scale.x.to),
- y: easing(progress, scale.y.from, scale.y.to)
- };
- transformations.push('scale(' + currentParams.scale.x + ',' + currentParams.scale.y + ')')
- }
- else if (elemSettings.scale)
- transformations.push('scale(' + elemSettings.scale.x + ',' + elemSettings.scale.y + ')');
- elem.element.setAttribute('transform', transformations.join())
- },
- base: function(elem, params, progress, easing, currentParams, attributeName) {
- currentParams[attributeName] = easing(progress, params.from, params.to);
- elem.element.setAttribute(attributeName, currentParams[attributeName])
- },
- _: noop,
- complete: function(element, currentSettings) {
- element.applySettings(currentSettings)
- }
- };
- var Animation = Class.inherit({
- ctor: function(element, params, options) {
- var that = this;
- that._progress = 0;
- that.element = element;
- that.params = params;
- that.options = options;
- that.duration = options.partitionDuration ? options.duration * options.partitionDuration : options.duration;
- that._animateStep = options.animateStep || renderers.animationSvgStep;
- that._easing = easingFunctions[options.easing] || easingFunctions['easeOutCubic'];
- that._currentParams = {};
- that.tick = that._start
- },
- _calcProgress: function(now) {
- return Math.min(1, (now - this._startTime) / this.duration)
- },
- _step: function(now) {
- var that = this,
- animateStep = that._animateStep,
- attrName;
- that._progress = that._calcProgress(now);
- for (attrName in that.params) {
- if (!that.params.hasOwnProperty(attrName))
- continue;
- var anim = animateStep[attrName] || animateStep.base;
- anim(that.element, that.params[attrName], that._progress, that._easing, that._currentParams, attrName)
- }
- that.options.step && that.options.step(that._easing(that._progress, 0, 1), that._progress);
- if (that._progress === 1)
- return that.stop();
- return true
- },
- _start: function(now) {
- this._startTime = now;
- this.tick = this._step;
- return true
- },
- _end: function(disableComplete) {
- var that = this;
- that.stop = noop;
- that.tick = noop;
- that._animateStep.complete && that._animateStep.complete(that.element, that._currentParams);
- that.options.complete && !disableComplete && that.options.complete()
- },
- tick: function(now) {
- return true
- },
- stop: function(breakAnimation, disableComplete) {
- var options = this.options;
- if (!breakAnimation && options.repeatCount && --options.repeatCount > 0) {
- this.tick = this._start;
- return true
- }
- else
- this._end(disableComplete)
- }
- });
- renderers.AnimationController = Class.inherit(function() {
- var FPS = 1000 / 60,
- requestAnimationFrame = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function(callback) {
- setTimeout(callback, FPS)
- };
- return {
- ctor: function() {
- var that = this;
- that.requestAnimationFrame = requestAnimationFrame;
- that._animationCount = 0;
- that._timerId = null;
- that._animations = {}
- },
- _loop: function() {
- var that = this,
- animations = that._animations,
- activeAnimation = 0,
- now = (new Date).getTime(),
- an;
- for (an in animations) {
- if (!animations.hasOwnProperty(an))
- continue;
- if (!animations[an].tick(now))
- delete animations[an];
- activeAnimation++
- }
- if (activeAnimation === 0) {
- that.stop();
- return
- }
- that._timerId = that.requestAnimationFrame.call(null, function() {
- that._loop()
- }, that.element)
- },
- addAnimation: function(animation) {
- var that = this;
- that._animations[that._animationCount++] = animation;
- if (!that._timerId) {
- clearTimeout(that._startDelay);
- that._startDelay = setTimeout(function() {
- that._timerId = 1;
- that._loop()
- }, 0)
- }
- },
- animateElement: function(elem, params, options) {
- if (elem && params && options) {
- elem.animation && elem.animation.stop(true);
- this.addAnimation(elem.animation = new Animation(elem, params, options))
- }
- },
- dispose: function() {
- this.stop();
- this.element = null
- },
- stop: function() {
- this._animations = {};
- this._animationCount = 0;
- clearTimeout(this._startDelay);
- this._timerId = null
- },
- lock: function() {
- var animations = this._animations;
- for (var an in animations)
- animations.hasOwnProperty(an) && animations[an].stop(true, true);
- this.stop()
- }
- }
- }());
- renderers.Animation = Animation;
- renderers.noop = noop
- })(DevExpress);
- /*! Module viz-core, file namespaces.js */
- (function(DevExpress) {
- DevExpress.viz.charts = {series: {}}
- })(DevExpress);
- /*! Module viz-core, file chartsConsts.js */
- (function(DX) {
- DX.viz.charts.consts = {
- dataTypes: {
- STRING: 'string',
- NUMERIC: 'numeric',
- DATETIME: 'datetime'
- },
- axisTypes: {
- DISCRETE: 'discrete',
- CONTINUOUS: 'continuous',
- LOGARITHMIC: 'logarithmic'
- }
- }
- })(DevExpress);
- /*! Module viz-core, file dataValidator.js */
- (function($, DX) {
- var viz = DX.viz,
- parseUtils = new viz.core.ParseUtils,
- chartConst = viz.charts.consts,
- dataTypes = chartConst.dataTypes,
- axisTypes = chartConst.axisTypes,
- utils = DX.utils,
- _each = $.each,
- _isDefined = utils.isDefined;
- var mergeSort = function(data, field) {
- function merge_sort(array, low, high, field) {
- if (low < high) {
- var mid = Math.floor((low + high) / 2);
- merge_sort(array, low, mid, field);
- merge_sort(array, mid + 1, high, field);
- merge(array, low, mid, high, field)
- }
- }
- var n = data.length;
- merge_sort(data, 0, n - 1, field);
- return data
- };
- var merge = function(array, low, mid, high, field) {
- var newArray = new Array(high - low + 1),
- countL = low,
- countR = mid + 1,
- k,
- i = 0;
- while (countL <= mid && countR <= high) {
- if (array[countL][field] <= array[countR][field] || !_isDefined(array[countR][field])) {
- newArray[i] = array[countL];
- countL++
- }
- else {
- newArray[i] = array[countR];
- countR++
- }
- i++
- }
- if (countL > mid)
- for (k = countR; k <= high; k++, i++)
- newArray[i] = array[k];
- else
- for (k = countL; k <= mid; k++, i++)
- newArray[i] = array[k];
- for (k = 0; k <= high - low; k++)
- array[k + low] = newArray[k];
- return array
- };
- viz.charts.DataValidator = DX.Class.inherit({
- ctor: function(data, groups, incidentOccured, dataPrepareOptions) {
- var that = this;
- groups = groups || [[]];
- if (!data)
- that._nullData = true;
- that.groups = groups;
- that.data = data || [];
- that._parsers = {};
- that._errorShowList = {};
- that._skipFields = {};
- that.options = dataPrepareOptions || {};
- that.incidentOccured = incidentOccured;
- that.userArgumentCategories = that.groups.length && that.groups[0].length && that.groups[0][0].getArgumentCategories();
- if (!incidentOccured)
- that.incidentOccured = $.noop
- },
- validate: function validate() {
- var that = this;
- that._data = that.data;
- if (!utils.isArray(that.data) || that._nullData)
- that._incorrectDataMessage();
- that.groups.argumentType = null;
- that.groups.argumentAxisType = null;
- $.each(that.groups, function(_, group) {
- group.valueType = null;
- group.valueAxisType = null;
- $.each(group, function(_, series) {
- series.updateDataType({})
- })
- });
- that._checkType();
- that._checkAxisType();
- if (that.options.convertToAxisDataType) {
- that._createParser();
- that._parse()
- }
- that._groupData();
- that._sort();
- $.each(that._skipFields, function(field, fieldValue) {
- if (fieldValue === that._data.length)
- that.incidentOccured("W2002", [field])
- });
- return that._data
- },
- _checkType: function _checkType() {
- var that = this,
- groupsWithUndefinedValueType = [],
- groupsWithUndefinedArgumentType = [],
- checkValueTypeOfGroup = function checkValueTypeOfGroup(group, cell) {
- $.each(group, function(_, series) {
- $.each(series.getValueFields(), function(_, field) {
- group.valueType = that._getType(cell[field], group.valueType)
- })
- });
- if (group.valueType)
- return true
- },
- checkArgumentTypeOfGroup = function checkArgumentTypeOfGroup(group, cell) {
- $.each(group, function(_, series) {
- that.groups.argumentType = that._getType(cell[series.getArgumentField()], that.groups.argumentType)
- });
- if (that.groups.argumentType)
- return true
- };
- $.each(that.groups, function(_, group) {
- if (!group.length)
- return null;
- var options = group[0].getOptions(),
- valueTypeGroup = options.valueType,
- argumentTypeGroup = options.argumentType;
- group.valueType = valueTypeGroup;
- that.groups.argumentType = argumentTypeGroup;
- valueTypeGroup ? null : groupsWithUndefinedValueType.push(group);
- argumentTypeGroup ? null : groupsWithUndefinedArgumentType.push(group)
- });
- if (groupsWithUndefinedValueType.length || groupsWithUndefinedArgumentType.length)
- $.each(that.data, function(_, cell) {
- var define = true;
- if (!utils.isObject(cell))
- return;
- $.each(groupsWithUndefinedValueType, function(index, group) {
- define = define && checkValueTypeOfGroup(group, cell)
- });
- $.each(groupsWithUndefinedArgumentType, function(index, group) {
- define = define && checkArgumentTypeOfGroup(group, cell)
- });
- if (!that.options.checkTypeForAllData && define)
- return false
- })
- },
- _checkAxisType: function _checkAxisType() {
- var that = this;
- $.each(that.groups, function(_, group) {
- $.each(group, function(_, series) {
- var optionsSeries = {},
- existingSeriesOptions = series.getOptions();
- optionsSeries.argumentAxisType = that._correctAxisType(that.groups.argumentType, existingSeriesOptions.argumentAxisType, !!that.userArgumentCategories.length);
- optionsSeries.valueAxisType = that._correctAxisType(group.valueType, existingSeriesOptions.valueAxisType, !!series.getValueCategories().length);
- that.groups.argumentAxisType = that.groups.argumentAxisType || optionsSeries.argumentAxisType;
- group.valueAxisType = group.valueAxisType || optionsSeries.valueAxisType;
- optionsSeries.argumentType = that.groups.argumentType;
- optionsSeries.valueType = group.valueType;
- series.updateDataType(optionsSeries)
- })
- })
- },
- _createParser: function _createParser() {
- var that = this;
- $.each(that.groups, function(index, group) {
- $.each(group, function(_, series) {
- that._parsers[series.getArgumentField()] = that._createParserUnit(that.groups.argumentType, that.groups.argumentAxisType === axisTypes.LOGARITHMIC ? that._filterForLogAxis : null);
- $.each(series.getValueFields(), function(_, field) {
- that._parsers[field] = that._createParserUnit(group.valueType, group.valueAxisType === axisTypes.LOGARITHMIC ? that._filterForLogAxis : null, series.getOptions().ignoreEmptyPoints)
- });
- if (series.getTagField())
- that._parsers[series.getTagField()] = null
- })
- })
- },
- _parse: function _parse() {
- var that = this,
- parsedData = [];
- $.each(that.data, function(_, cell) {
- var parserObject = {};
- if (!utils.isObject(cell)) {
- cell && that._incorrectDataMessage();
- return
- }
- $.each(that._parsers, function(field, parser) {
- parserObject[field] = parser ? parser(cell[field], field) : cell[field];
- parserObject['original' + field] = cell[field]
- });
- parsedData.push(parserObject)
- });
- this._data = parsedData
- },
- _groupMinSlices: function(argumentField, valueField, smallValuesGrouping) {
- var that = this,
- smallValuesGrouping = smallValuesGrouping || {},
- mode = smallValuesGrouping.mode,
- count = smallValuesGrouping.topCount,
- threshold = smallValuesGrouping.threshold,
- name = smallValuesGrouping.groupName || 'others',
- others = {},
- data = that._data.slice(),
- index;
- var groupingValues = function(index) {
- if (!_isDefined(index) || index < 0)
- return;
- _each(data.slice(index), function(_, cell) {
- if (!_isDefined(cell[valueField]))
- return;
- others[valueField] += cell[valueField];
- cell[valueField] = undefined;
- cell['original' + valueField] = undefined
- })
- };
- if (!mode || mode === 'none')
- return;
- others[argumentField] = name + '';
- others[valueField] = 0;
- data.sort(function(a, b) {
- if (_isDefined(b[valueField]) && _isDefined(a[valueField]))
- return b[valueField] - a[valueField];
- else if (!_isDefined(b[valueField]) && a[valueField])
- return -1;
- else if (!_isDefined(a[valueField]) && b[valueField])
- return 1
- });
- if (mode === 'smallValueThreshold') {
- _each(data, function(i, cell) {
- if (_isDefined(index) || !_isDefined(cell[valueField]))
- return;
- if (threshold > cell[valueField])
- index = i
- });
- groupingValues(index)
- }
- else if (mode === 'topN')
- groupingValues(count);
- others[valueField] && that._data.push(others)
- },
- _groupData: function() {
- var that = this,
- groups = that.groups,
- isPie = groups.length && groups[0].length && (groups[0][0].type === 'pie' || groups[0][0].type === 'doughnut' || groups[0][0].type === 'donut'),
- argumentField,
- valueFields;
- if (!isPie)
- return;
- _each(groups, function(_, group) {
- _each(group, function(_, series) {
- argumentField = series.getArgumentField();
- valueFields = series.getValueFields();
- if (groups.argumentAxisType === axisTypes.DISCRETE)
- that._groupSameArguments(argumentField, valueFields);
- that._groupMinSlices(argumentField, valueFields[0], series.getOptions().smallValuesGrouping)
- })
- })
- },
- _groupSameArguments: function(argumentField, valueFields) {
- var that = this,
- argument,
- dataOfArguments = {},
- parsedData = that._data;
- _each(parsedData, function(i, cell) {
- if (!_isDefined(cell[argumentField]) || !_isDefined(cell[valueFields[0]]))
- return;
- argument = cell[argumentField];
- if (_isDefined(dataOfArguments[argument])) {
- var data = parsedData[dataOfArguments[argument]];
- _each(valueFields, function(_, field) {
- data[field] += cell[field];
- cell[field] = undefined;
- cell['original' + field] = undefined
- })
- }
- else
- dataOfArguments[argument] = i
- })
- },
- _getType: function _getType(unit, type) {
- if (type === dataTypes.STRING || utils.isString(unit))
- return dataTypes.STRING;
- if (type === dataTypes.DATETIME || utils.isDate(unit))
- return dataTypes.DATETIME;
- if (utils.isNumber(unit))
- return dataTypes.NUMERIC;
- return type
- },
- _correctAxisType: function _correctAxisType(type, axisType, hasCategories) {
- if (type === dataTypes.STRING && (axisType === axisTypes.CONTINUOUS || axisType === axisTypes.LOGARITHMIC))
- this.incidentOccured("E2002");
- if (axisType === axisTypes.LOGARITHMIC)
- return axisTypes.LOGARITHMIC;
- axisType = (hasCategories || axisType === axisTypes.DISCRETE || type === dataTypes.STRING) && axisTypes.DISCRETE;
- return axisType || axisTypes.CONTINUOUS
- },
- _filterForLogAxis: function(val, field) {
- if (val <= 0) {
- this.incidentOccured("E2004", [field]);
- return null
- }
- return val
- },
- _createParserUnit: function _createParserUnit(type, filter, ignoreEmptyPoints) {
- var that = this,
- parser = type ? parseUtils.getParser(type, undefined, true) : function(unit) {
- return unit
- };
- return function(unit, field) {
- var parseUnit = parser(unit);
- if (filter)
- parseUnit = filter.call(that, parseUnit, field);
- parseUnit === null && ignoreEmptyPoints && (parseUnit = undefined);
- if (parseUnit === undefined) {
- that._addSkipFields(field);
- that._validUnit(unit, field, type)
- }
- return parseUnit
- }
- },
- _validUnit: function _validUnit(unit, field, type) {
- if (!unit)
- return;
- if (!utils.isNumber(unit) && !utils.isDate(unit) && !utils.isString(unit)) {
- this.incidentOccured("E2003", [field]);
- return
- }
- this.incidentOccured("E2004", [field])
- },
- _sort: function _sort() {
- var that = this,
- groups = that.groups,
- hash = {},
- argumentField = groups.length && groups[0].length && groups[0][0].getArgumentField();
- if (utils.isFunction(that.options.sortingMethod))
- that._data.sort(that.options.sortingMethod);
- else if (that.userArgumentCategories.length) {
- $.each(that.userArgumentCategories, function(index, value) {
- hash[value] = index
- });
- that._data.sort(function sortCat(a, b) {
- a = a[argumentField];
- b = b[argumentField];
- return hash[a] - hash[b]
- })
- }
- else if (that.options.sortingMethod === true && groups.argumentType !== dataTypes.STRING)
- mergeSort(that._data, argumentField)
- },
- _addSkipFields: function _addSkipFields(field) {
- this._skipFields[field] = (this._skipFields[field] || 0) + 1
- },
- _incorrectDataMessage: function() {
- if (this._erorrDataSource !== true) {
- this._erorrDataSource = true;
- this.incidentOccured("E2001")
- }
- }
- })
- })(jQuery, DevExpress);
- /*! Module viz-core, file themeManager.js */
- (function($, DX, undefined) {
- var viz = DX.viz,
- Palette = viz.core.Palette,
- utils = DX.utils;
- var HOVER_COLOR_HIGHLIGHTING = 20,
- HIGHLIGHTING_STEP = 50;
- viz.charts.ThemeManager = viz.core.BaseThemeManager.inherit(function() {
- var ctor = function(options, themeGroupName) {
- var that = this;
- options = options || {};
- that._userOptions = options;
- that._mergeAxisTitleOptions = [];
- themeGroupName && (that._themeSection = themeGroupName);
- that._IE8 = DX.browser.msie && DX.browser.version < 9;
- that.setTheme(options.theme);
- that.palette = new Palette(options.palette, {
- stepHighlight: HIGHLIGHTING_STEP,
- theme: that._themeName
- })
- };
- var dispose = function() {
- var that = this;
- that.palette.dispose();
- that.palette = that._userOptions = that._mergedSettings = null;
- that.callBase()
- };
- var initDefaultSeriesTheme = function(that) {
- var commonSeriesSettings = that._theme.commonSeriesSettings;
- commonSeriesSettings.point = commonSeriesSettings.point || {};
- commonSeriesSettings.label = commonSeriesSettings.label || {};
- that._initializeFont(commonSeriesSettings.label.font)
- };
- var initAxisTheme = function(that) {
- var axisTheme = that._theme.commonAxisSettings;
- if (axisTheme) {
- axisTheme.label = axisTheme.label || {};
- axisTheme.grid = axisTheme.grid || {};
- axisTheme.ticks = axisTheme.ticks || {};
- axisTheme.line = axisTheme.line || {};
- axisTheme.title = axisTheme.title || {};
- axisTheme.label.font = axisTheme.label.font || {};
- that._initializeFont(axisTheme.label.font);
- axisTheme.title.font = axisTheme.title.font || {};
- that._initializeFont(axisTheme.title.font)
- }
- };
- var resetPalette = function() {
- this.palette.reset()
- };
- var updatePalette = function(palette) {
- this.palette = new Palette(palette || this._theme.defaultPalette, {
- stepHighlight: HIGHLIGHTING_STEP,
- theme: this.themeName
- })
- };
- var processTitleOptions = function(options) {
- return utils.isString(options) ? {text: options} : options
- };
- var processAxisOptions = function(axisOptions, name) {
- if (!axisOptions)
- return;
- axisOptions = $.extend(true, {}, axisOptions);
- axisOptions.title = processTitleOptions(axisOptions.title);
- if (axisOptions.type === 'logarithmic' && axisOptions.logarithmBase <= 0 || axisOptions.logarithmBase && !$.isNumeric(axisOptions.logarithmBase)) {
- axisOptions.logarithmBase = undefined;
- axisOptions.logarithmBaseError = true
- }
- if (axisOptions.label) {
- if (axisOptions.label.alignment)
- axisOptions.label['userAlignment'] = true;
- if (!axisOptions.label.overlappingBehavior) {
- if (axisOptions.label.staggered)
- axisOptions.label.overlappingBehavior = {
- mode: 'stagger',
- staggeringSpacing: axisOptions.label.staggeringSpacing
- };
- if (axisOptions.label.rotationAngle)
- axisOptions.label.overlappingBehavior = {
- mode: 'rotate',
- rotationAngle: axisOptions.label.rotationAngle
- }
- }
- if (utils.isString(axisOptions.label.overlappingBehavior))
- axisOptions.label.overlappingBehavior = {mode: axisOptions.label.overlappingBehavior};
- if (!axisOptions.label.overlappingBehavior || !axisOptions.label.overlappingBehavior.mode)
- axisOptions.label.overlappingBehavior = axisOptions.label.overlappingBehavior || {}
- }
- return axisOptions
- };
- var applyParticularAxisOptions = function(name, userOptions, rotated) {
- var theme = this._theme,
- position = !(rotated ^ name === "valueAxis") ? "horizontalAxis" : "verticalAxis",
- commonAxisSettings = processAxisOptions(this._userOptions["commonAxisSettings"], name);
- return $.extend(true, {}, theme.commonAxisSettings, theme[position], theme[name], commonAxisSettings, processAxisOptions(userOptions, name))
- };
- var mergeOptions = function(name, userOptions) {
- userOptions = userOptions || this._userOptions[name];
- var theme = this._theme[name],
- result = this._mergedSettings[name];
- if (result)
- return result;
- if ($.isPlainObject(theme) && $.isPlainObject(userOptions))
- result = $.extend(true, {}, theme, userOptions);
- else
- result = utils.isDefined(userOptions) ? userOptions : theme;
- this._mergedSettings[name] = result;
- return result
- };
- var applyParticularTheme = {
- base: mergeOptions,
- argumentAxis: applyParticularAxisOptions,
- valueAxisRangeSelector: function() {
- return mergeOptions.call(this, 'valueAxis')
- },
- valueAxis: applyParticularAxisOptions,
- title: function(name) {
- var userOptions = processTitleOptions(this._userOptions[name]);
- return mergeOptions.call(this, name, userOptions)
- },
- series: function(name, userOptions, isPie) {
- var theme = this._theme,
- userCommonSettings = this._userOptions.commonSeriesSettings || {},
- themeCommonSettings = theme.commonSeriesSettings,
- type = ((userOptions.type || userCommonSettings.type || themeCommonSettings.type) + '').toLowerCase(),
- settings,
- palette = this.palette,
- isBar = ~type.indexOf('bar'),
- isBubble = ~type.indexOf('bubble'),
- mainSeriesColor,
- containerBackgroundColor = this.getOptions("containerBackgroundColor");
- if (isBar || isBubble) {
- userOptions = $.extend(true, {}, userCommonSettings, userCommonSettings[type], userOptions);
- var seriesVisibility = userOptions.visible;
- userCommonSettings = {type: {}};
- $.extend(true, userOptions, userOptions.point);
- userOptions.visible = seriesVisibility
- }
- settings = $.extend(true, {}, themeCommonSettings, themeCommonSettings[type], userCommonSettings, userCommonSettings[type], userOptions);
- settings.type = type;
- settings.containerBackgroundColor = containerBackgroundColor;
- if (!isPie) {
- settings.widgetType = 'chart';
- mainSeriesColor = settings.color || palette.getNextColor()
- }
- else {
- settings.widgetType = 'pieChart';
- mainSeriesColor = function() {
- return palette.getNextColor()
- }
- }
- settings.mainSeriesColor = mainSeriesColor;
- settings._IE8 = this._IE8;
- return settings
- },
- pieSegment: function(name, seriesSettings, segmentSettings) {
- var settings = $.extend(true, {}, seriesSettings, segmentSettings);
- var mainColor = new DX.Color(settings.color || this.palette.getNextColor());
- settings.color = mainColor.toHex();
- settings.border.color = settings.border.color || mainColor.toHex();
- settings.hoverStyle.color = settings.hoverStyle.color || this._IE8 && mainColor.highlight(HOVER_COLOR_HIGHLIGHTING) || mainColor.toHex();
- settings.hoverStyle.border.color = settings.hoverStyle.border.color || mainColor.toHex();
- settings.selectionStyle.color = settings.selectionStyle.color || this._IE8 && mainColor.highlight(HOVER_COLOR_HIGHLIGHTING) || mainColor.toHex();
- settings.selectionStyle.border.color = settings.selectionStyle.border.color || mainColor.toHex();
- return settings
- },
- animation: function(name) {
- var userOptions = this._userOptions[name];
- userOptions = $.isPlainObject(userOptions) ? userOptions : utils.isDefined(userOptions) ? {enabled: !!userOptions} : {};
- return mergeOptions.call(this, name, userOptions)
- }
- };
- return {
- _themeSection: 'chart',
- ctor: ctor,
- dispose: dispose,
- _initializeTheme: function() {
- var that = this,
- theme = this._theme;
- theme.legend = theme.legend || {};
- theme.legend.font = theme.legend.font || {};
- that._initializeFont(theme.legend.font);
- initDefaultSeriesTheme(that);
- initAxisTheme(that);
- theme.title = theme.title || {};
- theme.title.font = theme.title.font || {};
- that._initializeFont(theme.title.font);
- theme.tooltip = theme.tooltip || {};
- theme.tooltip.font = theme.tooltip.font || {};
- that._initializeFont(theme.tooltip.font);
- theme.loadingIndicator = theme.loadingIndicator || {};
- theme.loadingIndicator.font = theme.loadingIndicator.font || {};
- that._initializeFont(theme.loadingIndicator.font)
- },
- resetPalette: resetPalette,
- getOptions: function(name) {
- return (applyParticularTheme[name] || applyParticularTheme["base"]).apply(this, arguments)
- },
- setTheme: function(theme) {
- var that = this;
- that._mergedSettings = {};
- that.callBase(theme);
- that.getOptions('rtlEnabled') && $.extend(true, that._theme, that._theme._rtl)
- },
- resetOptions: function(name) {
- this._mergedSettings[name] = null
- },
- update: function(options) {
- this._userOptions = options
- },
- updatePalette: updatePalette
- }
- }())
- })(jQuery, DevExpress);
- /*! Module viz-core, file factory.js */
- (function($, DX) {
- var viz = DX.viz,
- charts = viz.charts,
- series = charts.series;
- charts.factory = function() {
- var createSeriesFamily = function(options) {
- return new series.SeriesFamily(options)
- };
- var createAxis = function(renderer, options) {
- return new charts.Axis(renderer, options)
- };
- var createThemeManager = function(options, groupName) {
- return new charts.ThemeManager(options, groupName)
- };
- var createDataValidator = function(data, groups, incidentOccured, dataPrepareOptions) {
- return new charts.DataValidator(data, groups, incidentOccured, dataPrepareOptions)
- };
- var createTracker = function(options) {
- return new charts.Tracker(options)
- };
- var createTitle = function(renderer, canvas, options, group) {
- return new charts.ChartTitle(renderer, canvas, options, group)
- };
- var createChartLayoutManager = function(options) {
- return new charts.LayoutManager(options)
- };
- return {
- createSeriesFamily: createSeriesFamily,
- createAxis: createAxis,
- createThemeManager: createThemeManager,
- createDataValidator: createDataValidator,
- createTracker: createTracker,
- createChartLayoutManager: createChartLayoutManager,
- createTitle: createTitle
- }
- }()
- })(jQuery, DevExpress);
- /*! Module viz-core, file baseWidget.js */
- (function($, DX, undefined) {
- var core = DX.viz.core,
- utils = DX.utils;
- DX.viz.core.BaseWidget = DX.DOMComponent.inherit({
- NAMESPACE: DX.ui,
- _init: function() {
- this._setRedrawOnResize(this._getOptionRedrawOnResize());
- this._incidentOccured = this._createIncidentOccured();
- this._renderVisiblityChange()
- },
- _optionChanged: function(name, value, prevValue) {
- var that = this;
- switch (name) {
- case'redrawOnResize':
- that._setRedrawOnResize(that._getOptionRedrawOnResize());
- break;
- case'loadingIndicator':
- that._updateLoadIndicator(that._getLoadIndicatorOption());
- break;
- default:
- that._invalidate()
- }
- that.callBase(name, value, prevValue)
- },
- _getOptionRedrawOnResize: function() {
- var redrawOnResize = this.option('redrawOnResize');
- redrawOnResize = redrawOnResize !== undefined ? !!redrawOnResize : true;
- return redrawOnResize
- },
- _getLoadIndicatorOption: function() {
- return this.option('loadingIndicator')
- },
- _dispose: function() {
- var that = this;
- if (that._resizeHandlerCallback)
- that._removeResizeCallbacks();
- that._incidentOccured = null;
- that.callBase()
- },
- _visibilityChanged: function(visible) {
- if (visible)
- this.render()
- },
- _setRedrawOnResize: function(redrawOnResize) {
- var that = this;
- if (redrawOnResize) {
- if (!that._resizeHandlerCallback && utils.isFunction(that._resize)) {
- that._resizeHandlerCallback = DX.utils.createResizeHandler(function() {
- that._resize()
- });
- utils.windowResizeCallbacks.add(that._resizeHandlerCallback)
- }
- }
- else
- that._removeResizeCallbacks()
- },
- _removeResizeCallbacks: function() {
- var that = this;
- that._resizeHandlerCallback && that._resizeHandlerCallback.stop();
- utils.windowResizeCallbacks.remove(that._resizeHandlerCallback);
- delete that._resizeHandlerCallback
- },
- _showLoadIndicator: function(options, canvas) {
- var that = this;
- that._loadIndicator = this._loadIndicator || core.CoreFactory.createLoadIndicator(options, that._element());
- that._loadIndicator.show(canvas.width, canvas.height);
- that._initializing && that._loadIndicator.endLoading(undefined, true)
- },
- _updateLoadIndicator: function(options, width, height) {
- this._loadIndicator && this._loadIndicator.applyOptions(options, width, height)
- },
- _endLoading: function(complete) {
- if (this._loadIndicator)
- this._loadIndicator.endLoading(complete);
- else
- complete && complete()
- },
- _reappendLoadIndicator: function() {
- this._loadIndicator && this._loadIndicator.toForeground()
- },
- _disposeLoadIndicator: function() {
- this._loadIndicator && this._loadIndicator.dispose();
- this._loadIndicator = null
- },
- _setDefaultOptions: function() {
- this.callBase();
- this.option({incidentOccured: function(options) {
- var message = "" + options.id + " - " + options.text,
- majorVerision = options.version.split(".").slice(0, 2).join("_"),
- url = "http://js.devexpress.com/error/" + majorVerision + "/" + options.id;
- utils.logger.warn(message + "\n" + url)
- }})
- },
- _createIncidentOccured: function() {
- var that = this;
- return function(errorOrWarningId, options) {
- var isError = errorOrWarningId[0] === 'E',
- type = isError ? "error" : "warning",
- formattingArray = options ? options.slice(0) : [],
- text,
- incidentOccuredFunc = that.option('incidentOccured');
- formattingArray.unshift(core.errorsWarnings[errorOrWarningId]);
- text = utils.stringFormat.apply(null, formattingArray);
- if (utils.isFunction(incidentOccuredFunc))
- setTimeout(function() {
- incidentOccuredFunc({
- id: errorOrWarningId,
- type: type,
- args: options,
- text: text,
- widget: that.NAME,
- version: DevExpress.VERSION
- })
- })
- }
- },
- _normalizeHtml: function(html) {
- var re = /xmlns="[\s\S]*?"/gi,
- first = true;
- html = html.replace(re, function(match) {
- if (!first)
- return "";
- first = false;
- return match
- });
- return html.replace(/xmlns:NS1="[\s\S]*?"/gi, "").replace(/NS1:xmlns:xlink="([\s\S]*?)"/gi, 'xmlns:xlink="$1"')
- },
- _drawn: function() {
- var that = this,
- drawnCallback = that.option('drawn');
- utils.isFunction(drawnCallback) && setTimeout(function() {
- drawnCallback(that)
- })
- },
- showLoadingIndicator: function() {
- this._showLoadIndicator(this.option('loadingIndicator'), this.canvas || {})
- },
- hideLoadingIndicator: function() {
- this._loadIndicator && this._loadIndicator.hide()
- },
- endUpdate: function() {
- if (this._updateLockCount === 1 && !this._requireRefresh)
- this.hideLoadingIndicator();
- this.callBase()
- },
- svg: function() {
- var renderer = this.renderer || this._renderer;
- return renderer ? this._normalizeHtml(renderer.svg()) : ''
- }
- })
- })(jQuery, DevExpress);
- /*! Module viz-core, file CoreFactory.js */
- (function(DX, undefined) {
- var renderers = DX.viz.renderers,
- core = DX.viz.core;
- DX.viz.core.CoreFactory = function() {
- return {
- createSeries: function(renderer, options) {
- return new core.series.Series(renderer, options)
- },
- createPoint: function(data, options) {
- return new core.series.points.Point(data, options)
- },
- createLabel: function(type, data, options) {
- if (type === "pie" || type === "doughnut" || type === "donut")
- return new core.series.points.PieLabel(data, options);
- else
- return new core.series.points.Label(data, options)
- },
- createRenderer: function(options) {
- return new renderers.Renderer(options)
- },
- createTranslator1D: function(fromValue, toValue, fromAngle, toAngle) {
- return (new core.Translator1D).setDomain(fromValue, toValue).setCodomain(fromAngle, toAngle)
- },
- createTranslator2D: function(range, canvas, options) {
- return new core.Translator2D(range, canvas, options)
- },
- getTickProvider: function() {
- return core.tickProvider
- },
- createTooltip: function(options, group, renderer) {
- return new core.Tooltip(options, group, renderer)
- },
- createLoadIndicator: function(options, group) {
- return new core.LoadIndicator(options, group)
- },
- createLegend: function(data, options, renderer, group) {
- return new core.Legend(data, options, renderer, group)
- },
- createSeriesFamily: function(options) {
- return new core.series.helpers.SeriesFamily(options)
- }
- }
- }()
- })(DevExpress);
- DevExpress.MOD_VIZ_CORE = true
- }
- if (!DevExpress.MOD_VIZ_CHARTS) {
- if (!DevExpress.MOD_VIZ_CORE)
- throw Error('Required module is not referenced: viz-core');
- /*! Module viz-charts, file chartTitle.js */
- (function($, DX, undefined) {
- var isDefined = DX.utils.isDefined,
- endsWith = function(value, pattern) {
- return value.substr(value.length - pattern.length) === pattern
- },
- startsWith = function(value, pattern) {
- return value.indexOf(pattern) === 0
- },
- decreaseGaps = DevExpress.viz.core.utils.decreaseGaps,
- DEFAULT_MARGIN = 10;
- DX.viz.charts.ChartTitle = DX.Class.inherit({
- ctor: function(renderer, options, width, group) {
- var that = this;
- that._init(options, width);
- that.renderer = renderer;
- that.titleGroup = group
- },
- dispose: function() {
- var that = this;
- that.renderer = null;
- that.clipRect = null;
- that.title = null;
- that.innerTitleGroup = null;
- that.titleGroup = null;
- that.options = null
- },
- update: function(options, width) {
- this._init(options, width)
- },
- _init: function(options, width) {
- var that = this;
- if (options) {
- that._parseAlignments(options);
- that.horizontalAlignment = options.horizontalAlignment;
- that.verticalAlignment = options.verticalAlignment;
- that._parseMargins(options);
- that.margin = options.margin;
- that.options = options
- }
- that.setSize({width: width})
- },
- _parseMargins: function(options) {
- options.margin = isDefined(options.margin) ? options.margin : {};
- if (typeof options.margin === 'number') {
- options.margin = options.margin >= 0 ? options.margin : DEFAULT_MARGIN;
- options.margin = {
- top: options.margin,
- bottom: options.margin,
- left: options.margin,
- right: options.margin
- }
- }
- else {
- options.margin.top = options.margin.top >= 0 ? options.margin.top : DEFAULT_MARGIN;
- options.margin.bottom = options.margin.bottom >= 0 ? options.margin.bottom : DEFAULT_MARGIN;
- options.margin.left = options.margin.left >= 0 ? options.margin.left : DEFAULT_MARGIN;
- options.margin.right = options.margin.right >= 0 ? options.margin.right : DEFAULT_MARGIN
- }
- },
- _parseAlignments: function(options) {
- if (isDefined(options.position) && !(isDefined(options.verticalAlignment) && isDefined(options.horizontalAlignment))) {
- options.position = options.position.toLowerCase();
- options.verticalAlignment = endsWith(options.position, 'top') ? 'top' : 'bottom';
- options.horizontalAlignment = startsWith(options.position, 'left') ? 'left' : startsWith(options.position, 'center') && 'center' || 'right';
- return
- }
- options.verticalAlignment = (options.verticalAlignment || '').toLowerCase();
- options.horizontalAlignment = (options.horizontalAlignment || '').toLowerCase();
- if (options.verticalAlignment !== 'top' && options.verticalAlignment !== 'bottom')
- options.verticalAlignment = 'top';
- if (options.horizontalAlignment !== 'left' && options.horizontalAlignment !== 'center' && options.horizontalAlignment !== 'right')
- options.horizontalAlignment = 'center'
- },
- _setBoundingRect: function() {
- var that = this,
- options = that.options,
- margin = that.changedMargin || that.margin,
- box;
- if (!that.innerTitleGroup)
- return;
- box = that.innerTitleGroup.getBBox();
- box.height += margin.top + margin.bottom;
- box.width += margin.left + margin.right;
- box.x -= margin.left;
- box.y -= margin.top;
- if (isDefined(options.placeholderSize))
- box.height = options.placeholderSize;
- that.boundingRect = box
- },
- draw: function() {
- var that = this,
- titleOptions = that.options,
- renderer = that.renderer,
- attr;
- if (!titleOptions.text)
- return;
- that.changedMargin = null;
- if (!that.innerTitleGroup) {
- that.innerTitleGroup = renderer.createGroup();
- that.clipRect = that.createClipRect();
- that.titleGroup && that.clipRect && that.titleGroup.applySettings({clipId: that.clipRect.id})
- }
- else
- that.innerTitleGroup.clear();
- that.innerTitleGroup.append(that.titleGroup);
- attr = {
- font: titleOptions.font,
- align: that.horizontalAlignment,
- style: titleOptions.fontStyle
- };
- that.title = renderer.createText(titleOptions.text, 0, 0, attr).append(that.innerTitleGroup);
- that.title.text = titleOptions.text;
- that._correctTitleLength();
- that._setClipRectSettings()
- },
- _correctTitleLength: function() {
- var that = this,
- text = that.title.text,
- updateText,
- lineLength,
- box;
- that.title.updateText(text);
- that._setBoundingRect();
- box = that.getLayoutOptions();
- if (that._width > box.width || text.indexOf("<br/>") !== -1)
- return;
- lineLength = text.length * that._width / box.width;
- updateText = text.substr(0, ~~lineLength - 1 - 3) + "...";
- that.title.updateText(updateText);
- that._setBoundingRect()
- },
- changeSize: function(size) {
- var that = this,
- margin = $.extend(true, {}, that.margin);
- if (margin.top + margin.bottom < size.height) {
- if (this.innerTitleGroup) {
- that.options._incidentOccured("W2103");
- this.innerTitleGroup.remove();
- this.innerTitleGroup = null
- }
- if (that.clipRect) {
- that.clipRect.remove();
- that.clipRect = null
- }
- }
- else if (size.height > 0) {
- decreaseGaps(margin, ["top", "bottom"], size.height);
- size.height && (that.changedMargin = margin)
- }
- that._correctTitleLength();
- that._setBoundingRect();
- that._setClipRectSettings()
- },
- getLayoutOptions: function() {
- var options = this.options,
- boundingRect = this.innerTitleGroup ? this.boundingRect : {
- width: 0,
- height: 0,
- x: 0,
- y: 0
- };
- boundingRect.verticalAlignment = options.verticalAlignment;
- boundingRect.horizontalAlignment = options.horizontalAlignment;
- boundingRect.cutLayoutSide = options.verticalAlignment;
- return boundingRect
- },
- setSize: function(size) {
- this._width = size.width || this._width
- },
- shift: function(x, y) {
- var that = this,
- box = that.getLayoutOptions();
- x -= box.x;
- y -= box.y;
- that.innerTitleGroup && that.innerTitleGroup.move(x, y);
- that.clipRect && that.clipRect.updateRectangle({
- translateX: x,
- translateY: y
- })
- },
- createClipRect: function() {
- if (isDefined(this.options.placeholderSize))
- return this.renderer.createClipRect(0, 0, 0, 0)
- },
- _setClipRectSettings: function() {
- var bbox = this.getLayoutOptions(),
- clipRect = this.clipRect;
- if (clipRect) {
- clipRect.append();
- clipRect.updateRectangle({
- x: bbox.x,
- y: bbox.y,
- width: bbox.width,
- height: bbox.height
- })
- }
- }
- });
- DX.viz.charts.ChartTitle.__DEFAULT_MARGIN = DEFAULT_MARGIN
- })(jQuery, DevExpress);
- /*! Module viz-charts, file axis.js */
- (function($, DX, undefined) {
- var utils = DX.utils,
- isDefinedUtils = utils.isDefined,
- isDateUtils = utils.isDate,
- mathAbs = Math.abs,
- core = DX.viz.core,
- AXIS_VALUE_MARGIN_PRIORITY = 100,
- DEFAULT_AXIS_LABEL_SPACING = 5,
- AXIS_STAGGER_OVERLAPPING_KOEF = 2,
- MAX_GRID_BORDER_ADHENSION = 4,
- CANVAS_POSITION_PREFIX = 'canvas_position_',
- CANVAS_POSITION_START = 'canvas_position_start',
- CANVAS_POSITION_END = 'canvas_position_end',
- TOP = 'top',
- BOTTOM = 'bottom',
- LEFT = 'left',
- RIGHT = 'right',
- CENTER = 'center';
- DX.viz.charts.AXIS_STAGGER_OVERLAPPING_KOEF = AXIS_STAGGER_OVERLAPPING_KOEF;
- var processCustomOptions = function(options) {
- var label = options.label,
- position = options.position;
- if (options.isHorizontal) {
- if (!(position === BOTTOM || position === TOP))
- position = BOTTOM
- }
- else if (!(position === LEFT || position === RIGHT))
- position = LEFT;
- options.position = position;
- if (position === RIGHT && !label.userAlignment)
- label.alignment = LEFT
- };
- var formatLabel = function(value, options, axisMinMax) {
- var formatObject = {
- value: value,
- valueText: DX.formatHelper.format(value, options.format, options.precision) || ''
- };
- if (axisMinMax) {
- formatObject.min = axisMinMax.min;
- formatObject.max = axisMinMax.max
- }
- return options.customizeText ? options.customizeText.call(formatObject, formatObject) : formatObject.valueText
- };
- var nextState = function(state) {
- switch (state) {
- case'overlap':
- return 'stagger';
- case'stagger':
- return 'rotate';
- case'rotate':
- default:
- return 'end'
- }
- };
- DX.viz.charts.Axis = function(renderer, options) {
- var debug = DX.utils.debug;
- debug.assertParam(renderer, 'renderer was not passed');
- debug.assertParam(options.label, 'label was not passed');
- debug.assertParam(options.tick, 'tick was not passed');
- debug.assertParam(options.grid, 'grid was not passed');
- debug.assertParam(options.title, 'title was not passed');
- debug.assert(options.axisDivisionFactor, 'axisDivisionFactor was not passed');
- debug.assert(options.stripStyle, 'stripStyle was not passed');
- debug.assert(options.constantLineStyle, 'constantLineStyle was not passed');
- debug.assert(options.position, 'position was not passed');
- debug.assertParam(options.isHorizontal, 'isHorizontal was not passed');
- this.renderer = renderer;
- this._init(options)
- };
- $.extend(DX.viz.charts.Axis.prototype, {
- dispose: function() {
- var that = this;
- that._axisElementsGroup && that._axisElementsGroup.dispose();
- $.each(that.labels || [], function(_, label) {
- label.removeData()
- });
- that.labels = null;
- that.title = null;
- that.stripLabels = null;
- that.stripRects = null;
- that.constantLineLabels = null;
- that.constantLines = null;
- that._axisStripGroup = null;
- that._axisConstantLineGroup = null;
- that._axisLableGroup = null;
- that._axisLineGroup = null;
- that._axisElementsGroup = null;
- that._axisGridGroup = null;
- that._axisGroup = null;
- that.axesContainerGroup = null;
- that.stripsGroup = null;
- that.constantLinesGroup = null;
- that._axisTitleGroup = null;
- that.renderer = null;
- that.translator = null;
- that.orthogonalTranslator = null;
- that.options = null;
- that.textOptions = null;
- that._tickValues = null;
- that._fullTickValues = null;
- that._fullTickPositions = null
- },
- _init: function(options) {
- var that = this,
- categories = options.categories,
- labelOptions = options.label;
- options.hoverMode = options.hoverMode ? options.hoverMode.toLowerCase() : 'none';
- that.hasLabelFormat = labelOptions.format !== '' && isDefinedUtils(labelOptions.format);
- that.options = options;
- that.staggered = labelOptions.staggered;
- labelOptions.minSpacing = isDefinedUtils(labelOptions.minSpacing) ? labelOptions.minSpacing : DEFAULT_AXIS_LABEL_SPACING;
- processCustomOptions(options);
- if (categories) {
- that.labelsNumber = categories.length;
- that.ticksNumber = that.labelsNumber
- }
- options.range = {
- min: options.min,
- max: options.max,
- categories: options.categories && options.categories.slice(0)
- };
- that.pane = options.pane;
- that.textOptions = {
- align: labelOptions.alignment,
- font: labelOptions.font,
- opacity: labelOptions.opacity,
- style: labelOptions.style
- };
- if (options.type === 'logarithmic') {
- if (options.logarithmBaseError) {
- options.incidentOccured('E2104');
- delete options.logarithmBaseError
- }
- that.calcInterval = function(value, prevValue) {
- return utils.getLog(value / prevValue, options.logarithmBase)
- }
- }
- },
- updateSize: function(clearAxis) {
- var that = this,
- options = that.options,
- direction = options.isHorizontal ? "horizontal" : "vertical";
- if (that.title && that._axisTitleGroup) {
- options.incidentOccured('W2105', [direction]);
- that._axisTitleGroup.remove();
- that._axisTitleGroup = null
- }
- if (clearAxis && that._axisElementsGroup && that.labels) {
- options.incidentOccured('W2106', [direction]);
- that._axisElementsGroup.remove();
- that._axisElementsGroup = null
- }
- that._setBoundingRect()
- },
- _updateTranslatorInterval: function() {
- var that = this,
- i,
- tickValues,
- businessRange = that.translator.getBusinessRange();
- if (businessRange && businessRange.addRange && !that.options.categories) {
- tickValues = that.getTickValues();
- for (i = 0; i < tickValues.length - 1; i++)
- businessRange.addRange({interval: mathAbs(tickValues[i] - tickValues[i + 1])})
- }
- },
- setTranslator: function(translator, orthogonalTranslator) {
- var that = this;
- var debug = DX.utils.debug;
- debug.assertParam(translator, 'translator was not passed');
- that.translator = translator;
- orthogonalTranslator && (that.orthogonalTranslator = orthogonalTranslator);
- that.resetTicks();
- that._updateTranslatorInterval()
- },
- resetTicks: function() {
- var that = this;
- that._tickValues = that._tickPositions = that._fullTickValues = that._fullTickPositions = null
- },
- setRange: function(range) {
- var debug = DX.utils.debug;
- debug.assertParam(range, 'range was not passed');
- var options = this.options;
- options.min = range.minVisible;
- options.max = range.maxVisible;
- options.categories = range.categories;
- options.stubData = range.stubData;
- this.resetTicks()
- },
- _drawAxis: function() {
- var that = this,
- translator = that.translator,
- options = that.options,
- hasCategories = !!options.categories,
- axisPosition = that.axisPosition,
- p11,
- p12,
- p21,
- p22;
- if (!options.visible)
- return;
- p11 = translator.translateSpecialCase(CANVAS_POSITION_START);
- p21 = translator.translateSpecialCase(CANVAS_POSITION_END);
- if (options.isHorizontal)
- p12 = p22 = axisPosition;
- else {
- p12 = p11;
- p22 = p21;
- p11 = p21 = axisPosition
- }
- that.renderer.createLine(p11, p12, p21, p22, {
- strokeWidth: options.width,
- stroke: options.color,
- strokeOpacity: options.opacity
- }).append(that._axisLineGroup)
- },
- _getOptimalRotationAngle: function(tick1, tick2, labelOptions) {
- var that = this,
- translator = that.options.isHorizontal ? that.translator : that.orthogonalTranslator,
- renderer = that.renderer,
- outOfScreen = core.outOfScreen,
- textOptions = that.textOptions,
- svgElement1 = renderer.createText(formatLabel(tick1, labelOptions), outOfScreen.x + translator.translate(tick1), outOfScreen.y, textOptions).append(),
- svgElement2 = renderer.createText(formatLabel(tick2, labelOptions), outOfScreen.x + translator.translate(tick2), outOfScreen.y, textOptions).append(),
- bBox1 = svgElement1.getBBox(),
- bBox2 = svgElement2.getBBox(),
- angle = Math.asin((bBox1.height + labelOptions.minSpacing) / (bBox2.x - bBox1.x)) * 180 / Math.PI;
- svgElement1.remove();
- svgElement2.remove();
- return isNaN(angle) ? 90 : Math.ceil(angle)
- },
- _applyOptimalOverlappingBehavior: function(ticks, ticksOptions) {
- var that = this,
- overlappingBehavior = that.overlappingBehavior,
- isOverlapped = false,
- rotationAngle = null,
- mode = null,
- options = $.extend({}, ticksOptions),
- state = 'overlap';
- while (state !== 'end') {
- isOverlapped = rotationAngle && rotationAngle !== 90 ? false : that.options.tickProvider.isOverlappedTicks(ticks, options);
- state = nextState(isOverlapped ? state : null);
- that.testAutoOverlappingState = state;
- switch (state) {
- case'stagger':
- options.screenDelta *= AXIS_STAGGER_OVERLAPPING_KOEF;
- mode = state;
- break;
- case'rotate':
- rotationAngle = that._getOptimalRotationAngle(ticks[0], ticks[1], that.options.label);
- that.testAutoOverlappingRotationAngle = rotationAngle;
- options.screenDelta = ticksOptions.screenDelta;
- options.textOptions.rotate = rotationAngle;
- mode = state;
- break
- }
- }
- that.testAutoOverlappingOptions = options;
- overlappingBehavior.isOverlapped = isOverlapped;
- overlappingBehavior.mode = mode;
- overlappingBehavior.rotationAngle = rotationAngle
- },
- _getTicksOptions: function() {
- var that = this,
- options = that.options,
- translator = that.translator,
- screenDelta = mathAbs(translator.translateSpecialCase(CANVAS_POSITION_START) - translator.translateSpecialCase(CANVAS_POSITION_END)),
- min = options.min,
- max = options.max,
- digitPosition = utils.getSignificantDigitPosition(mathAbs(max - min) / screenDelta),
- correctingValue,
- getText = function() {
- return ''
- };
- if (utils.isNumber(min) && options.type !== 'logarithmic') {
- min = utils.roundValue(options.min, digitPosition);
- if (min < options.min) {
- correctingValue = Math.pow(10, -digitPosition);
- min = utils.applyPrecisionByMinDelta(min, correctingValue, min + correctingValue)
- }
- if (min > max)
- min = options.min
- }
- if (!options.stubData)
- getText = function(value) {
- return formatLabel(value, options.label, {
- min: min,
- max: max
- })
- };
- return {
- min: min,
- max: max,
- base: options.type === 'logarithmic' ? options.logarithmBase : undefined,
- axisType: options.type,
- dataType: options.dataType,
- customTicks: $.isArray(options.categories) ? options.categories : that._tickValues,
- useTicksAutoArrangement: false,
- textOptions: that.textOptions,
- getText: getText,
- renderer: that.renderer,
- textSpacing: options.label.minSpacing,
- translator: translator,
- tickInterval: options.stubData ? null : options.tickInterval,
- screenDelta: screenDelta,
- gridSpacingFactor: options.axisDivisionFactor,
- isHorizontal: options.isHorizontal,
- setTicksAtUnitBeginning: options.setTicksAtUnitBeginning,
- incidentOccured: options.incidentOccured
- }
- },
- getTickValues: function() {
- var that = this,
- correctedScreenDelta,
- options = that.options,
- tickProvider = options.tickProvider,
- labelOptions = options.label,
- categories = options.categories,
- ticksOptions = that._getTicksOptions();
- that._fullTickValues = that._tickValues = tickProvider.getTicks(ticksOptions);
- if ((isDateUtils(options.min) || isDateUtils(categories && categories[0])) && !that.hasLabelFormat && that._tickValues.length)
- labelOptions.format = DX.formatHelper.getDateFormatByTicks(that._tickValues);
- that.overlappingBehavior = labelOptions.overlappingBehavior ? $.extend({}, labelOptions.overlappingBehavior) : null;
- if (that.overlappingBehavior) {
- if (!options.isHorizontal && that.overlappingBehavior.mode !== 'ignore')
- that.overlappingBehavior.mode = 'enlargeTickInterval';
- ticksOptions.useTicksAutoArrangement = that.overlappingBehavior.mode !== 'ignore';
- if (ticksOptions.useTicksAutoArrangement)
- that._fullTickValues = that._tickValues = tickProvider.getCorrectedTicks(that._fullTickValues, ticksOptions);
- if (that.overlappingBehavior.mode === 'auto') {
- that.textOptions.rotate = 0;
- that._applyOptimalOverlappingBehavior(that._fullTickValues, ticksOptions);
- ticksOptions.useTicksAutoArrangement = that.overlappingBehavior.isOverlapped
- }
- if (that.overlappingBehavior.mode === 'rotate') {
- that.textOptions.rotate = that.overlappingBehavior.rotationAngle;
- if (!labelOptions.userAlignment)
- that.textOptions.align = LEFT
- }
- else if (!labelOptions.userAlignment)
- that.textOptions.align = labelOptions.alignment
- }
- if (ticksOptions.useTicksAutoArrangement) {
- correctedScreenDelta = that._tickValues.length ? that.translator.translate(that._tickValues[that._tickValues.length - 1]) - that.translator.translate(that._tickValues[0]) : null;
- if (correctedScreenDelta) {
- ticksOptions.screenDelta = mathAbs(correctedScreenDelta);
- ticksOptions.ticksCount = that._tickValues.length - 1
- }
- else
- ticksOptions.ticksCount = that._tickValues.length;
- if (that.overlappingBehavior && that.overlappingBehavior.mode === 'stagger')
- ticksOptions.screenDelta *= AXIS_STAGGER_OVERLAPPING_KOEF;
- ticksOptions.customTicks = that._tickValues;
- that._tickValues = tickProvider.getTicks(ticksOptions)
- }
- that._testTKScreenDelta = ticksOptions.screenDelta;
- that._autoArrangementStep = that._tickValues.autoArrangementStep;
- that._useTicksAutoArrangement = ticksOptions.useTicksAutoArrangement;
- if (that.options.stubData) {
- that._testSkippedFormattingAndOverlapping = true;
- return that._tickValues
- }
- if (!$.isArray(categories))
- that._fullTickValues = that._tickValues;
- return that._tickValues
- },
- setTickValues: function(tickValues) {
- this.resetTicks();
- this._fullTickValues = this._tickValues = tickValues
- },
- _prepareLabelsToDraw: function() {
- var that = this,
- ticksValues = that.getTickValues(),
- ticks = [],
- i;
- if (ticksValues.hideLabels || that.options.stubData)
- ticks.hideLabels = true;
- for (i = 0; i < ticksValues.length; i++)
- ticks.push({
- text: ticksValues[i],
- pos: that.translator.translate(ticksValues[i])
- });
- return ticks
- },
- _correctTicksPosition: function(ticks) {
- var that = this,
- options = that.options,
- tickDelta = that.translator.getInterval() / 2,
- i;
- if (options.categories && (options.discreteAxisDivisionMode !== 'crossLabels' || !options.discreteAxisDivisionMode)) {
- if (options.isHorizontal) {
- if (!options.valueMarginsEnabled)
- ticks = ticks.slice(0, ticks.length - 1)
- }
- else {
- tickDelta = -tickDelta;
- if (!options.valueMarginsEnabled)
- ticks = ticks.slice(1, ticks.length)
- }
- for (i = 0; i < ticks.length; i++)
- ticks[i].pos = ticks[i].pos + tickDelta
- }
- return ticks
- },
- _prepareFullTicksToDraw: function() {
- var that = this,
- ticksValues = that._fullTickValues,
- ticks = [],
- i;
- if (!that._fullTickPositions) {
- if (!ticksValues) {
- that.getTickValues();
- ticksValues = that._fullTickValues || []
- }
- for (i = 0; i < ticksValues.length; i++)
- ticks.push({pos: that.translator.translate(ticksValues[i])});
- that._fullTickPositions = that._correctTicksPosition(ticks)
- }
- return that._fullTickPositions
- },
- _drawTicks: function() {
- var that = this,
- options = that.options,
- ticksOptions = options.tick,
- i,
- axisPosition = that.axisPosition,
- tickStart = axisPosition - 4,
- tickEnd = axisPosition + 4,
- tick,
- ticksToDraw;
- if (!ticksOptions.visible)
- return;
- var drawLine = function(p11, p12, p21, p22) {
- that.renderer.createLine(p11, p12, p21, p22, {
- strokeWidth: 1,
- stroke: ticksOptions.color,
- strokeOpacity: ticksOptions.opacity
- }).append(that._axisLineGroup)
- };
- ticksToDraw = that._prepareFullTicksToDraw();
- if (options.isHorizontal)
- for (i = 0; i < ticksToDraw.length; i++) {
- tick = ticksToDraw[i];
- drawLine(tick.pos, tickStart, tick.pos, tickEnd)
- }
- else
- for (i = 0; i < ticksToDraw.length; i++) {
- tick = ticksToDraw[i];
- drawLine(tickStart, tick.pos, tickEnd, tick.pos)
- }
- },
- setPercentLabelFormat: function() {
- var labelOptions = this.options.label;
- if (!this.hasLabelFormat)
- labelOptions.format = 'percent'
- },
- resetAutoLabelFormat: function() {
- var labelOptions = this.options.label;
- if (!this.hasLabelFormat)
- delete labelOptions.format
- },
- _drawLabels: function() {
- var that = this,
- i,
- options = that.options,
- renderer = that.renderer,
- axisPosition = that.axisPosition,
- labelOptions = options.label,
- labelOffset = labelOptions.indentFromAxis,
- labelsToDraw,
- labelPoint,
- label,
- labels = [],
- createText = options.isHorizontal ? renderer.createText : function(text, y, x, textOptions) {
- return this.createText(text, x, y, textOptions)
- },
- emptyStrRegExp = /^\s+$/,
- currentLabelConst = options.position === TOP || options.position === LEFT ? axisPosition - labelOffset : axisPosition + labelOffset,
- text;
- if (!labelOptions.visible || !that._axisElementsGroup)
- return;
- labelsToDraw = that._prepareLabelsToDraw();
- if (labelsToDraw.length === 0 || labelsToDraw.hideLabels)
- return true;
- for (i = 0; i < labelsToDraw.length; i++) {
- labelPoint = labelsToDraw[i];
- text = formatLabel(labelPoint.text, labelOptions, {
- min: options.min,
- max: options.max
- });
- if (isDefinedUtils(text) && text !== '' && !emptyStrRegExp.test(text)) {
- label = createText.call(renderer, text, labelPoint.pos, currentLabelConst, that.textOptions);
- labels.push(label);
- label.append(that._axisElementsGroup);
- label.data({argument: labelPoint.text})
- }
- }
- that.labels = labels
- },
- getMultipleAxesSpacing: function() {
- return this.options.multipleAxesSpacing || 0
- },
- _drawTitle: function() {
- var that = this,
- i,
- options = that.options,
- renderer = that.renderer,
- axisPosition = that.axisPosition,
- titleOptions = options.title,
- title,
- attr = {
- font: titleOptions.font,
- opacity: titleOptions.opacity,
- align: CENTER,
- 'class': 'dx-chart-axis-title'
- },
- centerPosition = that.translator.translateSpecialCase(CANVAS_POSITION_PREFIX + CENTER),
- x,
- y;
- if (!titleOptions.text || !that._axisTitleGroup)
- return;
- if (options.isHorizontal) {
- x = centerPosition;
- y = axisPosition
- }
- else {
- if (options.position === LEFT)
- attr.rotate = 270;
- else
- attr.rotate = 90;
- x = axisPosition;
- y = centerPosition
- }
- that.title = renderer.createText(titleOptions.text, x, y, attr).append(that._axisTitleGroup)
- },
- _drawGrid: function(borderOptions) {
- var that = this,
- positionsToDraw,
- options = that.options,
- gridOptions = options.grid,
- i;
- if (!gridOptions.visible)
- return;
- borderOptions = borderOptions || {visible: false};
- var drawLine = function() {
- var translator = that.translator,
- orthogonalTranslator = that.orthogonalTranslator,
- isHorizontal = options.isHorizontal,
- canvasStart = isHorizontal ? LEFT : TOP,
- canvasEnd = isHorizontal ? RIGHT : BOTTOM,
- positionFrom = orthogonalTranslator.translateSpecialCase(CANVAS_POSITION_START),
- positionTo = orthogonalTranslator.translateSpecialCase(CANVAS_POSITION_END),
- firstBorderLinePosition = borderOptions.visible && borderOptions[canvasStart] ? translator.translateSpecialCase(CANVAS_POSITION_PREFIX + canvasStart) : undefined,
- lastBorderLinePosition = borderOptions.visible && borderOptions[canvasEnd] ? translator.translateSpecialCase(CANVAS_POSITION_PREFIX + canvasEnd) : undefined;
- return function(tick) {
- if (mathAbs(tick.pos - firstBorderLinePosition) < MAX_GRID_BORDER_ADHENSION || mathAbs(tick.pos - lastBorderLinePosition) < MAX_GRID_BORDER_ADHENSION)
- return;
- var p11 = tick.pos,
- p12 = positionFrom,
- p21 = tick.pos,
- p22 = positionTo;
- if (!isHorizontal) {
- p11 = positionFrom;
- p12 = p22 = tick.pos;
- p21 = positionTo
- }
- that.renderer.createLine(p11, p12, p21, p22, {
- strokeWidth: gridOptions.width,
- stroke: gridOptions.color,
- strokeOpacity: gridOptions.opacity
- }).append(that._axisGridGroup)
- }
- }();
- positionsToDraw = that._prepareFullTicksToDraw();
- for (i = 0; i < positionsToDraw.length; i++)
- drawLine(positionsToDraw[i])
- },
- _drawConstantLine: function() {
- var that = this,
- group = that._axisConstantLineGroup,
- renderer = that.renderer,
- options = that.options,
- data = options.constantLines,
- translator = that.translator,
- orthogonalTranslator = that.orthogonalTranslator,
- isHorizontal = options.isHorizontal,
- i,
- lines = [],
- labels = [],
- positionFrom = orthogonalTranslator.translateSpecialCase(CANVAS_POSITION_START),
- positionTo = orthogonalTranslator.translateSpecialCase(CANVAS_POSITION_END),
- canvasStart = translator.translateSpecialCase(CANVAS_POSITION_START),
- canvasEnd = translator.translateSpecialCase(CANVAS_POSITION_END),
- range = translator.getBusinessRange();
- var getPos = function(lineValue) {
- var parsedValue = that.validateUnit(lineValue, "E2105", 'constantLine'),
- value = translator.translate(parsedValue),
- isContinous = !!(range.minVisible || range.maxVisible);
- if (!isContinous && $.inArray(lineValue, range.categories || []) === -1 || !isDefinedUtils(value) || value < Math.min(canvasStart, canvasEnd) || value > Math.max(canvasStart, canvasEnd))
- return {};
- return {
- value: value,
- parsedValue: parsedValue
- }
- };
- var drawLinesAndLabels = function(lineOptions) {
- if (lineOptions.value === undefined)
- return;
- var pos = getPos(lineOptions.value),
- labelOptions = lineOptions.label || {},
- value = pos.value,
- line,
- attr = {
- stroke: lineOptions.color,
- strokeWidth: lineOptions.width,
- dashStyle: lineOptions.dashStyle
- };
- if (!isDefinedUtils(value)) {
- lines.push(null);
- if (labelOptions.visible)
- labels.push(null);
- return
- }
- line = isHorizontal ? renderer.createLine(value, positionTo, value, positionFrom, attr) : renderer.createLine(positionFrom, value, positionTo, value, attr);
- lines.push(line.append(group));
- if (labelOptions.visible)
- labels.push(that._drawConstantLineLabels(pos.parsedValue, labelOptions, value, group));
- else
- labels.push(null)
- };
- for (i = 0; i < data.length; i++)
- drawLinesAndLabels(data[i]);
- that.constantLines = lines;
- that.constantLineLabels = labels
- },
- _checkAlignmentConstantLineLabels: function(labelOptions) {
- var options = this.options;
- labelOptions.verticalAlignment = (labelOptions.verticalAlignment || '').toLowerCase();
- labelOptions.horizontalAlignment = (labelOptions.horizontalAlignment || '').toLowerCase();
- if (options.isHorizontal && labelOptions.position === 'outside') {
- labelOptions.verticalAlignment = labelOptions.verticalAlignment === BOTTOM ? BOTTOM : TOP;
- labelOptions.horizontalAlignment = CENTER
- }
- if (options.isHorizontal && labelOptions.position === 'inside') {
- labelOptions.verticalAlignment = labelOptions.verticalAlignment === CENTER ? CENTER : labelOptions.verticalAlignment === BOTTOM ? BOTTOM : TOP;
- labelOptions.horizontalAlignment = labelOptions.horizontalAlignment === LEFT ? LEFT : RIGHT
- }
- if (!options.isHorizontal && labelOptions.position === 'outside') {
- labelOptions.verticalAlignment = CENTER;
- labelOptions.horizontalAlignment = labelOptions.horizontalAlignment === LEFT ? LEFT : RIGHT
- }
- if (!options.isHorizontal && labelOptions.position === 'inside') {
- labelOptions.verticalAlignment = labelOptions.verticalAlignment === BOTTOM ? BOTTOM : TOP;
- labelOptions.horizontalAlignment = labelOptions.horizontalAlignment === RIGHT ? RIGHT : labelOptions.horizontalAlignment === CENTER ? CENTER : LEFT
- }
- },
- _drawConstantLineLabels: function(parsedValue, lineLabelOptions, value, group) {
- var that = this,
- text = lineLabelOptions.text,
- orthogonalTranslator = that.orthogonalTranslator,
- options = that.options,
- labelOptions = options.label,
- attr = {
- align: CENTER,
- font: $.extend({}, labelOptions.font, lineLabelOptions.font)
- },
- x,
- y;
- that._checkAlignmentConstantLineLabels(lineLabelOptions);
- text = isDefinedUtils(text) ? text : formatLabel(parsedValue, labelOptions);
- if (options.isHorizontal) {
- x = value;
- switch (lineLabelOptions.horizontalAlignment) {
- case LEFT:
- attr.align = RIGHT;
- break;
- case RIGHT:
- attr.align = LEFT;
- break
- }
- y = orthogonalTranslator.translateSpecialCase(CANVAS_POSITION_PREFIX + lineLabelOptions.verticalAlignment)
- }
- else {
- y = value;
- x = orthogonalTranslator.translateSpecialCase(CANVAS_POSITION_PREFIX + lineLabelOptions.horizontalAlignment);
- switch (lineLabelOptions.horizontalAlignment) {
- case LEFT:
- attr.align = lineLabelOptions.position === 'inside' ? LEFT : RIGHT;
- break;
- case CENTER:
- attr.align = CENTER;
- break;
- case RIGHT:
- attr.align = lineLabelOptions.position === 'inside' ? RIGHT : LEFT;
- break
- }
- }
- return that.renderer.createText(text, x, y, attr).append(group)
- },
- _adjustConstantLineLabels: function() {
- var that = this,
- options = that.options,
- isHorizontal = options.isHorizontal,
- lines = that.constantLines,
- labels = that.constantLineLabels,
- label,
- line,
- lineBox,
- linesOptions,
- labelOptions,
- box,
- x,
- y,
- i,
- padding = isHorizontal ? {
- top: 0,
- bottom: 0
- } : {
- left: 0,
- right: 0
- };
- if (labels === undefined && lines === undefined)
- return;
- for (i = 0; i < labels.length; i++) {
- x = y = 0;
- linesOptions = options.constantLines[i];
- labelOptions = linesOptions.label;
- label = labels[i];
- if (label !== null) {
- line = lines[i];
- box = label.getBBox();
- lineBox = line.getBBox();
- if (isHorizontal)
- if (labelOptions.position === 'inside') {
- switch (labelOptions.horizontalAlignment) {
- case LEFT:
- x -= linesOptions.paddingLeftRight;
- break;
- default:
- x += linesOptions.paddingLeftRight;
- break
- }
- switch (labelOptions.verticalAlignment) {
- case CENTER:
- y += lineBox.y + lineBox.height / 2 - box.y - box.height / 2;
- break;
- case BOTTOM:
- y -= linesOptions.paddingTopBottom;
- break;
- default:
- y += linesOptions.paddingTopBottom + box.height;
- break
- }
- }
- else
- switch (labelOptions.verticalAlignment) {
- case BOTTOM:
- y += box.height + linesOptions.paddingTopBottom - (box.y + box.height - that.orthogonalTranslator.translateSpecialCase(CANVAS_POSITION_PREFIX + labelOptions.verticalAlignment));
- if (padding[BOTTOM] < box.height + linesOptions.paddingTopBottom)
- padding[BOTTOM] = box.height + linesOptions.paddingTopBottom;
- break;
- default:
- y -= linesOptions.paddingTopBottom;
- if (padding[TOP] < linesOptions.paddingTopBottom + box.height)
- padding[TOP] = linesOptions.paddingTopBottom + box.height;
- break
- }
- else if (labelOptions.position === 'inside') {
- switch (labelOptions.horizontalAlignment) {
- case CENTER:
- x += lineBox.x + lineBox.width / 2 - box.x - box.width / 2;
- break;
- case RIGHT:
- x -= linesOptions.paddingLeftRight;
- break;
- default:
- x += linesOptions.paddingLeftRight;
- break
- }
- switch (labelOptions.verticalAlignment) {
- case BOTTOM:
- y += lineBox.y - box.y + linesOptions.paddingTopBottom;
- break;
- default:
- y -= linesOptions.paddingTopBottom;
- break
- }
- }
- else {
- y += lineBox.y + lineBox.height / 2 - box.y - box.height / 2;
- switch (labelOptions.horizontalAlignment) {
- case RIGHT:
- x += linesOptions.paddingLeftRight;
- if (padding[RIGHT] < linesOptions.paddingLeftRight + box.width)
- padding[RIGHT] = linesOptions.paddingLeftRight + box.width;
- break;
- default:
- x -= linesOptions.paddingLeftRight;
- if (padding[LEFT] < linesOptions.paddingLeftRight + box.width)
- padding[LEFT] = linesOptions.paddingLeftRight + box.width;
- break
- }
- }
- label.move(x, y)
- }
- }
- that.padding = padding
- },
- _drawStrip: function() {
- var that = this,
- renderer = that.renderer,
- options = that.options,
- stripData = options.strips,
- translator = that.translator,
- orthogonalTranslator = that.orthogonalTranslator,
- range = translator.getBusinessRange(),
- i,
- stripLabels = [],
- stripRects = [],
- rect,
- isHorizontal = options.isHorizontal,
- stripOptions,
- positionFrom,
- positionTo,
- stripPos,
- stripLabelOptions,
- attr;
- if (options.stubData)
- return;
- var getPos = function(startV, endV) {
- var isContinous = !!(range.minVisible || range.maxVisible),
- cateories = range.categories || [],
- start = translator.translate(that.validateUnit(startV, "E2105", "strip")),
- end = translator.translate(that.validateUnit(endV, "E2105", "strip")),
- canvasStart = translator.translateSpecialCase(CANVAS_POSITION_START),
- canvasEnd = translator.translateSpecialCase(CANVAS_POSITION_END),
- min = range.minVisible;
- if (!isContinous && ($.inArray(startV, cateories) === -1 || $.inArray(endV, cateories) === -1))
- return {
- stripFrom: 0,
- stripTo: 0
- };
- if (!isDefinedUtils(start) && isContinous)
- start = startV < min ? canvasStart : canvasEnd;
- if (!isDefinedUtils(end) && isContinous)
- end = endV < min ? canvasStart : canvasEnd;
- return start < end ? {
- stripFrom: start,
- stripTo: end
- } : {
- stripFrom: end,
- stripTo: start
- }
- };
- positionFrom = orthogonalTranslator.translateSpecialCase(CANVAS_POSITION_START);
- positionTo = orthogonalTranslator.translateSpecialCase(CANVAS_POSITION_END);
- for (i = 0; i < stripData.length; i++) {
- stripOptions = stripData[i];
- stripLabelOptions = stripOptions.label || {};
- attr = {fill: stripOptions.color};
- if (stripOptions.startValue !== undefined && stripOptions.endValue !== undefined && stripOptions.color !== undefined) {
- stripPos = getPos(stripOptions.startValue, stripOptions.endValue);
- if (stripPos.stripTo - stripPos.stripFrom === 0 || !stripPos.stripTo && stripPos.stripTo !== 0 || !stripPos.stripFrom && stripPos.stripFrom !== 0) {
- stripRects.push(null);
- if (stripLabelOptions.text)
- stripLabels.push(null);
- continue
- }
- rect = isHorizontal ? renderer.createRect(stripPos.stripFrom, Math.min(positionFrom, positionTo), stripPos.stripTo - stripPos.stripFrom, mathAbs(positionFrom - positionTo), 0, attr) : renderer.createRect(Math.min(positionFrom, positionTo), stripPos.stripFrom, mathAbs(positionFrom - positionTo), stripPos.stripTo - stripPos.stripFrom, 0, attr);
- stripRects.push(rect.append(that._axisStripGroup));
- if (stripLabelOptions.text)
- stripLabels.push(that._drawStripLabel(stripLabelOptions, stripPos.stripFrom, stripPos.stripTo));
- else
- stripLabels.push(null)
- }
- }
- that.stripLabels = stripLabels;
- that.stripRects = stripRects
- },
- _drawStripLabel: function(stripLabelOptions, stripFrom, stripTo) {
- var that = this,
- orthogonalTranslator = that.orthogonalTranslator,
- options = that.options,
- isHorizontal = options.isHorizontal,
- attr = {
- align: isHorizontal ? CENTER : LEFT,
- font: $.extend({}, options.label.font, stripLabelOptions.font)
- },
- x,
- y;
- if (isHorizontal) {
- if (stripLabelOptions.horizontalAlignment === CENTER) {
- x = stripFrom + (stripTo - stripFrom) / 2;
- attr.align = CENTER
- }
- else if (stripLabelOptions.horizontalAlignment === LEFT) {
- x = stripFrom;
- attr.align = LEFT
- }
- else if (stripLabelOptions.horizontalAlignment === RIGHT) {
- x = stripTo;
- attr.align = RIGHT
- }
- y = orthogonalTranslator.translateSpecialCase(CANVAS_POSITION_PREFIX + stripLabelOptions.verticalAlignment)
- }
- else {
- x = orthogonalTranslator.translateSpecialCase(CANVAS_POSITION_PREFIX + stripLabelOptions.horizontalAlignment);
- attr.align = stripLabelOptions.horizontalAlignment;
- if (stripLabelOptions.verticalAlignment === TOP)
- y = stripFrom;
- else if (stripLabelOptions.verticalAlignment === CENTER)
- y = stripTo + (stripFrom - stripTo) / 2;
- else if (stripLabelOptions.verticalAlignment === BOTTOM)
- y = stripTo
- }
- return that.renderer.createText(stripLabelOptions.text, x, y, attr).append(that._axisLableGroup)
- },
- _initAxisPositions: function() {
- var that = this,
- position = that.options.position,
- delta = 0;
- if (that.delta)
- delta = that.delta[position] || 0;
- that.axisPosition = that.orthogonalTranslator.translateSpecialCase(CANVAS_POSITION_PREFIX + position) + delta
- },
- _adjustLabels: function() {
- var that = this,
- options = that.options,
- isHorizontal = options.isHorizontal,
- position = options.position,
- labels = that.labels,
- label,
- labelHeight,
- isNeedLabelAdjustment,
- staggeringSpacing,
- i,
- xt,
- shift = that.padding && that.padding[position] || 0,
- boxAxis = that._axisElementsGroup && that._axisElementsGroup.getBBox() || {},
- box;
- if (!options.label.visible || !labels || !labels.length)
- return;
- for (i = 0; i < labels.length; i++) {
- label = labels[i];
- box = label.getBBox();
- if (isHorizontal && position === BOTTOM)
- label.applySettings({y: 2 * label.settings.y - box.y + shift});
- else if (!isHorizontal) {
- if (position === LEFT)
- if (that.textOptions.align === RIGHT)
- xt = box.x + box.width - shift;
- else if (that.textOptions.align === CENTER)
- xt = box.x + box.width / 2 - shift - (boxAxis.width / 2 || 0);
- else
- xt = box.x - shift - (boxAxis.width || 0);
- else if (that.textOptions.align === CENTER)
- xt = box.x + box.width / 2 + (boxAxis.width / 2 || 0) + shift;
- else if (that.textOptions.align === RIGHT)
- xt = box.x + box.width + (boxAxis.width || 0) + shift;
- else
- xt = box.x + shift;
- label.applySettings({
- x: xt,
- y: label.settings.y + ~~(label.settings.y - box.y - box.height / 2)
- })
- }
- else if (isHorizontal && position === TOP)
- label.applySettings({y: 2 * label.settings.y - box.y - box.height - shift})
- }
- isNeedLabelAdjustment = isHorizontal && that.overlappingBehavior && that.overlappingBehavior.mode === 'stagger';
- that._testIsNeedLabelAdjustment = isNeedLabelAdjustment;
- if (isNeedLabelAdjustment) {
- labelHeight = 0;
- for (i = 0; i < labels.length; i = i + 2) {
- label = labels[i];
- box = label.getBBox();
- if (box.height > labelHeight)
- labelHeight = box.height
- }
- staggeringSpacing = that.overlappingBehavior.staggeringSpacing;
- that._testStaggeringSpacing = staggeringSpacing;
- labelHeight = Math.round(labelHeight) + staggeringSpacing;
- for (i = 1; i < labels.length; i = i + 2) {
- label = labels[i];
- if (position === BOTTOM)
- label.move(0, labelHeight);
- else if (position === TOP)
- label.move(0, -labelHeight)
- }
- for (i = 0; i < labels.length; i++)
- labels[i].rotate(0)
- }
- },
- _adjustStripLabels: function() {
- var that = this,
- labelOptions,
- labels = that.stripLabels,
- rects = that.stripRects,
- label,
- i,
- box,
- rectBox,
- stripOptions,
- x,
- y;
- if (labels === undefined && rects === undefined)
- return;
- for (i = 0; i < labels.length; i++) {
- x = y = 0;
- stripOptions = that.options.strips[i];
- labelOptions = stripOptions.label;
- label = labels[i];
- if (label !== null) {
- box = label.getBBox();
- rectBox = rects[i].getBBox();
- if (labelOptions.horizontalAlignment === LEFT)
- x += stripOptions.paddingLeftRight;
- else if (labelOptions.horizontalAlignment === RIGHT)
- x -= stripOptions.paddingLeftRight;
- if (labelOptions.verticalAlignment === TOP)
- y += rectBox.y - box.y + stripOptions.paddingTopBottom;
- else if (labelOptions.verticalAlignment === CENTER)
- y += rectBox.y + rectBox.height / 2 - box.y - box.height / 2;
- else if (labelOptions.verticalAlignment === BOTTOM)
- y -= stripOptions.paddingTopBottom;
- label.move(x, y)
- }
- }
- },
- _adjustTitle: function() {
- var that = this,
- options = that.options,
- position = options.position,
- title = that.title,
- margin = options.title.margin,
- boxGroup,
- boxTitle;
- if (!title || !that._axisElementsGroup)
- return;
- boxTitle = title.getBBox();
- boxGroup = that._axisElementsGroup.getBBox();
- if (options.isHorizontal)
- if (position === BOTTOM)
- title.applySettings({
- y: boxGroup.isEmpty ? undefined : boxGroup.y + boxGroup.height,
- translateY: margin + boxTitle.height
- });
- else
- title.applySettings({
- y: boxGroup.isEmpty ? undefined : boxGroup.y,
- translateY: -margin
- });
- else if (position === LEFT)
- title.applySettings({
- x: boxGroup.isEmpty ? undefined : boxGroup.x,
- translateX: -margin
- });
- else
- title.applySettings({
- x: boxGroup.isEmpty ? undefined : boxGroup.x + boxGroup.width,
- translateX: margin
- })
- },
- draw: function(externalOptions, adjustAxis) {
- var that = this,
- options = that.options,
- isHorizontal = options.isHorizontal,
- cssClass = isHorizontal ? 'dxc-h-axis' : 'dxc-v-axis',
- stripClass = isHorizontal ? 'dxc-h-strips' : 'dxc-v-strips',
- constantLineClass = isHorizontal ? 'dxc-h-constant-lines' : 'dxc-v-constant-lines';
- externalOptions = externalOptions || {};
- var debug = DX.utils.debug;
- debug.assertParam(this.translator, 'translator was not set before Draw call');
- if (that._axisGroup) {
- that._axisGroup.detach();
- that._axisStripGroup.detach();
- that._axisLableGroup.detach();
- that._axisConstantLineGroup.detach();
- that._axisTitleGroup ? that._axisTitleGroup.clear() : !adjustAxis && (that._axisTitleGroup = that.renderer.createGroup({'class': 'dxc-title'}).append(that._axisGroup));
- that._axisGridGroup.clear();
- that._axisElementsGroup ? that._axisElementsGroup.clear() : !adjustAxis && (that._axisElementsGroup = that.renderer.createGroup({'class': 'dxc-elements'}).append(that._axisGroup));
- that._axisLineGroup.clear();
- that._axisStripGroup.clear();
- that._axisConstantLineGroup.clear();
- that._axisLableGroup.clear()
- }
- else {
- that._axisGroup = that.renderer.createGroup({
- 'class': cssClass,
- clipId: that.clipRectID
- });
- that._axisStripGroup = that.renderer.createGroup({'class': stripClass});
- that._axisGridGroup = that.renderer.createGroup({'class': 'dxc-grid'}).append(that._axisGroup);
- that._axisElementsGroup = that.renderer.createGroup({'class': 'dxc-elements'}).append(that._axisGroup);
- that._axisLineGroup = that.renderer.createGroup({'class': 'dxc-line'}).append(that._axisGroup);
- that._axisTitleGroup = that.renderer.createGroup({'class': 'dxc-title'}).append(that._axisGroup);
- that._axisConstantLineGroup = that.renderer.createGroup({'class': constantLineClass});
- that._axisLableGroup = that.renderer.createGroup({'class': 'dxc-axis-labels'})
- }
- that._initAxisPositions();
- if (!that._virtual) {
- that._drawAxis();
- that._drawTicks();
- that._drawLabels();
- that._drawTitle()
- }
- if (options.strips)
- that._drawStrip();
- if (options.constantLines)
- that._drawConstantLine();
- that._drawGrid(externalOptions.borderOptions);
- that._axisStripGroup.append(that.stripsGroup);
- that._axisConstantLineGroup.append(that.constantLinesGroup);
- that._axisGroup.append(that.axesContainerGroup);
- that._axisLableGroup.append(that.labelAxesGroup);
- that._adjustConstantLineLabels();
- that._adjustLabels();
- that._adjustStripLabels();
- that._adjustTitle();
- that._setBoundingRect()
- },
- _setBoundingRect: function() {
- var that = this,
- options = that.options,
- axisBox = that._axisElementsGroup ? that._axisElementsGroup.getBBox() : {
- x: 0,
- y: 0,
- width: 0,
- height: 0,
- isEmpty: true
- },
- lineBox = that._axisLineGroup.getBBox(),
- placeholderSize = options.placeholderSize,
- start,
- isHorizontal = options.isHorizontal,
- coord = isHorizontal && 'y' || 'x',
- side = isHorizontal && 'height' || 'width',
- axisTitleBox = that.title && that._axisTitleGroup ? that._axisTitleGroup.getBBox() : axisBox;
- if (axisBox.isEmpty && axisTitleBox.isEmpty && !placeholderSize) {
- that.boundingRect = axisBox;
- return
- }
- start = lineBox[coord] || that.axisPosition;
- if (options.position === (isHorizontal && BOTTOM || RIGHT)) {
- axisBox[side] = placeholderSize || axisTitleBox[coord] + axisTitleBox[side] - start;
- axisBox[coord] = start
- }
- else {
- axisBox[side] = placeholderSize || lineBox[side] + start - axisTitleBox[coord];
- axisBox[coord] = axisTitleBox.isEmpty ? start : axisTitleBox[coord]
- }
- that.boundingRect = axisBox
- },
- getBoundingRect: function() {
- return this._axisElementsGroup ? this.boundingRect : {
- x: 0,
- y: 0,
- width: 0,
- height: 0
- }
- },
- shift: function(x, y) {
- var settings = {};
- if (x)
- settings.translateX = x;
- if (y)
- settings.translateY = y;
- this._axisGroup.applySettings(settings)
- },
- applyClipRect: function(clipId) {
- this._axisStripGroup.applySettings({clipId: clipId})
- },
- validate: function(isArgumentAxis, incidentOccured) {
- var that = this,
- options = that.options,
- range = options.range,
- parseUtils = new core.ParseUtils,
- dataType = isArgumentAxis ? options.argumentType : options.valueType,
- parser = dataType ? parseUtils.getParser(dataType, 'axis') : function(unit) {
- return unit
- };
- that.parser = parser;
- that.incidentOccured = incidentOccured;
- options.dataType = dataType;
- if (options.min)
- options.min = that.validateUnit(options.min, "E2106");
- if (options.max)
- options.max = that.validateUnit(options.max, "E2106");
- if (range.min)
- range.min = that.validateUnit(range.min);
- if (range.max)
- range.max = that.validateUnit(range.max)
- },
- validateUnit: function(unit, idError, parameters) {
- var that = this,
- dataType = that.options.dataType;
- unit = that.parser(unit);
- if (unit === undefined && idError)
- that.incidentOccured(idError, [parameters]);
- return unit
- },
- adjustZoomValues: function(min, max) {
- var that = this,
- range = that.options.range;
- min = that.validateUnit(min);
- max = that.validateUnit(max);
- if (range && isDefinedUtils(range.min)) {
- min = isDefinedUtils(min) ? range.min < min ? min : range.min : min;
- max = isDefinedUtils(max) ? range.min < max ? max : range.min : max
- }
- if (range && isDefinedUtils(range.max)) {
- max = isDefinedUtils(max) ? range.max > max ? max : range.max : max;
- min = isDefinedUtils(min) ? range.max > min ? min : range.max : min
- }
- that.minRangeArg = min;
- that.maxRangeArg = max;
- return {
- min: min,
- max: max
- }
- },
- getRangeData: function() {
- var that = this,
- options = that.options,
- optionsRange = options.range,
- range = {},
- min,
- max;
- var addValueMarginToRange = function(prefix) {
- if (options.valueMarginsEnabled) {
- if (isDefinedUtils(options[prefix])) {
- range[prefix] = options[prefix];
- range[prefix + 'Priority'] = AXIS_VALUE_MARGIN_PRIORITY
- }
- }
- else {
- range[prefix] = 0;
- range[prefix + 'Priority'] = AXIS_VALUE_MARGIN_PRIORITY
- }
- };
- if (isDefinedUtils(optionsRange.min) && isDefinedUtils(optionsRange.max)) {
- min = optionsRange.min < optionsRange.max ? optionsRange.min : optionsRange.max;
- max = optionsRange.max > optionsRange.min ? optionsRange.max : optionsRange.min
- }
- else {
- min = optionsRange.min;
- max = optionsRange.max
- }
- range.min = min;
- range.max = max;
- addValueMarginToRange('minValueMargin');
- addValueMarginToRange('maxValueMargin');
- range.stick = !options.valueMarginsEnabled;
- range.categories = optionsRange.categories;
- range.dataType = options.dataType;
- range.axisType = options.type;
- if (range.axisType === 'logarithmic')
- range.base = options.logarithmBase;
- if (options.isHorizontal) {
- range.minVisible = isDefinedUtils(that.minRangeArg) ? that.minRangeArg : optionsRange.min;
- range.maxVisible = isDefinedUtils(that.maxRangeArg) ? that.maxRangeArg : optionsRange.max;
- range.invert = options.inverted
- }
- else {
- range.minVisible = optionsRange.min;
- range.maxVisible = optionsRange.max;
- range.invert = options.inverted || options.type === 'discrete' && options.oppositeDirectionYAxis
- }
- return range
- }
- })
- })(jQuery, DevExpress);
- /*! Module viz-charts, file baseChart.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- charts = DX.viz.charts,
- utils = DX.utils,
- TRACKER_RENDERING_DELAY = 1200,
- resizeRedrawOptions = {
- animate: false,
- isResize: true
- },
- ACTIONS_BY_PRIORITY = ['reinit', '_reinitDataSource', '_handleDataSourceChanged', 'force_render'],
- core = DX.viz.core,
- DEFAULT_ANIMATION_OPTIONS = {
- asyncSeriesRendering: true,
- asyncTrackersRendering: true,
- trackerRenderingDelay: TRACKER_RENDERING_DELAY
- };
- charts.BaseChart = core.BaseWidget.inherit({
- _setDefaultOptions: function() {
- this.callBase();
- this.option({
- done: $.noop,
- drawn: $.noop,
- seriesClick: null,
- pointClick: null,
- legendClick: null,
- argumentAxisClick: null,
- seriesHover: null,
- pointHover: null,
- seriesSelected: null,
- pointSelected: null,
- seriesSelectionChanged: null,
- pointSelectionChanged: null,
- seriesHoverChanged: null,
- pointHoverChanged: null
- })
- },
- _createThemeManager: function() {
- return charts.factory.createThemeManager(this.option())
- },
- _init: function() {
- this.__TRACKER_RENDERING_DELAY = TRACKER_RENDERING_DELAY;
- var that = this;
- that.callBase();
- that.themeManager = this._createThemeManager();
- that._initRenderer();
- that.canvasClipRect = that.renderer.createClipRect();
- that._createHtmlStructure();
- that._needHandleRenderComplete = true;
- that.layoutManager = charts.factory.createChartLayoutManager(that.themeManager.getOptions("adaptiveLayout"));
- that._reinit();
- that._element().css({webkitUserSelect: 'none'}).on('contextmenu', function(event) {
- that.eventType = 'contextmenu';
- if (ui.events.isTouchEvent(event) || ui.events.isPointerEvent(event))
- event.preventDefault()
- }).on('MSHoldVisual', function(event) {
- that.eventType = 'MSHoldVisual';
- event.preventDefault()
- })
- },
- _reinit: function() {
- var that = this;
- that.layoutManager.update(that);
- that._createTracker();
- that._reinitDataSource()
- },
- _createHtmlStructure: function() {
- var that = this,
- renderer = that.renderer;
- that._panesBackgroundGroup = renderer.createGroup({'class': 'dxc-background'});
- that._titleGroup = renderer.createGroup({'class': 'dxc-title'});
- that._legendGroup = renderer.createGroup({
- 'class': 'dxc-legend',
- clipId: that._getCanvasClipRectID()
- });
- that._stripsGroup = renderer.createGroup({'class': 'dxc-strips-group'});
- that._constantLinesGroup = renderer.createGroup({'class': 'dxc-constant-lines-group'});
- that._axesGroup = renderer.createGroup({'class': 'dxc-axes-group'});
- that._panesBorderGroup = renderer.createGroup({'class': 'dxc-border'});
- that._labelAxesGroup = renderer.createGroup({'class': 'dxc-strips-labels-group'});
- that._seriesGroup = renderer.createGroup({'class': 'dxc-series-group'});
- that._labelsGroup = renderer.createGroup({'class': 'dxc-labels-group'});
- that._tooltipGroup = renderer.createGroup({'class': 'dxc-tooltip'});
- that._trackerGroup = renderer.createGroup({
- 'class': 'dxc-trackers',
- opacity: 0.0001,
- stroke: "gray",
- fill: "gray"
- });
- that._crosshairTrackerGroup = renderer.createGroup({
- 'class': 'dxc-crosshair-trackers',
- stroke: 'none',
- fill: 'grey'
- }).append(that._trackerGroup);
- that._seriesTrackerGroup = renderer.createGroup({'class': 'dxc-series-trackers'}).append(that._trackerGroup);
- that._markerTrackerGroup = renderer.createGroup({
- 'class': 'dxc-markers-trackers',
- stroke: 'none',
- fill: 'grey'
- }).append(that._trackerGroup);
- that._crossHairCursorGroup = renderer.createGroup({'class': 'dxc-crosshair-cursor'})
- },
- _cleanHtmlStructure: function() {
- var that = this;
- that._panesBackgroundGroup && that._panesBackgroundGroup.clear();
- that._titleGroup && that._titleGroup.clear();
- that._legendGroup && (that._legendGroup.detach(), that._legendGroup.clear());
- that._stripsGroup && (that._stripsGroup.detach(), that._stripsGroup.clear());
- that._constantLinesGroup && (that._constantLinesGroup.detach(), that._constantLinesGroup.clear());
- that._axesGroup && (that._axesGroup.detach(), that._axesGroup.clear());
- that._labelAxesGroup && (that._labelAxesGroup.detach(), that._labelAxesGroup.clear());
- that._seriesGroup && (that._seriesGroup.detach(), that._seriesGroup.clear());
- that._labelsGroup && (that._labelsGroup.detach(), that._labelsGroup.clear());
- that._trackerGroup && (that._trackerGroup.detach(), that._seriesTrackerGroup.clear(), that._markerTrackerGroup.clear(), that._crosshairTrackerGroup.clear());
- that._panesBorderGroup && that._panesBorderGroup.clear();
- that._tooltipGroup && that._tooltipGroup.clear();
- that._crossHairCursorGroup && (that._crossHairCursorGroup.clear(), that._crossHairCursorGroup.detach())
- },
- _disposeObjectsInArray: function(propName, fieldNames) {
- $.each(this[propName] || [], function(_, item) {
- if (fieldNames && item)
- $.each(fieldNames, function(_, field) {
- item[field] && item[field].dispose()
- });
- else
- item && item.dispose()
- });
- this[propName] = null
- },
- _dispose: function() {
- var that = this,
- disposeObject = function(propName) {
- that[propName] && that[propName].dispose(),
- that[propName] = null
- },
- detachGroup = function(groupName) {
- that[groupName] && that[groupName].detach()
- },
- disposeObjectsInArray = this._disposeObjectsInArray;
- clearTimeout(that.delayedRedraw);
- that.callBase();
- disposeObjectsInArray.call(that, "businessRanges", ["arg", "val"]);
- that.translators = null;
- disposeObjectsInArray.call(that, "series");
- disposeObject("layoutManager");
- disposeObject("themeManager");
- disposeObject("renderer");
- disposeObject("tracker");
- disposeObject("tooltip");
- disposeObject("chartTitle");
- that.paneAxis = null;
- that._userOptions = null;
- that.dirtyCanvas = null;
- that.canvas = null;
- detachGroup("_legendGroup");
- detachGroup("_stripsGroup");
- detachGroup("_constantLinesGroup");
- detachGroup("_axesGroup");
- detachGroup("_labelAxesGroup");
- detachGroup("_seriesGroup");
- detachGroup("_labelsGroup");
- detachGroup("_trackerGroup");
- detachGroup("_crossHairCursorGroup");
- disposeObject("canvasClipRect");
- disposeObject("_panesBackgroundGroup");
- disposeObject("_titleGroup");
- disposeObject("_legendGroup");
- disposeObject("_stripsGroup");
- disposeObject("_constantLinesGroup");
- disposeObject("_axesGroup");
- disposeObject("_labelAxesGroup");
- disposeObject("_panesBorderGroup");
- disposeObject("_seriesGroup");
- disposeObject("_labelsGroup");
- disposeObject("_tooltipGroup");
- disposeObject("_crossHairCursorGroup");
- disposeObject("_seriesTrackerGroup");
- disposeObject("_markerTrackerGroup");
- disposeObject("_crosshairTrackerGroup");
- disposeObject("_trackerGroup");
- that._disposeLoadIndicator()
- },
- _clean: function _clean(hideLoadIndicator) {
- this.renderer && this.renderer.stopAllAnimations();
- hideLoadIndicator && this.hideLoadingIndicator();
- this._cleanHtmlStructure();
- this.callBase();
- this._saveDirtyCanvas()
- },
- _getAnimationOptions: function() {
- return $.extend({}, DEFAULT_ANIMATION_OPTIONS, this.themeManager.getOptions("animation"))
- },
- _initRenderer: function _initRenderer() {
- if (this.renderer)
- return;
- this.renderer = core.CoreFactory.createRenderer({
- animation: this._getAnimationOptions(),
- cssClass: 'dxc dxc-chart',
- pathModified: this.option('pathModified'),
- rtl: this.themeManager.getOptions('rtlEnabled')
- })
- },
- _initSeries: function() {
- this.series = this.series || this._populateSeries()
- },
- _reinitDataSource: function() {
- this._refreshDataSource()
- },
- _saveDirtyCanvas: function() {
- this.dirtyCanvas = $.extend({}, this.canvas)
- },
- _resize: function() {
- this._render(resizeRedrawOptions)
- },
- _calculateCanvas: function() {
- var canvas = this.themeManager.getOptions('size'),
- result = {},
- container = this._element();
- if (!utils.isDefined(canvas.width))
- result.width = container.width() || 400;
- else
- result.width = canvas.width < 0 ? 0 : canvas.width;
- if (!utils.isDefined(canvas.height))
- result.height = container.height() || 400;
- else
- result.height = canvas.height < 0 ? 0 : canvas.height;
- return $.extend({}, result, this.themeManager.getOptions('margin'))
- },
- _createTracker: function() {
- var that = this,
- tooltipOptions = that.themeManager.getOptions('tooltip') || {};
- if (that.tracker)
- that.tracker.dispose();
- that.tracker = charts.factory.createTracker({
- series: that.series,
- valueAxis: that._valueAxes,
- argumentAxis: that._argumentAxes,
- seriesSelectionMode: that.themeManager.getOptions('seriesSelectionMode'),
- pointSelectionMode: that.themeManager.getOptions('pointSelectionMode'),
- tooltipShown: that.option('tooltipShown'),
- tooltipHidden: that.option('tooltipHidden'),
- markerTrackerGroup: that._markerTrackerGroup,
- crossHairOptions: that._crossHairOptions,
- seriesTrackerGroup: that._seriesTrackerGroup,
- seriesGroup: that._seriesGroup,
- tooltipEnabled: tooltipOptions.enabled,
- renderer: that.renderer,
- events: {
- seriesClick: that.option('seriesClick'),
- pointClick: that.option('pointClick'),
- argumentAxisClick: that.option('argumentAxisClick'),
- seriesHover: that.option('seriesHover'),
- seriesSelected: that.option('seriesSelected'),
- pointHover: that.option('pointHover'),
- pointSelected: that.option('pointSelected'),
- legendClick: that.option('legendClick'),
- seriesSelectionChanged: that.option('seriesSelectionChanged'),
- pointSelectionChanged: that.option('pointSelectionChanged'),
- seriesHoverChanged: that.option('seriesHoverChanged'),
- pointHoverChanged: that.option('pointHoverChanged')
- }
- })
- },
- _updateTracker: function() {
- var that = this;
- if (!that.tracker)
- that._createTracker();
- else
- that.tracker._reinit({
- series: that.series,
- valueAxis: that._valueAxes,
- argumentAxis: that._argumentAxes,
- legendGroup: that.legend.getTrackerGroup(),
- legendCallback: $.proxy(that.legend.getActionCallback, that.legend)
- })
- },
- _render: function(drawOptions) {
- this._optionsInitializing = false;
- var that = this,
- renderer = that.renderer,
- updatedCanvas = that.canvas,
- container = this._element(),
- currentDirtyCanvas = that._calculateCanvas(),
- oldDirtyCanvas = that.dirtyCanvas;
- drawOptions = drawOptions || {recreateCanvas: true};
- drawOptions.recreateCanvas = drawOptions.recreateCanvas || !renderer.isInitialized();
- if (!drawOptions.force && oldDirtyCanvas && oldDirtyCanvas.width === currentDirtyCanvas.width && oldDirtyCanvas.height === currentDirtyCanvas.height && !that.hiddenContainer) {
- that.stopRedraw = true;
- return
- }
- clearTimeout(that.delayedRedraw);
- if (drawOptions.recreateCanvas)
- that.canvas = updatedCanvas = that._calculateCanvas();
- if (updatedCanvas.width && updatedCanvas.height && container.is(':visible'))
- that.hiddenContainer = false;
- else {
- that._incidentOccured('W2001', [that.NAME]);
- that.hiddenContainer = true;
- that.stopRedraw = true;
- renderer.detachContainer();
- return
- }
- if (drawOptions.recreateCanvas) {
- renderer.recreateCanvas(that.canvas.width, that.canvas.height);
- renderer.draw(that._element()[0]);
- that._reappendLoadIndicator();
- that._updateLoadIndicator(undefined, updatedCanvas.width, updatedCanvas.height);
- that._updateCanvasClipRect()
- }
- that.renderer.stopAllAnimations(true);
- that.layoutManager.update(that);
- that._cleanGroups(drawOptions);
- that._saveDirtyCanvas()
- },
- _cleanGroups: function(drawOptions) {
- var that = this;
- that._stripsGroup.detach();
- that._constantLinesGroup.detach();
- that._axesGroup.detach();
- that._labelAxesGroup.detach();
- that._labelsGroup.detach();
- that._tooltipGroup.detach();
- that._crossHairCursorGroup.detach();
- if (!drawOptions || drawOptions.drawLegend) {
- that._legendGroup.detach();
- that._legendGroup.clear()
- }
- if (!drawOptions || drawOptions.drawTitle) {
- that._titleGroup.detach();
- that._titleGroup.clear()
- }
- that._stripsGroup.clear();
- that._constantLinesGroup.clear();
- that._axesGroup.clear();
- that._labelAxesGroup.clear();
- that._labelsGroup.clear();
- that._tooltipGroup.clear();
- that._crossHairCursorGroup.clear();
- that._crosshairTrackerGroup.clear()
- },
- _drawTitle: function() {
- var that = this,
- options = that.themeManager.getOptions("title"),
- width = that.canvas.width - that.canvas.left - that.canvas.right;
- options._incidentOccured = that._incidentOccured;
- if (that.chartTitle)
- that.chartTitle.update(options, width);
- else
- that.chartTitle = charts.factory.createTitle(that.renderer, options, width, that._titleGroup)
- },
- _createTooltip: function() {
- var that = this,
- tooltipOptions = $.extend(true, {
- canvasWidth: that.canvas.width,
- canvasHeight: that.canvas.height
- }, that.themeManager.getOptions('tooltip') || {}),
- tooltipCoords,
- point = this.tracker.pointAtShownTooltip;
- if (!$.isFunction(tooltipOptions.customizeText) && utils.isDefined(tooltipOptions.customizeText)) {
- that._incidentOccured("E2103", ['customizeText']);
- tooltipOptions.customizeText = undefined
- }
- if (that.tooltip)
- that.tooltip.update(tooltipOptions);
- else
- that.tooltip = core.CoreFactory.createTooltip(tooltipOptions, that._tooltipGroup, that.renderer);
- that.tracker.setTooltip(that.tooltip);
- if (point) {
- tooltipCoords = point.getTooltipCoords();
- that.tooltip.move(~~tooltipCoords.x, ~~tooltipCoords.y, tooltipCoords.offset);
- that.tooltip.show()
- }
- },
- _prepareDrawOptions: function(drawOptions) {
- var animationOptions = this._getAnimationOptions(),
- options;
- options = $.extend({}, {
- force: false,
- adjustAxes: true,
- drawLegend: true,
- drawTitle: true,
- adjustSeriesLabels: true,
- animate: animationOptions.enabled,
- animationPointsLimit: animationOptions.maxPointCountSupported,
- asyncSeriesRendering: animationOptions.asyncSeriesRendering,
- asyncTrackersRendering: animationOptions.asyncTrackersRendering,
- trackerRenderingDelay: animationOptions.trackerRenderingDelay
- }, drawOptions);
- if (!utils.isDefined(options.recreateCanvas))
- options.recreateCanvas = options.adjustAxes && options.drawLegend && options.drawTitle;
- return options
- },
- _processRefreshData: function(newRefreshAction) {
- var currentRefreshActionPosition = $.inArray(this._currentRefreshData, ACTIONS_BY_PRIORITY),
- newRefreshActionPosition = $.inArray(newRefreshAction, ACTIONS_BY_PRIORITY);
- if (!this._currentRefreshData || currentRefreshActionPosition >= 0 && newRefreshActionPosition < currentRefreshActionPosition)
- this._currentRefreshData = newRefreshAction
- },
- _disposeSeries: function() {
- var that = this;
- that.tracker._clean();
- $.each(that.series || [], function(_, series) {
- series.dispose()
- });
- that.series = null;
- $.each(that.seriesFamilies || [], function(_, family) {
- family.dispose()
- });
- that.seriesFamilies = null
- },
- _optionChanged: function(name) {
- var that = this,
- themeManager = this.themeManager;
- themeManager.resetOptions(name);
- themeManager.update(that._options);
- if (name === 'animation') {
- that.renderer.updateAnimationOptions(this._getAnimationOptions());
- return
- }
- clearTimeout(that.delayedRedraw);
- switch (name) {
- case'dataSource':
- that._needHandleRenderComplete = true;
- that._processRefreshData('_reinitDataSource');
- break;
- case'palette':
- that.themeManager.updatePalette(this.option(name));
- that._disposeSeries();
- that._needHandleRenderComplete = true;
- that._processRefreshData('_handleDataSourceChanged');
- break;
- case'series':
- case'commonSeriesSettings':
- case'containerBackgroundColor':
- case'dataPrepareSettings':
- that._disposeSeries();
- that._needHandleRenderComplete = true;
- that._processRefreshData('_handleDataSourceChanged');
- break;
- case'legend':
- case'seriesTemplate':
- that._processRefreshData('_handleDataSourceChanged');
- break;
- case'title':
- that._processRefreshData('force_render');
- break;
- case'valueAxis':
- case'argumentAxis':
- case'commonAxisSettings':
- that._needHandleRenderComplete = true;
- that._processRefreshData('reinit');
- that._disposeSeries();
- that.paneAxis = {};
- break;
- case'panes':
- case'defaultPane':
- that._disposeSeries();
- that.paneAxis = {};
- that._needHandleRenderComplete = true;
- that._processRefreshData('reinit');
- break;
- case'size':
- that._processRefreshData('force_render');
- break;
- case'rotated':
- case'equalBarWidth':
- case'customizePoint':
- case'customizeLabel':
- that._disposeSeries();
- that._needHandleRenderComplete = true;
- that._processRefreshData('reinit');
- break;
- case'theme':
- that._disposeSeries();
- themeManager.setTheme(that.option(name));
- that._processRefreshData('reinit');
- break;
- default:
- that._processRefreshData('reinit')
- }
- that.callBase.apply(that, arguments)
- },
- _getLoadIndicatorOption: function() {
- return this.themeManager.getOptions("loadingIndicator")
- },
- _refresh: function() {
- var that = this;
- this.renderer.stopAllAnimations(true);
- if (that._currentRefreshData) {
- switch (that._currentRefreshData) {
- case'force_render':
- that._render({force: true});
- break;
- case'reinit':
- that._reinit(true);
- break;
- default:
- that[that._currentRefreshData] && that[that._currentRefreshData]()
- }
- delete that._currentRefreshData
- }
- else
- that._render({force: true})
- },
- _dataSourceOptions: function() {
- return {
- paginate: false,
- _preferSync: true
- }
- },
- _updateCanvasClipRect: function(canvas) {
- var that = this,
- width,
- height;
- canvas = canvas || that.canvas;
- width = Math.max(canvas.width - canvas.left - canvas.right, 0);
- height = Math.max(canvas.height - canvas.top - canvas.bottom, 0);
- that.canvasClipRect.updateRectangle({
- x: canvas.left,
- y: canvas.top,
- width: width,
- height: height
- });
- that.canvasClipRect.append()
- },
- _getCanvasClipRectID: function() {
- return this.canvasClipRect.id
- },
- _handleDataSourceChanged: function() {
- clearTimeout(this.delayedRedraw);
- this._dataSpecificInit(true)
- },
- _groupSeries: function() {
- this._groupedSeries = [this.series]
- },
- _dataSpecificInit: function(needRedraw) {
- this._initSeries();
- this._repopulateSeries();
- this._handleSeriesPopulated(needRedraw)
- },
- _processSingleSeries: function(){},
- _repopulateSeries: function() {
- var that = this,
- parsedData,
- data = that._dataSource && that._dataSource.items(),
- dataValidatorOptions = that.themeManager.getOptions('dataPrepareSettings'),
- seriesTemplate = that.themeManager.getOptions('seriesTemplate');
- if (that._dataSource && seriesTemplate) {
- that._templatedSeries = utils.processSeriesTemplate(seriesTemplate, that._dataSource.items());
- that._populateSeries();
- delete that._templatedSeries;
- data = that.teamplateData || data
- }
- that._groupSeries();
- that._dataValidator = charts.factory.createDataValidator(data, that._groupedSeries, that._incidentOccured, dataValidatorOptions);
- parsedData = that._dataValidator.validate();
- that.themeManager.resetPalette();
- $.each(that.series, function(_, singleSeries) {
- singleSeries.updateData(parsedData);
- that._processSingleSeries(singleSeries)
- })
- },
- _handleRenderComplete: function() {
- var that = this,
- userHandle = this.option('done'),
- allSeriesInited = true;
- if (that._needHandleRenderComplete) {
- $.each(that.series, function(_, s) {
- allSeriesInited = allSeriesInited && s.canRenderCompleteHandle()
- });
- if (allSeriesInited) {
- that._needHandleRenderComplete = false;
- $.isFunction(userHandle) && userHandle.call(that)
- }
- }
- },
- _renderTitleAndLegend: function(drawOptions, legendHasInsidePosition) {
- var that = this,
- titleOptions = that.themeManager.getOptions("title"),
- drawTitle = titleOptions.text && drawOptions.drawTitle,
- drawLegend = drawOptions.drawLegend && that.legend && !legendHasInsidePosition,
- drawElements = [];
- if (drawTitle) {
- that._titleGroup.append();
- that._drawTitle();
- drawElements.push(that.chartTitle)
- }
- if (drawLegend) {
- that._legendGroup.append();
- drawElements.push(that.legend)
- }
- drawElements.length && that.layoutManager.drawElements(drawElements, that.canvas);
- if (drawTitle)
- that.layoutManager.correctSizeElement(that.chartTitle, that.canvas)
- },
- getAllSeries: function getAllSeries() {
- return this.series.slice()
- },
- getSeriesByName: function getSeriesByName(name) {
- var found = null;
- $.each(this.series, function(i, singleSeries) {
- if (singleSeries.name === name) {
- found = singleSeries;
- return false
- }
- });
- return found
- },
- getSeriesByPos: function getSeriesByPos(pos) {
- return this.series[pos]
- },
- getSelectedSeries: function getSelectedSeries() {
- return null
- },
- clearSelection: function clearSelection() {
- this.tracker.clearSelection()
- },
- hideTooltip: function() {
- this.tracker._hideTooltip()
- },
- showLoadingIndicator: function() {
- this._showLoadIndicator(this.themeManager.getOptions("loadingIndicator"), this.canvas || {})
- },
- render: function(renderOptions) {
- this._render(renderOptions)
- },
- getSize: function() {
- var canvas = this.canvas || {};
- return {
- width: canvas.width,
- height: canvas.height
- }
- }
- }).include(ui.DataHelperMixin)
- })(jQuery, DevExpress);
- /*! Module viz-charts, file chart.js */
- (function($, DX, undefined) {
- var core = DX.viz.core,
- charts = DX.viz.charts,
- utils = DX.utils,
- MAX_ADJUSTMENT_ATTEMPTS = 5,
- DEFAULT_PANE_NAME = 'default',
- DEFAULT_AXIS_NAME = 'defaultAxisName',
- DEFAULT_BUSINESS_RANGE_VALUE_MARGIN = 0.1,
- ASYNC_SERIES_RENDERING_DELAY = 25,
- _each = $.each;
- function prepareAxis(axisOptions) {
- return $.isArray(axisOptions) ? axisOptions.length === 0 ? [{}] : axisOptions : [axisOptions]
- }
- charts.Chart = charts.BaseChart.inherit({
- _setDefaultOptions: function() {
- this.callBase();
- this.option({
- defaultPane: DEFAULT_PANE_NAME,
- panes: [{
- name: DEFAULT_PANE_NAME,
- border: {}
- }]
- })
- },
- _dispose: function() {
- var that = this,
- disposeObjectsInArray = this._disposeObjectsInArray;
- that.callBase();
- that.panes = null;
- that.legend && (that.legend.dispose(), that.legend = null);
- disposeObjectsInArray.call(that, "panesBackground");
- disposeObjectsInArray.call(that, "panesClipRects");
- disposeObjectsInArray.call(that, "financialPanesClipRects");
- disposeObjectsInArray.call(that, "_argumentAxes");
- disposeObjectsInArray.call(that, "_valueAxes");
- disposeObjectsInArray.call(that, "seriesFamilies");
- _each(that._paneTrackerGroups || [], function(_, groups) {
- groups.paneSeriesGroup.dispose();
- groups.paneMarkerGroup.dispose()
- });
- that._paneTrackerGroups = null
- },
- _init: function() {
- this.__ASYNC_SERIES_RENDERING_DELAY = ASYNC_SERIES_RENDERING_DELAY;
- this.paneAxis = {};
- this._crossHairOptions = {};
- this.callBase()
- },
- _reinit: function(needRedraw) {
- var that = this;
- that.translators = {};
- that.panes = that._createPanes();
- that._populateAxes();
- that.callBase();
- delete that._seriesInitializing;
- if (!that.series)
- that._dataSpecificInit();
- else
- that._correctValueAxes();
- that._endLoading(function() {
- needRedraw && that._render({force: true})
- })
- },
- _correctBusinessRange: function(range, tickInterval, setTicksAtUnitBeginning) {
- var min = 'min',
- max = 'max';
- if (!tickInterval || !utils.isDefined(range[min]) || !utils.isDefined(range[max]))
- return false;
- var tickIntervalRange = {},
- originInterval = tickInterval;
- tickInterval = $.isNumeric(tickInterval) ? tickInterval : utils.convertDateTickIntervalToMilliseconds(tickInterval);
- if (tickInterval >= Math.abs(range[max] - range[min])) {
- if (utils.isDate(range[min])) {
- if (!$.isNumeric(originInterval)) {
- tickIntervalRange[min] = utils.addInterval(range[min], originInterval, true);
- tickIntervalRange[max] = utils.addInterval(range[max], originInterval, false)
- }
- else {
- tickIntervalRange[min] = new Date(range[min].valueOf() - tickInterval);
- tickIntervalRange[max] = new Date(range[max].valueOf() + tickInterval)
- }
- if (setTicksAtUnitBeginning) {
- utils.correctDateWithUnitBeginning(tickIntervalRange[max], originInterval);
- utils.correctDateWithUnitBeginning(tickIntervalRange[min], originInterval)
- }
- }
- else {
- tickIntervalRange[min] = range[min] - tickInterval;
- tickIntervalRange[max] = range[max] + tickInterval
- }
- range.addRange(tickIntervalRange);
- return true
- }
- return false
- },
- _seriesVisibilityChanged: function() {
- this._processSeriesFamilies();
- this._populateBusinessRange();
- this.renderer.stopAllAnimations(true);
- this._render({
- force: true,
- asyncSeriesRendering: false,
- asyncTrackersRendering: false
- })
- },
- _populateBusinessRange: function(visibleArea) {
- var that = this,
- businessRanges = [],
- aggregationRange,
- minBound,
- maxBound,
- i,
- themeManager = that.themeManager,
- rotated = themeManager.getOptions('rotated'),
- singleSeriesRange,
- valAxes = that._valueAxes,
- valueAxes = {},
- argAxes = that._argumentAxes,
- useAggregation = themeManager.getOptions('useAggregation'),
- argumentTickInterval,
- setTicksAtUnitBeginning,
- paneAxis = that.paneAxis,
- groupedSeries = that._groupedSeries;
- that._disposeObjectsInArray("businessRanges", ["arg", "val"]);
- var argRange = new core.Range({
- rotated: !!rotated,
- minValueMargin: DEFAULT_BUSINESS_RANGE_VALUE_MARGIN,
- maxValueMargin: DEFAULT_BUSINESS_RANGE_VALUE_MARGIN
- });
- _each(valAxes, function(_, axis) {
- valueAxes[axis.name] = axis
- });
- _each(paneAxis, function(paneName, pane) {
- _each(pane, function(axisName, _) {
- var seriesForRange = [],
- firstSeriesForRange,
- options,
- valueAxesForRange,
- valRange = new core.Range({
- isValueRange: true,
- rotated: !!rotated,
- pane: paneName,
- axis: axisName,
- minValueMargin: DEFAULT_BUSINESS_RANGE_VALUE_MARGIN,
- maxValueMargin: DEFAULT_BUSINESS_RANGE_VALUE_MARGIN
- }),
- valueType,
- calcInterval;
- _each(groupedSeries, function(_, particularSeriesGroup) {
- if (particularSeriesGroup[0].pane === paneName && particularSeriesGroup[0].axis === axisName)
- seriesForRange = particularSeriesGroup
- });
- _each(valAxes, function(_, axis) {
- if (axis.pane === paneName && axis.name === axisName) {
- valueAxesForRange = axis;
- return false
- }
- });
- firstSeriesForRange = seriesForRange && seriesForRange.length ? seriesForRange[0] : {};
- _each(argAxes, function(_, axis) {
- var options = axis.options;
- options.type = firstSeriesForRange.argumentAxisType || options.type;
- options.argumentType = firstSeriesForRange.argumentType || options.argumentType;
- axis.validate(true, that._incidentOccured);
- argRange = argRange.addRange(axis.getRangeData());
- argumentTickInterval = options.tickInterval;
- setTicksAtUnitBeginning = options.setTicksAtUnitBeginning;
- calcInterval = axis.calcInterval
- });
- options = valueAxesForRange.options;
- options.type = firstSeriesForRange.valueAxisType || options.type;
- options.valueType = firstSeriesForRange.valueType || options.valueType;
- valueAxesForRange.validate(false, that._incidentOccured);
- var axisRange = new core.Range(valueAxesForRange.getRangeData());
- valueType = valueType || options.valueType === 'datetime' ? 'datetime' : undefined;
- valRange = valRange.addRange(axisRange);
- minBound = valRange.min;
- maxBound = valRange.max;
- for (i = 0; i < seriesForRange.length; i++) {
- if (visibleArea) {
- visibleArea.minVal = minBound;
- visibleArea.maxVal = maxBound;
- if (useAggregation && !visibleArea.adjustOnZoom) {
- aggregationRange = seriesForRange[i]._originalBusinessRange;
- visibleArea.minVal = utils.isDefined(visibleArea.minVal) ? visibleArea.minVal : aggregationRange.val.min;
- visibleArea.maxVal = utils.isDefined(visibleArea.maxVal) ? visibleArea.maxVal : aggregationRange.val.max
- }
- }
- singleSeriesRange = seriesForRange[i].getRangeData(visibleArea, calcInterval);
- valRange = valRange.addRange(singleSeriesRange.val);
- argRange = argRange.addRange(singleSeriesRange.arg)
- }
- if (!valRange.isDefined())
- valRange.setStubData(valueType);
- businessRanges.push({val: valRange})
- })
- });
- if (!argRange.isDefined())
- argRange.setStubData(argAxes[0].options.argumentType);
- var bussinesRangeCorrectedWithTickInterval = that._correctBusinessRange(argRange, argumentTickInterval, setTicksAtUnitBeginning);
- !bussinesRangeCorrectedWithTickInterval && argRange.applyValueMargins();
- _each(businessRanges, function(_, item) {
- var range = item.val,
- vAxis = valueAxes[range.axis];
- range.applyValueMargins();
- if (vAxis && vAxis.options.showZero)
- range.correctValueZeroLevel();
- item.arg = argRange
- });
- that.businessRanges = businessRanges
- },
- _groupSeries: function() {
- var that = this,
- panes = that.panes,
- valAxes = that._valueAxes,
- paneList = $.map(panes, function(pane) {
- return pane.name
- }),
- series = that.series,
- paneAxis = that.paneAxis,
- groupedSeries = that._groupedSeries = [];
- var getFirstAxisNameForPane = function(axes, paneName) {
- var result;
- for (var i = 0; i < axes.length; i++)
- if (axes[i].pane === paneName) {
- result = axes[i].name;
- break
- }
- if (!result)
- result = valAxes[0].name;
- return result
- };
- _each(series, function(i, particularSeries) {
- particularSeries.axis = particularSeries.axis || getFirstAxisNameForPane(valAxes, particularSeries.pane);
- if (particularSeries.axis) {
- paneAxis[particularSeries.pane] = paneAxis[particularSeries.pane] || {};
- paneAxis[particularSeries.pane][particularSeries.axis] = true
- }
- });
- _each(valAxes, function(_, axis) {
- if (axis.name && axis.pane && $.inArray(axis.pane, paneList) != -1) {
- paneAxis[axis.pane] = paneAxis[axis.pane] || {};
- paneAxis[axis.pane][axis.name] = true
- }
- });
- that._correctValueAxes();
- var hideGridsOnNonFirstValueAxisForPane = function(paneName) {
- var axesForPane = [],
- firstShownAxis;
- _each(valAxes, function(_, axis) {
- if (axis.pane === paneName)
- axesForPane.push(axis)
- });
- if (axesForPane.length > 1 && that.themeManager.getOptions('synchronizeMultiAxes'))
- _each(axesForPane, function(_, axis) {
- var gridOpt = axis.options.grid;
- if (firstShownAxis && gridOpt && gridOpt.visible)
- gridOpt.visible = false;
- else
- firstShownAxis = firstShownAxis ? firstShownAxis : gridOpt && gridOpt.visible
- })
- };
- _each(paneAxis, function(paneName, pane) {
- hideGridsOnNonFirstValueAxisForPane(paneName);
- _each(pane, function(axisName, _) {
- var group = [];
- _each(series, function(_, particularSeries) {
- if (particularSeries.pane === paneName && particularSeries.axis === axisName)
- group.push(particularSeries)
- });
- group.length && groupedSeries.push(group)
- })
- })
- },
- _cleanPanesClipRects: function(clipArrayName) {
- var that = this,
- clipArray = that[clipArrayName];
- _each(clipArray || [], function(_, clipRect) {
- clipRect && clipRect.remove()
- });
- that[clipArrayName] = []
- },
- _createPanes: function() {
- var that = this,
- panes = that.option('panes'),
- panesNameCounter = 0,
- bottomPaneName;
- if (panes && utils.isArray(panes) && !panes.length || $.isEmptyObject(panes))
- panes = that.initialOption("panes");
- that._cleanPanesClipRects('panesClipRects');
- that._cleanPanesClipRects('financialPanesClipRects');
- that.defaultPane = that.option('defaultPane');
- panes = $.isArray(panes) ? panes : panes ? [panes] : [];
- _each(panes, function(_, pane) {
- pane.name = !utils.isDefined(pane.name) ? DEFAULT_PANE_NAME + panesNameCounter++ : pane.name
- });
- if (!that._doesPaneExists(panes, that.defaultPane) && panes.length > 0) {
- bottomPaneName = panes[panes.length - 1].name;
- that._incidentOccured('W2101', [that.defaultPane, bottomPaneName]);
- that.defaultPane = bottomPaneName
- }
- panes = that.themeManager.getOptions('rotated') ? panes.reverse() : panes;
- return panes
- },
- _doesPaneExists: function(panes, paneName) {
- var found = false;
- _each(panes, function(_, pane) {
- if (pane.name === paneName) {
- found = true;
- return false
- }
- });
- return found
- },
- _populateSeries: function() {
- var that = this,
- themeManager = that.themeManager,
- hasSeriesTemplate = !!themeManager.getOptions('seriesTemplate'),
- series = hasSeriesTemplate ? that._templatedSeries : that.option('series'),
- allSeriesOptions = $.isArray(series) ? series : series ? [series] : [],
- argumentAxisOptions = that.option('argumentAxis'),
- valueAxisOptions = that.option('valueAxis'),
- data,
- particularSeriesOptions,
- particularSeries,
- rotated = themeManager.getOptions('rotated'),
- i,
- paneList = $.map(that.panes, function(pane) {
- return pane.name
- }),
- paneName,
- paneIndex;
- that.teamplateData = [];
- _each(that._paneTrackerGroups || [], function(_, groups) {
- groups.paneSeriesGroup.remove();
- groups.paneMarkerGroup.remove()
- });
- that._paneTrackerGroups = [];
- _each(that.panes, function(_, pane) {
- var paneSeriesTrackerGroup = that.renderer.createGroup({'class': 'dxc-pane-tracker'}),
- paneMarkerTrackerGroup = that.renderer.createGroup({'class': 'dxc-pane-tracker'});
- that._paneTrackerGroups.push({
- paneSeriesGroup: paneSeriesTrackerGroup,
- paneMarkerGroup: paneMarkerTrackerGroup
- })
- });
- that._disposeSeries();
- that.series = [];
- themeManager.resetPalette();
- for (i = 0; i < allSeriesOptions.length; i++) {
- particularSeriesOptions = $.extend(true, {}, allSeriesOptions[i]);
- if (particularSeriesOptions.type && !utils.isString(particularSeriesOptions.type))
- particularSeriesOptions.type = '';
- data = particularSeriesOptions.data;
- particularSeriesOptions.data = null;
- particularSeriesOptions.rotated = rotated;
- particularSeriesOptions.customizePoint = themeManager.getOptions("customizePoint");
- particularSeriesOptions.customizeLabel = themeManager.getOptions("customizeLabel");
- particularSeriesOptions.visibilityChanged = $.proxy(this._seriesVisibilityChanged, this);
- particularSeriesOptions.resolveLabelsOverlapping = themeManager.getOptions("resolveLabelsOverlapping");
- if (argumentAxisOptions) {
- particularSeriesOptions.argumentCategories = argumentAxisOptions.categories;
- particularSeriesOptions.argumentAxisType = argumentAxisOptions.type;
- particularSeriesOptions.argumentType = argumentAxisOptions.argumentType
- }
- if (valueAxisOptions)
- if (utils.isArray(valueAxisOptions))
- _each(valueAxisOptions, function(iter, options) {
- if (!particularSeriesOptions.axis && !iter || particularSeriesOptions.axis === options.name) {
- particularSeriesOptions.valueCategories = options.categories;
- particularSeriesOptions.valueAxisType = options.type;
- particularSeriesOptions.valueType = options.valueType;
- particularSeriesOptions.showZero = options.showZero
- }
- });
- else {
- particularSeriesOptions.valueCategories = valueAxisOptions.categories;
- particularSeriesOptions.valueAxisType = valueAxisOptions.type;
- particularSeriesOptions.valueType = valueAxisOptions.valueType;
- particularSeriesOptions.showZero = valueAxisOptions.showZero
- }
- particularSeriesOptions.incidentOccured = that._incidentOccured;
- if (!particularSeriesOptions.name)
- particularSeriesOptions.name = 'Series ' + (i + 1).toString();
- var seriesTheme = themeManager.getOptions("series", particularSeriesOptions);
- seriesTheme.pane = seriesTheme.pane || that.defaultPane;
- paneName = seriesTheme.pane;
- paneIndex = that._getPaneIndex(paneName);
- if ($.inArray(paneName, paneList) === -1)
- continue;
- seriesTheme.seriesGroup = that._seriesGroup;
- seriesTheme.labelsGroup = that._labelsGroup;
- seriesTheme.trackersGroup = that._paneTrackerGroups[paneIndex].paneSeriesGroup;
- seriesTheme.markerTrackerGroup = that._paneTrackerGroups[paneIndex].paneMarkerGroup;
- particularSeries = core.CoreFactory.createSeries(that.renderer, seriesTheme);
- if (!particularSeries.isUpdated)
- that._incidentOccured("E2101", [seriesTheme.type]);
- else {
- particularSeries.index = i;
- that.series.push(particularSeries)
- }
- if (hasSeriesTemplate) {
- _each(data, function(_, data) {
- _each(particularSeries.getTeamplatedFields(), function(_, field) {
- data[field.teamplateField] = data[field.originalField]
- });
- that.teamplateData.push(data)
- });
- particularSeries.updateTeamplateFieldNames()
- }
- }
- return that.series
- },
- _createValueAxis: function(axisOptions, rotated, tickProvider) {
- var that = this,
- axis;
- axisOptions = that.themeManager.getOptions("valueAxis", $.extend({
- isHorizontal: rotated,
- tickProvider: tickProvider,
- incidentOccured: that._incidentOccured
- }, axisOptions), rotated);
- if (axisOptions.strips)
- _each(axisOptions.strips, function(i, strips) {
- axisOptions.strips[i] = $.extend(true, {}, axisOptions.stripStyle, axisOptions.strips[i])
- });
- if (axisOptions.constantLines)
- _each(axisOptions.constantLines, function(i, line) {
- axisOptions.constantLines[i] = $.extend(true, {}, axisOptions.constantLineStyle, line)
- });
- axis = charts.factory.createAxis(that.renderer, axisOptions);
- axis.name = axisOptions.name;
- axis.pane = axis.pane || axisOptions.pane;
- axis.priority = axisOptions.priority;
- return axis
- },
- _disposeAxes: function() {
- var that = this;
- _each(that._valueAxes || [], function(_, axis) {
- axis.dispose()
- });
- _each(that._argumentAxes || [], function(_, axis) {
- axis.dispose()
- });
- that._valueAxes = null;
- that._argumentAxes = null
- },
- _populateAxes: function() {
- var that = this,
- valueAxes = [],
- argumentAxes = [],
- panes = that.panes,
- themeManager = that.themeManager,
- rotated = themeManager.getOptions('rotated'),
- valueAxisOptions = that.option('valueAxis') || {},
- argumentOption = that.option('argumentAxis') || {},
- argumentAxesOptions = prepareAxis(argumentOption),
- valueAxesOptions = prepareAxis(valueAxisOptions),
- axis,
- axisNames = [],
- tickProvider = core.CoreFactory.getTickProvider(),
- paneWithNonVirtualAxis;
- that._disposeAxes();
- var createArgumentAxis = function(axisOptions, virtual) {
- axisOptions = that.themeManager.getOptions("argumentAxis", $.extend(true, {
- isHorizontal: !rotated,
- tickProvider: tickProvider,
- pane: that.defaultPane,
- incidentOccured: that._incidentOccured
- }, axisOptions), rotated);
- if (axisOptions.strips)
- _each(axisOptions.strips, function(i, strips) {
- axisOptions.strips[i] = $.extend(true, {}, axisOptions.stripStyle, axisOptions.strips[i])
- });
- if (axisOptions.constantLines)
- _each(axisOptions.constantLines, function(i, line) {
- axisOptions.constantLines[i] = $.extend(true, {}, axisOptions.constantLineStyle, line)
- });
- axis = charts.factory.createAxis(that.renderer, axisOptions);
- axis._virtual = virtual;
- argumentAxes.push(axis);
- return axis
- };
- if (rotated)
- paneWithNonVirtualAxis = argumentAxesOptions[0].position === 'right' ? panes[panes.length - 1].name : panes[0].name;
- else
- paneWithNonVirtualAxis = argumentAxesOptions[0].position === 'top' ? panes[0].name : panes[panes.length - 1].name;
- _each(panes, function(_, pane) {
- var paneName = pane.name,
- virtual = paneName != paneWithNonVirtualAxis;
- var axisOptions = $.extend(true, {}, argumentAxesOptions[0], {pane: paneName});
- createArgumentAxis(axisOptions, virtual)
- });
- var valueAxesCounter = 0;
- var getNextAxisName = function() {
- return DEFAULT_AXIS_NAME + valueAxesCounter++
- };
- var unique = function(array) {
- var values = {},
- i,
- len = array.length;
- for (i = 0; i < len; i++)
- values[array[i]] = true;
- return $.map(values, function(_, key) {
- return key
- })
- };
- _each(valueAxesOptions, function(priority, axisOptions) {
- var axisPanes = [],
- name = axisOptions.name;
- if (name && $.inArray(name, axisNames) != -1) {
- that._incidentOccured("E2102");
- return
- }
- name && axisNames.push(name);
- if (axisOptions.pane)
- axisPanes.push(axisOptions.pane);
- if (axisOptions.panes && axisOptions.panes.length)
- axisPanes = axisPanes.concat(axisOptions.panes.slice(0));
- axisPanes = unique(axisPanes);
- if (!axisPanes.length)
- axisPanes.push(undefined);
- _each(axisPanes, function(_, pane) {
- valueAxes.push(that._createValueAxis($.extend(true, {}, axisOptions, {
- name: name || getNextAxisName(),
- pane: pane,
- priority: priority
- }), rotated, tickProvider))
- })
- });
- that._valueAxes = valueAxes;
- that._argumentAxes = argumentAxes
- },
- _correctValueAxes: function() {
- var that = this,
- rotated = that.themeManager.getOptions('rotated'),
- valueAxisOptions = that.option('valueAxis') || {},
- valueAxesOptions = $.isArray(valueAxisOptions) ? valueAxisOptions : [valueAxisOptions],
- tickProvider = core.CoreFactory.getTickProvider(),
- valueAxes = that._valueAxes || [],
- defaultAxisName = valueAxes[0].name,
- paneAxis = that.paneAxis || {},
- panes = that.panes,
- i,
- neededAxis = {};
- var getPaneForAxis = function(axisNameWithoutPane) {
- var result;
- _each(that.paneAxis, function(paneName, pane) {
- _each(pane, function(axisName, _) {
- if (axisNameWithoutPane == axisName) {
- result = paneName;
- return false
- }
- })
- });
- return result
- };
- var axesWithoutPanes = $.map(valueAxes, function(axis) {
- if (axis.pane)
- return null;
- return axis
- });
- _each(axesWithoutPanes, function(_, axis) {
- axis.pane = getPaneForAxis(axis.name);
- if (!axis.pane) {
- axis.pane = that.defaultPane;
- paneAxis[axis.pane] = paneAxis[axis.pane] || {};
- paneAxis[axis.pane][axis.name] = true
- }
- axis.options.pane = axis.pane
- });
- for (i = 0; i < panes.length; i++)
- if (!paneAxis[panes[i].name]) {
- paneAxis[panes[i].name] = {};
- paneAxis[panes[i].name][defaultAxisName] = true
- }
- var findAxisOptions = function(axisName) {
- var result,
- axInd;
- for (axInd = 0; axInd < valueAxesOptions.length; axInd++)
- if (valueAxesOptions[axInd].name == axisName) {
- result = valueAxesOptions[axInd];
- result.priority = axInd;
- break
- }
- if (!result)
- for (axInd = 0; axInd < valueAxes.length; axInd++)
- if (valueAxes[axInd].name == axisName) {
- result = valueAxes[axInd].options;
- result.priority = valueAxes[axInd].priority;
- break
- }
- if (!result) {
- that._incidentOccured("W2102", [axisName]);
- result = {
- name: axisName,
- priority: valueAxes.length
- }
- }
- return result
- };
- var findAxis = function(paneName, axisName) {
- var axis;
- for (i = 0; i < valueAxes.length; i++) {
- axis = valueAxes[i];
- if (axis.name === axisName && axis.pane === paneName)
- return axis
- }
- };
- _each(that.paneAxis, function(paneName, axisNames) {
- _each(axisNames, function(axisName, _) {
- neededAxis[axisName + '-' + paneName] = true;
- if (!findAxis(paneName, axisName)) {
- var axisOptions = findAxisOptions(axisName);
- if (axisOptions)
- valueAxes.push(that._createValueAxis($.extend(true, {}, axisOptions, {
- pane: paneName,
- name: axisName
- }), rotated, tickProvider))
- }
- })
- });
- valueAxes = $.grep(valueAxes, function(elem) {
- return !!neededAxis[elem.name + '-' + elem.pane]
- });
- valueAxes.sort(function(a, b) {
- return a.priority - b.priority
- });
- that._valueAxes = valueAxes
- },
- _processSeriesFamilies: function() {
- var that = this,
- types = [],
- families = [],
- paneSeries,
- themeManager = that.themeManager,
- rotated = themeManager.getOptions('rotated');
- if (that.seriesFamilies && that.seriesFamilies.length) {
- _each(that.seriesFamilies, function(_, family) {
- family.adjustSeriesValues()
- });
- return
- }
- _each(that.series, function(_, item) {
- if ($.inArray(item.type, types) === -1)
- types.push(item.type)
- });
- _each(that.panes, function(_, pane) {
- paneSeries = [];
- _each(that.series, function(_, oneSeries) {
- if (oneSeries.pane === pane.name)
- paneSeries.push(oneSeries)
- });
- _each(types, function(_, type) {
- var family = core.CoreFactory.createSeriesFamily({
- type: type,
- pane: pane.name,
- rotated: rotated,
- equalBarWidth: themeManager.getOptions('equalBarWidth'),
- minBubbleSize: themeManager.getOptions('minBubbleSize'),
- maxBubbleSize: themeManager.getOptions('maxBubbleSize')
- });
- family.add(paneSeries);
- family.adjustSeriesValues();
- families.push(family)
- })
- });
- that.seriesFamilies = families
- },
- _createLegend: function() {
- var that = this,
- legendData = [],
- legendOptions = that.themeManager.getOptions('legend');
- legendData = $.map(that.series, function(seriesItem) {
- if (seriesItem.getOptions().showInLegend)
- return {
- text: seriesItem.name,
- color: seriesItem.getColor(),
- id: seriesItem.index,
- states: seriesItem.getLegendStyles()
- }
- });
- legendOptions.containerBackgroundColor = that.themeManager.getOptions("containerBackgroundColor");
- legendOptions._incidentOccured = that._incidentOccured;
- if (that.legend)
- that.legend.update(legendData, legendOptions);
- else
- that.legend = core.CoreFactory.createLegend(legendData, legendOptions, that.renderer, that._legendGroup)
- },
- _createTranslator: function(range, canvas, options) {
- return core.CoreFactory.createTranslator2D(range, canvas, options)
- },
- _createPanesBorderOptions: function() {
- var commonBorderOptions = this.themeManager.getOptions('commonPaneSettings').border,
- panesBorderOptions = {};
- _each(this.panes, function(_, pane) {
- var borderOptions = $.extend(true, {}, commonBorderOptions, pane.border);
- panesBorderOptions[pane.name] = borderOptions
- });
- return panesBorderOptions
- },
- _render: function(drawOptions) {
- var that = this,
- themeManager = that.themeManager,
- rotated = themeManager.getOptions('rotated'),
- i,
- layoutManager = that.layoutManager,
- panesBorderOptions = that._createPanesBorderOptions(),
- needHideLoadIndicator,
- legendHasInsidePosition = that.legend && that.legend.getPosition() === "inside";
- var drawSeries = function drawSeries() {
- var panes = that.panes,
- hideLayoutLabels = that.layoutManager.needMoreSpaceForPanesCanvas(that.panes, rotated) && !that.themeManager.getOptions("adaptiveLayout").keepLabels,
- stackPoints = {};
- _each(that.seriesFamilies || [], function(_, seriesFamily) {
- var tr = that._getTranslator(seriesFamily.pane) || {},
- translators = {};
- translators[rotated ? 'x' : 'y'] = tr.val;
- translators[rotated ? 'y' : 'x'] = tr.arg;
- seriesFamily.updateSeriesValues(translators);
- seriesFamily.adjustSeriesDimensions(translators)
- });
- that._createCrossHairCursor();
- function applyPaneClipRect(seriesOptions) {
- var paneIndex = that._getPaneIndex(seriesOptions.pane);
- seriesOptions.setClippingParams(seriesOptions.isFinancialSeries() ? that.financialPanesClipRects[paneIndex].id : that.panesClipRects[paneIndex].id, that._getPaneBorderVisibility(paneIndex))
- }
- function preparePointsForSharedTooltip(singleSeries, stackPoints) {
- if (!themeManager.getOptions('tooltip').shared)
- return;
- var points = singleSeries.getPoints(),
- stackName = singleSeries.getStackName();
- _each(points, function(index, point) {
- var argument = point.argument;
- if (!stackPoints[argument]) {
- stackPoints[argument] = {};
- stackPoints[argument][null] = []
- }
- if (stackName && !DX.utils.isArray(stackPoints[argument][stackName])) {
- stackPoints[argument][stackName] = [];
- _each(stackPoints[argument][null], function(_, point) {
- if (!point.stackName)
- stackPoints[argument][stackName].push(point)
- })
- }
- if (stackName) {
- stackPoints[argument][stackName].push(point);
- stackPoints[argument][null].push(point)
- }
- else
- _each(stackPoints[argument], function(_, stack) {
- stack.push(point)
- });
- point.stackPoints = stackPoints[argument][stackName];
- point.stackName = stackName
- })
- }
- _each(that.series, function(_, particularSeries) {
- preparePointsForSharedTooltip(particularSeries, stackPoints);
- applyPaneClipRect(particularSeries);
- particularSeries.setAdjustSeriesLabels(drawOptions.adjustSeriesLabels);
- var tr = that._getTranslator(particularSeries.pane, particularSeries.axis),
- translators = {};
- translators[rotated ? 'x' : 'y'] = tr.val;
- translators[rotated ? 'y' : 'x'] = tr.arg;
- particularSeries.draw(translators, drawOptions.animate && particularSeries.getPoints().length <= drawOptions.animationPointsLimit && that.renderer.animationEnabled(), hideLayoutLabels, that.legend && that.legend.getActionCallback(particularSeries))
- });
- that._trackerGroup.append();
- if (drawOptions.drawLegend && that.legend && legendHasInsidePosition) {
- var newCanvas = $.extend({}, panes[0].canvas),
- layoutManager = charts.factory.createChartLayoutManager();
- newCanvas.right = panes[panes.length - 1].canvas.right;
- newCanvas.bottom = panes[panes.length - 1].canvas.bottom;
- that._legendGroup.append();
- that._tooltipGroup.append();
- layoutManager.drawElements([that.legend], newCanvas);
- layoutManager.placeDrawnElements(newCanvas)
- }
- needHideLoadIndicator && that.hideLoadingIndicator();
- that._drawn();
- var drawChartTrackers = function drawChartTrackers() {
- var i;
- for (i = 0; i < that.series.length; i++)
- that.series[i].drawTrackers();
- if (that.legend) {
- that.legend.drawTrackers();
- legendHasInsidePosition && that._legendGroup.append();
- legendHasInsidePosition && that._tooltipGroup.append()
- }
- that.tracker._prepare();
- _each(that._paneTrackerGroups, function(index, paneGroups) {
- paneGroups.paneSeriesGroup.append(that._seriesTrackerGroup);
- paneGroups.paneMarkerGroup.append(that._markerTrackerGroup)
- });
- that._handleRenderComplete()
- };
- that._createTooltip();
- if (drawOptions.asyncTrackersRendering)
- that.delayedRedraw = setTimeout(drawChartTrackers, drawOptions.trackerRenderingDelay);
- else
- drawChartTrackers()
- };
- drawOptions = that._prepareDrawOptions(drawOptions);
- that.callBase(drawOptions);
- if (that.stopRedraw) {
- that.stopRedraw = false;
- return
- }
- that._createPanesBackground();
- that._stripsGroup.append();
- that._axesGroup.append();
- that._constantLinesGroup.append();
- that._labelAxesGroup.append();
- that._createTranslators(drawOptions);
- that._options.useAggregation && _each(that.series, function(_, series) {
- series._originalBusinessRange = series._originalBusinessRange || series.getRangeData();
- var tr = that._getTranslator(series.pane, series.axis),
- translators = {};
- translators[rotated ? 'x' : 'y'] = tr.val;
- translators[rotated ? 'y' : 'x'] = tr.arg;
- series.resamplePoints(translators, that._zoomMinArg, that._zoomMaxArg)
- });
- if (utils.isDefined(that._zoomMinArg) || utils.isDefined(that._zoomMaxArg))
- that._populateBusinessRange({
- adjustOnZoom: themeManager.getOptions('adjustOnZoom'),
- minArg: that._zoomMinArg,
- maxArg: that._zoomMaxArg
- });
- if (that._options.useAggregation || utils.isDefined(that._zoomMinArg) || utils.isDefined(that._zoomMaxArg))
- that._updateTranslators();
- that._renderTitleAndLegend(drawOptions, legendHasInsidePosition);
- if (drawOptions && drawOptions.recreateCanvas)
- layoutManager.updatePanesCanvases(that.panes, that.canvas, rotated);
- that._drawAxes(panesBorderOptions, drawOptions);
- if (layoutManager.needMoreSpaceForPanesCanvas(that.panes, rotated)) {
- layoutManager.updateDrawnElements(that._argumentAxes, that._valueAxes, that.canvas, that.dirtyCanvas, that.panes, rotated);
- if (that.chartTitle)
- that.layoutManager.correctSizeElement(that.chartTitle, that.canvas);
- that._updateCanvasClipRect(that.dirtyCanvas);
- layoutManager.updatePanesCanvases(that.panes, that.canvas, rotated);
- that._drawAxes(panesBorderOptions, drawOptions, true)
- }
- layoutManager.placeDrawnElements(that.canvas);
- that._drawPanesBorders(panesBorderOptions);
- that._createClipRectsForPanes();
- for (i = 0; i < that._argumentAxes.length; i++)
- that._argumentAxes[i].applyClipRect(that._getElementsClipRectID(that._argumentAxes[i].pane));
- for (i = 0; i < that._valueAxes.length; i++)
- that._valueAxes[i].applyClipRect(that._getElementsClipRectID(that._valueAxes[i].pane));
- that._fillPanesBackground();
- that._seriesGroup.append();
- that._labelsGroup.append();
- that._crossHairCursorGroup.append();
- that._legendGroup.append();
- that._tooltipGroup.append();
- needHideLoadIndicator = that._loadIndicator && that._loadIndicator.isShown && that._dataSource && that._dataSource.isLoaded() && !drawOptions.isResize;
- if (drawOptions.asyncSeriesRendering)
- that.delayedRedraw = setTimeout(drawSeries, ASYNC_SERIES_RENDERING_DELAY);
- else
- drawSeries()
- },
- _createTranslators: function(drawOptions) {
- var that = this,
- rotated = that.themeManager.getOptions("rotated"),
- translators;
- if (!drawOptions.recreateCanvas)
- return;
- that.translators = translators = {};
- that.layoutManager.updatePanesCanvases(that.panes, that.canvas, rotated);
- _each(that.paneAxis, function(paneName, pane) {
- translators[paneName] = translators[paneName] || {};
- _each(pane, function(axisName, _) {
- var translator = that._createTranslator(new core.Range(that._getBusinessRange(paneName, axisName).val), that._getCanvasForPane(paneName), rotated ? {direction: 'horizontal'} : {});
- translator.pane = paneName;
- translator.axis = axisName;
- translators[paneName][axisName] = {val: translator}
- })
- });
- _each(that._argumentAxes, function(_, axis) {
- var translator = that._createTranslator(new core.Range(that._getBusinessRange(axis.pane).arg), that._getCanvasForPane(axis.pane), !rotated ? {direction: 'horizontal'} : {});
- _each(translators[axis.pane], function(valAxis, paneAsixTran) {
- paneAsixTran.arg = translator
- })
- })
- },
- _updateTranslators: function() {
- var that = this;
- _each(that.translators, function(pane, axisTrans) {
- _each(axisTrans, function(axis, translator) {
- translator.arg.updateBusinessRange(new core.Range(that._getBusinessRange(pane).arg));
- delete translator.arg._originalBusinessRange;
- translator.val.updateBusinessRange(new core.Range(that._getBusinessRange(pane, axis).val));
- delete translator.val._originalBusinessRange
- })
- })
- },
- _reinitTranslators: function() {
- var that = this;
- _each(that._argumentAxes, function(_, axis) {
- var translator = that._getTranslator(axis.pane);
- if (translator) {
- translator.arg.reinit();
- axis.setRange(translator.arg.getBusinessRange());
- axis.setTranslator(translator.arg, translator.val)
- }
- });
- _each(that._valueAxes, function(_, axis) {
- var translator = that._getTranslator(axis.pane, axis.name);
- if (translator) {
- translator.val.reinit();
- axis.setRange(translator.val.getBusinessRange());
- axis.setTranslator(translator.val, translator.arg)
- }
- })
- },
- _drawAxes: function(panesBorderOptions, drawOptions, adjustUnits) {
- var that = this,
- i = 0,
- layoutManager = that.layoutManager,
- rotated = that.themeManager.getOptions("rotated"),
- translators = that.translators,
- adjustmentCounter = 0,
- synchronizeMultiAxes = that.themeManager.getOptions('synchronizeMultiAxes');
- that._reinitTranslators();
- do {
- for (i = 0; i < that._argumentAxes.length; i++)
- that._argumentAxes[i].resetTicks();
- for (i = 0; i < that._valueAxes.length; i++)
- that._valueAxes[i].resetTicks();
- if (synchronizeMultiAxes)
- charts.multiAxesSynchronizer.synchronize(that._valueAxes);
- drawAxes(rotated ? that._valueAxes : that._argumentAxes);
- layoutManager.requireAxesRedraw = false;
- if (drawOptions.adjustAxes) {
- layoutManager.applyHorizontalAxesLayout(rotated ? that._valueAxes : that._argumentAxes);
- !layoutManager.stopDrawAxes && _each(translators, function(pane, axisTrans) {
- _each(axisTrans, function(axis, translator) {
- translator.arg.reinit();
- translator.val.reinit()
- })
- })
- }
- drawAxes(rotated ? that._argumentAxes : that._valueAxes);
- if (drawOptions.adjustAxes && !layoutManager.stopDrawAxes) {
- layoutManager.applyVerticalAxesLayout(rotated ? that._argumentAxes : that._valueAxes);
- !layoutManager.stopDrawAxes && _each(translators, function(pane, axisTrans) {
- _each(axisTrans, function(axis, translator) {
- translator.arg.reinit();
- translator.val.reinit()
- })
- })
- }
- adjustmentCounter = adjustmentCounter + 1
- } while (!layoutManager.stopDrawAxes && layoutManager.requireAxesRedraw && adjustmentCounter < MAX_ADJUSTMENT_ATTEMPTS);
- that.__axisAdjustmentsCount = adjustmentCounter;
- function drawAxes(axes) {
- _each(axes, function(_, axis) {
- axis.clipRectID = that._getCanvasClipRectID();
- axis.stripsGroup = that._stripsGroup;
- axis.labelAxesGroup = that._labelAxesGroup;
- axis.constantLinesGroup = that._constantLinesGroup;
- axis.axesContainerGroup = that._axesGroup;
- axis.draw({borderOptions: panesBorderOptions[axis.pane]}, adjustUnits)
- })
- }
- },
- _createCrossHairCursor: function() {
- var that = this,
- renderer = that.renderer,
- panes = that.panes,
- commonCanvas,
- canvas,
- options = that.themeManager.getOptions('crosshair') || {},
- hLine,
- vLine,
- attrHLine,
- attrVLine,
- i;
- if (!options || !options.enabled)
- return;
- attrHLine = {
- stroke: options.horizontalLine.color || options.color,
- strokeWidth: options.horizontalLine.width || options.width,
- dashStyle: options.horizontalLine.dashStyle || options.dashStyle,
- visibility: 'hidden',
- opacity: options.horizontalLine.opacity || options.opacity
- };
- attrVLine = {
- stroke: options.verticalLine.color || options.color,
- strokeWidth: options.verticalLine.width || options.width,
- dashStyle: options.verticalLine.dashStyle || options.dashStyle,
- visibility: 'hidden',
- opacity: options.verticalLine.opacity || options.opacity
- };
- for (i = 0; i < panes.length; i++) {
- canvas = panes[i].canvas;
- if (!commonCanvas)
- commonCanvas = $.extend({}, canvas);
- else {
- commonCanvas.right = canvas.right;
- commonCanvas.bottom = canvas.bottom
- }
- renderer.createRect(canvas.left, canvas.top, canvas.width - canvas.right - canvas.left, canvas.height - canvas.bottom - canvas.top, 0).append(this._crosshairTrackerGroup)
- }
- if (options.horizontalLine && options.horizontalLine.visible)
- hLine = renderer.createLine(commonCanvas.left, commonCanvas.top, commonCanvas.width - commonCanvas.right, commonCanvas.top, attrHLine).append(that._crossHairCursorGroup);
- if (options.verticalLine && options.verticalLine.visible)
- vLine = renderer.createLine(commonCanvas.left, commonCanvas.top, commonCanvas.left, commonCanvas.height - commonCanvas.bottom, attrVLine).append(that._crossHairCursorGroup);
- that._crossHairOptions.horizontalLine = hLine;
- that._crossHairOptions.verticalLine = vLine;
- that._crossHairOptions.canvas = commonCanvas
- },
- _createPanesBackground: function() {
- var that = this,
- defaultBackgroundColor = that.themeManager.getOptions('commonPaneSettings').backgroundColor,
- backgroundColor,
- renderer = that.renderer,
- rect,
- i,
- rects = [];
- that._panesBackgroundGroup && that._panesBackgroundGroup.clear();
- for (i = 0; i < that.panes.length; i++) {
- backgroundColor = that.panes[i].backgroundColor || defaultBackgroundColor;
- if (!backgroundColor || backgroundColor === 'none') {
- rects.push(null);
- continue
- }
- rect = renderer.createRect(0, 0, 0, 0, 0, {
- fill: backgroundColor,
- strokeWidth: 0
- }).append(that._panesBackgroundGroup);
- rects.push(rect)
- }
- that.panesBackground = rects;
- that._panesBackgroundGroup.append()
- },
- _fillPanesBackground: function() {
- var that = this,
- bc;
- _each(that.panes, function(i, pane) {
- bc = pane.borderCoords;
- if (that.panesBackground[i] != null)
- that.panesBackground[i].applySettings({
- x: bc.left,
- y: bc.top,
- width: bc.width,
- height: bc.height
- })
- })
- },
- _calcPaneBorderCoords: function(pane, rotated) {
- var canvas = pane.canvas,
- bc = pane.borderCoords = pane.borderCoords || {};
- bc.left = canvas.left;
- bc.top = canvas.top;
- bc.right = canvas.width - canvas.right;
- bc.bottom = canvas.height - canvas.bottom;
- bc.width = Math.max(bc.right - bc.left, 0);
- bc.height = Math.max(bc.bottom - bc.top, 0)
- },
- _drawPanesBorders: function(panesBorderOptions) {
- var that = this,
- rotated = that.themeManager.getOptions('rotated');
- that._panesBorderGroup && (that._panesBorderGroup.detach(), that._panesBorderGroup.clear());
- _each(that.panes, function(i, pane) {
- var bc,
- borderOptions = panesBorderOptions[pane.name],
- attr = {
- fill: 'none',
- stroke: borderOptions.color,
- strokeOpacity: borderOptions.opacity,
- strokeWidth: borderOptions.width,
- dashStyle: borderOptions.dashStyle
- };
- that._calcPaneBorderCoords(pane, rotated);
- if (!borderOptions.visible)
- return;
- bc = pane.borderCoords;
- that.renderer.createSegmentRect(bc.left, bc.top, bc.width, bc.height, 0, borderOptions, attr).append(that._panesBorderGroup)
- });
- that._panesBorderGroup.append()
- },
- _createClipRect: function(clipArray, index, left, top, width, height) {
- var that = this,
- clipRect = clipArray[index];
- if (!clipRect) {
- clipRect = that.renderer.createClipRect(left, top, width, height);
- clipArray[index] = clipRect
- }
- else
- clipRect.updateRectangle({
- x: left,
- y: top,
- width: width,
- height: height
- });
- clipRect.append()
- },
- _createClipRectsForPanes: function() {
- var that = this,
- canvas = that.canvas;
- _each(that.panes, function(i, pane) {
- var hasFinancialSeries = false,
- bc = pane.borderCoords,
- left = bc.left,
- top = bc.top,
- width = bc.width,
- height = bc.height;
- that._createClipRect(that.panesClipRects, i, left, top, width, height);
- _each(that.series, function(_, series) {
- if (series.pane === pane.name && series.isFinancialSeries())
- hasFinancialSeries = true
- });
- if (hasFinancialSeries) {
- if (that.themeManager.getOptions('rotated')) {
- top = 0;
- height = canvas.height
- }
- else {
- left = 0;
- width = canvas.width
- }
- that._createClipRect(that.financialPanesClipRects, i, left, top, width, height)
- }
- else
- that.financialPanesClipRects.push(null)
- })
- },
- _getPaneIndex: function(paneName) {
- var paneIndex;
- _each(this.panes, function(index, pane) {
- if (pane.name === paneName) {
- paneIndex = index;
- return false
- }
- });
- return paneIndex
- },
- _getPaneBorderVisibility: function(paneIndex) {
- var commonPaneBorderVisible = this.themeManager.getOptions('commonPaneSettings').border.visible,
- pane = this.panes[paneIndex] || {},
- paneBorder = pane.border || {};
- return 'visible' in paneBorder ? paneBorder.visible : commonPaneBorderVisible
- },
- _getElementsClipRectID: function(paneName) {
- return this.panesClipRects[this._getPaneIndex(paneName)].id
- },
- _getTranslator: function(paneName, axisName) {
- var paneTrans = this.translators[paneName],
- foundTranslator = null;
- if (!paneTrans)
- return foundTranslator;
- foundTranslator = paneTrans[axisName];
- if (!foundTranslator)
- _each(paneTrans, function(axis, trans) {
- foundTranslator = trans;
- return false
- });
- return foundTranslator
- },
- _getCanvasForPane: function(paneName) {
- var panes = this.panes,
- panesNumber = panes.length,
- i;
- for (i = 0; i < panesNumber; i++)
- if (panes[i].name === paneName)
- return panes[i].canvas
- },
- _getBusinessRange: function(paneName, axisName) {
- var ranges = this.businessRanges || [],
- rangesNumber = ranges.length,
- foundRange,
- i;
- for (i = 0; i < rangesNumber; i++)
- if (ranges[i].val.pane === paneName && ranges[i].val.axis === axisName) {
- foundRange = ranges[i];
- break
- }
- if (!foundRange)
- for (i = 0; i < rangesNumber; i++)
- if (ranges[i].val.pane === paneName) {
- foundRange = ranges[i];
- break
- }
- return foundRange
- },
- _handleSeriesPopulated: function(needRedraw) {
- var that = this;
- that._processSeriesFamilies();
- that._createLegend();
- that._populateBusinessRange();
- that._processValueAxisFormat();
- that._updateTracker();
- that._endLoading(function() {
- needRedraw && that._render({force: true})
- })
- },
- _processValueAxisFormat: function() {
- var that = this,
- valueAxes = that._valueAxes,
- axesWithFullStackedFormat = [];
- _each(that.series, function() {
- if (this.isFullStackedSeries() && $.inArray(this.axis, axesWithFullStackedFormat) === -1)
- axesWithFullStackedFormat.push(this.axis)
- });
- _each(valueAxes, function() {
- if ($.inArray(this.name, axesWithFullStackedFormat) !== -1)
- this.setPercentLabelFormat();
- else
- this.resetAutoLabelFormat()
- })
- },
- zoomArgument: function(min, max) {
- var that = this,
- zoomArg = that._argumentAxes[0].adjustZoomValues(min, max);
- that._zoomMinArg = zoomArg.min;
- that._zoomMaxArg = zoomArg.max;
- that._render({
- force: true,
- drawTitle: false,
- drawLegend: false,
- adjustAxes: false,
- animate: false,
- adjustSeriesLabels: false,
- asyncSeriesRendering: false
- })
- }
- })
- })(jQuery, DevExpress);
- /*! Module viz-charts, file pieChart.js */
- (function($, DX, undefined) {
- var core = DX.viz.core,
- charts = DX.viz.charts,
- utils = DX.utils;
- charts.PieChart = charts.BaseChart.inherit({
- _createThemeManager: function() {
- return charts.factory.createThemeManager(this.option(), "pie")
- },
- _reinit: function(needRedraw) {
- var that = this;
- that.callBase();
- if (!that.series)
- that._dataSpecificInit();
- that._endLoading(function() {
- needRedraw && that._render({force: true})
- })
- },
- _populateBusinessRange: function() {
- var businessRanges = [],
- series = this.series,
- singleSeries = series[0],
- range,
- singleSeriesRange;
- this._disposeObjectsInArray("businessRanges");
- if (singleSeries) {
- range = new core.Range({series: singleSeries});
- singleSeriesRange = singleSeries.getRangeData();
- range = range.addRange(singleSeriesRange.val);
- if (!range.isDefined())
- range.setStubData();
- businessRanges.push(range)
- }
- this.businessRanges = businessRanges
- },
- _seriesVisibilytyChanged: function() {
- this.series[0].arrangePoints();
- this._populateBusinessRange();
- this._refresh()
- },
- _createTranslator: function(range) {
- return core.CoreFactory.createTranslator1D(range.min, range.max, 360, 0)
- },
- _populateSeries: function() {
- var that = this,
- renderer = that.renderer,
- themeManager = that.themeManager,
- hasSeriesTemplate = !!themeManager.getOptions("seriesTemplate"),
- seriesOptions = hasSeriesTemplate ? that._templatedSeries : that.option("series"),
- allSeriesOptions = $.isArray(seriesOptions) ? seriesOptions : seriesOptions ? [seriesOptions] : [],
- data,
- particularSeriesOptions,
- particularSeries,
- seriesTheme;
- that._disposeSeries();
- that.series = [];
- themeManager.resetPalette();
- if (allSeriesOptions.length) {
- particularSeriesOptions = $.extend(true, {}, allSeriesOptions[0]);
- if (particularSeriesOptions.type && !utils.isString(particularSeriesOptions.type))
- particularSeriesOptions.type = "";
- data = particularSeriesOptions.data;
- particularSeriesOptions.data = null;
- particularSeriesOptions.incidentOccured = that._incidentOccured;
- seriesTheme = themeManager.getOptions("series", particularSeriesOptions, true);
- seriesTheme.seriesGroup = that._seriesGroup;
- seriesTheme.trackerGroup = that._trackerGroup;
- seriesTheme.seriesLabelsGroup = that._labelsGroup;
- seriesTheme.seriesTrackerGroup = that._seriesTrackerGroup;
- seriesTheme.markerTrackerGroup = that._markerTrackerGroup;
- seriesTheme.visibilityChanged = $.proxy(this._seriesVisibilytyChanged, this);
- seriesTheme.customizePoint = themeManager.getOptions("customizePoint");
- seriesTheme.customizeLabel = themeManager.getOptions("customizeLabel");
- particularSeries = core.CoreFactory.createSeries(renderer, seriesTheme);
- if (!particularSeries.isUpdated)
- that._incidentOccured("E2101", [seriesTheme.type]);
- else {
- that._processSingleSeries(particularSeries);
- that.series.push(particularSeries)
- }
- particularSeriesOptions.data = data
- }
- return that.series
- },
- _processSingleSeries: function(singleSeries) {
- singleSeries.arrangePoints()
- },
- _handleSeriesPopulated: function(needRedraw) {
- var that = this;
- that._populateBusinessRange();
- that._createLegend();
- that._updateTracker();
- that._endLoading(function() {
- needRedraw && that._render({
- force: true,
- recreateCanvas: true
- })
- })
- },
- _createLegend: function() {
- var that = this,
- legendOptions = that.themeManager.getOptions("legend"),
- data = $.map(that.series[0] ? that.series[0].getPoints() : [], function(item) {
- return {
- text: item.argument,
- color: item.getColor(),
- id: item.index,
- states: item.getLegendStyles()
- }
- });
- legendOptions._incidentOccured = that._incidentOccured;
- that.legend = core.CoreFactory.createLegend(data, legendOptions, that.renderer, that._legendGroup)
- },
- _render: function(drawOptions) {
- var that = this,
- singleSeries = that.series && that.series[0],
- layoutManager = that.layoutManager,
- hideLayoutLabels;
- drawOptions = that._prepareDrawOptions(drawOptions);
- that.callBase(drawOptions);
- if (that.stopRedraw) {
- that.stopRedraw = false;
- return
- }
- that._renderTitleAndLegend(drawOptions);
- if (layoutManager.needMoreSpaceForPanesCanvas([that])) {
- layoutManager.updateDrawnElements([], [], that.canvas, that.dirtyCanvas, [that]);
- if (that.chartTitle)
- that.layoutManager.correctSizeElement(that.chartTitle, that.canvas);
- that._updateCanvasClipRect(that.dirtyCanvas)
- }
- layoutManager.placeDrawnElements(that.canvas);
- if (singleSeries) {
- hideLayoutLabels = layoutManager.needMoreSpaceForPanesCanvas([that]) && !that.themeManager.getOptions("adaptiveLayout").keepLabels;
- layoutManager.applyPieChartSeriesLayout(that.canvas, singleSeries, true);
- that._seriesGroup.append();
- that._labelsGroup.append();
- singleSeries.canvas = that.canvas;
- singleSeries.resetLabelEllipsis();
- singleSeries.draw(that._createTranslator(that.businessRanges[0], that.canvas), drawOptions.animate && that.renderer.animationEnabled(), hideLayoutLabels);
- if (singleSeries.redraw) {
- that.renderer.stopAllAnimations(true);
- layoutManager.applyPieChartSeriesLayout(that.canvas, singleSeries, hideLayoutLabels);
- singleSeries.draw(that._createTranslator(that.businessRanges[0], that.canvas), drawOptions.animate && that.renderer.animationEnabled(), hideLayoutLabels)
- }
- that._tooltipGroup.append();
- that._trackerGroup.append();
- that._createTooltip();
- singleSeries.drawTrackers();
- that.tracker._prepare("pieChart")
- }
- that._dataSource && that._dataSource.isLoaded() && !drawOptions.isResize && that.hideLoadingIndicator();
- that._drawn();
- that._handleRenderComplete()
- },
- getSeries: function getSeries() {
- return this.series && this.series[0]
- }
- })
- })(jQuery, DevExpress);
- /*! Module viz-charts, file layoutManager.js */
- (function($, DX, undefined) {
- var isNumber = DX.utils.isNumber,
- math = Math,
- decreaseGaps = DevExpress.viz.core.utils.decreaseGaps,
- CONNECTOR_MARGIN = 10,
- round = math.round;
- DX.viz.charts.LayoutManager = DX.Class.inherit(function() {
- var ctor = function(options) {
- this.verticalElements = [];
- this.horizontalElements = [];
- this._options = options
- };
- var update = function(chart) {
- this.chart = chart;
- setCanvasValues(chart && chart.canvas)
- };
- var dispose = function() {
- this.chart = null
- };
- var setCanvasValues = function(canvas) {
- if (canvas) {
- canvas.originalTop = canvas.top;
- canvas.originalBottom = canvas.bottom;
- canvas.originalLeft = canvas.left;
- canvas.originalRight = canvas.right
- }
- };
- var placeElementAndCutCanvas = function(elements, canvas) {
- $.each(elements, function(_, element) {
- var shiftX,
- shiftY,
- options = element.getLayoutOptions(),
- length = getLength(options.cutLayoutSide);
- if (!options.width)
- return;
- switch (options.horizontalAlignment) {
- case"left":
- shiftX = canvas.left;
- break;
- case"center":
- shiftX = (canvas.width - canvas.left - canvas.right - options.width) / 2 + canvas.left;
- break;
- case"right":
- shiftX = canvas.width - canvas.right - options.width;
- break
- }
- switch (options.verticalAlignment) {
- case"top":
- shiftY = canvas.top;
- break;
- case"bottom":
- shiftY = canvas.height - canvas.bottom - options.height;
- break
- }
- element.shift(round(shiftX), round(shiftY));
- canvas[options.cutLayoutSide] += options[length];
- setCanvasValues(canvas)
- })
- };
- var drawElements = function(elements, canvas) {
- var that = this,
- verticalElements = that.verticalElements = [],
- horizontalElements = that.horizontalElements = [];
- $.each(elements, function(_, element) {
- var freeHeight = canvas.height - canvas.top - canvas.bottom,
- freeWidth = canvas.width - canvas.left - canvas.right,
- options,
- length,
- arrayElements;
- element.setSize({
- height: freeHeight,
- width: freeWidth
- });
- element.draw();
- options = element.getLayoutOptions();
- length = getLength(options.cutLayoutSide);
- arrayElements = length === "width" ? horizontalElements : verticalElements;
- arrayElements.push(element);
- canvas[options.cutLayoutSide] += options[length];
- setCanvasValues(canvas)
- })
- };
- var getLength = function(side) {
- var length = "height";
- if (side === "left" || side === "right")
- length = "width";
- return length
- };
- var updatePanesCanvases = function(panes, canvas, rotated) {
- var pane,
- i,
- paneSpaceHeight = canvas.height - canvas.top - canvas.bottom,
- paneSpaceWidth = canvas.width - canvas.left - canvas.right,
- weightSum = 0,
- padding = panes.padding || 10;
- for (i = 0; i < panes.length; i++) {
- pane = panes[i];
- pane.weight = pane.weight || 1;
- weightSum = weightSum + pane.weight
- }
- rotated ? createPanes(panes, paneSpaceWidth, "left", "right") : createPanes(panes, paneSpaceHeight, "top", "bottom");
- function createPanes(panes, paneSpace, startName, endName) {
- var distributedSpace = 0,
- oneWeight = (paneSpace - padding * (panes.length - 1)) / weightSum;
- $.each(panes, function(_, pane) {
- var calcLength = round(pane.weight * oneWeight);
- pane.canvas = pane.canvas || {};
- $.extend(pane.canvas, {
- deltaLeft: 0,
- deltaRight: 0,
- deltaTop: 0,
- deltaBottom: 0
- }, canvas);
- pane.canvas[startName] = canvas[startName] + distributedSpace;
- pane.canvas[endName] = canvas[endName] + (paneSpace - calcLength - distributedSpace);
- distributedSpace = distributedSpace + calcLength + padding;
- setCanvasValues(pane.canvas)
- })
- }
- };
- var applyPieChartSeriesLayout = function(canvas, singleSeries, hideLayoutLabels) {
- var paneSpaceHeight = canvas.height - canvas.top - canvas.bottom,
- paneSpaceWidth = canvas.width - canvas.left - canvas.right,
- paneCenterX = paneSpaceWidth / 2 + canvas.left,
- paneCenterY = paneSpaceHeight / 2 + canvas.top,
- accessibleRadius = Math.min(paneSpaceWidth, paneSpaceHeight) / 2,
- minR = 0.7 * accessibleRadius,
- innerRadius = getInnerRadius(singleSeries);
- if (!hideLayoutLabels)
- $.each(singleSeries.getPoints(), function(_, point) {
- if (point._label.hasText() && point.isVisible()) {
- var labelBBox = point._label._getOutsideGroupLabelPosition(),
- nearestX = getNearestCoord(labelBBox.x, labelBBox.x + labelBBox.width, paneCenterX),
- nearestY = getNearestCoord(labelBBox.y, labelBBox.y + labelBBox.height, paneCenterY),
- minRadiusWithLabels = Math.max(getLengthFromCenter(nearestX, nearestY) - CONNECTOR_MARGIN, minR);
- accessibleRadius = Math.min(accessibleRadius, minRadiusWithLabels)
- }
- point._label.setPosition(point._label.originalPosition)
- });
- else
- $.each(singleSeries.getPoints(), function(_, point) {
- if (singleSeries.getOptions().label.position === "inside")
- return false;
- point._label.originalPosition = point._label.getPosition();
- point._label.setPosition('outside')
- });
- singleSeries.correctPosition({
- centerX: math.floor(paneCenterX),
- centerY: math.floor(paneCenterY),
- radiusInner: math.floor(accessibleRadius * innerRadius),
- radiusOuter: math.floor(accessibleRadius)
- });
- function getNearestCoord(firstCoord, secondCoord, pointCenterCoord) {
- var nearestCoord;
- if (pointCenterCoord < firstCoord)
- nearestCoord = firstCoord;
- else if (secondCoord < pointCenterCoord)
- nearestCoord = secondCoord;
- else
- nearestCoord = pointCenterCoord;
- return nearestCoord
- }
- function getLengthFromCenter(x, y) {
- return Math.sqrt(Math.pow(x - paneCenterX, 2) + Math.pow(y - paneCenterY, 2))
- }
- function getInnerRadius(series) {
- var innerRadius;
- if (singleSeries.type === 'pie')
- innerRadius = 0;
- else {
- innerRadius = singleSeries.innerRadius;
- if (!isNumber(innerRadius))
- innerRadius = 0.5;
- else {
- innerRadius = Number(innerRadius);
- if (innerRadius < 0.2)
- innerRadius = 0.2;
- if (innerRadius > 0.8)
- innerRadius = 0.8
- }
- }
- return innerRadius
- }
- };
- var isValidBox = function isValidBox(box) {
- return !!(box.x || box.y || box.width || box.height)
- };
- var correctDeltaMarginValue = function(panes, marginSides) {
- var axisPanePosition,
- canvasCell,
- canvas,
- deltaSide,
- requireAxesRedraw;
- $.each(panes, function(_, pane) {
- canvas = pane.canvas;
- $.each(marginSides, function(_, side) {
- deltaSide = 'delta' + side;
- canvas[deltaSide] = Math.max(canvas[deltaSide] - (canvas[side.toLowerCase()] - canvas['original' + side]), 0);
- if (canvas[deltaSide] > 0)
- requireAxesRedraw = true
- })
- });
- return requireAxesRedraw
- };
- var getPane = function getPane(name, panes) {
- var findPane = panes[0];
- $.each(panes, function(_, pane) {
- if (name === pane.name)
- findPane = pane
- });
- return findPane
- };
- var applyAxesLayout = function(axes, panes, rotated) {
- var that = this,
- canvas,
- axisPanePosition,
- axisPosition,
- canvasCell,
- box,
- delta,
- axis,
- axisLength,
- direction,
- directionMultiplier,
- someDirection = [],
- pane,
- i;
- $.each(panes, function(_, pane) {
- $.extend(pane.canvas, {
- deltaLeft: 0,
- deltaRight: 0,
- deltaTop: 0,
- deltaBottom: 0
- })
- });
- for (i = 0; i < axes.length; i++) {
- axis = axes[i];
- axisPosition = axis.options.position || 'left';
- axis.delta = {};
- box = axis.getBoundingRect();
- pane = getPane(axis.pane, panes);
- canvas = pane.canvas;
- if (!isValidBox(box))
- continue;
- direction = "delta" + axisPosition.slice(0, 1).toUpperCase() + axisPosition.slice(1);
- switch (axisPosition) {
- case"right":
- directionMultiplier = 1;
- canvas.deltaLeft += axis.padding ? axis.padding.left : 0;
- break;
- case"left":
- directionMultiplier = -1;
- canvas.deltaRight += axis.padding ? axis.padding.right : 0;
- break;
- case"top":
- directionMultiplier = -1;
- canvas.deltaBottom += axis.padding ? axis.padding.bottom : 0;
- break;
- case"bottom":
- directionMultiplier = 1;
- canvas.deltaTop += axis.padding ? axis.padding.top : 0;
- break
- }
- switch (axisPosition) {
- case"right":
- case"left":
- if (!box.isEmpty) {
- delta = box.y + box.height - (canvas.height - canvas.originalBottom);
- if (delta > 0) {
- that.requireAxesRedraw = true;
- canvas.deltaBottom += delta
- }
- delta = canvas.originalTop - box.y;
- if (delta > 0) {
- that.requireAxesRedraw = true;
- canvas.deltaTop += delta
- }
- }
- axisLength = box.width;
- someDirection = ['Left', 'Right'];
- break;
- case"top":
- case"bottom":
- if (!box.isEmpty) {
- delta = box.x + box.width - (canvas.width - canvas.originalRight);
- if (delta > 0) {
- that.requireAxesRedraw = true;
- canvas.deltaRight += delta
- }
- delta = canvas.originalLeft - box.x;
- if (delta > 0) {
- that.requireAxesRedraw = true;
- canvas.deltaLeft += delta
- }
- }
- someDirection = ['Bottom', 'Top'];
- axisLength = box.height;
- break
- }
- if (!axis.delta[axisPosition] && canvas[direction] > 0)
- canvas[direction] += axis.getMultipleAxesSpacing();
- axis.delta[axisPosition] = axis.delta[axisPosition] || 0;
- axis.delta[axisPosition] += canvas[direction] * directionMultiplier;
- canvas[direction] += axisLength
- }
- that.requireAxesRedraw = correctDeltaMarginValue(panes, someDirection) || that.requireAxesRedraw;
- this.stopDrawAxes = applyFoundExceedings(panes, rotated)
- };
- var applyVerticalAxesLayout = function(axes) {
- var chart = this.chart;
- this.applyAxesLayout(axes, chart.panes, chart.option('rotated'))
- };
- var applyHorizontalAxesLayout = function(axes) {
- var chart = this.chart;
- axes.reverse();
- this.applyAxesLayout(axes, chart.panes, chart.option('rotated'));
- axes.reverse()
- };
- var placeDrawnElements = function(canvas) {
- var that = this,
- horizontalElements = that.horizontalElements,
- verticalElements = that.verticalElements;
- correctElementsPosition(horizontalElements, 'width');
- placeElementAndCutCanvas(horizontalElements, canvas);
- correctElementsPosition(verticalElements, 'height');
- placeElementAndCutCanvas(verticalElements, canvas);
- function correctElementsPosition(elements, direction) {
- $.each(elements, function(_, element) {
- var options = element.getLayoutOptions(),
- side = options.cutLayoutSide;
- canvas[side] -= options[direction]
- })
- }
- };
- var needMoreSpaceForPanesCanvas = function(panes, rotated) {
- var that = this,
- needHorizontalSpace = 0,
- needVerticalSpace = 0;
- $.each(panes, function(_, pane) {
- var paneCanvas = pane.canvas,
- needPaneHorizonralSpace = that._options.width - (paneCanvas.width - paneCanvas.left - paneCanvas.right),
- needPaneVerticalSpace = that._options.height - (paneCanvas.height - paneCanvas.top - paneCanvas.bottom);
- if (rotated) {
- needHorizontalSpace += needPaneHorizonralSpace > 0 ? needPaneHorizonralSpace : 0;
- needVerticalSpace = Math.max(needPaneVerticalSpace > 0 ? needPaneVerticalSpace : 0, needVerticalSpace)
- }
- else {
- needHorizontalSpace = Math.max(needPaneHorizonralSpace > 0 ? needPaneHorizonralSpace : 0, needHorizontalSpace);
- needVerticalSpace += needPaneVerticalSpace > 0 ? needPaneVerticalSpace : 0
- }
- });
- return needHorizontalSpace > 0 || needVerticalSpace > 0 ? {
- width: needHorizontalSpace,
- height: needVerticalSpace
- } : false
- };
- var updateDrawnElements = function(argumentAxis, valueAxis, canvas, dirtyCanvas, panes, rotated) {
- var that = this,
- needRemoveSpace,
- saveDirtyCanvas = $.extend({}, dirtyCanvas),
- verticalAxes = rotated ? argumentAxis : valueAxis,
- horizontalAxes = rotated ? valueAxis : argumentAxis;
- needRemoveSpace = this.needMoreSpaceForPanesCanvas(panes, rotated);
- if (!needRemoveSpace)
- return;
- needRemoveSpace.height = decreaseGaps(dirtyCanvas, ["top", "bottom"], needRemoveSpace.height);
- needRemoveSpace.width = decreaseGaps(dirtyCanvas, ["left", "right"], needRemoveSpace.width);
- canvas.top -= saveDirtyCanvas.top - dirtyCanvas.top;
- canvas.bottom -= saveDirtyCanvas.bottom - dirtyCanvas.bottom;
- canvas.left -= saveDirtyCanvas.left - dirtyCanvas.left;
- canvas.right -= saveDirtyCanvas.right - dirtyCanvas.right;
- updateElements(that.horizontalElements, "width", "height");
- updateElements(that.verticalElements, "height", "width");
- updateAxis(verticalAxes, "width");
- updateAxis(horizontalAxes, "height");
- function updateAxis(axes, side) {
- if (axes && needRemoveSpace[side] > 0) {
- $.each(axes, function(i, axis) {
- var bbox = axis.getBoundingRect();
- axis.updateSize();
- needRemoveSpace[side] -= bbox[side] - axis.getBoundingRect()[side]
- });
- if (needRemoveSpace[side] > 0)
- $.each(axes, function(_, axis) {
- axis.updateSize(true)
- })
- }
- }
- function updateElements(elements, length, otherLength) {
- $.each(elements, function(_, element) {
- var options = element.getLayoutOptions(),
- side = options.cutLayoutSide,
- freeSpaceWidth = dirtyCanvas.width - dirtyCanvas.left - dirtyCanvas.right,
- freeSpaceHeight = dirtyCanvas.height - dirtyCanvas.top - dirtyCanvas.bottom,
- updateObject = {};
- element.setSize({
- width: freeSpaceWidth,
- height: freeSpaceHeight
- });
- updateObject[otherLength] = 0;
- updateObject[length] = needRemoveSpace[length];
- element.changeSize(updateObject);
- canvas[side] -= options[length] - element.getLayoutOptions()[length];
- needRemoveSpace[length] -= options[length] - element.getLayoutOptions()[length]
- })
- }
- };
- var correctSizeElement = function(element, canvas) {
- element.setSize({
- width: canvas.width - canvas.right - canvas.left,
- height: canvas.width - canvas.right - canvas.left
- });
- element.changeSize({
- width: 0,
- height: 0
- })
- };
- var applyFoundExceedings = function applyFoundExceedings(panes, rotated) {
- var col,
- row,
- stopDrawAxes,
- maxLeft = 0,
- maxRight = 0,
- maxTop = 0,
- maxBottom = 0,
- maxColNumber = 0;
- $.each(panes, function(_, pane) {
- maxLeft = Math.max(maxLeft, pane.canvas.deltaLeft);
- maxRight = Math.max(maxRight, pane.canvas.deltaRight);
- maxTop = Math.max(maxTop, pane.canvas.deltaTop);
- maxBottom = Math.max(maxBottom, pane.canvas.deltaBottom)
- });
- if (rotated)
- $.each(panes, function(_, pane) {
- pane.canvas.top += maxTop;
- pane.canvas.bottom += maxBottom;
- pane.canvas.right += pane.canvas.deltaRight;
- pane.canvas.left += pane.canvas.deltaLeft
- });
- else
- $.each(panes, function(_, pane) {
- pane.canvas.top += pane.canvas.deltaTop;
- pane.canvas.bottom += pane.canvas.deltaBottom;
- pane.canvas.right += maxRight;
- pane.canvas.left += maxLeft
- });
- $.each(panes, function(_, pane) {
- if (pane.canvas.top + pane.canvas.bottom > pane.canvas.height)
- stopDrawAxes = true;
- if (pane.canvas.left + pane.canvas.right > pane.canvas.width)
- stopDrawAxes = true
- });
- return stopDrawAxes
- };
- return {
- ctor: ctor,
- update: update,
- drawElements: drawElements,
- updatePanesCanvases: updatePanesCanvases,
- applyVerticalAxesLayout: applyVerticalAxesLayout,
- applyHorizontalAxesLayout: applyHorizontalAxesLayout,
- applyAxesLayout: applyAxesLayout,
- applyPieChartSeriesLayout: applyPieChartSeriesLayout,
- dispose: dispose,
- updateDrawnElements: updateDrawnElements,
- placeDrawnElements: placeDrawnElements,
- needMoreSpaceForPanesCanvas: needMoreSpaceForPanesCanvas,
- correctSizeElement: correctSizeElement
- }
- }())
- })(jQuery, DevExpress);
- /*! Module viz-charts, file multiAxesSynchronizer.js */
- (function($, DX, undefined) {
- var Range = DX.viz.core.Range,
- utils = DX.utils,
- adjustValueUtils = utils.adjustValue,
- applyPrecisionByMinDeltaUtils = utils.applyPrecisionByMinDelta,
- isDefinedUtils = utils.isDefined,
- math = Math,
- mathFloor = math.floor,
- mathMax = math.max,
- _each = $.each,
- MIN_RANGE_FOR_ADJUST_BOUNDS = 0.1;
- var getValueAxesPerPanes = function(valueAxes) {
- var result = {};
- _each(valueAxes, function(_, axis) {
- var pane = axis.pane;
- if (!result[pane])
- result[pane] = [];
- result[pane].push(axis)
- });
- return result
- };
- var restoreOriginalBusinessRange = function(axis) {
- var businessRange;
- if (!axis.translator._originalBusinessRange)
- axis.translator._originalBusinessRange = new Range(axis.translator.getBusinessRange());
- else {
- businessRange = new Range(axis.translator._originalBusinessRange);
- axis.translator.updateBusinessRange(businessRange);
- axis.setRange(businessRange)
- }
- };
- var linearConvertor = {
- transform: function(v, b) {
- return utils.getLog(v, b)
- },
- addInterval: function(v, i) {
- return v + i
- },
- getInterval: function(base, tickInterval) {
- return tickInterval
- },
- adjustValue: mathFloor
- };
- var logConvertor = {
- transform: function(v, b) {
- return utils.raiseTo(v, b)
- },
- addInterval: function(v, i) {
- return v * i
- },
- getInterval: function(base, tickInterval) {
- return math.pow(base, tickInterval)
- },
- adjustValue: adjustValueUtils
- };
- var convertAxisInfo = function(axisInfo, convertor) {
- if (!axisInfo.isLogarithmic)
- return;
- var base = axisInfo.logarithmicBase,
- tickValues = axisInfo.tickValues,
- tick,
- ticks = [],
- interval;
- axisInfo.minValue = convertor.transform(axisInfo.minValue, base);
- axisInfo.oldMinValue = convertor.transform(axisInfo.oldMinValue, base);
- axisInfo.maxValue = convertor.transform(axisInfo.maxValue, base);
- axisInfo.oldMaxValue = convertor.transform(axisInfo.oldMaxValue, base);
- axisInfo.tickInterval = math.round(axisInfo.tickInterval);
- if (axisInfo.tickInterval < 1)
- axisInfo.tickInterval = 1;
- interval = convertor.getInterval(base, axisInfo.tickInterval);
- for (tick = convertor.adjustValue(convertor.transform(tickValues[0], base)); ticks.length < tickValues.length; tick = convertor.addInterval(tick, interval))
- ticks.push(tick);
- ticks.tickInterval = axisInfo.tickInterval;
- axisInfo.tickValues = ticks
- };
- var populateAxesInfo = function(axes) {
- return $.map(axes, function(axis) {
- restoreOriginalBusinessRange(axis);
- var tickValues = axis.getTickValues(),
- options = axis.options,
- minValue,
- maxValue,
- axisInfo = null,
- businessRange,
- tickInterval,
- synchronizedValue;
- if (tickValues && tickValues.length > 0 && utils.isNumber(tickValues[0]) && options.type !== 'discrete') {
- tickInterval = tickValues.tickInterval;
- businessRange = axis.translator.getBusinessRange();
- minValue = businessRange.minVisible;
- maxValue = businessRange.maxVisible;
- synchronizedValue = options.synchronizedValue;
- if (minValue === maxValue && isDefinedUtils(synchronizedValue)) {
- minValue = tickValues[0] - 1;
- maxValue = tickValues[0] + 1;
- tickInterval = 1
- }
- axisInfo = {
- axis: axis,
- isLogarithmic: options.type === 'logarithmic',
- logarithmicBase: businessRange.base,
- tickValues: tickValues,
- minValue: minValue,
- oldMinValue: minValue,
- maxValue: maxValue,
- oldMaxValue: maxValue,
- inverted: businessRange.invert,
- tickInterval: tickInterval,
- synchronizedValue: synchronizedValue
- };
- if (businessRange.stubData) {
- axisInfo.stubData = true;
- axisInfo.tickInterval = axisInfo.tickInterval || options.tickInterval;
- axisInfo.isLogarithmic = false
- }
- convertAxisInfo(axisInfo, linearConvertor);
- DX.utils.debug.assert(axisInfo.tickInterval !== undefined && axisInfo.tickInterval !== null, 'tickInterval was not provided')
- }
- return axisInfo
- })
- };
- var updateTickValues = function(axesInfo) {
- var maxTicksCount = 0;
- _each(axesInfo, function(_, axisInfo) {
- maxTicksCount = mathMax(maxTicksCount, axisInfo.tickValues.length)
- });
- _each(axesInfo, function(_, axisInfo) {
- var ticksMultiplier,
- ticksCount,
- additionalStartTicksCount = 0,
- synchronizedValue = axisInfo.synchronizedValue,
- tickValues = axisInfo.tickValues,
- tickInterval = axisInfo.tickInterval;
- if (isDefinedUtils(synchronizedValue)) {
- axisInfo.baseTickValue = axisInfo.invertedBaseTickValue = synchronizedValue;
- axisInfo.tickValues = [axisInfo.baseTickValue]
- }
- else {
- if (tickValues.length > 1 && tickInterval) {
- ticksMultiplier = mathFloor((maxTicksCount + 1) / tickValues.length);
- ticksCount = ticksMultiplier > 1 ? mathFloor((maxTicksCount + 1) / ticksMultiplier) : maxTicksCount;
- additionalStartTicksCount = mathFloor((ticksCount - tickValues.length) / 2);
- while (additionalStartTicksCount > 0 && tickValues[0] !== 0) {
- tickValues.unshift(applyPrecisionByMinDeltaUtils(tickValues[0], tickInterval, tickValues[0] - tickInterval));
- additionalStartTicksCount--
- }
- while (tickValues.length < ticksCount)
- tickValues.push(applyPrecisionByMinDeltaUtils(tickValues[0], tickInterval, tickValues[tickValues.length - 1] + tickInterval));
- axisInfo.tickInterval = tickInterval / ticksMultiplier
- }
- axisInfo.baseTickValue = tickValues[0];
- axisInfo.invertedBaseTickValue = tickValues[tickValues.length - 1]
- }
- })
- };
- var getAxisRange = function(axisInfo) {
- return axisInfo.maxValue - axisInfo.minValue || 1
- };
- var getMainAxisInfo = function(axesInfo) {
- for (var i = 0; i < axesInfo.length; i++)
- if (!axesInfo[i].stubData)
- return axesInfo[i];
- return null
- };
- var correctMinMaxValues = function(axesInfo) {
- var mainAxisInfo = getMainAxisInfo(axesInfo),
- mainAxisInfoTickInterval = mainAxisInfo.tickInterval;
- _each(axesInfo, function(_, axisInfo) {
- var scale,
- move,
- mainAxisBaseValueOffset,
- valueFromAxisInfo;
- if (axisInfo !== mainAxisInfo) {
- if (mainAxisInfoTickInterval && axisInfo.tickInterval) {
- if (axisInfo.stubData && isDefinedUtils(axisInfo.synchronizedValue)) {
- axisInfo.oldMinValue = axisInfo.minValue = axisInfo.baseTickValue - (mainAxisInfo.baseTickValue - mainAxisInfo.minValue) / mainAxisInfoTickInterval * axisInfo.tickInterval;
- axisInfo.oldMaxValue = axisInfo.maxValue = axisInfo.baseTickValue - (mainAxisInfo.baseTickValue - mainAxisInfo.maxValue) / mainAxisInfoTickInterval * axisInfo.tickInterval
- }
- scale = mainAxisInfoTickInterval / getAxisRange(mainAxisInfo) / axisInfo.tickInterval * getAxisRange(axisInfo);
- axisInfo.maxValue = axisInfo.minValue + getAxisRange(axisInfo) / scale
- }
- if (mainAxisInfo.inverted && !axisInfo.inverted || !mainAxisInfo.inverted && axisInfo.inverted)
- mainAxisBaseValueOffset = mainAxisInfo.maxValue - mainAxisInfo.invertedBaseTickValue;
- else
- mainAxisBaseValueOffset = mainAxisInfo.baseTickValue - mainAxisInfo.minValue;
- valueFromAxisInfo = getAxisRange(axisInfo);
- move = (mainAxisBaseValueOffset / getAxisRange(mainAxisInfo) - (axisInfo.baseTickValue - axisInfo.minValue) / valueFromAxisInfo) * valueFromAxisInfo;
- axisInfo.minValue -= move;
- axisInfo.maxValue -= move
- }
- })
- };
- var calculatePaddings = function(axesInfo) {
- var minPadding,
- maxPadding,
- startPadding = 0,
- endPadding = 0;
- _each(axesInfo, function(_, axisInfo) {
- var inverted = axisInfo.inverted;
- minPadding = axisInfo.minValue > axisInfo.oldMinValue ? (axisInfo.minValue - axisInfo.oldMinValue) / getAxisRange(axisInfo) : 0;
- maxPadding = axisInfo.maxValue < axisInfo.oldMaxValue ? (axisInfo.oldMaxValue - axisInfo.maxValue) / getAxisRange(axisInfo) : 0;
- startPadding = mathMax(startPadding, inverted ? maxPadding : minPadding);
- endPadding = mathMax(endPadding, inverted ? minPadding : maxPadding)
- });
- return {
- start: startPadding,
- end: endPadding
- }
- };
- var correctMinMaxValuesByPaddings = function(axesInfo, paddings) {
- _each(axesInfo, function(_, info) {
- var range = getAxisRange(info),
- inverted = info.inverted;
- info.minValue -= paddings[inverted ? 'end' : 'start'] * range;
- info.maxValue += paddings[inverted ? 'start' : 'end'] * range;
- if (range > MIN_RANGE_FOR_ADJUST_BOUNDS) {
- info.minValue = math.min(info.minValue, adjustValueUtils(info.minValue));
- info.maxValue = mathMax(info.maxValue, adjustValueUtils(info.maxValue))
- }
- })
- };
- var updateTickValuesIfSyncronizedValueUsed = function(axesInfo) {
- var hasSyncronizedValue = false;
- _each(axesInfo, function(_, info) {
- hasSyncronizedValue = hasSyncronizedValue || isDefinedUtils(info.synchronizedValue)
- });
- _each(axesInfo, function(_, info) {
- var lastTickValue,
- tickInterval = info.tickInterval,
- tickValues = info.tickValues,
- maxValue = info.maxValue,
- minValue = info.minValue;
- if (hasSyncronizedValue && tickInterval) {
- while (tickValues[0] - tickInterval >= minValue)
- tickValues.unshift(adjustValueUtils(tickValues[0] - tickInterval));
- lastTickValue = tickValues[tickValues.length - 1];
- while ((lastTickValue = lastTickValue + tickInterval) <= maxValue)
- tickValues.push(utils.isExponential(lastTickValue) ? adjustValueUtils(lastTickValue) : utils.applyPrecisionByMinDelta(minValue, tickInterval, lastTickValue))
- }
- while (tickValues[0] < minValue)
- tickValues.shift();
- while (tickValues[tickValues.length - 1] > maxValue)
- tickValues.pop()
- })
- };
- var applyMinMaxValues = function(axesInfo) {
- _each(axesInfo, function(_, info) {
- var axis = info.axis,
- range = axis.translator.getBusinessRange();
- if (range.min === range.minVisible)
- range.min = info.minValue;
- if (range.max === range.maxVisible)
- range.max = info.maxValue;
- range.minVisible = info.minValue;
- range.maxVisible = info.maxValue;
- if (isDefinedUtils(info.stubData))
- range.stubData = info.stubData;
- if (range.min > range.minVisible)
- range.min = range.minVisible;
- if (range.max < range.maxVisible)
- range.max = range.maxVisible;
- axis.translator.updateBusinessRange(range);
- axis.setRange(range);
- axis.setTickValues(info.tickValues)
- })
- };
- var correctAfterSynchronize = function(axesInfo) {
- var invalidAxisInfo = [],
- correctValue,
- validAxisInfo;
- _each(axesInfo, function(i, info) {
- if (info.oldMaxValue - info.oldMinValue === 0)
- invalidAxisInfo.push(info);
- else if (!isDefinedUtils(correctValue) && !isDefinedUtils(info.synchronizedValue)) {
- correctValue = math.abs((info.maxValue - info.minValue) / (info.tickValues[mathFloor(info.tickValues.length / 2)] || info.maxValue));
- validAxisInfo = info
- }
- });
- if (!isDefinedUtils(correctValue))
- return;
- _each(invalidAxisInfo, function(i, info) {
- var firstTick = info.tickValues[0],
- correctedTick = firstTick * correctValue,
- tickValues = validAxisInfo.tickValues,
- centralTick = tickValues[mathFloor(tickValues.length / 2)];
- if (firstTick > 0) {
- info.maxValue = correctedTick;
- info.minValue = 0
- }
- else if (firstTick < 0) {
- info.minValue = correctedTick;
- info.maxValue = 0
- }
- else if (firstTick === 0) {
- info.maxValue = validAxisInfo.maxValue - centralTick;
- info.minValue = validAxisInfo.minValue - centralTick
- }
- })
- };
- DX.viz.charts.multiAxesSynchronizer = {synchronize: function(valueAxes) {
- _each(getValueAxesPerPanes(valueAxes), function(_, axes) {
- var axesInfo,
- paddings;
- if (axes.length > 1) {
- axesInfo = populateAxesInfo(axes);
- if (axesInfo.length === 0 || !getMainAxisInfo(axesInfo))
- return;
- updateTickValues(axesInfo);
- correctMinMaxValues(axesInfo);
- paddings = calculatePaddings(axesInfo);
- correctMinMaxValuesByPaddings(axesInfo, paddings);
- correctAfterSynchronize(axesInfo);
- updateTickValuesIfSyncronizedValueUsed(axesInfo);
- _each(axesInfo, function() {
- convertAxisInfo(this, logConvertor)
- });
- applyMinMaxValues(axesInfo)
- }
- })
- }}
- })(jQuery, DevExpress);
- /*! Module viz-charts, file tracker.js */
- (function($, DX) {
- var charts = DX.viz.charts,
- eventsConsts = DX.viz.core.series.helpers.consts.events,
- utils = DX.utils,
- isFunction = utils.isFunction,
- isDefined = utils.isDefined,
- MULTIPLE_MODE = 'multiple',
- SINGLE_MODE = 'single',
- ALL_ARGUMENTS_POINTS_MODE = 'allargumentpoints',
- ALL_SERIES_POINTS_MODE = 'allseriespoints',
- msPointerEnabled = window.navigator.msPointerEnabled && window.navigator.msMaxTouchPoints || window.navigator.pointerEnabled && window.navigator.maxTouchPoints || null,
- MOUSE_EVENT_LOCK_TIMEOUT = 1000,
- CLICK_EVENT_LOCK_TIMEOUT = 600,
- HOVER_START_DELAY = 100,
- HOVER_HOLD_DELAY = 200,
- TOOLTIP_HOLD_TIMEOUT = 400,
- NONE_MODE = 'none';
- var processMode = function(mode) {
- return (mode + "").toLowerCase()
- };
- charts.Tracker = DX.Class.inherit({
- ctor: function(options) {
- this.__HOVER_HOLD_DELAY = HOVER_HOLD_DELAY;
- this.__TOOLTIP_HOLD_TIMEOUT = TOOLTIP_HOLD_TIMEOUT;
- this.__HOVER_START_DELAY = HOVER_START_DELAY;
- var that = this,
- events = options.events = options.events || {},
- getEventHandler = function(func) {
- return func && func.call ? function() {
- var eventContext = this,
- eventArgs = arguments;
- setTimeout(function() {
- func.apply(eventContext, eventArgs)
- })
- } : null
- };
- that._reinit(options);
- that.pointSelectionMode = that._prepareMode(options.pointSelectionMode);
- that.seriesSelectionMode = that._prepareMode(options.seriesSelectionMode);
- that.hoverStartDelay = 0;
- that.sensitivity = 7;
- if (that.pointSelectionMode === MULTIPLE_MODE) {
- that._releaseSelectedPoint = that._releaseSelectedPointMultiMode;
- that.selectedPoint = []
- }
- else
- that._releaseSelectedPoint = that._releaseSelectedPointSingleMode;
- if (that.seriesSelectionMode === MULTIPLE_MODE) {
- that._releaseSelectedSeries = that._releaseSelectedSeriesMultiMode;
- that.selectedSeries = []
- }
- else
- that._releaseSelectedSeries = that._releaseSelectedSeriesSingleMode;
- that.tooltipEnabled = options.tooltipEnabled;
- that.tooltipShown = options.tooltipShown;
- that.tooltipHidden = options.tooltipHidden;
- that.seriesClick = getEventHandler(events.seriesClick);
- that.pointClick = getEventHandler(events.pointClick);
- that.legendClick = getEventHandler(events.legendClick);
- that.argumentAxisClick = getEventHandler(events.argumentAxisClick);
- that.seriesHover = getEventHandler(events.seriesHover);
- that.seriesSelected = getEventHandler(events.seriesSelected);
- that.pointHover = getEventHandler(events.pointHover);
- that.seriesSelectionChanged = getEventHandler(events.seriesSelectionChanged);
- that.pointSelectionChanged = getEventHandler(events.pointSelectionChanged);
- that.seriesHoverChanged = getEventHandler(events.seriesHoverChanged);
- that.pointHoverChanged = getEventHandler(events.pointHoverChanged);
- that.pointSelected = getEventHandler(events.pointSelected);
- that.renderer = options.renderer;
- that.seriesTrackerGroup = options.seriesTrackerGroup;
- that.markerTrackerGroup = options.markerTrackerGroup;
- that.seriesGroup = options.seriesGroup;
- that.seriesGroup.on(eventsConsts.selectSeries, {tracker: that}, that._selectSeries);
- that.seriesGroup.on(eventsConsts.deselectSeries, {tracker: that}, that._deselectSeries);
- that.seriesGroup.on(eventsConsts.selectPoint, {tracker: that}, that._selectPoint);
- that.seriesGroup.on(eventsConsts.deselectPoint, {tracker: that}, that._deselectPoint);
- that.seriesGroup.on(eventsConsts.showPointTooltip, {tracker: that}, that._showPointTooltip);
- that.seriesGroup.on(eventsConsts.hidePointTooltip, {tracker: that}, that._hidePointTooltip);
- that.crossHairOptions = options.crossHairOptions
- },
- _clean: function() {
- var that = this;
- that.selectedPoint = that.pointSelectionMode === MULTIPLE_MODE ? [] : null;
- that.selectedSeries = that.seriesSelectionMode === MULTIPLE_MODE ? [] : null;
- that.hoveredPoint = null;
- that.hoveredSeries = null;
- that._hideTooltip(that.pointAtShownTooltip);
- that._clearTimeouts()
- },
- _reinit: function(options) {
- var that = this;
- options = options || {};
- if (that.storedSeries !== options.series) {
- that.storedSeries = options.series || [];
- that._clean()
- }
- else if (isDefined(that.storedSeries)) {
- that._clearPointSelection();
- that._clearHover(that);
- that._clearTimeouts()
- }
- that.argumentAxis = options.argumentAxis || [];
- that.legendGroup = options.legendGroup;
- that.legendCallback = options.legendCallback || $.noop
- },
- _clearTimeouts: function() {
- var that = this,
- _clearTimeout = clearTimeout;
- _clearTimeout(that.tooltipHoldTimeout);
- _clearTimeout(that.cmpCoordTimeout);
- _clearTimeout(that.hoverStartTimeOut);
- _clearTimeout(that.hoverHoldTimeOut)
- },
- dispose: function() {
- var that = this;
- that._clearTimeouts();
- clearTimeout(that.unlockMouseTimer);
- clearTimeout(that.lockClickTimer);
- $.each(that.argumentAxis, function(_, axis) {
- axis._axisElementsGroup && axis._axisElementsGroup.off()
- });
- that.seriesTrackerGroup.off();
- that.markerTrackerGroup.off();
- that.legendGroup && that.legendGroup.off();
- that.seriesGroup.off();
- that.rootTracker && that.rootTracker.off();
- that.argumentAxis = null;
- that.seriesTrackerGroup = null;
- that.markerTrackerGroup = null;
- that.legendGroup = null;
- that.legendCallback = null;
- that.seriesGroup = null;
- that.crossHairOptions = null;
- that.selectedPoint = null;
- that.selectedSeries = null;
- that.hoveredSeries = null;
- that.hoveredPoint = null;
- that.storedSeries = null;
- that.argumentAxis = null;
- that.hoveredObject = null;
- that.pointAtShownTooltip = null
- },
- _prepareMode: function(mode) {
- mode = (mode || '').toLowerCase();
- return mode = mode !== SINGLE_MODE && mode !== MULTIPLE_MODE ? SINGLE_MODE : mode
- },
- _prepare: function(typeChart) {
- var that = this;
- that.rootTracker = that.renderer.getRoot();
- $.each(that.argumentAxis, function(_, axis) {
- axis._axisElementsGroup && that._eventHandler(axis._axisElementsGroup, {
- parser: that._getOptionsAxis,
- condition: that._axisCondition,
- execute: that._axisEvent
- }, {
- tracker: that,
- axis: axis
- })
- });
- that._eventHandler(that.seriesTrackerGroup, {
- parser: that._getOptionsPointSeries,
- condition: that._seriesCondition,
- execute: that._seriesEvent
- }, {tracker: that});
- that._eventHandler(that.markerTrackerGroup, {
- parser: that._getOptionsPointSeries,
- condition: that._pointCondition,
- execute: that._pointEvent
- }, {tracker: that});
- that.legendGroup && that._eventHandler(that.legendGroup, {
- parser: that._getLegendData(typeChart),
- condition: that._seriesCondition,
- execute: that._getLegendEvent(typeChart)
- }, {tracker: that});
- that._eventHandler(that.rootTracker, {
- parser: that._getOptionsCrossHair,
- execute: that._crossHairEvent
- }, {tracker: that})
- },
- _getLegendData: function(typeChart) {
- return function(event) {
- var target = $(event.target),
- itemIndex = target.data('itemIndex'),
- that = event.data.tracker,
- mode = utils.isNumber(itemIndex) && target.data('mode');
- if (event.type === 'mousemove')
- return [that, event.pageX, event.pageY, event.offsetX, event.offsetY];
- if (!utils.isNumber(itemIndex))
- return null;
- if (typeChart === 'pieChart')
- return [that, that.storedSeries[0].getPoints()[itemIndex], mode, event];
- else
- return [that, that.storedSeries[itemIndex], mode, event]
- }
- },
- _getLegendEvent: function(typeChart) {
- var that = this,
- legendEvent;
- if (typeChart === 'pieChart')
- legendEvent = $.extend({}, this._pointEvent, {
- touchend: function(that, point, mode, event) {
- if (!that.showHoldTooltip)
- that._legendClick(that, point, true, event) || that._pointClick(that, point, true, event);
- clearTimeout(that.tooltipHoldTimeout);
- that._clickLock(that);
- that._clearHover(that)
- },
- click: function(that, point, mode, event) {
- that._legendClick(that, point, false, event) || that._pointClick(that, point, false, event)
- }
- });
- else
- legendEvent = $.extend({}, this._seriesEvent, {
- click: function(that, series, mode, event) {
- that._legendClick(that, series, false, event) || that._seriesClick(that, series, false, event)
- },
- touchend: function(that, series, mode, event) {
- that._legendClick(that, series, true, event) || that._seriesClick(that, series, true, event);
- that._clickLock(that)
- }
- });
- this.__legendEvent = legendEvent;
- return legendEvent
- },
- _eventHandler: function(group, handlers, data) {
- var prepareHandlers = this._designerHandlers(handlers);
- group.off(".dxc-tracker");
- group.on(prepareHandlers, data)
- },
- _designerHandlers: function(handler) {
- var handlers = {},
- parser = handler.parser,
- condition = handler.condition,
- execute = handler.execute,
- designerHandle = function(eventType, func) {
- if (condition && condition[eventType] === null)
- return;
- handlers[eventType + ".dxc-tracker"] = function(event) {
- var options = parser ? parser(event) : event;
- if (!options)
- return;
- if (condition && condition[eventType] && condition[eventType].call)
- condition[eventType].apply(null, options.concat([func]));
- else
- func.apply(null, options)
- }
- };
- $.each(execute, designerHandle);
- return handlers
- },
- _getOptionsCrossHair: function(event) {
- var that = event.data.tracker;
- var rootOffset = utils.getRootOffset(that.renderer);
- var xe = event.pageX - rootOffset.left;
- var ye = event.pageY - rootOffset.top;
- return [that, xe, ye]
- },
- _getOptionsPointSeries: function(event) {
- var object = $(event.target).data('point') || $(event.target).data('series'),
- that = event.data.tracker,
- mode = object && processMode($(event.target).data('mode') || object.getOptions().hoverMode);
- if (event.type === 'mousemove')
- return [that, event.pageX, event.pageY, event.offsetX, event.offsetY];
- if (!object)
- return null;
- return [that, object, mode, event]
- },
- _getOptionsAxis: function(event) {
- var that = event.data.tracker,
- axis = event.data.axis,
- mode = axis.options.hoverMode,
- argument;
- if (event.target.tagName === "tspan")
- argument = $(event.target).parent().data('argument');
- else
- argument = $(event.target).data('argument');
- if (event.type === 'mousemove')
- return [that, event.pageX, event.pageY];
- if (!axis)
- return null;
- return [that, axis, mode, argument, event]
- },
- _pointEvent: {
- mouseover: function(that, point, mode) {
- if (that.mouseLocked)
- return;
- that._setHoveredPoint(point, mode);
- if (that.tooltipEnabled && point && point.getOptions())
- that._compareCoords(that, function() {
- that._showTooltip(that.tooltip, point)
- })
- },
- mouseout: function(that, point, mode) {
- if (that.mouseLocked)
- return;
- that._clearHover(that)
- },
- touchmove: function(that, point, mode) {
- clearTimeout(that.tooltipHoldTimeout);
- that.tooltipHoldTimeout = null;
- that.showHoldTooltip = true
- },
- mousemove: function(that, pageX, pageY, offsetX, offsetY) {
- that._setCurCoords(that, pageX, pageY)
- },
- touchstart: function(that, point, mode) {
- that.showHoldTooltip = false;
- that._mouseLock(that);
- if (that.tooltipEnabled)
- that.tooltipHoldTimeout = setTimeout(function() {
- that.showHoldTooltip = true;
- that._showTooltip(that.tooltip, point)
- }, TOOLTIP_HOLD_TIMEOUT)
- },
- touchend: function(that, point, mode, event) {
- if (!that.showHoldTooltip)
- that._pointClick(that, point, true, event);
- clearTimeout(that.tooltipHoldTimeout);
- that._clickLock(that);
- that._clearHover(that)
- },
- click: function(that, point, mode, event) {
- that._pointClick(that, point, false, event)
- },
- mousedown: function(that, point, mode) {
- that._pointEvent.touchstart(that, point, mode)
- },
- mouseup: function(that, point, mode, event) {
- that._pointEvent.touchend(that, point, mode, event)
- }
- },
- _pointCondition: {
- mouseover: function(that, point, mode, event, func) {
- if (mode === ALL_ARGUMENTS_POINTS_MODE && that.hoveredPoint && that.hoveredPoint.argument === point.argument) {
- that.hoverHoldTimeOut = clearTimeout(that.hoverHoldTimeOut);
- that.hoveredObject = point;
- func(that, point, mode);
- return
- }
- that._setHover(that, point, mode, func)
- },
- mouseout: function(that, point, mode, event, func) {
- that._releaseHover(that, point, mode, func)
- },
- touchstart: !msPointerEnabled,
- touchend: !msPointerEnabled,
- mousedown: msPointerEnabled,
- mouseup: msPointerEnabled
- },
- _seriesEvent: {
- mouseover: function(that, series, mode) {
- if (that.mouseLocked)
- return;
- that._setHoveredSeries(series, mode)
- },
- mouseout: function(that, series, mode) {
- that._clearHover(that)
- },
- mousemove: function(that, pageX, pageY, offsetX, offsetY) {
- that._setCurCoords(that, pageX, pageY)
- },
- touchstart: function(that) {
- that._mouseLock(that)
- },
- touchend: function(that, series, _, event) {
- that._seriesClick(that, series, true, event);
- that._clickLock(that)
- },
- click: function(that, series, mode, event) {
- that._seriesClick(that, series, false, event)
- },
- mousedown: function(that, point, mode) {
- that._seriesEvent.touchstart(that, point, mode)
- },
- mouseup: function(that, point, mode) {
- that._seriesEvent.touchend(that, point, mode)
- }
- },
- _crossHairEvent: {
- mousemove: function(that, x, y) {
- if (!that.eventType) {
- that.eventType = 'mouse';
- return
- }
- else if (that.eventType === 'touch')
- return;
- else if (that.eventType === 'mouse') {
- that._moveCrossHair(that, x, y);
- that.eventType = null
- }
- },
- mouseout: function(that) {
- that._hideCrossHair(that);
- that.eventType = null
- },
- touchstart: function(that, x, y) {
- that.eventType = 'touch'
- },
- touchend: function(that, x, y) {
- that.eventType = null
- },
- mousedown: function(that, x, y) {
- that._crossHairEvent.touchstart(that, x, y)
- },
- mouseup: function(that, x, y) {
- that._crossHairEvent.touchend(that, x, y)
- }
- },
- _hideCrossHair: function(that) {
- if (!that.crossHairOptions)
- return;
- var horizontalLine = that.crossHairOptions.horizontalLine,
- verticalLine = that.crossHairOptions.verticalLine;
- horizontalLine && horizontalLine.applySettings({visibility: 'hidden'});
- verticalLine && verticalLine.applySettings({visibility: 'hidden'})
- },
- _moveCrossHair: function(that, x, y) {
- if (!that.crossHairOptions)
- return;
- var horizontalLine = that.crossHairOptions.horizontalLine,
- verticalLine = that.crossHairOptions.verticalLine,
- canvas = that.crossHairOptions.canvas || {};
- if (x > canvas.left && x < canvas.width - canvas.right && y > canvas.top && y < canvas.height - canvas.bottom) {
- horizontalLine && horizontalLine.applySettings({visibility: 'visible'});
- verticalLine && verticalLine.applySettings({visibility: 'visible'});
- horizontalLine && horizontalLine.applySettings({translateY: y - canvas.top});
- verticalLine && verticalLine.applySettings({translateX: x - canvas.left})
- }
- else {
- horizontalLine && horizontalLine.applySettings({visibility: 'hidden'});
- verticalLine && verticalLine.applySettings({visibility: 'hidden'})
- }
- },
- _seriesCondition: {
- mouseover: function(that, series, mode, event, func) {
- that.hoverStartDelay = 0;
- that._setHover(that, series, mode, func)
- },
- mouseout: function(that, series, mode, event, func) {
- that.hoverStartDelay = HOVER_START_DELAY;
- that._releaseHover(that, series, mode, func)
- },
- touchstart: !msPointerEnabled,
- touchend: !msPointerEnabled,
- mousedown: msPointerEnabled,
- mouseup: msPointerEnabled
- },
- _axisEvent: {
- mouseover: function(that, axis, argument) {
- if (that.mouseLocked || isDefined(that.hoveredArgument) && that.hoveredArgument === argument)
- return;
- that._clearHover(that);
- if (isDefined(that.hoveredArgument))
- that._toAllArgumentPoints(that.hoveredArgument, 'releasePointHoverState');
- that._toAllArgumentPoints(argument, 'setPointHoverState');
- that.hoveredArgument = argument
- },
- mouseout: function(that, axis) {
- if (that.mouseLocked || !isDefined(that.hoveredArgument))
- return;
- that._toAllArgumentPoints(that.hoveredArgument, 'releasePointHoverState');
- that.hoveredArgument = null
- },
- mousemove: function(that, pageX, pageY) {
- that._setCurCoords(that, pageX, pageY)
- },
- touchstart: function(that) {
- that._mouseLock(that)
- },
- touchend: function(that, axis, mode, argument, event) {
- that._argumentAxisClick(that, axis, argument, true, event);
- that._clearHover(that);
- that._clickLock(that)
- },
- click: function(that, axis, mode, argument, event) {
- that._clearHover(that);
- that._argumentAxisClick(that, axis, argument, false, event)
- },
- mousedown: function(that) {
- that._axisEvent.touchstart(that)
- },
- mouseup: function(that, axis, mode, argument, event) {
- that._axisEvent.touchend(that, axis, mode, argument, event)
- }
- },
- _axisCondition: {
- mouseover: function(that, axis, mode, argument, event, func) {
- that._hideCrossHair(that);
- if (mode === ALL_ARGUMENTS_POINTS_MODE)
- that._setHover(that, axis, argument, func)
- },
- mouseout: function(that, axis, mode, argument, event, func) {
- that._releaseHover(that, axis, argument, func)
- },
- touchstart: !msPointerEnabled,
- touchend: !msPointerEnabled,
- mousedown: msPointerEnabled,
- mouseup: msPointerEnabled
- },
- _setHover: function(that, object, mode, func) {
- if (object === that.hoveredObject) {
- that.hoverHoldTimeOut = clearTimeout(that.hoverHoldTimeOut);
- if (mode === object.lastHoverMode)
- return
- }
- if (that.mouseLocked)
- return;
- clearTimeout(that.cmpCoordTimeout);
- clearTimeout(that.hoverStartTimeOut);
- that.hoverStartTimeOut = setTimeout(function() {
- clearTimeout(that.hoverHoldTimeOut);
- that.hoveredObject = object;
- func(that, object, mode)
- }, that.hoverStartDelay)
- },
- _releaseHover: function(that, object, mode, func) {
- if (that.mouseLocked)
- return;
- clearTimeout(that.cmpCoordTimeout);
- clearTimeout(that.hoverStartTimeOut);
- if (object === that.hoveredObject)
- that.hoverHoldTimeOut = setTimeout(function() {
- that.hoveredObject = null;
- func(that, object, mode);
- that.hoverStartDelay = 0
- }, HOVER_HOLD_DELAY)
- },
- _compareCoords: function(that, func) {
- clearTimeout(that.cmpCoordTimeout);
- if (Math.abs(that.pX - that.cX) + Math.abs(that.pY - that.cY) < that.sensitivity) {
- if (that.mouseLocked)
- return;
- func()
- }
- else {
- that.pX = that.cX;
- that.pY = that.cY;
- that.cmpCoordTimeout = setTimeout(function() {
- that._compareCoords(that, func)
- }, that.hoverStartDelay === 0 ? HOVER_START_DELAY : 0)
- }
- },
- _seriesClick: function(that, series, touchEvent, event) {
- if (that.lockClick && !touchEvent)
- return;
- that.seriesClick && that.seriesClick.call(series, series, event)
- },
- _legendClick: function(that, series, touchEvent, event) {
- var legendClick = that.legendClick;
- if (that.lockClick && !touchEvent)
- return true;
- if (legendClick) {
- legendClick.call(series, series, event);
- return true
- }
- return false
- },
- _pointClick: function(that, point, touchEvent, event) {
- var series = point.series;
- if (that.lockClick && !touchEvent)
- return;
- if (that.pointClick) {
- that.pointClick.call(point, point, event);
- return
- }
- that.seriesClick && that.seriesClick.call(series, series, event);
- return
- },
- _argumentAxisClick: function(that, axis, argument, touchEvent, event) {
- if (that.lockClick && !touchEvent)
- return;
- that.argumentAxisClick && that.argumentAxisClick.call(axis, axis, argument, event)
- },
- _selectSeries: function(event, mode) {
- event.data.tracker._setSelectedSeries(event.target, mode)
- },
- _deselectSeries: function(event, mode) {
- event.data.tracker._releaseSelectedSeries(event.target, mode)
- },
- _selectPoint: function(event, point) {
- event.data.tracker._setSelectedPoint(point)
- },
- _deselectPoint: function(event, point) {
- event.data.tracker._releaseSelectedPoint(point)
- },
- _showPointTooltip: function(event, point) {
- var that = event.data.tracker;
- that._showTooltip(that.tooltip, point)
- },
- _hidePointTooltip: function(event, point) {
- event.data.tracker._hideTooltip(point)
- },
- _hideTooltip: function(point) {
- var tooltip = this && this.tooltip;
- if (!tooltip || point && this.pointAtShownTooltip !== point)
- return;
- point = point || this.pointAtShownTooltip;
- tooltip.hide();
- if (this.pointAtShownTooltip) {
- this.pointAtShownTooltip = null;
- isFunction(this.tooltipHidden) && this.tooltipHidden.call(point, point)
- }
- },
- _showTooltip: function(tooltip, point) {
- var tooltipFormatObject = point.getTooltipFormatObject(tooltip);
- if (!isDefined(tooltipFormatObject.valueText) && !tooltipFormatObject.points || !point.isVisible())
- return;
- this.pointAtShownTooltip && this._hideTooltip(this.pointAtShownTooltip);
- if (point && point.getOptions()) {
- var tooltipCoords = point.getTooltipCoords();
- if (!tooltip.prepare(tooltipFormatObject, {
- x: tooltipCoords.x,
- y: tooltipCoords.y,
- offset: tooltipCoords.offset
- }))
- return;
- tooltip.show();
- !this.pointAtShownTooltip && isFunction(this.tooltipShown) && this.tooltipShown.call(point, point);
- this.pointAtShownTooltip = point
- }
- },
- _setHoveredSeries: function(series, mode) {
- var that = this;
- if (mode !== NONE_MODE && that.hoveredSeries !== series || series.lastHoverMode !== mode) {
- that._clearHover(that);
- that.hoveredSeries = series;
- series.setHoverState(mode, that.legendCallback(series));
- that.seriesHover && that.seriesHover.call(series, series);
- that.seriesHoverChanged && that.seriesHoverChanged.call(series, series)
- }
- if (mode === NONE_MODE)
- $(series).trigger('NoneMode')
- },
- _setSelectedSeries: function(series, mode) {
- var that = this,
- seriesContain = false;
- if (this.seriesSelectionMode === MULTIPLE_MODE)
- $.each(that.selectedSeries, function(_, sr) {
- if (sr == series) {
- seriesContain = true;
- return false
- }
- });
- else if (that.selectedSeries == series)
- seriesContain = true;
- if (!seriesContain || series.lastSelectionMode !== mode) {
- if (that.seriesSelectionMode === SINGLE_MODE) {
- this._releaseSelectedSeries();
- that.selectedSeries = series
- }
- else
- that.selectedSeries.push(series);
- series.setSelectedState(mode, that.legendCallback(series));
- that.seriesSelected && that.seriesSelected.call(series, series);
- that.seriesSelectionChanged && that.seriesSelectionChanged.call(series, series)
- }
- },
- _setHoveredPoint: function(point, mode) {
- var that = this;
- var debug = DX.utils.debug;
- debug.assert(point.series, 'series was not assigned to point or empty');
- if (that.hoveredPoint === point && !point.series)
- return;
- that._clearHover(that);
- that.hoveredPoint = point;
- if (point && point.getOptions())
- that._setHoverStylePointWithMode(point, 'setPointHoverState', mode || processMode(point.getOptions().hoverMode), that.pointHoverChanged, that.legendCallback(point));
- that.pointHover && that.pointHover.call(point, point)
- },
- _toAllArgumentPoints: function(argument, func, callBack) {
- var that = this;
- $.each(that.storedSeries, function(_, series) {
- var neighborPoint = series.getPointByArg(argument);
- if (neighborPoint) {
- series[func](neighborPoint);
- callBack && callBack.call(neighborPoint, neighborPoint)
- }
- })
- },
- _setHoverStylePointWithMode: function(point, func, mode, callBack, legendCallback) {
- var that = this;
- switch (mode) {
- case ALL_ARGUMENTS_POINTS_MODE:
- this._toAllArgumentPoints(point.argument, func, callBack);
- break;
- case ALL_SERIES_POINTS_MODE:
- $.each(point.series.getPoints(), function(_, point) {
- point.series[func](point);
- callBack && callBack.call(point, point)
- });
- break;
- case NONE_MODE:
- break;
- default:
- point.series[func](point, legendCallback);
- callBack && callBack.call(point, point)
- }
- },
- _setSelectedPoint: function(point) {
- var that = this,
- pointContain = false;
- if (this.pointSelectionMode === MULTIPLE_MODE) {
- $.each(that.selectedPoint, function(_, pt) {
- if (pt == point) {
- pointContain = true;
- return false
- }
- });
- !pointContain && that.selectedPoint.push(point)
- }
- else if (that.selectedPoint !== point) {
- this._releaseSelectedPoint();
- that.selectedPoint = point
- }
- else
- pointContain = true;
- if (!pointContain) {
- that._setHoverStylePointWithMode(point, 'setPointSelectedState', processMode(point.getOptions().selectionMode), that.pointSelectionChanged, that.legendCallback(point));
- that.pointSelected && that.pointSelected.call(point, point)
- }
- },
- _releaseHoveredSeries: function() {
- var that = this;
- if (!that.hoveredSeries)
- return;
- that.hoveredSeries.releaseHoverState(undefined, that.legendCallback(that.hoveredSeries));
- that.seriesHoverChanged && that.seriesHoverChanged.call(that.hoveredSeries, that.hoveredSeries);
- that.hoveredSeries = null
- },
- _releaseSelectedSeriesMultiMode: function(series) {
- var that = this;
- if (!that.selectedSeries)
- return;
- series.releaseSelectedState(undefined, that.legendCallback(series));
- that.seriesSelectionChanged && that.seriesSelectionChanged.call(series, series);
- that.selectedSeries = $.map(that.selectedSeries, function(sr) {
- if (sr !== series)
- return sr
- })
- },
- _releaseSelectedSeriesSingleMode: function() {
- var that = this,
- series = this.selectedSeries;
- if (!series)
- return;
- series.releaseSelectedState(undefined, that.legendCallback(series));
- that.seriesSelectionChanged && that.seriesSelectionChanged.call(series, series);
- that.selectedSeries = null
- },
- _releaseHoveredPoint: function() {
- var that = this,
- point = that.hoveredPoint,
- mode;
- if (!point || !point.getOptions())
- return;
- mode = processMode(point.getOptions().hoverMode);
- if (mode === ALL_SERIES_POINTS_MODE)
- $.each(point.series.getPoints(), function(_, point) {
- point.series.releasePointHoverState(point);
- that.pointHoverChanged && that.pointHoverChanged.call(point, point)
- });
- else if (mode === ALL_ARGUMENTS_POINTS_MODE)
- that._toAllArgumentPoints(point.argument, 'releasePointHoverState', that.pointHoverChanged);
- else {
- point.releaseHoverState(that.legendCallback(point));
- that.pointHoverChanged && that.pointHoverChanged.call(point, point)
- }
- if (that.tooltipEnabled && !that.showHoldTooltip)
- that._hideTooltip(point);
- that.hoveredPoint = null
- },
- _releaseSelectedPointMultiMode: function(point) {
- var that = this,
- points = that.selectedPoint;
- if (!points)
- return;
- that._setHoverStylePointWithMode(point, 'releasePointSelectedState', processMode(point.getOptions().selectionMode), that.pointSelectionChanged, that.legendCallback(point));
- this.selectedPoint = $.map(this.selectedPoint, function(pt) {
- if (pt !== point)
- return pt
- })
- },
- _releaseSelectedPointSingleMode: function() {
- var that = this,
- point = that.selectedPoint;
- if (!point)
- return;
- that._setHoverStylePointWithMode(point, 'releasePointSelectedState', processMode(point.getOptions().selectionMode), that.pointSelectionChanged, that.legendCallback(point));
- this.selectedPoint = null
- },
- _clearPointSelection: function() {
- var that = this;
- if (that.pointSelectionMode === SINGLE_MODE)
- that._releaseSelectedPoint();
- else
- $.each(that.selectedPoint || [], function(_, point) {
- that._releaseSelectedPoint(point)
- })
- },
- clearSelection: function() {
- var that = this;
- that._clearPointSelection();
- if (that.seriesSelectionMode === SINGLE_MODE)
- that._releaseSelectedSeries();
- else
- $.each(that.selectedSeries, function(_, series) {
- that._releaseSelectedSeries(series)
- })
- },
- setTooltip: function(tooltip) {
- this.tooltip = tooltip
- },
- _mouseLock: function(tracker) {
- if (tracker.unlockMouseTimer)
- clearTimeout(tracker.unlockMouseTimer);
- tracker.mouseLocked = true;
- tracker.unlockMouseTimer = setTimeout(function() {
- tracker.mouseLocked = false
- }, MOUSE_EVENT_LOCK_TIMEOUT)
- },
- _clickLock: function(tracker) {
- tracker.lockClick = true;
- if (tracker.lockClickTimer)
- clearTimeout(tracker.lockClickTimer);
- tracker.lockClickTimer = setTimeout(function() {
- tracker.lockClick = false
- }, CLICK_EVENT_LOCK_TIMEOUT)
- },
- _setCurCoords: function(that, pageX, pageY) {
- that.cX = pageX;
- that.cY = pageY
- },
- _clearHover: function(that) {
- that._releaseHoveredSeries();
- that._releaseHoveredPoint()
- }
- })
- })(jQuery, DevExpress);
- /*! Module viz-charts, file dxChart.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- viz = DX.viz;
- DX.registerComponent("dxChart", viz.charts.Chart)
- })(jQuery, DevExpress);
- /*! Module viz-charts, file dxPieChart.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- viz = DX.viz;
- DX.registerComponent("dxPieChart", viz.charts.PieChart)
- })(jQuery, DevExpress);
- DevExpress.MOD_VIZ_CHARTS = true
- }
- if (!DevExpress.MOD_VIZ_GAUGES) {
- if (!DevExpress.MOD_VIZ_CORE)
- throw Error('Required module is not referenced: viz-core');
- /*! Module viz-gauges, file namespaces.js */
- (function(DX) {
- DX.viz.gauges = {__internals: {
- circularNeedles: {},
- circularMarkers: {},
- linearNeedles: {},
- linearMarkers: {}
- }};
- DX.viz.gauges.__tests = {}
- })(DevExpress);
- /*! Module viz-gauges, file factory.js */
- (function(DX, $, undefined) {
- var internals = DX.viz.gauges.__internals,
- circularNeedles = internals.circularNeedles,
- circularMarkers = internals.circularMarkers,
- linearNeedles = internals.linearNeedles,
- linearMarkers = internals.linearMarkers;
- var _String = window.String,
- _isString = DX.utils.isString;
- DX.viz.gauges.__factory = {
- createCircularValueIndicator: function(type) {
- var indicatorType = circularNeedles.RectangleNeedle;
- switch (_String(type).toLowerCase()) {
- case'rectangleneedle':
- case'rectangle':
- indicatorType = circularNeedles.RectangleNeedle;
- break;
- case'triangleneedle':
- case'triangle':
- indicatorType = circularNeedles.TriangleNeedle;
- break;
- case'twocolorneedle':
- case'twocolorrectangle':
- indicatorType = circularNeedles.TwoColorRectangleNeedle;
- break;
- case'rangebar':
- indicatorType = internals.CircularRangeBar;
- break
- }
- return new indicatorType
- },
- createLinearValueIndicator: function(type) {
- var indicatorType = internals.LinearRangeBar;
- switch (_String(type).toLowerCase()) {
- case'rectangle':
- indicatorType = linearNeedles.RectangleNeedle;
- break;
- case'rhombus':
- indicatorType = linearNeedles.RhombusNeedle;
- break;
- case'circle':
- indicatorType = linearNeedles.CircleNeedle;
- break;
- case'rangebar':
- indicatorType = internals.LinearRangeBar;
- break
- }
- return new indicatorType
- },
- createCircularSubvalueIndicator: function(type) {
- var indicatorType = circularMarkers.TriangleMarker;
- switch (_String(type).toLowerCase()) {
- case'trianglemarker':
- case'triangle':
- indicatorType = circularMarkers.TriangleMarker;
- break;
- case'textcloud':
- indicatorType = circularMarkers.TextCloudMarker;
- break
- }
- return new indicatorType
- },
- createLinearSubvalueIndicator: function(type) {
- var indicatorType = linearMarkers.TriangleMarker;
- switch (_String(type).toLowerCase()) {
- case'trianglemarker':
- case'triangle':
- indicatorType = linearMarkers.TriangleMarker;
- break;
- case'textcloud':
- indicatorType = linearMarkers.TextCloudMarker;
- break
- }
- return new indicatorType
- },
- createCircularValueIndicatorInHardMode: function(type) {
- var indicatorType = null;
- switch (_String(type).toLowerCase()) {
- case'rectangleneedle':
- indicatorType = circularNeedles.RectangleNeedle;
- break;
- case'triangleneedle':
- indicatorType = circularNeedles.TriangleNeedle;
- break;
- case'twocolorneedle':
- indicatorType = circularNeedles.TwoColorRectangleNeedle;
- break;
- case'rangebar':
- indicatorType = internals.CircularRangeBar;
- break;
- case'trianglemarker':
- indicatorType = circularMarkers.TriangleMarker;
- break;
- case'textcloud':
- indicatorType = circularMarkers.TextCloudMarker;
- break
- }
- return indicatorType ? new indicatorType : null
- },
- createLinearValueIndicatorInHardMode: function(type) {
- var indicatorType = null;
- switch (_String(type).toLowerCase()) {
- case'rectangle':
- indicatorType = linearNeedles.RectangleNeedle;
- break;
- case'rhombus':
- indicatorType = linearNeedles.RhombusNeedle;
- break;
- case'circle':
- indicatorType = linearNeedles.CircleNeedle;
- break;
- case'rangebar':
- indicatorType = internals.LinearRangeBar;
- break;
- case'trianglemarker':
- indicatorType = linearMarkers.TriangleMarker;
- break;
- case'textcloud':
- indicatorType = linearMarkers.TextCloudMarker;
- break
- }
- return indicatorType ? new indicatorType : null
- },
- createCircularNeedle: function(type) {
- switch (_String(type).toLowerCase()) {
- case'rectangleneedle':
- case'rectangle':
- return new circularNeedles.RectangleNeedle;
- case'twocolorneedle':
- case'twocolorrectangle':
- return new circularNeedles.TwoColorRectangleNeedle;
- case'triangleneedle':
- case'triangle':
- return new circularNeedles.TriangleNeedle;
- case'rangebar':
- return new internals.CircularRangeBar
- }
- return undefined
- },
- createLinearNeedle: function(type) {
- switch (_String(type).toLowerCase()) {
- case'rectangle':
- return new linearNeedles.RectangleNeedle;
- case'rhombus':
- return new linearNeedles.RhombusNeedle;
- case'circle':
- return new linearNeedles.CircleNeedle;
- case'rangebar':
- return new internals.LinearRangeBar
- }
- return undefined
- },
- createCircularMarker: function(type) {
- switch (_String(type).toLowerCase()) {
- case'trianglemarker':
- case'triangle':
- return new circularMarkers.TriangleMarker;
- case'textcloud':
- return new circularMarkers.TextCloudMarker
- }
- return undefined
- },
- createLinearMarker: function(type) {
- switch (_String(type).toLowerCase()) {
- case'trianglemarker':
- case'triangle':
- return new linearMarkers.TriangleMarker;
- case'textcloud':
- return new linearMarkers.TextCloudMarker
- }
- return undefined
- },
- createCircularRangeBar: function(parameters) {
- return new internals.CircularRangeBar(parameters)
- },
- createLinearRangeBar: function(parameters) {
- return new internals.LinearRangeBar(parameters)
- },
- createCircularScale: function(parameters) {
- return new internals.CircularScale(parameters)
- },
- createLinearScale: function(parameters) {
- return new internals.LinearScale(parameters)
- },
- createCircularRangeContainer: function(parameters) {
- return new internals.CircularRangeContainer(parameters)
- },
- createLinearRangeContainer: function(parameters) {
- return new internals.LinearRangeContainer(parameters)
- },
- createTitle: function(parameters) {
- return new internals.Title(parameters)
- },
- createIndicator: function() {
- return internals.Indicator && new internals.Indicator || null
- },
- createLayoutManager: function() {
- return new internals.LayoutManager
- },
- createThemeManager: function(options) {
- return new internals.ThemeManager(options)
- },
- createTracker: function(parameters) {
- return new internals.Tracker(parameters)
- }
- };
- var _isFunction = DX.utils.isFunction,
- _String = window.String,
- _extend = $.extend;
- var _formatHelper = DX.formatHelper;
- internals.formatValue = function(value, options, extra) {
- options = options || {};
- var text = _formatHelper.format(value, options.format, options.precision),
- context;
- if (_isFunction(options.customizeText)) {
- var context = _extend({
- value: value,
- valueText: text
- }, extra);
- return _String(options.customizeText.call(context, context))
- }
- return text
- };
- internals.getSampleText = function(translator, options) {
- var text1 = internals.formatValue(translator.getDomainStart(), options),
- text2 = internals.formatValue(translator.getDomainEnd(), options);
- return text1.length >= text2.length ? text1 : text2
- }
- })(DevExpress, jQuery);
- /*! Module viz-gauges, file scale.js */
- (function(DX, $, undefined) {
- var _Number = Number,
- _String = String,
- _isFinite = isFinite,
- _min = Math.min,
- _max = Math.max,
- _abs = Math.abs,
- _atan = Math.atan,
- _acos = Math.acos,
- _ceil = Math.ceil,
- _isFunction = DX.utils.isFunction,
- _isArray = DX.utils.isArray,
- _getCosAndSin = DX.utils.getCosAndSin,
- _normalizeAngle = DX.utils.normalizeAngle,
- _convertAngleToRendererSpace = DX.utils.convertAngleToRendererSpace,
- _map = $.map;
- var _formatHelper = DX.formatHelper,
- _tickProvider = DX.viz.core.tickProvider;
- var PI_DIV_180 = Math.PI / 180;
- function binarySearch(x, list) {
- var a = 0,
- b = list.length - 1,
- flag = list[a] - list[b] < 0,
- c,
- k = -1;
- if (list[a] === x)
- k = a;
- if (list[b] === x)
- k = b;
- while (k < 0 && a <= b) {
- c = ~~((a + b) / 2);
- if (list[c] === x)
- k = c;
- else if (list[c] - x < 0 === flag)
- a = c + 1;
- else
- b = c - 1
- }
- return k
- }
- function sortAsc(x, y) {
- return x - y
- }
- function sortDes(x, y) {
- return y - x
- }
- DX.viz.gauges.__internals.BaseScale = DX.Class.inherit({
- ctor: function(parameters) {
- var that = this;
- that._renderer = parameters.renderer;
- that._container = parameters.container;
- that._translator = parameters.translator;
- that._root = that._renderer.createGroup({'class': 'dxg-scale'});
- that._majorTicks = that._renderer.createGroup({'class': 'dxg-major-ticks'});
- that._minorTicks = that._renderer.createGroup({'class': 'dxg-minor-ticks'});
- that._labels = that._renderer.createGroup({'class': 'dxg-labels'})
- },
- dispose: function() {
- var that = this;
- that._renderer = that._container = that._renderer = that._root = that._majorTicks = that._minorTicks = that._labels = null;
- return that
- },
- clean: function() {
- var that = this;
- that._root.detach();
- that._majorTicks.detach().clear();
- that._minorTicks.detach().clear();
- that._labels.detach().clear();
- that._majorTicksEnabled = that._minorTicksEnabled = that._labelsEnabled = that._options = that.enabled = null;
- return that
- },
- render: function(options) {
- var that = this;
- that._options = options;
- that._processOptions(options);
- if (that._majorTicksEnabled || that._minorTicksEnabled || that._labelsEnabled) {
- that.enabled = true;
- that._root.append(that._container);
- if (that._majorTicksEnabled)
- that._majorTicks.append(that._root);
- if (that._minorTicksEnabled)
- that._minorTicks.append(that._root);
- if (that._labelsEnabled) {
- that._labels.append(that._root);
- that._measureText()
- }
- }
- return that
- },
- _processOptions: function(options) {
- var that = this;
- that._majorTicksEnabled = options.majorTick.visible && options.majorTick.length > 0 && options.majorTick.width > 0;
- that._minorTicksEnabled = options.minorTick.visible && options.minorTick.length > 0 && options.minorTick.width > 0;
- that._labelsEnabled = options.label.visible && _Number(options.label.indentFromTick) !== 0;
- that._setupOrientation()
- },
- _getSampleText: function() {
- var that = this,
- domain = that._translator.getDomain(),
- texts = [],
- i,
- ii,
- text,
- maxLength = 0,
- maxText = '';
- var ticks = _tickProvider.getTicks({
- min: domain[0],
- max: domain[1],
- tickInterval: that._options.majorTick.tickInterval > 0 ? _Number(that._options.majorTick.tickInterval) : undefined,
- screenDelta: that._options.approximateScreenDelta,
- gridSpacingFactor: that._getGridSpacingFactor().majorTicks
- });
- for (i = 0, ii = ticks.length; i < ii; ++i) {
- text = that._formatValue(ticks[i]);
- text.length > maxLength && (maxText = text) && (maxLength = text.length)
- }
- return maxText
- },
- _measureText: function() {
- var that = this,
- value = that._getSampleText(),
- text = that._renderer.createText(value, 0, 0, {font: that._options.label.font}).append(that._labels),
- bbox = text.getBBox();
- text.remove();
- that._textVerticalOffset = -bbox.y - bbox.height / 2;
- that._textWidth = bbox.width;
- that._textHeight = bbox.height;
- that._textLength = value.length
- },
- _formatValue: function(value) {
- var options = this._options.label,
- text = _formatHelper.format(value, options.format, options.precision);
- if (_isFunction(options.customizeText)) {
- text = {
- value: value,
- valueText: text
- };
- text = _String(options.customizeText.call(text, text))
- }
- return text
- },
- _setupOrientation: null,
- _getCustomValues: function(values, compare) {
- var translator = this._translator,
- result = [];
- if (_isArray(values)) {
- result = _map(values, function(x) {
- return _isFinite(translator.translate(x)) ? _Number(x) : null
- }).sort(compare);
- result = _map(result, function(x, i) {
- return x !== result[i - 1] ? x : null
- })
- }
- return result
- },
- _generateTicks: function(layout) {
- var that = this,
- majorTicksOptions = {
- tickInterval: that._options.majorTick.tickInterval > 0 ? _Number(that._options.majorTick.tickInterval) : undefined,
- gridSpacingFactor: that._getGridSpacingFactor().majorTicks,
- numberMultipliers: [1, 2, 5]
- },
- minorTicksOptions = {
- tickInterval: that._options.minorTick.tickInterval > 0 ? _Number(that._options.minorTick.tickInterval) : undefined,
- gridSpacingFactor: that._getGridSpacingFactor().minorTicks,
- numberMultipliers: [1, 2, 5]
- };
- if (that._options.majorTick.useTicksAutoArrangement) {
- majorTicksOptions.useTicksAutoArrangement = true;
- majorTicksOptions.renderer = that._renderer;
- majorTicksOptions.translator = that._translator;
- majorTicksOptions.getCustomAutoArrangementStep = function(values) {
- return that._getCuttingFactor(values.length, {
- width: that._textWidth,
- height: that._textHeight
- }, layout)
- }
- }
- return _tickProvider.getFullTicks(that._translator.getDomain()[0], that._translator.getDomain()[1], that._getScreenDelta(layout), majorTicksOptions, minorTicksOptions)
- },
- _getTicks: function(layout) {
- var that = this,
- compareCallback = that._translator.getDomain()[0] < that._translator.getDomain()[1] ? sortAsc : sortDes,
- info = that._generateTicks(layout);
- var majorValues = that._options.majorTick.showCalculatedTicks ? info.majorTicks : [];
- var customMajorValues = that._getCustomValues(that._options.majorTick.customTickValues, compareCallback);
- customMajorValues = _map(customMajorValues, function(value) {
- return binarySearch(value, majorValues) === -1 ? value : null
- });
- var minorValues = that._options.minorTick.showCalculatedTicks ? info.minorTicks : [];
- minorValues = _map(minorValues, function(value) {
- return binarySearch(value, customMajorValues) === -1 ? value : null
- });
- var customMinorValues = that._getCustomValues(that._options.minorTick.customTickValues, compareCallback);
- var list = majorValues.concat(minorValues, customMajorValues).sort(compareCallback);
- customMinorValues = _map(customMinorValues, function(value) {
- return binarySearch(value, list) === -1 ? value : null
- });
- return {
- major: _map(majorValues.concat(customMajorValues), function(value) {
- return {
- value: value,
- position: that._translator.translate(value)
- }
- }),
- minor: _map(minorValues.concat(customMinorValues), function(value) {
- return {
- value: value,
- position: that._translator.translate(value)
- }
- })
- }
- },
- _createMajorTicks: function(ticks, layout) {
- var that = this;
- that._majorTicks.clear().applySettings({fill: that._options.majorTick.color});
- var points = that._getTickPoints(_Number(that._options.majorTick.length), _Number(that._options.majorTick.width), layout);
- if (points) {
- var i = 0,
- ii = ticks.length,
- element;
- that._options.hideFirstTick && ++i;
- that._options.hideLastTick && --ii;
- for (; i < ii; ++i) {
- element = that._renderer.createArea(points);
- that._moveTick(element, ticks[i], layout);
- element.append(that._majorTicks)
- }
- }
- },
- _createMinorTicks: function(ticks, layout) {
- var that = this;
- that._minorTicks.clear().applySettings({fill: that._options.minorTick.color});
- var points = that._getTickPoints(_Number(that._options.minorTick.length), _Number(that._options.minorTick.width), layout);
- if (points) {
- var i = 0,
- ii = ticks.length,
- element;
- for (; i < ii; ++i) {
- element = that._renderer.createArea(points);
- that._moveTick(element, ticks[i], layout);
- element.append(that._minorTicks)
- }
- }
- },
- _createLabels: function(ticks, layout) {
- var that = this,
- indentFromTick = _Number(that._options.label.indentFromTick);
- that._labels.clear().applySettings({
- align: that._getLabelAlign(indentFromTick),
- font: that._options.label.font
- });
- var textPosition = that._getLabelPosition(that._majorTicksEnabled ? _Number(that._options.majorTick.length) : 0, indentFromTick, layout);
- if (textPosition) {
- var i = 0,
- ii = ticks.length,
- points,
- text;
- that._options.hideFirstLabel && ++i;
- that._options.hideLastLabel && --ii;
- for (; i < ii; ++i) {
- text = that._formatValue(ticks[i].value);
- points = that._getLabelOptions(text, textPosition, indentFromTick, ticks[i], layout);
- that._renderer.createText(text, points.x, points.y + that._textVerticalOffset).append(that._labels)
- }
- }
- },
- resize: function(layout) {
- var that = this,
- ticks = that._getTicks(layout);
- if (that._majorTicksEnabled)
- that._createMajorTicks(ticks.major, layout);
- if (that._minorTicksEnabled)
- that._createMinorTicks(ticks.minor, layout);
- if (that._labelsEnabled)
- that._createLabels(ticks.major, layout);
- return that
- }
- });
- function getBasedAngle(startAngle, endAngle) {
- var startDelta,
- endDelta,
- tmp;
- if (startAngle > endAngle) {
- tmp = endAngle;
- endAngle = startAngle;
- startAngle = tmp
- }
- startDelta = 0 <= startAngle && startAngle <= 180 ? _abs(90 - startAngle) : _abs(270 - startAngle);
- startDelta = startAngle < 90 && 90 < endAngle || startAngle < 270 && 270 < endAngle ? 0 : startDelta;
- endDelta = 0 < endAngle && endAngle < 180 ? _abs(90 - endAngle) : _abs(270 - endAngle);
- return startDelta < endDelta ? startDelta : endDelta
- }
- DX.viz.gauges.__internals.CircularScale = DX.viz.gauges.__internals.BaseScale.inherit({
- _getGridSpacingFactor: function() {
- return {
- majorTicks: 17,
- minorTicks: 5
- }
- },
- _getScreenDelta: function(layout) {
- return (this._translator.getCodomainStart() - this._translator.getCodomainEnd()) * layout.radius * PI_DIV_180
- },
- _getCuttingFactor: function(ticksCount, maxLabelSize, layout) {
- var that = this,
- options = that._options,
- startAngle = that._translator.getCodomainStart(),
- endAngle = that._translator.getCodomainEnd(),
- radius = that._getLabelPosition(that._majorTicksEnabled ? _Number(that._options.majorTick.length) : 0, _Number(that._options.label.indentFromTick), layout),
- baseAngle = getBasedAngle(_normalizeAngle(startAngle), _normalizeAngle(endAngle)),
- baseAngleCosSin = _getCosAndSin(baseAngle),
- degreesPerTick = (startAngle - endAngle) / ticksCount,
- minAngleBetweenTicks,
- widthBasedAngle,
- tanOfWidthBasedAngle,
- heightBasedAngle,
- cosOfHeightBasedAngle,
- cuttingBackFactor = 1;
- tanOfWidthBasedAngle = (baseAngleCosSin.sin * radius + maxLabelSize.width) / (baseAngleCosSin.cos * radius);
- widthBasedAngle = _abs(baseAngle - _atan(tanOfWidthBasedAngle) / PI_DIV_180);
- cosOfHeightBasedAngle = baseAngleCosSin.cos - maxLabelSize.height / radius;
- heightBasedAngle = -1 > cosOfHeightBasedAngle || cosOfHeightBasedAngle > 1 ? 90 : _abs(baseAngle - _acos(cosOfHeightBasedAngle) / PI_DIV_180);
- minAngleBetweenTicks = widthBasedAngle < heightBasedAngle ? widthBasedAngle : heightBasedAngle;
- if (degreesPerTick < minAngleBetweenTicks)
- cuttingBackFactor = _ceil(minAngleBetweenTicks / degreesPerTick);
- return _max(1, cuttingBackFactor)
- },
- _setupOrientation: function() {
- var that = this;
- that._inner = that._outer = 0;
- switch (that._options.orientation) {
- case'inside':
- that._inner = 1;
- break;
- case'center':
- that._inner = that._outer = 0.5;
- break;
- default:
- that._outer = 1;
- break
- }
- },
- _getTickPoints: function(length, width, layout) {
- var x1 = layout.x - width / 2,
- x2 = layout.x + width / 2,
- y1 = layout.y - layout.radius - length * this._outer,
- y2 = layout.y - layout.radius + length * this._inner;
- return y1 > 0 && y2 > 0 ? [x1, y1, x2, y1, x2, y2, x1, y2] : null
- },
- _moveTick: function(element, tick, layout) {
- element.rotate(_convertAngleToRendererSpace(tick.position), layout.x, layout.y)
- },
- _getLabelPosition: function(tickLength, textIndent, layout) {
- var position = layout.radius + tickLength * (textIndent >= 0 ? this._outer : -this._inner) + textIndent;
- return position > 0 ? position : null
- },
- _getLabelAlign: function() {
- return 'center'
- },
- _getLabelOptions: function(textValue, textPosition, textIndent, tick, layout) {
- var cossin = _getCosAndSin(tick.position),
- x = layout.x + cossin.cos * textPosition,
- y = layout.y - cossin.sin * textPosition,
- dx = cossin.cos * (textValue.length / this._textLength) * this._textWidth / 2,
- dy = cossin.sin * this._textHeight / 2;
- if (textIndent > 0) {
- x += dx;
- y -= dy
- }
- else {
- x -= dx;
- y += dy
- }
- return {
- x: x,
- y: y
- }
- },
- measure: function(layout) {
- var that = this,
- result = {
- min: layout.radius,
- max: layout.radius
- };
- if (that._majorTicksEnabled) {
- result.min = _min(result.min, layout.radius - that._inner * that._options.majorTick.length);
- result.max = _max(result.max, layout.radius + that._outer * that._options.majorTick.length)
- }
- if (that._minorTicksEnabled) {
- result.min = _min(result.min, layout.radius - that._inner * that._options.minorTick.length);
- result.max = _max(result.max, layout.radius + that._outer * that._options.minorTick.length)
- }
- if (that._labelsEnabled) {
- if (that._options.label.indentFromTick > 0) {
- result.horizontalOffset = _Number(that._options.label.indentFromTick) + that._textWidth;
- result.verticalOffset = _Number(that._options.label.indentFromTick) + that._textHeight
- }
- else {
- result.horizontalOffset = result.verticalOffset = 0;
- result.min -= -_Number(that._options.label.indentFromTick) + _max(that._textWidth, that._textHeight)
- }
- result.inverseHorizontalOffset = that._textWidth / 2;
- result.inverseVerticalOffset = that._textHeight / 2
- }
- return result
- }
- });
- DX.viz.gauges.__internals.LinearScale = DX.viz.gauges.__internals.BaseScale.inherit({
- _getGridSpacingFactor: function() {
- return {
- majorTicks: 25,
- minorTicks: 5
- }
- },
- _getScreenDelta: function(layout) {
- return _abs(this._translator.getCodomainEnd() - this._translator.getCodomainStart())
- },
- _getCuttingFactor: function(ticksCount, maxLabelSize, layout) {
- var that = this,
- labelSize = that.vertical ? maxLabelSize.height : maxLabelSize.width,
- screenSize = _abs(that._translator.getCodomainEnd() - that._translator.getCodomainStart());
- return _max(1, _ceil(ticksCount * labelSize / (screenSize + labelSize)))
- },
- _setupOrientation: function() {
- var that = this;
- that.vertical = that._options.vertical;
- that._inner = that._outer = 0;
- if (that.vertical)
- switch (that._options.horizontalOrientation) {
- case'left':
- that._inner = 1;
- break;
- case'center':
- that._inner = that._outer = 0.5;
- break;
- default:
- that._outer = 1;
- break
- }
- else
- switch (that._options.verticalOrientation) {
- case'top':
- that._inner = 1;
- break;
- case'middle':
- that._inner = that._outer = 0.5;
- break;
- default:
- that._outer = 1;
- break
- }
- },
- _getTickPoints: function(length, width, layout) {
- var that = this,
- x1,
- x2,
- y1,
- y2;
- if (that.vertical) {
- x1 = layout.x - length * that._inner;
- x2 = layout.x + length * that._outer;
- y1 = -width / 2;
- y2 = +width / 2
- }
- else {
- x1 = -width / 2;
- x2 = +width / 2;
- y1 = layout.y - length * that._inner;
- y2 = layout.y + length * that._outer
- }
- return [x1, y1, x2, y1, x2, y2, x1, y2]
- },
- _moveTick: function(element, tick, layout) {
- var x = 0,
- y = 0;
- if (this.vertical)
- y = tick.position;
- else
- x = tick.position;
- element.move(x, y)
- },
- _getLabelPosition: function(tickLength, textIndent, layout) {
- var position = tickLength * (textIndent >= 0 ? this._outer : -this._inner) + textIndent;
- if (this.vertical)
- position += layout.x;
- else
- position += layout.y + (textIndent >= 0 ? 1 : -1) * this._textVerticalOffset;
- return position
- },
- _getLabelAlign: function(textIndent) {
- return this.vertical ? textIndent > 0 ? 'left' : 'right' : 'center'
- },
- _getLabelOptions: function(textValue, textPosition, textIndent, tick, layout) {
- var x,
- y;
- if (this.vertical) {
- x = textPosition;
- y = tick.position
- }
- else {
- x = tick.position;
- y = textPosition
- }
- return {
- x: x,
- y: y
- }
- },
- measure: function(layout) {
- var that = this,
- p = layout[that.vertical ? 'x' : 'y'],
- result = {
- min: p,
- max: p
- };
- if (that._majorTicksEnabled) {
- result.min = _min(result.min, p - that._inner * that._options.majorTick.length);
- result.max = _max(result.max, p + that._outer * that._options.majorTick.length)
- }
- if (that._minorTicksEnabled) {
- result.min = _min(result.min, p - that._inner * that._options.minorTick.length);
- result.max = _max(result.max, p + that._outer * that._options.minorTick.length)
- }
- if (that._labelsEnabled) {
- if (that._options.label.indentFromTick > 0)
- result.max += +_Number(that._options.label.indentFromTick) + that[that.vertical ? '_textWidth' : '_textHeight'];
- else
- result.min -= -_Number(that._options.label.indentFromTick) + that[that.vertical ? '_textWidth' : '_textHeight'];
- result.indent = that[that.vertical ? '_textHeight' : '_textWidth'] / 2
- }
- return result
- }
- })
- })(DevExpress, jQuery);
- /*! Module viz-gauges, file baseIndicator.js */
- (function(DX, $, undefined) {
- var _isFinite = isFinite,
- _Number = Number,
- _extend = $.extend;
- DX.viz.gauges.__internals.BaseIndicator = DX.Class.inherit({
- setup: function(parameters) {
- var that = this;
- that._renderer = parameters.renderer;
- that._translator = parameters.translator;
- that._owner = parameters.owner;
- that._tracker = parameters.tracker;
- that._className = parameters.className;
- that._options = {};
- that._rootElement = that._createRoot();
- that._trackerElement = that._createTracker();
- return that
- },
- dispose: function() {
- var that = this;
- that._renderer = that._owner = that._translator = that._tracker = that._options = that._rootElement = that._trackerElement = null;
- return that
- },
- _setupAnimation: function() {
- var that = this;
- if (that._options.animation)
- that._animation = {
- step: function(pos) {
- that._actualValue = that._animation.start + that._animation.delta * pos;
- that._actualPosition = that._translator.translate(that._actualValue);
- that._move()
- },
- duration: that._options.animation.duration > 0 ? _Number(that._options.animation.duration) : 0,
- easing: that._options.animation.easing
- }
- },
- _runAnimation: function(value) {
- var that = this,
- animation = that._animation;
- animation.start = that._actualValue;
- animation.delta = value - that._actualValue;
- that._rootElement.animate({_: 0}, {
- step: animation.step,
- duration: animation.duration,
- easing: animation.easing
- })
- },
- _createRoot: function() {
- return this._renderer.createGroup({'class': this._className})
- },
- _createTracker: function() {
- return this._renderer.createArea()
- },
- _getTrackerSettings: function(){},
- clean: function() {
- var that = this;
- that._animation && that._rootElement.stopAnimation();
- that._rootElement.detach();
- that._rootElement.clear();
- that._clear();
- that._tracker.detach(that._trackerElement);
- that._options = that.enabled = that._animation = null;
- return that
- },
- render: function(options) {
- var that = this;
- that.type = options.type;
- that._options = options;
- that._actualValue = that._currentValue = that._translator.adjust(that._options.currentValue);
- that.enabled = that._isEnabled();
- if (that.enabled) {
- that._setupAnimation();
- that._rootElement.applySettings({fill: that._options.color}).append(that._owner);
- that._tracker.attach(that._trackerElement, that, that._trackerInfo)
- }
- return that
- },
- resize: function(layout) {
- var that = this;
- that._rootElement.clear();
- that._clear();
- that.visible = that._isVisible(layout);
- if (that.visible) {
- _extend(that._options, layout);
- that._actualPosition = that._translator.translate(that._actualValue);
- that._render();
- that._trackerElement.applySettings(that._getTrackerSettings());
- that._move()
- }
- return that
- },
- value: function(arg, _noAnimation) {
- var that = this;
- if (arg !== undefined) {
- var val = that._translator.adjust(arg);
- if (that._currentValue !== val && _isFinite(val)) {
- that._currentValue = val;
- if (that.visible)
- if (that._animation && !_noAnimation)
- that._runAnimation(val);
- else {
- that._actualValue = val;
- that._actualPosition = that._translator.translate(val);
- that._move()
- }
- }
- return that
- }
- return that._currentValue
- },
- _isEnabled: null,
- _isVisible: null,
- _render: null,
- _clear: null,
- _move: null
- })
- })(DevExpress, jQuery);
- /*! Module viz-gauges, file baseMarker.js */
- (function(DX, undefined) {
- var TextCloud = DX.viz.core.TextCloud;
- var formatValue = DX.viz.gauges.__internals.formatValue,
- getSampleText = DX.viz.gauges.__internals.getSampleText;
- DX.viz.gauges.__internals.BaseTextCloudMarker = DX.viz.gauges.__internals.BaseIndicator.inherit({
- _move: function() {
- var that = this,
- bbox,
- info = new TextCloud,
- textCloudOptions = that._getTextCloudOptions();
- that._text.applySettings({text: formatValue(that._actualValue, that._options.text)});
- bbox = that._text.getBBox();
- info.setup({
- x: textCloudOptions.x,
- y: textCloudOptions.y,
- textWidth: bbox.width,
- textHeight: bbox.height,
- horMargin: that._options.horizontalOffset,
- verMargin: that._options.verticalOffset,
- tailLength: that._options.arrowLength,
- type: textCloudOptions.type
- });
- that._text.applySettings({
- x: info.cx(),
- y: info.cy() + that._textVerticalOffset
- });
- that._cloud.applySettings({points: info.points()});
- that._trackerElement && that._trackerElement.applySettings({points: info.points()})
- },
- _measureText: function() {
- var that = this,
- root,
- text,
- bbox;
- if (!that._textVerticalOffset) {
- root = that._createRoot().append(that._owner);
- text = that._renderer.createText(getSampleText(that._translator, that._options.text), 0, 0, {
- align: 'center',
- font: that._options.text.font
- }).append(root);
- bbox = text.getBBox();
- root.remove();
- that._textVerticalOffset = -bbox.y - bbox.height / 2;
- that._textWidth = bbox.width;
- that._textHeight = bbox.height;
- that._textFullWidth = that._textWidth + 2 * that._options.horizontalOffset;
- that._textFullHeight = that._textHeight + 2 * that._options.verticalOffset
- }
- },
- _render: function() {
- var that = this;
- that._measureText();
- that._cloud = that._cloud || that._renderer.createArea().append(that._rootElement);
- that._text = that._text || that._renderer.createText().append(that._rootElement);
- that._text.applySettings({
- align: 'center',
- font: that._options.text.font
- })
- },
- _clear: function() {
- delete this._cloud;
- delete this._text
- },
- getTooltipParameters: function() {
- var position = this._getTextCloudOptions();
- return {
- x: position.x,
- y: position.y,
- value: this._currentValue,
- color: this._options.color
- }
- }
- })
- })(DevExpress);
- /*! Module viz-gauges, file baseRangeBar.js */
- (function(DX, $, undefined) {
- var $extend = $.extend;
- var formatValue = DX.viz.gauges.__internals.formatValue,
- getSampleText = DX.viz.gauges.__internals.getSampleText;
- DX.viz.gauges.__internals.BaseRangeBar = DX.viz.gauges.__internals.BaseIndicator.inherit({
- _measureText: function() {
- var that = this,
- root,
- text,
- bbox;
- that._hasText = that._isTextVisible();
- if (that._hasText && !that._textVerticalOffset) {
- root = that._createRoot().append(that._owner);
- text = that._renderer.createText(getSampleText(that._translator, that._options.text), 0, 0, {
- 'class': 'dxg-text',
- align: 'center',
- font: that._options.text.font
- }).append(root);
- bbox = text.getBBox();
- root.remove();
- that._textVerticalOffset = -bbox.y - bbox.height / 2;
- that._textWidth = bbox.width;
- that._textHeight = bbox.height
- }
- },
- _move: function() {
- var that = this;
- that._updateBarItemsPositions();
- if (that._hasText) {
- that._text.applySettings({text: formatValue(that._actualValue, that._options.text)});
- that._updateTextPosition();
- that._updateLinePosition()
- }
- },
- _updateBarItems: function() {
- var that = this,
- options = that._options,
- backgroundColor,
- spaceColor;
- that._setBarSides();
- that._startPosition = that._translator.translate(that._translator.getDomainStart());
- that._endPosition = that._translator.translate(that._translator.getDomainEnd());
- that._basePosition = that._translator.translate(options.baseValue);
- that._space = that._getSpace();
- backgroundColor = options.backgroundColor || 'none';
- if (backgroundColor !== 'none' && that._space > 0)
- spaceColor = options.containerBackgroundColor || 'none';
- else {
- that._space = 0;
- spaceColor = 'none'
- }
- that._backItem1.applySettings({fill: backgroundColor});
- that._backItem2.applySettings({fill: backgroundColor});
- that._spaceItem1.applySettings({fill: spaceColor});
- that._spaceItem2.applySettings({fill: spaceColor})
- },
- _getSpace: function() {
- return 0
- },
- _updateTextItems: function() {
- var that = this;
- if (that._hasText) {
- that._line = that._line || that._renderer.createPath([], {'class': 'dxg-main-bar'}).append(that._rootElement);
- that._text = that._text || that._renderer.createText('', 0, 0, {'class': 'dxg-text'}).append(that._rootElement);
- that._text.applySettings({
- align: that._getTextAlign(),
- font: that._getFontOptions()
- });
- that._setTextItemsSides()
- }
- else {
- if (that._line) {
- that._line.remove();
- delete that._line
- }
- if (that._text) {
- that._text.remove();
- delete that._text
- }
- }
- },
- _isTextVisible: function() {
- return false
- },
- _getTextAlign: function() {
- return 'center'
- },
- _getFontOptions: function() {
- var options = this._options,
- font = options.text.font;
- if (!font || !font.color)
- font = $extend({}, font, {color: options.color});
- return font
- },
- _updateBarItemsPositions: function() {
- var that = this,
- positions = that._getPositions();
- that._backItem1.applySettings(that._buildItemSettings(positions.start, positions.back1));
- that._backItem2.applySettings(that._buildItemSettings(positions.back2, positions.end));
- that._spaceItem1.applySettings(that._buildItemSettings(positions.back1, positions.main1));
- that._spaceItem2.applySettings(that._buildItemSettings(positions.main2, positions.back2));
- that._mainItem.applySettings(that._buildItemSettings(positions.main1, positions.main2));
- that._trackerElement && that._trackerElement.applySettings(that._buildItemSettings(positions.main1, positions.main2))
- },
- _render: function() {
- var that = this;
- that._measureText();
- if (!that._backItem1) {
- that._backItem1 = that._createBarItem();
- that._backItem1.applySettings({'class': 'dxg-back-bar'})
- }
- if (!that._backItem2) {
- that._backItem2 = that._createBarItem();
- that._backItem2.applySettings({'class': 'dxg-back-bar'})
- }
- if (!that._spaceItem1) {
- that._spaceItem1 = that._createBarItem();
- that._spaceItem1.applySettings({'class': 'dxg-space-bar'})
- }
- if (!that._spaceItem2) {
- that._spaceItem2 = that._createBarItem();
- that._spaceItem2.applySettings({'class': 'dxg-space-bar'})
- }
- if (!that._mainItem) {
- that._mainItem = that._createBarItem();
- that._mainItem.applySettings({'class': 'dxg-main-bar'})
- }
- that._updateBarItems();
- that._updateTextItems()
- },
- _clear: function() {
- var that = this;
- delete that._backItem1;
- delete that._backItem2;
- delete that._spaceItem1;
- delete that._spaceItem2;
- delete that._mainItem;
- delete that._hasText;
- delete that._line;
- delete that._text
- },
- getTooltipParameters: function() {
- var position = this._getTooltipPosition();
- return {
- x: position.x,
- y: position.y,
- value: this._currentValue,
- color: this._options.color,
- offset: 0
- }
- }
- })
- })(DevExpress, jQuery);
- /*! Module viz-gauges, file circularNeedle.js */
- (function(DX, undefined) {
- var circularNeedles = DX.viz.gauges.__internals.circularNeedles;
- var _Number = Number;
- circularNeedles.SimpleIndicator = DX.viz.gauges.__internals.BaseIndicator.inherit({
- _move: function() {
- var that = this,
- options = that._options,
- angle = DX.utils.convertAngleToRendererSpace(that._actualPosition);
- that._rootElement.rotate(angle, options.x, options.y);
- that._trackerElement && that._trackerElement.rotate(angle, options.x, options.y)
- },
- _isEnabled: function() {
- return this._options.width > 0
- },
- _isVisible: function(layout) {
- return layout.radius - _Number(this._options.indentFromCenter) > 0
- },
- _getTrackerSettings: function() {
- var options = this._options,
- x = options.x,
- y = options.y - (options.radius + _Number(options.indentFromCenter)) / 2,
- width = options.width / 2,
- length = (options.radius - _Number(options.indentFromCenter)) / 2;
- width > 10 || (width = 10);
- length > 10 || (length = 10);
- return {points: [x - width, y - length, x - width, y + length, x + width, y + length, x + width, y - length]}
- },
- _renderSpindle: function() {
- var that = this,
- options = that._options,
- gapSize;
- if (options.spindleSize > 0) {
- gapSize = _Number(options.spindleGapSize) || 0;
- if (gapSize > 0)
- gapSize = gapSize <= options.spindleSize ? gapSize : _Number(options.spindleSize);
- that._spindleOuter = that._spindleOuter || that._renderer.createCircle().append(that._rootElement);
- that._spindleInner = that._spindleInner || that._renderer.createCircle().append(that._rootElement);
- that._spindleOuter.applySettings({
- 'class': 'dxg-spindle-border',
- cx: options.x,
- cy: options.y,
- r: options.spindleSize / 2
- });
- that._spindleInner.applySettings({
- 'class': 'dxg-spindle-hole',
- cx: options.x,
- cy: options.y,
- r: gapSize / 2,
- fill: options.containerBackgroundColor
- })
- }
- },
- _render: function() {
- var that = this;
- that._renderPointer();
- that._renderSpindle()
- },
- _clearSpindle: function() {
- delete this._spindleOuter;
- delete this._spindleInner
- },
- _clearPointer: function() {
- delete this._element
- },
- _clear: function() {
- this._clearPointer();
- this._clearSpindle()
- },
- measure: function(layout) {
- var result = {max: layout.radius};
- if (this._options.indentFromCenter < 0)
- result.inverseHorizontalOffset = result.inverseVerticalOffset = -_Number(this._options.indentFromCenter);
- return result
- },
- getTooltipParameters: function() {
- var options = this._options,
- cossin = DX.utils.getCosAndSin(this._actualPosition),
- r = (options.radius + _Number(options.indentFromCenter)) / 2;
- return {
- x: options.x + cossin.cos * r,
- y: options.y - cossin.sin * r,
- value: this._currentValue,
- color: options.color,
- offset: options.width / 2
- }
- }
- });
- circularNeedles.RectangleNeedle = circularNeedles.SimpleIndicator.inherit({_renderPointer: function() {
- var that = this,
- options = that._options,
- y2 = options.y - options.radius,
- y1 = options.y - _Number(options.indentFromCenter),
- x1 = options.x - options.width / 2,
- x2 = x1 + _Number(options.width);
- that._element = that._element || that._renderer.createArea().append(that._rootElement);
- that._element.applySettings({points: [x1, y1, x1, y2, x2, y2, x2, y1]})
- }});
- circularNeedles.TriangleNeedle = circularNeedles.SimpleIndicator.inherit({_renderPointer: function() {
- var that = this,
- options = that._options,
- y2 = options.y - options.radius,
- y1 = options.y - _Number(options.indentFromCenter),
- x1 = options.x - options.width / 2,
- x2 = options.x + options.width / 2;
- that._element = that._element || that._renderer.createArea().append(that._rootElement);
- that._element.applySettings({points: [x1, y1, options.x, y2, x2, y1]})
- }});
- circularNeedles.TwoColorRectangleNeedle = circularNeedles.SimpleIndicator.inherit({
- _renderPointer: function() {
- var that = this,
- options = that._options,
- x1 = options.x - options.width / 2,
- x2 = options.x + options.width / 2,
- y4 = options.y - options.radius,
- y1 = options.y - _Number(options.indentFromCenter),
- fraction = _Number(options.secondFraction) || 0,
- y2,
- y3;
- if (fraction >= 1)
- y2 = y3 = y1;
- else if (fraction <= 0)
- y2 = y3 = y2;
- else {
- y3 = y4 + (y1 - y4) * fraction;
- y2 = y3 + options.space
- }
- that._firstElement = that._firstElement || that._renderer.createArea().append(that._rootElement);
- that._spaceElement = that._spaceElement || that._renderer.createArea().append(that._rootElement);
- that._secondElement = that._secondElement || that._renderer.createArea().append(that._rootElement);
- that._firstElement.applySettings({points: [x1, y1, x1, y2, x2, y2, x2, y1]});
- that._spaceElement.applySettings({
- points: [x1, y2, x1, y3, x2, y3, x2, y2],
- 'class': 'dxg-hole',
- fill: options.containerBackgroundColor
- });
- that._secondElement.applySettings({
- points: [x1, y3, x1, y4, x2, y4, x2, y3],
- 'class': 'dxg-part',
- fill: options.secondColor
- })
- },
- _clearPointer: function() {
- delete this._firstElement;
- delete this._secondElement;
- delete this._spaceElement
- }
- })
- })(DevExpress);
- /*! Module viz-gauges, file linearNeedle.js */
- (function(DX, undefined) {
- var linearNeedles = DX.viz.gauges.__internals.linearNeedles;
- var _Number = Number;
- linearNeedles.SimpleIndicator = DX.viz.gauges.__internals.BaseIndicator.inherit({
- _move: function() {
- var that = this,
- delta = that._actualPosition - that._zeroPosition;
- that._rootElement.move(that.vertical ? 0 : delta, that.vertical ? delta : 0);
- that._trackerElement && that._trackerElement.move(that.vertical ? 0 : delta, that.vertical ? delta : 0)
- },
- _isEnabled: function() {
- this.vertical = this._options.vertical;
- return this._options.length > 0 && this._options.width > 0
- },
- _isVisible: function(layout) {
- return true
- },
- _getTrackerSettings: function() {
- var options = this._options,
- x1,
- x2,
- y1,
- y2,
- width = options.width / 2,
- length = options.length / 2,
- p = this._zeroPosition;
- width > 10 || (width = 10);
- length > 10 || (length = 10);
- if (this.vertical) {
- x1 = options.x - length;
- x2 = options.x + length;
- y1 = p + width;
- y2 = p - width
- }
- else {
- x1 = p - width;
- x2 = p + width;
- y1 = options.y + length;
- y2 = options.y - length
- }
- return {points: [x1, y1, x1, y2, x2, y2, x2, y1]}
- },
- _render: function() {
- var that = this;
- that._zeroPosition = that._translator.getCodomainStart()
- },
- _clear: function() {
- delete this._element
- },
- measure: function(layout) {
- var p = this.vertical ? layout.x : layout.y;
- return {
- min: p - this._options.length / 2,
- max: p + this._options.length / 2
- }
- },
- getTooltipParameters: function() {
- var that = this,
- options = that._options,
- p = that._actualPosition,
- parameters = {
- x: p,
- y: p,
- value: that._currentValue,
- color: options.color,
- offset: options.width / 2
- };
- that.vertical ? parameters.x = options.x : parameters.y = options.y;
- return parameters
- }
- });
- linearNeedles.RectangleNeedle = linearNeedles.SimpleIndicator.inherit({_render: function() {
- var that = this,
- options = that._options,
- p,
- x1,
- x2,
- y1,
- y2;
- that.callBase();
- p = that._zeroPosition;
- if (that.vertical) {
- x1 = options.x - options.length / 2;
- x2 = options.x + options.length / 2;
- y1 = p + options.width / 2;
- y2 = p - options.width / 2
- }
- else {
- x1 = p - options.width / 2;
- x2 = p + options.width / 2;
- y1 = options.y + options.length / 2;
- y2 = options.y - options.length / 2
- }
- that._element = that._element || that._renderer.createArea().append(that._rootElement);
- that._element.applySettings({points: [x1, y1, x1, y2, x2, y2, x2, y1]})
- }});
- linearNeedles.RhombusNeedle = linearNeedles.SimpleIndicator.inherit({_render: function() {
- var that = this,
- options = that._options,
- x,
- y,
- dx,
- dy;
- that.callBase();
- if (that.vertical) {
- x = options.x;
- y = that._zeroPosition;
- dx = options.length / 2 || 0;
- dy = options.width / 2 || 0
- }
- else {
- x = that._zeroPosition;
- y = options.y;
- dx = options.width / 2 || 0;
- dy = options.length / 2 || 0
- }
- that._element = that._element || that._renderer.createArea().append(that._rootElement);
- that._element.applySettings({points: [x - dx, y, x, y - dy, x + dx, y, x, y + dy]})
- }});
- linearNeedles.CircleNeedle = linearNeedles.SimpleIndicator.inherit({_render: function() {
- var that = this,
- options = that._options,
- x,
- y,
- r;
- that.callBase();
- if (that.vertical) {
- x = options.x;
- y = that._zeroPosition
- }
- else {
- x = that._zeroPosition;
- y = options.y
- }
- r = options.length / 2 || 0;
- that._element = that._element || that._renderer.createCircle().append(that._rootElement);
- that._element.applySettings({
- cx: x,
- cy: y,
- r: r
- })
- }})
- })(DevExpress);
- /*! Module viz-gauges, file circularMarker.js */
- (function(DX, undefined) {
- var circularMarkers = DX.viz.gauges.__internals.circularMarkers;
- var _Number = Number;
- circularMarkers.TriangleMarker = DX.viz.gauges.__internals.circularNeedles.SimpleIndicator.inherit({
- _isEnabled: function() {
- return this._options.length > 0 && this._options.width > 0
- },
- _isVisible: function(layout) {
- return layout.radius > 0
- },
- _render: function() {
- var that = this,
- options = that._options,
- x = options.x,
- y1 = options.y - options.radius,
- dx = options.width / 2 || 0,
- y2 = y1 - _Number(options.length),
- settings;
- that._element = that._element || that._renderer.createArea().append(that._rootElement);
- settings = {
- points: [x, y1, x - dx, y2, x + dx, y2],
- stroke: 'none',
- strokeWidth: 0
- };
- if (options.space > 0) {
- settings.strokeWidth = Math.min(options.space, options.width / 4) || 0;
- settings.stroke = settings.strokeWidth > 0 ? options.containerBackgroundColor || 'none' : 'none'
- }
- that._element.applySettings(settings)
- },
- _clear: function() {
- delete this._element
- },
- _getTrackerSettings: function() {
- var options = this._options,
- x = options.x,
- y = options.y - options.radius - options.length / 2,
- width = options.width / 2,
- length = options.length / 2;
- width > 10 || (width = 10);
- length > 10 || (length = 10);
- return {points: [x - width, y - length, x - width, y + length, x + width, y + length, x + width, y - length]}
- },
- measure: function(layout) {
- return {
- min: layout.radius,
- max: layout.radius + _Number(this._options.length)
- }
- },
- getTooltipParameters: function() {
- var options = this._options,
- cossin = DX.utils.getCosAndSin(this._actualPosition),
- r = options.radius + options.length / 2,
- parameters = this.callBase();
- parameters.x = options.x + cossin.cos * r;
- parameters.y = options.y - cossin.sin * r;
- parameters.offset = options.length / 2;
- return parameters
- }
- });
- circularMarkers.TextCloudMarker = DX.viz.gauges.__internals.BaseTextCloudMarker.inherit({
- _isEnabled: function() {
- return true
- },
- _isVisible: function(layout) {
- return layout.radius > 0
- },
- _getTextCloudOptions: function() {
- var that = this,
- cossin = DX.utils.getCosAndSin(that._actualPosition),
- nangle = DX.utils.normalizeAngle(that._actualPosition);
- return {
- x: that._options.x + cossin.cos * that._options.radius,
- y: that._options.y - cossin.sin * that._options.radius,
- type: nangle > 270 ? 'left-top' : nangle > 180 ? 'top-right' : nangle > 90 ? 'right-bottom' : 'bottom-left'
- }
- },
- measure: function(layout) {
- var that = this;
- that._measureText();
- return {
- min: layout.radius,
- max: layout.radius,
- horizontalOffset: that._textFullWidth + (_Number(that._options.arrowLength) || 0),
- verticalOffset: that._textFullHeight + (_Number(that._options.arrowLength) || 0)
- }
- }
- })
- })(DevExpress);
- /*! Module viz-gauges, file linearMarker.js */
- (function(DX, undefined) {
- var linearMarkers = DX.viz.gauges.__internals.linearMarkers;
- var _Number = Number,
- _String = String;
- linearMarkers.TriangleMarker = DX.viz.gauges.__internals.linearNeedles.SimpleIndicator.inherit({
- _isEnabled: function() {
- var that = this;
- that.vertical = that._options.vertical;
- that._inverted = that.vertical ? _String(that._options.horizontalOrientation).toLowerCase() === 'right' : _String(that._options.verticalOrientation).toLowerCase() === 'bottom';
- return that._options.length > 0 && that._options.width > 0
- },
- _isVisible: function(layout) {
- return true
- },
- _render: function() {
- var that = this,
- options = that._options,
- x1,
- x2,
- y1,
- y2,
- settings = {
- stroke: 'none',
- strokeWidth: 0
- };
- that.callBase();
- if (that.vertical) {
- x1 = options.x;
- y1 = that._zeroPosition;
- x2 = x1 + _Number(that._inverted ? options.length : -options.length);
- settings.points = [x1, y1, x2, y1 - options.width / 2, x2, y1 + options.width / 2]
- }
- else {
- y1 = options.y;
- x1 = that._zeroPosition;
- y2 = y1 + _Number(that._inverted ? options.length : -options.length);
- settings.points = [x1, y1, x1 - options.width / 2, y2, x1 + options.width / 2, y2]
- }
- if (options.space > 0) {
- settings.strokeWidth = Math.min(options.space, options.width / 4) || 0;
- settings.stroke = settings.strokeWidth > 0 ? options.containerBackgroundColor || 'none' : 'none'
- }
- that._element = that._element || that._renderer.createArea().append(that._rootElement);
- that._element.applySettings(settings)
- },
- _getTrackerSettings: function() {
- var that = this,
- options = that._options,
- width = options.width / 2,
- length = _Number(options.length),
- x1,
- x2,
- y1,
- y2,
- result;
- width > 10 || (width = 10);
- length > 20 || (length = 20);
- if (that.vertical) {
- x1 = x2 = options.x;
- x2 = x1 + (that._inverted ? length : -length);
- y1 = that._zeroPosition + width;
- y2 = that._zeroPosition - width;
- result = [x1, y1, x2, y1, x2, y2, x1, y2]
- }
- else {
- y1 = options.y;
- y2 = y1 + (that._inverted ? length : -length);
- x1 = that._zeroPosition - width;
- x2 = that._zeroPosition + width;
- result = [x1, y1, x1, y2, x2, y2, x2, y1]
- }
- return {points: result}
- },
- measure: function(layout) {
- var that = this,
- length = _Number(that._options.length),
- minbound,
- maxbound;
- if (that.vertical) {
- minbound = maxbound = layout.x;
- if (that._inverted)
- maxbound = minbound + length;
- else
- minbound = maxbound - length
- }
- else {
- minbound = maxbound = layout.y;
- if (that._inverted)
- maxbound = minbound + length;
- else
- minbound = maxbound - length
- }
- return {
- min: minbound,
- max: maxbound,
- indent: that._options.width / 2
- }
- },
- getTooltipParameters: function() {
- var that = this,
- options = that._options,
- s = (that._inverted ? options.length : -options.length) / 2,
- parameters = that.callBase();
- that.vertical ? parameters.x += s : parameters.y += s;
- parameters.offset = options.length / 2;
- return parameters
- }
- });
- linearMarkers.TextCloudMarker = DX.viz.gauges.__internals.BaseTextCloudMarker.inherit({
- _isEnabled: function() {
- var that = this;
- that.vertical = that._options.vertical;
- that._inverted = that.vertical ? _String(that._options.horizontalOrientation).toLowerCase() === 'right' : _String(that._options.verticalOrientation).toLowerCase() === 'bottom';
- return true
- },
- _isVisible: function(layout) {
- return true
- },
- _getTextCloudOptions: function() {
- var that = this,
- x = that._actualPosition,
- y = that._actualPosition,
- type;
- if (that.vertical) {
- x = that._options.x;
- type = that._inverted ? 'top-left' : 'top-right'
- }
- else {
- y = that._options.y;
- type = that._inverted ? 'right-top' : 'right-bottom'
- }
- return {
- x: x,
- y: y,
- type: type
- }
- },
- measure: function(layout) {
- var that = this,
- minbound,
- maxbound,
- arrowLength = _Number(that._options.arrowLength) || 0,
- indent;
- that._measureText();
- if (that.vertical) {
- indent = that._textFullHeight;
- if (that._inverted) {
- minbound = layout.x;
- maxbound = layout.x + arrowLength + that._textFullWidth
- }
- else {
- minbound = layout.x - arrowLength - that._textFullWidth;
- maxbound = layout.x
- }
- }
- else {
- indent = that._textFullWidth;
- if (that._inverted) {
- minbound = layout.y;
- maxbound = layout.y + arrowLength + that._textFullHeight
- }
- else {
- minbound = layout.y - arrowLength - that._textFullHeight;
- maxbound = layout.y
- }
- }
- return {
- min: minbound,
- max: maxbound,
- indent: indent
- }
- }
- })
- })(DevExpress);
- /*! Module viz-gauges, file circularRangeBar.js */
- (function(DX, undefined) {
- var _Number = Number,
- getCosAndSin = DX.utils.getCosAndSin,
- convertAngleToRendererSpace = DX.utils.convertAngleToRendererSpace,
- max = Math.max,
- min = Math.min;
- DX.viz.gauges.__internals.CircularRangeBar = DX.viz.gauges.__internals.BaseRangeBar.inherit({
- _isEnabled: function() {
- return this._options.size > 0
- },
- _isVisible: function(layout) {
- return layout.radius - _Number(this._options.size) > 0
- },
- _createBarItem: function() {
- return this._renderer.createArc().append(this._rootElement)
- },
- _createTracker: function() {
- return this._renderer.createArc()
- },
- _setBarSides: function() {
- var that = this;
- that._maxSide = that._options.radius;
- that._minSide = that._maxSide - _Number(that._options.size)
- },
- _getSpace: function() {
- var options = this._options;
- return options.space > 0 ? options.space * 180 / options.radius / Math.PI : 0
- },
- _isTextVisible: function() {
- var options = this._options.text || {};
- return options.indent > 0
- },
- _setTextItemsSides: function() {
- var that = this,
- options = that._options;
- that._lineFrom = options.y - options.radius;
- that._lineTo = that._lineFrom - _Number(options.text.indent);
- that._textRadius = options.radius + _Number(options.text.indent)
- },
- _getPositions: function() {
- var that = this,
- basePosition = that._basePosition,
- actualPosition = that._actualPosition,
- mainPosition1,
- mainPosition2;
- if (basePosition >= actualPosition) {
- mainPosition1 = basePosition;
- mainPosition2 = actualPosition
- }
- else {
- mainPosition1 = actualPosition;
- mainPosition2 = basePosition
- }
- return {
- start: that._startPosition,
- end: that._endPosition,
- main1: mainPosition1,
- main2: mainPosition2,
- back1: min(mainPosition1 + that._space, that._startPosition),
- back2: max(mainPosition2 - that._space, that._endPosition)
- }
- },
- _buildItemSettings: function(from, to) {
- var that = this;
- return {
- x: that._options.x,
- y: that._options.y,
- innerRadius: that._minSide,
- outerRadius: that._maxSide,
- startAngle: to,
- endAngle: from
- }
- },
- _updateTextPosition: function() {
- var that = this,
- cossin = getCosAndSin(that._actualPosition),
- x = that._options.x + that._textRadius * cossin.cos,
- y = that._options.y - that._textRadius * cossin.sin;
- x += cossin.cos * that._textWidth * 0.6;
- y -= cossin.sin * that._textHeight * 0.6;
- that._text.applySettings({
- x: x,
- y: y + that._textVerticalOffset
- })
- },
- _updateLinePosition: function() {
- var that = this,
- x = that._options.x,
- x1,
- x2;
- if (that._basePosition > that._actualPosition) {
- x1 = x - 2;
- x2 = x
- }
- else if (that._basePosition < that._actualPosition) {
- x1 = x;
- x2 = x + 2
- }
- else {
- x1 = x - 1;
- x2 = x + 1
- }
- that._line.applySettings({points: [x1, that._lineFrom, x1, that._lineTo, x2, that._lineTo, x2, that._lineFrom]});
- that._line.rotate(convertAngleToRendererSpace(that._actualPosition), x, that._options.y)
- },
- _getTooltipPosition: function() {
- var that = this,
- cossin = getCosAndSin((that._basePosition + that._actualPosition) / 2),
- r = (that._minSide + that._maxSide) / 2;
- return {
- x: that._options.x + cossin.cos * r,
- y: that._options.y - cossin.sin * r
- }
- },
- measure: function(layout) {
- var that = this,
- result = {
- min: layout.radius - _Number(that._options.size),
- max: layout.radius
- };
- that._measureText();
- if (that._hasText) {
- result.max += _Number(that._options.text.indent);
- result.horizontalOffset = that._textWidth;
- result.verticalOffset = that._textHeight
- }
- return result
- }
- })
- })(DevExpress);
- /*! Module viz-gauges, file linearRangeBar.js */
- (function(DX, undefined) {
- var _Number = Number,
- _String = String;
- DX.viz.gauges.__internals.LinearRangeBar = DX.viz.gauges.__internals.BaseRangeBar.inherit({
- _isEnabled: function() {
- var that = this;
- that.vertical = that._options.vertical;
- that._inverted = that.vertical ? _String(that._options.horizontalOrientation).toLowerCase() === 'right' : _String(that._options.verticalOrientation).toLowerCase() === 'bottom';
- return that._options.size > 0
- },
- _isVisible: function(layout) {
- return true
- },
- _createBarItem: function() {
- return this._renderer.createArea().append(this._rootElement)
- },
- _createTracker: function() {
- return this._renderer.createArea()
- },
- _setBarSides: function() {
- var that = this,
- options = that._options,
- size = _Number(options.size),
- minSide,
- maxSide;
- if (that.vertical)
- if (that._inverted) {
- minSide = options.x;
- maxSide = options.x + size
- }
- else {
- minSide = options.x - size;
- maxSide = options.x
- }
- else if (that._inverted) {
- minSide = options.y;
- maxSide = options.y + size
- }
- else {
- minSide = options.y - size;
- maxSide = options.y
- }
- that._minSide = minSide;
- that._maxSide = maxSide;
- that._minBound = minSide;
- that._maxBound = maxSide
- },
- _getSpace: function() {
- var options = this._options;
- return options.space > 0 ? _Number(options.space) : 0
- },
- _isTextVisible: function() {
- var textOptions = this._options.text || {};
- return textOptions.indent > 0 || textOptions.indent < 0
- },
- _getTextAlign: function() {
- return this.vertical ? this._options.text.indent > 0 ? 'left' : 'right' : 'center'
- },
- _setTextItemsSides: function() {
- var that = this,
- indent = _Number(that._options.text.indent);
- if (indent > 0) {
- that._lineStart = that._maxSide;
- that._lineEnd = that._maxSide + indent;
- that._textPosition = that._lineEnd + (that.vertical ? 2 : that._textHeight / 2);
- that._maxBound = that._textPosition + (that.vertical ? that._textWidth : that._textHeight / 2)
- }
- else if (indent < 0) {
- that._lineStart = that._minSide;
- that._lineEnd = that._minSide + indent;
- that._textPosition = that._lineEnd - (that.vertical ? 2 : that._textHeight / 2);
- that._minBound = that._textPosition - (that.vertical ? that._textWidth : that._textHeight / 2)
- }
- },
- _getPositions: function() {
- var that = this,
- options = that._options,
- startPosition = that._startPosition,
- endPosition = that._endPosition,
- space = that._space,
- basePosition = that._basePosition,
- actualPosition = that._actualPosition,
- mainPosition1,
- mainPosition2,
- backPosition1,
- backPosition2;
- if (startPosition < endPosition) {
- if (basePosition < actualPosition) {
- mainPosition1 = basePosition;
- mainPosition2 = actualPosition
- }
- else {
- mainPosition1 = actualPosition;
- mainPosition2 = basePosition
- }
- backPosition1 = mainPosition1 - space;
- backPosition2 = mainPosition2 + space
- }
- else {
- if (basePosition > actualPosition) {
- mainPosition1 = basePosition;
- mainPosition2 = actualPosition
- }
- else {
- mainPosition1 = actualPosition;
- mainPosition2 = basePosition
- }
- backPosition1 = mainPosition1 + space;
- backPosition2 = mainPosition2 - space
- }
- return {
- start: startPosition,
- end: endPosition,
- main1: mainPosition1,
- main2: mainPosition2,
- back1: backPosition1,
- back2: backPosition2
- }
- },
- _buildItemSettings: function(from, to) {
- var that = this,
- side1 = that._minSide,
- side2 = that._maxSide;
- var points = that.vertical ? [side1, from, side1, to, side2, to, side2, from] : [from, side1, from, side2, to, side2, to, side1];
- return {points: points}
- },
- _updateTextPosition: function() {
- var that = this;
- that._text.applySettings(that.vertical ? {
- x: that._textPosition,
- y: that._actualPosition + that._textVerticalOffset
- } : {
- x: that._actualPosition,
- y: that._textPosition + that._textVerticalOffset
- })
- },
- _updateLinePosition: function() {
- var that = this,
- actualPosition = that._actualPosition,
- side1,
- side2,
- points;
- if (that.vertical) {
- if (that._basePosition >= actualPosition) {
- side1 = actualPosition;
- side2 = actualPosition + 2
- }
- else {
- side1 = actualPosition - 2;
- side2 = actualPosition
- }
- points = [that._lineStart, side1, that._lineStart, side2, that._lineEnd, side2, that._lineEnd, side1]
- }
- else {
- if (that._basePosition <= actualPosition) {
- side1 = actualPosition - 2;
- side2 = actualPosition
- }
- else {
- side1 = actualPosition;
- side2 = actualPosition + 2
- }
- points = [side1, that._lineStart, side1, that._lineEnd, side2, that._lineEnd, side2, that._lineStart]
- }
- that._line.applySettings({points: points})
- },
- _getTooltipPosition: function() {
- var that = this,
- crossCenter = (that._minSide + that._maxSide) / 2,
- alongCenter = (that._basePosition + that._actualPosition) / 2,
- position = {};
- if (that.vertical)
- position = {
- x: crossCenter,
- y: alongCenter
- };
- else
- position = {
- x: alongCenter,
- y: crossCenter
- };
- return position
- },
- measure: function(layout) {
- var that = this,
- size = _Number(that._options.size),
- textIndent = _Number(that._options.text.indent),
- minbound,
- maxbound,
- indent;
- that._measureText();
- if (that.vertical) {
- minbound = maxbound = layout.x;
- if (that._inverted)
- maxbound = maxbound + size;
- else
- minbound = minbound - size;
- if (that._hasText) {
- indent = that._textHeight / 2;
- if (textIndent > 0)
- maxbound += textIndent + that._textWidth;
- if (textIndent < 0)
- minbound += textIndent - that._textWidth
- }
- }
- else {
- minbound = maxbound = layout.y;
- if (that._inverted)
- maxbound = maxbound + size;
- else
- minbound = minbound - size;
- if (that._hasText) {
- indent = that._textWidth / 2;
- if (textIndent > 0)
- maxbound += textIndent + that._textHeight;
- if (textIndent < 0)
- minbound += textIndent - that._textHeight
- }
- }
- return {
- min: minbound,
- max: maxbound,
- indent: indent
- }
- }
- })
- })(DevExpress);
- /*! Module viz-gauges, file rangeContainer.js */
- (function(DX, $, undefined) {
- var _Number = Number,
- _String = String,
- _max = Math.max,
- _abs = Math.abs,
- _isString = DX.utils.isString,
- _isArray = DX.utils.isArray,
- _isFinite = isFinite,
- _each = $.each,
- _map = $.map;
- var _Palette = DX.viz.core.Palette;
- DX.viz.gauges.__internals.BaseRangeContainer = DX.Class.inherit({
- ctor: function(parameters) {
- var that = this;
- that._renderer = parameters.renderer;
- that._container = parameters.container;
- that._translator = parameters.translator;
- that._root = that._renderer.createGroup({'class': 'dxg-range-container'})
- },
- dispose: function() {
- var that = this;
- that._renderer = that._container = that._translator = that._root = null
- },
- clean: function() {
- this._root.detach().clear();
- this._options = this.enabled = null;
- return this
- },
- _getRanges: function() {
- var that = this,
- options = that._options,
- translator = that._translator,
- totalStart = translator.getDomain()[0],
- totalEnd = translator.getDomain()[1],
- totalDelta = totalEnd - totalStart,
- isNotEmptySegment = totalDelta >= 0 ? isNotEmptySegmentAsc : isNotEmptySegmentDes,
- subtractSegment = totalDelta >= 0 ? subtractSegmentAsc : subtractSegmentDes,
- list = [],
- ranges = [],
- backgroundRanges = [{
- start: totalStart,
- end: totalEnd
- }],
- threshold = _abs(totalDelta) / 1E4,
- palette = new _Palette(options.palette, {
- type: 'indicatingSet',
- theme: options.themeName
- }),
- backgroundColor = _isString(options.backgroundColor) ? options.backgroundColor : 'none',
- width = options.width || {},
- startWidth = _Number(width > 0 ? width : width.start),
- endWidth = _Number(width > 0 ? width : width.end),
- deltaWidth = endWidth - startWidth;
- if (options.ranges !== undefined && !_isArray(options.ranges))
- return null;
- if (!(startWidth >= 0 && endWidth >= 0 && startWidth + endWidth > 0))
- return null;
- list = _map(_isArray(options.ranges) ? options.ranges : [], function(rangeOptions, i) {
- rangeOptions = rangeOptions || {};
- var start = translator.adjust(rangeOptions.startValue),
- end = translator.adjust(rangeOptions.endValue);
- return _isFinite(start) && _isFinite(end) && isNotEmptySegment(start, end, threshold) ? {
- start: start,
- end: end,
- color: rangeOptions.color,
- classIndex: i
- } : null
- });
- _each(list, function(i, item) {
- var paletteColor = palette.getNextColor();
- item.color = _isString(item.color) && item.color || paletteColor || 'none';
- item.className = 'dxg-range dxg-range-' + item.classIndex;
- delete item.classIndex
- });
- _each(list, function(_, item) {
- var i,
- ii,
- sub,
- subs,
- range,
- newRanges = [],
- newBackgroundRanges = [];
- for (i = 0, ii = ranges.length; i < ii; ++i) {
- range = ranges[i];
- subs = subtractSegment(range.start, range.end, item.start, item.end);
- (sub = subs[0]) && (sub.color = range.color) && (sub.className = range.className) && newRanges.push(sub);
- (sub = subs[1]) && (sub.color = range.color) && (sub.className = range.className) && newRanges.push(sub)
- }
- newRanges.push(item);
- ranges = newRanges;
- for (i = 0, ii = backgroundRanges.length; i < ii; ++i) {
- range = backgroundRanges[i];
- subs = subtractSegment(range.start, range.end, item.start, item.end);
- (sub = subs[0]) && newBackgroundRanges.push(sub);
- (sub = subs[1]) && newBackgroundRanges.push(sub)
- }
- backgroundRanges = newBackgroundRanges
- });
- _each(backgroundRanges, function(_, range) {
- range.color = backgroundColor;
- range.className = 'dxg-range dxg-background-range';
- ranges.push(range)
- });
- _each(ranges, function(_, range) {
- range.startWidth = (range.start - totalStart) / totalDelta * deltaWidth + startWidth;
- range.endWidth = (range.end - totalStart) / totalDelta * deltaWidth + startWidth
- });
- return ranges
- },
- render: function(options) {
- var that = this;
- that._options = options;
- that._processOptions();
- that._ranges = that._getRanges();
- if (that._ranges) {
- that.enabled = true;
- that._root.append(that._container)
- }
- return that
- },
- resize: function(layout) {
- var that = this;
- that._root.clear();
- if (that._isVisible(layout))
- _each(that._ranges, function(_, range) {
- that._createRange(range, layout).applySettings({
- fill: range.color,
- 'class': range.className
- }).append(that._root)
- });
- return that
- },
- _processOptions: null,
- _isVisible: null,
- _createRange: null
- });
- function subtractSegmentAsc(segmentStart, segmentEnd, otherStart, otherEnd) {
- var result;
- if (otherStart > segmentStart && otherEnd < segmentEnd)
- result = [{
- start: segmentStart,
- end: otherStart
- }, {
- start: otherEnd,
- end: segmentEnd
- }];
- else if (otherStart >= segmentEnd || otherEnd <= segmentStart)
- result = [{
- start: segmentStart,
- end: segmentEnd
- }];
- else if (otherStart <= segmentStart && otherEnd >= segmentEnd)
- result = [];
- else if (otherStart > segmentStart)
- result = [{
- start: segmentStart,
- end: otherStart
- }];
- else if (otherEnd < segmentEnd)
- result = [{
- start: otherEnd,
- end: segmentEnd
- }];
- return result
- }
- function subtractSegmentDes(segmentStart, segmentEnd, otherStart, otherEnd) {
- var result;
- if (otherStart < segmentStart && otherEnd > segmentEnd)
- result = [{
- start: segmentStart,
- end: otherStart
- }, {
- start: otherEnd,
- end: segmentEnd
- }];
- else if (otherStart <= segmentEnd || otherEnd >= segmentStart)
- result = [{
- start: segmentStart,
- end: segmentEnd
- }];
- else if (otherStart >= segmentStart && otherEnd <= segmentEnd)
- result = [];
- else if (otherStart < segmentStart)
- result = [{
- start: segmentStart,
- end: otherStart
- }];
- else if (otherEnd > segmentEnd)
- result = [{
- start: otherEnd,
- end: segmentEnd
- }];
- return result
- }
- function isNotEmptySegmentAsc(start, end, threshold) {
- return end - start >= threshold
- }
- function isNotEmptySegmentDes(start, end, threshold) {
- return start - end >= threshold
- }
- DX.viz.gauges.__internals.CircularRangeContainer = DX.viz.gauges.__internals.BaseRangeContainer.inherit({
- _processOptions: function() {
- var that = this;
- that._inner = that._outer = 0;
- switch (_String(that._options.orientation).toLowerCase()) {
- case'inside':
- that._inner = 1;
- break;
- case'center':
- that._inner = that._outer = 0.5;
- break;
- default:
- that._outer = 1;
- break
- }
- },
- _isVisible: function(layout) {
- var width = this._options.width;
- width = _Number(width) || _max(_Number(width.start), _Number(width.end));
- return layout.radius - this._inner * width > 0
- },
- _createRange: function(range, layout) {
- var that = this,
- width = (range.startWidth + range.endWidth) / 2;
- return that._renderer.createArc(layout.x, layout.y, layout.radius + that._outer * width, layout.radius - that._inner * width, that._translator.translate(range.end), that._translator.translate(range.start))
- },
- measure: function(layout) {
- var width = this._options.width;
- width = _Number(width) || _max(_Number(width.start), _Number(width.end));
- return {
- min: layout.radius - this._inner * width,
- max: layout.radius + this._outer * width
- }
- }
- });
- DX.viz.gauges.__internals.LinearRangeContainer = DX.viz.gauges.__internals.BaseRangeContainer.inherit({
- _processOptions: function() {
- var that = this;
- that.vertical = that._options.vertical;
- that._inner = that._outer = 0;
- if (that.vertical)
- switch (_String(that._options.horizontalOrientation).toLowerCase()) {
- case'left':
- that._inner = 1;
- break;
- case'center':
- that._inner = that._outer = 0.5;
- break;
- default:
- that._outer = 1;
- break
- }
- else
- switch (_String(that._options.verticalOrientation).toLowerCase()) {
- case'top':
- that._inner = 1;
- break;
- case'middle':
- that._inner = that._outer = 0.5;
- break;
- default:
- that._outer = 1;
- break
- }
- },
- _isVisible: function(layout) {
- return true
- },
- _createRange: function(range, layout) {
- var that = this,
- inner = that._inner,
- outer = that._outer,
- startPosition = that._translator.translate(range.start),
- endPosition = that._translator.translate(range.end),
- points;
- if (that.vertical)
- points = [layout.x - range.startWidth * inner, startPosition, layout.x - range.endWidth * inner, endPosition, layout.x + range.endWidth * outer, endPosition, layout.x + range.startWidth * outer, startPosition];
- else
- points = [startPosition, layout.y + range.startWidth * outer, startPosition, layout.y - range.startWidth * inner, endPosition, layout.y - range.endWidth * inner, endPosition, layout.y + range.endWidth * outer];
- return that._renderer.createArea(points)
- },
- measure: function(layout) {
- var result = {};
- result.min = result.max = layout[this.vertical ? 'x' : 'y'];
- var width = this._options.width;
- width = _Number(width) || _max(_Number(width.start), _Number(width.end));
- result.min -= this._inner * width;
- result.max += this._outer * width;
- return result
- }
- })
- })(DevExpress, jQuery);
- /*! Module viz-gauges, file title.js */
- (function(DX, $, undefined) {
- var _isString = DX.utils.isString,
- _max = Math.max,
- _extend = $.extend;
- DX.viz.gauges.__internals.Title = DX.Class.inherit({
- ctor: function(parameters) {
- this._renderer = parameters.renderer;
- this._container = parameters.container
- },
- dispose: function() {
- this._renderer = this._container = null;
- return this
- },
- clean: function() {
- var that = this;
- if (that._root) {
- that._root.detach().clear();
- that._root = that._layout = null
- }
- return that
- },
- render: function(titleOptions, subtitleOptions) {
- var that = this,
- hasTitle = _isString(titleOptions.text) && titleOptions.text.length > 0,
- hasSubtitle = _isString(subtitleOptions.text) && subtitleOptions.text.length > 0;
- if (!hasTitle && !hasSubtitle)
- return that;
- that._root = that._renderer.createGroup({'class': 'dxg-title'}).append(that._container);
- var title = hasTitle ? that._renderer.createText(titleOptions.text, 0, 0, {
- align: 'center',
- font: titleOptions.font
- }).append(that._root) : null,
- subtitle = hasSubtitle ? that._renderer.createText(subtitleOptions.text, 0, 0, {
- align: 'center',
- font: subtitleOptions.font
- }).append(that._root) : null,
- titleBox = title ? title.getBBox() : {},
- subtitleBox = subtitle ? subtitle.getBBox() : {},
- y = 0;
- if (title) {
- y += -titleBox.y;
- title.applySettings({
- x: 0,
- y: y
- })
- }
- if (subtitle) {
- y += -subtitleBox.y;
- subtitle.applySettings({
- x: 0,
- y: y
- })
- }
- that._layout = _extend({
- position: titleOptions.position,
- width: _max(titleBox.width || 0, subtitleBox.width || 0),
- height: title && subtitle ? -titleBox.y + subtitleBox.height : titleBox.height || subtitleBox.height
- }, titleOptions.layout);
- return that
- },
- getLayoutOptions: function() {
- return this._layout
- },
- locate: function(left, top) {
- this._root.applySettings({
- translateX: left + this._layout.width / 2,
- translateY: top
- });
- return this
- }
- })
- })(DevExpress, jQuery);
- /*! Module viz-gauges, file tooltip.js */
- (function(DX, $, undefined) {
- var _extend = $.extend;
- DX.viz.gauges.__internals.Tooltip = DX.viz.core.Tooltip.inherit({
- ctor: function(parameters) {
- var that = this;
- that._container = parameters.container;
- that._tracker = parameters.tracker;
- that._root = parameters.renderer.createGroup({'class': 'dxg-tooltip'});
- that.callBase(null, that._root, parameters.renderer);
- that._setTrackerCallbacks()
- },
- dispose: function() {
- var that = this;
- that._container = that._tracker = that._root = null;
- return that._shadow ? that.callBase.apply(that, arguments) : that
- },
- _setTrackerCallbacks: function() {
- var that = this;
- function prepareCallback(target, info) {
- var tooltipParameters = target.getTooltipParameters(),
- formatObject = _extend({
- value: tooltipParameters.value,
- valueText: that.formatValue(tooltipParameters.value),
- color: tooltipParameters.color
- }, info);
- return that.prepare(formatObject, {
- x: tooltipParameters.x,
- y: tooltipParameters.y,
- offset: tooltipParameters.offset
- })
- }
- function showCallback() {
- return that.show()
- }
- function hideCallback() {
- return that.hide()
- }
- that._tracker.setCallbacks({
- 'tooltip-prepare': prepareCallback,
- 'tooltip-show': showCallback,
- 'tooltip-hide': hideCallback
- })
- },
- clean: function() {
- this._root.detach();
- return this
- },
- render: function(options, size) {
- var that = this;
- options.canvasWidth = size.width;
- options.canvasHeight = size.height;
- options.text = {'class': 'dxg-text'};
- that.update(options);
- that._tracker.setTooltipState(that.enabled());
- that.enabled() && that._root.append(that._container);
- return that
- }
- })
- })(DevExpress, jQuery);
- /*! Module viz-gauges, file layoutManager.js */
- (function(DX, $, undefined) {
- var _Number = Number,
- _String = String,
- _min = Math.min,
- _max = Math.max,
- _each = $.each;
- function patchLayoutOptions(options) {
- if (options.position) {
- var position = _String(options.position).toLowerCase().split('-');
- options.verticalAlignment = position[0];
- options.horizontalAlignment = position[1]
- }
- }
- DX.viz.gauges.__internals.LayoutManager = DX.Class.inherit({
- setRect: function(rect) {
- this._currentRect = rect.clone();
- return this
- },
- getRect: function() {
- return this._currentRect.clone()
- },
- beginLayout: function(rect) {
- this._rootRect = rect.clone();
- this._currentRect = rect.clone();
- this._cache = [];
- return this
- },
- applyLayout: function(target) {
- var options = target.getLayoutOptions();
- if (!options)
- return this;
- var currentRect = this._currentRect,
- verticalOverlay = _Number(options.overlay) || 0;
- patchLayoutOptions(options);
- switch (_String(options.verticalAlignment).toLowerCase()) {
- case'bottom':
- currentRect.bottom -= _max(options.height - verticalOverlay, 0);
- break;
- default:
- currentRect.top += _max(options.height - verticalOverlay, 0);
- break
- }
- this._cache.push({
- target: target,
- options: options
- });
- return this
- },
- endLayout: function() {
- var that = this,
- rootRect = that._rootRect,
- currentRect = that._currentRect;
- _each(that._cache, function(_, cacheItem) {
- var options = cacheItem.options,
- left,
- top,
- verticalOverlay = _Number(options.overlay) || 0;
- switch (_String(options.verticalAlignment).toLowerCase()) {
- case'bottom':
- top = currentRect.bottom - verticalOverlay;
- currentRect.bottom += _max(options.height - verticalOverlay, 0);
- break;
- default:
- top = currentRect.top - options.height + verticalOverlay;
- currentRect.top -= _max(options.height - verticalOverlay, 0);
- break
- }
- switch (_String(options.horizontalAlignment).toLowerCase()) {
- case'left':
- left = rootRect.left;
- break;
- case'right':
- left = rootRect.right - options.width;
- break;
- default:
- left = rootRect.horizontalMiddle() - options.width / 2;
- break
- }
- cacheItem.target.locate(left, top)
- });
- that._cache = null;
- return that
- },
- selectRectByAspectRatio: function(aspectRatio, margins) {
- var rect = this._currentRect.clone(),
- selfAspectRatio,
- width = 0,
- height = 0;
- margins = margins || {};
- if (aspectRatio > 0) {
- rect.left += margins.left || 0;
- rect.right -= margins.right || 0;
- rect.top += margins.top || 0;
- rect.bottom -= margins.bottom || 0;
- if (rect.width() > 0 && rect.height() > 0) {
- selfAspectRatio = rect.height() / rect.width();
- if (selfAspectRatio > 1)
- aspectRatio < selfAspectRatio ? width = rect.width() : height = rect.height();
- else
- aspectRatio > selfAspectRatio ? height = rect.height() : width = rect.width();
- width > 0 || (width = height / aspectRatio);
- height > 0 || (height = width * aspectRatio);
- width = (rect.width() - width) / 2;
- height = (rect.height() - height) / 2;
- rect.left += width;
- rect.right -= width;
- rect.top += height;
- rect.bottom -= height
- }
- else {
- rect.left = rect.right = rect.horizontalMiddle();
- rect.top = rect.bottom = rect.verticalMiddle()
- }
- }
- return rect
- },
- selectRectBySizes: function(sizes, margins) {
- var rect = this._currentRect.clone(),
- step;
- margins = margins || {};
- if (sizes) {
- rect.left += margins.left || 0;
- rect.right -= margins.right || 0;
- rect.top += margins.top || 0;
- rect.bottom -= margins.bottom || 0;
- if (sizes.width > 0) {
- step = (rect.width() - sizes.width) / 2;
- if (step > 0) {
- rect.left += step;
- rect.right -= step
- }
- }
- if (sizes.height > 0) {
- step = (rect.height() - sizes.height) / 2;
- if (step > 0) {
- rect.top += step;
- rect.bottom -= step
- }
- }
- }
- return rect
- }
- })
- })(DevExpress, jQuery);
- /*! Module viz-gauges, file themeManager.js */
- (function(DX, $, undefined) {
- var _extend = $.extend;
- DX.viz.gauges.__internals.ThemeManager = DX.viz.core.BaseThemeManager.inherit({
- _themeSection: 'gauge',
- _initializeTheme: function() {
- var that = this;
- if (that._subTheme) {
- var subTheme = _extend(true, {}, that._theme[that._subTheme], that._theme);
- _extend(true, that._theme, subTheme)
- }
- that._initializeFont(that._theme.scale.label.font);
- that._initializeFont(that._theme.valueIndicator.rangebar.text.font);
- that._initializeFont(that._theme.subvalueIndicator.textcloud.text.font);
- that._initializeFont(that._theme.valueIndicators.rangebar.text.font);
- that._initializeFont(that._theme.valueIndicators.textcloud.text.font);
- that._initializeFont(that._theme.title.font);
- that._initializeFont(that._theme.subtitle.font);
- that._initializeFont(that._theme.tooltip.font);
- that._initializeFont(that._theme.indicator.text.font);
- that._initializeFont(that._theme.loadingIndicator.font)
- }
- })
- })(DevExpress, jQuery);
- /*! Module viz-gauges, file presetManager.js */
- /*! Module viz-gauges, file baseGauge.js */
- (function(DX, $, undefined) {
- var _Number = Number,
- _isNumber = DX.utils.isNumber,
- _isString = DX.utils.isString,
- _getAppropriateFormat = DX.utils.getAppropriateFormat,
- _extend = $.extend,
- _each = $.each;
- DX.viz.gauges.__internals.BaseGauge = DX.viz.core.BaseWidget.inherit({
- _init: function() {
- var that = this;
- that.callBase.apply(that, arguments);
- that._renderer = that._factory.createRenderer({
- width: 1,
- height: 1,
- pathModified: that.option('pathModified'),
- rtl: that.option('rtlEnabled')
- });
- that._root = that._renderer.getRoot();
- that._root.applySettings({'class': 'dxg ' + that._rootClass});
- that._translator = that._factory.createTranslator();
- that._themeManager = that._factory.createThemeManager();
- that._tracker = that._factory.createTracker({
- renderer: that._renderer,
- container: that._root
- });
- that._layoutManager = that._factory.createLayoutManager();
- that._tooltip = that._factory.createTooltip({
- renderer: that._renderer,
- container: that._root,
- tracker: that._tracker
- });
- that._title = that._factory.createTitle({
- renderer: that._renderer,
- container: that._root
- });
- that._deltaIndicator = that._factory.createDeltaIndicator({
- renderer: that._renderer,
- container: that._root
- });
- that._setupDomain();
- that._themeManager.setTheme(that.option('theme'))
- },
- _dispose: function() {
- var that = this;
- that.callBase.apply(that, arguments);
- that._renderer.dispose();
- that._themeManager.dispose();
- that._tracker.dispose();
- that._title.dispose();
- that._deltaIndicator && that._deltaIndicator.dispose();
- that._tooltip.dispose();
- that._disposeLoadIndicator();
- that._renderer = that._root = that._translator = that._themeManager = that._tracker = that._layoutManager = that._title = that._tooltip = null
- },
- _refresh: function() {
- var that = this,
- callBase = that.callBase;
- that._endLoading(function() {
- callBase.call(that)
- })
- },
- _clean: function() {
- this._cleanCore()
- },
- _render: function() {
- var that = this;
- that._setupCodomain();
- that._setupAnimationSettings();
- if (that._calculateSize() && that._checkDomain()) {
- that._renderer.draw(that._element()[0]);
- that._setupDefaultFormat();
- that._renderCore()
- }
- that._drawn()
- },
- _cleanCore: function() {
- var that = this;
- that._tooltip.clean();
- that._title.clean();
- that._deltaIndicator && that._deltaIndicator.clean();
- that._tracker.deactivate();
- that._cleanContent()
- },
- _renderCore: function() {
- var that = this;
- that._title.render(_extend(true, {}, that._themeManager.theme()['title'], processTitleOptions(that.option('title'))), _extend(true, {}, that._themeManager.theme()['subtitle'], processTitleOptions(that.option('subtitle'))));
- that._deltaIndicator && that._deltaIndicator.render(_extend(true, {}, that._themeManager.theme()['indicator'], that.option('indicator')));
- that._layoutManager.beginLayout(that._rootRect);
- _each([that._deltaIndicator, that._title], function(_, item) {
- item && that._layoutManager.applyLayout(item)
- });
- that._mainRect = that._layoutManager.getRect();
- that._renderContent();
- that._layoutManager.endLayout();
- that._tooltip.render(_extend(true, {}, that._themeManager.theme()['tooltip'], that.option('tooltip')), {
- width: that._width,
- height: that._height
- });
- that._tracker.activate();
- that._updateLoadIndicator(undefined, that._width, that._height);
- that._noAnimation = null;
- that.option('debugMode') === true && that._renderDebugInfo();
- that._debug_rendered && that._debug_rendered()
- },
- _renderDebugInfo: function() {
- var that = this,
- group = that._debugGroup || that._renderer.createGroup({'class': 'debug-info'}).append(),
- rect;
- group.clear();
- rect = that._rootRect;
- that._renderer.createRect(rect.left, rect.top, rect.width(), rect.height(), 0, {
- stroke: '#000000',
- strokeWidth: 1,
- fill: 'none'
- }).append(group);
- rect = that._mainRect;
- that._renderer.createRect(rect.left, rect.top, rect.width(), rect.height(), 0, {
- stroke: '#0000FF',
- strokeWidth: 1,
- fill: 'none'
- }).append(group);
- rect = that._layoutManager.getRect();
- rect && that._renderer.createRect(rect.left, rect.top, rect.width(), rect.height(), 0, {
- stroke: '#FF0000',
- strokeWidth: 1,
- fill: 'none'
- }).append(group);
- rect = that._title.getLayoutOptions() ? that._title._root.getBBox() : null;
- rect && that._renderer.createRect(rect.x, rect.y, rect.width, rect.height, 0, {
- stroke: '#00FF00',
- strokeWidth: 1,
- fill: 'none'
- }).append(group);
- rect = that._deltaIndicator && that._deltaIndicator.getLayoutOptions() ? that._deltaIndicator._root.getBBox() : null;
- rect && that._renderer.createRect(rect.x, rect.y, rect.width, rect.height, 0, {
- stroke: '#00FF00',
- strokeWidth: 1,
- fill: 'none'
- }).append(group)
- },
- _resize: function() {
- var that = this;
- if (that._calculateSize()) {
- that._resizing = that._noAnimation = true;
- that._cleanCore();
- that._renderCore();
- that._resizing = null
- }
- },
- render: function(options) {
- options && options.animate !== undefined && !options.animate && (this._noAnimation = true);
- this._refresh();
- return this
- },
- showLoadingIndicator: function() {
- this._showLoadIndicator(this._getLoadIndicatorOption(), {
- width: this._width,
- height: this._height
- })
- },
- _getLoadIndicatorOption: function() {
- return _extend(true, {}, this._themeManager.theme()['loadingIndicator'], this.option('loadingIndicator'))
- },
- _optionChanged: function(name, newv, oldv) {
- var that = this;
- switch (name) {
- case'theme':
- that._themeManager.setTheme(newv);
- that._invalidate();
- break;
- case'startValue':
- case'endValue':
- that._setupDomain();
- that._invalidate();
- break;
- default:
- that.callBase.apply(that, arguments);
- break
- }
- },
- _calculateSize: function() {
- var that = this;
- that._calculateSizeCore();
- if (that._width === 0 || that._height === 0 || !that._element().is(':visible')) {
- that._incidentOccured('W2001', [that.NAME]);
- return false
- }
- else {
- that._renderer.resize(that._width, that._height);
- return true
- }
- },
- _checkDomain: function() {
- var that = this,
- domain = that._translator.getDomain(),
- isValid = isFinite(1 / (domain[1] - domain[0]));
- if (!isValid)
- that._incidentOccured('W2301');
- return isValid
- },
- _setupAnimationSettings: function() {
- var that = this,
- option = that.option('animation');
- that._animationSettings = null;
- if (option === undefined || option) {
- if (option === undefined)
- option = {
- enabled: that.option('animationEnabled'),
- duration: that.option('animationDuration')
- };
- option = _extend({
- enabled: true,
- duration: 1000,
- easing: 'easeOutCubic'
- }, option);
- if (option.enabled && option.duration > 0)
- that._animationSettings = {
- duration: _Number(option.duration),
- easing: option.easing
- }
- }
- that._containerBackgroundColor = that.option('containerBackgroundColor') || that._themeManager.theme().containerBackgroundColor
- },
- _setupDefaultFormat: function() {
- var domain = this._translator.getDomain();
- this._defaultFormatOptions = _getAppropriateFormat(domain[0], domain[1], this._getApproximateScreenRange())
- },
- _setupDomain: null,
- _calculateSizeCore: null,
- _cleanContent: null,
- _renderContent: null,
- _setupCodomain: null,
- _getApproximateScreenRange: null,
- _factory: {
- createRenderer: DX.viz.core.CoreFactory.createRenderer,
- createTranslator: function() {
- return new DX.viz.core.Translator1D
- },
- createTracker: function(parameters) {
- return new DX.viz.gauges.__internals.Tracker(parameters)
- },
- createLayoutManager: function() {
- return new DX.viz.gauges.__internals.LayoutManager
- },
- createTitle: function(parameters) {
- return new DX.viz.gauges.__internals.Title(parameters)
- },
- createDeltaIndicator: function(parameters) {
- return DX.viz.gauges.__internals.DeltaIndicator ? new DX.viz.gauges.__internals.DeltaIndicator(parameters) : null
- },
- createTooltip: function(parameters) {
- return new DX.viz.gauges.__internals.Tooltip(parameters)
- }
- }
- });
- function processTitleOptions(options) {
- return _isString(options) ? {text: options} : options || {}
- }
- })(DevExpress, jQuery);
- /*! Module viz-gauges, file gauge.js */
- (function(DX, $, undefined) {
- var _Rectangle = DX.viz.core.Rectangle;
- var _isDefined = DX.utils.isDefined,
- _isArray = DX.utils.isArray,
- _isNumber = DX.utils.isNumber,
- _isFinite = isFinite,
- _Number = Number,
- _String = String,
- _abs = Math.abs,
- _extend = $.extend,
- _each = $.each,
- _map = $.map,
- _noop = $.noop;
- var OPTION_VALUE = 'value',
- OPTION_SUBVALUES = 'subvalues';
- DX.viz.gauges.Gauge = DX.viz.gauges.__internals.BaseGauge.inherit({
- _init: function() {
- var that = this;
- that.__value = that.option(OPTION_VALUE);
- that.__subvalues = that.option(OPTION_SUBVALUES);
- if (!_isArray(that.__subvalues))
- that.__subvalues = _isNumber(that.__subvalues) ? [that.__subvalues] : null;
- that._selectMode();
- that.callBase.apply(that, arguments);
- that._scale = that._createScale({
- renderer: that._renderer,
- container: that._root,
- translator: that._translator
- });
- that._rangeContainer = that._createRangeContainer({
- renderer: that._renderer,
- container: that._root,
- translator: that._translator
- })
- },
- _dispose: function() {
- var that = this;
- that.callBase.apply(that, arguments);
- that._scale.dispose();
- that._rangeContainer.dispose();
- that._disposeValueIndicators();
- that._scale = that._rangeContainer = null
- },
- _disposeValueIndicators: function() {
- var that = this;
- that._valueIndicator && that._valueIndicator.dispose();
- that._subvalueIndicatorsSet && that._subvalueIndicatorsSet.dispose();
- that._valueIndicator = that._subvalueIndicatorsSet = null
- },
- _selectMode: function() {
- var that = this;
- if (that.option(OPTION_VALUE) === undefined && that.option(OPTION_SUBVALUES) === undefined)
- if (that.option('needles') !== undefined || that.option('markers') !== undefined || that.option('rangeBars') !== undefined) {
- disableDefaultMode(that);
- selectObsoleteMode(that)
- }
- else if (that.option('valueIndicators') !== undefined) {
- disableDefaultMode(that);
- selectHardMode(that)
- }
- },
- _setupDomain: function() {
- var that = this,
- scaleOption = that.option('scale') || {},
- startValue = that.option('startValue'),
- endValue = that.option('endValue');
- startValue = _isNumber(startValue) ? _Number(startValue) : _isNumber(scaleOption.startValue) ? _Number(scaleOption.startValue) : 0;
- endValue = _isNumber(endValue) ? _Number(endValue) : _isNumber(scaleOption.endValue) ? _Number(scaleOption.endValue) : 100;
- that._baseValue = startValue < endValue ? startValue : endValue;
- that._translator.setDomain(startValue, endValue);
- that._setupValueState()
- },
- _setupValueState: function() {
- this._setupValue();
- this.__subvalues !== null && this._setupSubvalues()
- },
- _calculateSizeCore: function() {
- var that = this,
- size = that.option('size') || {},
- margin = that.option('margin') || {};
- if (_Number(size.width) === 0 || _Number(size.height) === 0) {
- that._width = that._height = 0;
- that._rootRect = new _Rectangle
- }
- else {
- var width = size.width > 0 ? _Number(size.width) : that._element().width() || that._getDefaultContainerSize().width,
- height = size.height > 0 ? _Number(size.height) : that._element().height() || that._getDefaultContainerSize().height,
- marginL = margin.left > 0 ? _Number(margin.left) : 0,
- marginR = margin.right > 0 ? _Number(margin.right) : 0,
- marginT = margin.top > 0 ? _Number(margin.top) : 0,
- marginB = margin.bottom > 0 ? _Number(margin.bottom) : 0;
- marginL + marginR >= width && (marginL = marginR = 0);
- marginT + marginB >= height && (marginT = marginB = 0);
- that._width = width;
- that._height = height;
- that._rootRect = new _Rectangle({
- left: marginL,
- top: marginT,
- right: width - marginR,
- bottom: height - marginB
- })
- }
- },
- _cleanContent: function() {
- var that = this;
- that._rangeContainer.clean();
- that._scale.clean();
- that._cleanValueIndicators()
- },
- _renderContent: function() {
- var that = this;
- that._rangeContainer.render(_extend(true, {}, that._themeManager.theme().rangeContainer, that.option('rangeContainer'), {
- themeName: that._themeManager.themeName(),
- vertical: that._area.vertical
- }));
- that._scale.render(_extend(true, {}, that._themeManager.theme().scale, that.option('scale'), {
- approximateScreenDelta: that._getApproximateScreenRange(),
- offset: 0,
- vertical: that._area.vertical
- }));
- var elements = that._prepareValueIndicators();
- elements = _map([that._scale, that._rangeContainer].concat(elements), function(element) {
- return element && element.enabled ? element : null
- });
- that._applyMainLayout(elements);
- _each(elements, function(_, element) {
- that._updateElementPosition(element)
- });
- that._updateActiveElements()
- },
- _updateIndicatorSettings: function(settings) {
- var that = this;
- settings.currentValue = settings.baseValue = _isFinite(that._translator.translate(settings.baseValue)) ? _Number(settings.baseValue) : that._baseValue;
- settings.vertical = that._area.vertical;
- if (settings.text && !settings.text.format && !settings.text.precision) {
- settings.text.format = that._defaultFormatOptions.format;
- settings.text.precision = that._defaultFormatOptions.precision
- }
- },
- _prepareValueIndicatorSettings: function() {
- var that = this,
- options = that.option('valueIndicator') || {},
- defaultOptions = _extend(true, {}, that._themeManager.theme().valueIndicator),
- type = _String(options.type || defaultOptions.type).toLowerCase();
- that._valueIndicatorSettings = _extend(true, defaultOptions._default, defaultOptions[type], options, {
- type: type,
- animation: that._animationSettings,
- containerBackgroundColor: that._containerBackgroundColor
- });
- that._updateIndicatorSettings(that._valueIndicatorSettings)
- },
- _prepareSubvalueIndicatorSettings: function() {
- var that = this,
- options = that.option('subvalueIndicator') || {},
- defaultOptions = _extend(true, {}, that._themeManager.theme().subvalueIndicator),
- type = _String(options.type || defaultOptions.type).toLowerCase();
- that._subvalueIndicatorSettings = _extend(true, defaultOptions._default, defaultOptions[type], options, {
- type: type,
- animation: that._animationSettings,
- containerBackgroundColor: that._containerBackgroundColor
- });
- that._updateIndicatorSettings(that._subvalueIndicatorSettings)
- },
- _cleanValueIndicators: function() {
- this._valueIndicator && this._valueIndicator.clean();
- this._subvalueIndicatorsSet && this._subvalueIndicatorsSet.clean()
- },
- _prepareValueIndicators: function() {
- var that = this;
- that._prepareValueIndicator();
- that.__subvalues !== null && that._prepareSubvalueIndicators();
- return [that._valueIndicator, that._subvalueIndicatorsSet]
- },
- _updateActiveElements: function() {
- this._updateValueIndicator();
- this._updateSubvalueIndicators()
- },
- _prepareValueIndicator: function() {
- var that = this,
- indicator = that._valueIndicator,
- currentValue;
- that._prepareValueIndicatorSettings();
- indicator && that._valueIndicatorType !== that._valueIndicatorSettings.type && indicator.dispose() && (indicator = null);
- that._valueIndicatorType = that._valueIndicatorSettings.type;
- if (!indicator) {
- indicator = that._valueIndicator = that._createValueIndicator(that._valueIndicatorType);
- if (indicator) {
- indicator.setup({
- renderer: that._renderer,
- translator: that._translator,
- owner: that._root,
- tracker: that._tracker,
- className: 'dxg-value-indicator'
- });
- indicator._trackerInfo = {type: 'value-indicator'}
- }
- }
- indicator.render(that._valueIndicatorSettings)
- },
- _prepareSubvalueIndicators: function() {
- var that = this,
- subvalueIndicatorsSet = that._subvalueIndicatorsSet;
- if (!subvalueIndicatorsSet)
- subvalueIndicatorsSet = that._subvalueIndicatorsSet = new DX.viz.gauges.__internals.ValueIndicatorsSet({
- renderer: that._renderer,
- translator: that._translator,
- owner: that._root,
- tracker: that._tracker,
- className: 'dxg-subvalue-indicators',
- indicatorClassName: 'dxg-subvalue-indicator',
- trackerType: 'subvalue-indicator',
- createIndicator: function() {
- return that._createSubvalueIndicator(that._subvalueIndicatorType)
- }
- });
- that._prepareSubvalueIndicatorSettings();
- var isRecreate = that._subvalueIndicatorSettings.type !== that._subvalueIndicatorType;
- that._subvalueIndicatorType = that._subvalueIndicatorSettings.type;
- if (that._createSubvalueIndicator(that._subvalueIndicatorType))
- subvalueIndicatorsSet.render(that._subvalueIndicatorSettings, isRecreate)
- },
- _processValue: function(value, fallbackValue) {
- var _value = this._translator.adjust(value !== undefined ? value : this.__value);
- return _isFinite(_value) ? _value : fallbackValue
- },
- _setupValue: function(value) {
- this.__value = this._processValue(value, this.__value)
- },
- _setupSubvalues: function(subvalues) {
- var _subvalues = subvalues === undefined ? this.__subvalues : _isArray(subvalues) ? subvalues : _isNumber(subvalues) ? [subvalues] : null;
- if (_subvalues === null)
- return;
- var i = 0,
- ii = _subvalues.length,
- list = [];
- for (; i < ii; ++i)
- list.push(this._processValue(_subvalues[i], this.__subvalues[i]));
- this.__subvalues = list
- },
- _updateValueIndicator: function() {
- var that = this;
- that._valueIndicator && that._valueIndicator.value(that.__value, that._noAnimation);
- that._resizing || that.hideLoadingIndicator()
- },
- _updateSubvalueIndicators: function() {
- var that = this;
- that._subvalueIndicatorsSet && that._subvalueIndicatorsSet.values(that.__subvalues, that._noAnimation);
- that._resizing || that.hideLoadingIndicator()
- },
- value: function(arg) {
- var that = this;
- if (arg !== undefined) {
- that._setupValue(arg);
- that._updateValueIndicator();
- that.option(OPTION_VALUE, that.__value);
- return that
- }
- return that.__value
- },
- subvalues: function(arg) {
- var that = this;
- if (arg !== undefined) {
- if (that.__subvalues !== null) {
- that._setupSubvalues(arg);
- that._updateSubvalueIndicators();
- that.option(OPTION_SUBVALUES, that.__subvalues)
- }
- return that
- }
- return that.__subvalues !== null ? that.__subvalues.slice() : undefined
- },
- _handleValueChanged: function(name, newv, oldv) {
- var that = this;
- switch (name) {
- case OPTION_VALUE:
- that._setupValue(newv);
- that._updateValueIndicator();
- that.option(OPTION_VALUE, that.__value);
- return true;
- case OPTION_SUBVALUES:
- if (that.__subvalues !== null) {
- that._setupSubvalues(newv);
- that._updateSubvalueIndicators();
- that.option(OPTION_SUBVALUES, that.__subvalues);
- return true
- }
- return false;
- default:
- return false
- }
- },
- _optionChanged: function(name, newValue, oldValue) {
- var that = this;
- if (that._handleValueChanged(name, newValue, oldValue))
- return;
- switch (name) {
- case'scale':
- that._setupDomain();
- that._invalidate();
- break;
- default:
- that.callBase.apply(that, arguments);
- break
- }
- },
- _optionValuesEqual: function(name, oldValue, newValue) {
- switch (name) {
- case OPTION_VALUE:
- return oldValue === newValue;
- case OPTION_SUBVALUES:
- return compareArrays(oldValue, newValue);
- default:
- return this.callBase.apply(this, arguments)
- }
- },
- _getDefaultContainerSize: null,
- _applyMainLayout: null,
- _updateElementPosition: null,
- _createScale: null,
- _createRangeContainer: null,
- _createValueIndicator: null,
- _createSubvalueIndicator: null,
- _getApproximateScreenRange: null
- });
- DX.viz.gauges.Gauge.prototype._factory = DX.utils.clone(DX.viz.gauges.__internals.BaseGauge.prototype._factory);
- DX.viz.gauges.Gauge.prototype._factory.createThemeManager = function() {
- return new DX.viz.gauges.__internals.ThemeManager
- };
- function valueGetter(arg) {
- return arg.value
- }
- function setupValues(that, fieldName, optionItems) {
- var currentValues = that[fieldName],
- newValues = _isArray(optionItems) ? _map(optionItems, valueGetter) : [],
- i = 0,
- ii = newValues.length,
- list = [];
- for (; i < ii; ++i)
- list.push(that._processValue(newValues[i], currentValues[i]));
- that[fieldName] = list
- }
- function disableDefaultMode(that) {
- that.value = that.subvalues = _noop;
- that._setupValue = that._setupSubvalues = that._updateValueIndicator = that._updateSubvalueIndicators = null
- }
- function selectObsoleteMode(that) {
- that._needleValues = _map(that.option('needles') || [], valueGetter);
- that._markerValues = _map(that.option('markers') || [], valueGetter);
- that._rangeBarValues = _map(that.option('rangeBars') || [], valueGetter);
- that._needles = [];
- that._markers = [];
- that._rangeBars = [];
- that._setupValueState = function() {
- var that = this;
- setupValues(that, '_needleValues', that.option('needles'));
- setupValues(that, '_markerValues', that.option('markers'));
- setupValues(that, '_rangeBarValues', that.option('rangeBars'))
- };
- that._handleValueChanged = function(name, newv, oldv) {
- var that = this,
- result = false;
- switch (name) {
- case'needles':
- setupValues(that, '_needleValues', newv);
- result = true;
- break;
- case'markers':
- setupValues(that, '_markerValues', newv);
- result = true;
- break;
- case'rangeBars':
- setupValues(that, '_rangeBarValues', newv);
- result = true;
- break
- }
- result && that._invalidate();
- return result
- };
- that._updateActiveElements = function() {
- var that = this;
- _each(that._needles, function(_, needle) {
- needle.value(that._needleValues[needle._index], that._noAnimation)
- });
- _each(that._markers, function(_, marker) {
- marker.value(that._markerValues[marker._index], that._noAnimation)
- });
- _each(that._rangeBars, function(_, rangeBar) {
- rangeBar.value(that._rangeBarValues[rangeBar._index], that._noAnimation)
- });
- that._resizing || that.hideLoadingIndicator()
- };
- that._prepareValueIndicators = function() {
- return prepareObsoleteElements(this)
- };
- that._disposeValueIndicators = function() {
- var that = this;
- _each([].concat(that._needles, that._markers, that._rangeBars), function(_, pointer) {
- pointer.dispose()
- });
- that._needles = that._markers = that._rangeBars = null
- };
- that._cleanValueIndicators = function() {
- _each([].concat(this._needles, this._markers, this._rangeBars), function(_, pointer) {
- pointer.clean()
- })
- };
- that.needleValue = function(index, value) {
- return accessPointerValue(this, this._needles, this._needleValues, index, value)
- };
- that.markerValue = function(index, value) {
- return accessPointerValue(this, this._markers, this._markerValues, index, value)
- };
- that.rangeBarValue = function(index, value) {
- return accessPointerValue(this, this._rangeBars, this._rangeBarValues, index, value)
- }
- }
- function selectHardMode(that) {
- that._indicatorValues = [];
- that._valueIndicators = [];
- that._setupValueState = function() {
- setupValues(this, '_indicatorValues', this.option('valueIndicators'))
- };
- that._handleValueChagned = function(name, newv, oldv) {
- if (name === 'valueIndicators') {
- setupValues(this, '_indicatorValues', newv);
- this._invalidate();
- return true
- }
- return false
- };
- that._updateActiveElements = function() {
- var that = this;
- _each(that._valueIndicators, function(_, valueIndicator) {
- valueIndicator.value(that._indicatorValues[valueIndicator._index], that._noAnimation)
- });
- that._resizing || that.hideLoadingIndicator()
- };
- that._prepareValueIndicators = function() {
- return prepareValueIndicatorsInHardMode(this)
- };
- that._disposeValueIndicators = function() {
- _each(this._valueIndicators, function(_, valueIndicator) {
- valueIndicator.dispose()
- });
- this._valueIndicators = null
- };
- that._cleanValueIndicators = function() {
- _each(this._valueIndicators, function(_, valueIndicator) {
- valueIndicator.clean()
- })
- };
- that.indicatorValue = function(index, value) {
- return accessPointerValue(this, this._valueIndicators, this._indicatorValues, index, value)
- }
- }
- function prepareValueIndicatorsInHardMode(that) {
- var valueIndicators = that._valueIndicators || [],
- userOptions = that.option('valueIndicators'),
- optionList = [],
- i = 0,
- ii;
- for (ii = _isArray(userOptions) ? userOptions.length : 0; i < ii; ++i)
- optionList.push(userOptions[i]);
- for (ii = valueIndicators.length; i < ii; ++i)
- optionList.push(null);
- var themeSettings = that._themeManager.theme().valueIndicators,
- parameters = {
- renderer: that._renderer,
- owner: that._root,
- translator: that._translator,
- tracker: that._tracker
- },
- newValueIndicators = [];
- _each(optionList, function(i, userSettings) {
- var valueIndicator = valueIndicators[i];
- if (!userSettings) {
- valueIndicator && valueIndicator.dispose();
- return
- }
- var type = _String(userSettings.type || themeSettings._type).toLowerCase();
- if (valueIndicator && type !== valueIndicator.type) {
- valueIndicator.dispose();
- valueIndicator = null
- }
- if (!valueIndicator) {
- valueIndicator = that._createValueIndicatorInHardMode(type);
- valueIndicator && valueIndicator.setup(parameters)
- }
- if (valueIndicator) {
- var settings = _extend(true, {}, themeSettings._default, themeSettings[type], userSettings, {
- type: type,
- animation: that._animationSettings,
- containerBackgroundColor: that._containerBackgroundColor
- });
- that._updateIndicatorSettings(settings);
- valueIndicator.render(settings);
- valueIndicator._index = i;
- valueIndicator._trackerInfo = {index: i};
- newValueIndicators.push(valueIndicator)
- }
- });
- that._valueIndicators = newValueIndicators;
- return that._valueIndicators
- }
- function prepareObsoleteElements(that) {
- var rangeBars = prepareObsoletePointers(that, '_rangeBars', '_createRangeBar', {
- user: that.option('rangeBars'),
- common: that.option('commonRangeBarSettings'),
- theme: that._themeManager.theme().valueIndicator,
- preset: {},
- type: 'rangebar',
- className: 'dxg-value-indicator'
- });
- var needles = prepareObsoletePointers(that, '_needles', '_createNeedle', {
- user: that.option('needles'),
- common: that.option('commonNeedleSettings'),
- theme: that._themeManager.theme().valueIndicator,
- preset: that._getPreset().commonNeedleSettings,
- className: 'dxg-value-indicator'
- });
- var markers = prepareObsoletePointers(that, '_markers', '_createMarker', {
- user: that.option('markers'),
- common: that.option('commonMarkerSettings'),
- theme: that._themeManager.theme().subvalueIndicator,
- preset: that._getPreset().commonMarkerSettings,
- className: 'dxg-subvalue-indicator'
- });
- var spindle = that._prepareObsoleteSpindle && that._prepareObsoleteSpindle();
- return [].concat(rangeBars, needles, markers, [spindle])
- }
- function prepareObsoletePointers(that, fieldName, methodName, options) {
- var pointers = that[fieldName],
- userOptions = [],
- i = 0,
- ii;
- for (ii = _isArray(options.user) ? options.user.length : 0; i < ii; ++i)
- userOptions.push(options.user[i]);
- for (ii = pointers.length; i < ii; ++i)
- userOptions.push(null);
- var themeOption = options.theme,
- presetOption = options.preset,
- commonOption = options.common || {},
- parameters = {
- renderer: that._renderer,
- owner: that._root,
- translator: that._translator,
- tracker: that._tracker,
- className: options.className
- },
- newPointers = [];
- _each(userOptions, function(i, pointerOption) {
- var pointer = pointers[i];
- if (!pointerOption) {
- pointer && pointer.dispose();
- return
- }
- var type = _String(pointerOption.type || commonOption.type || presetOption.type || themeOption.type).toLowerCase(),
- settings;
- if (pointer && pointer.type !== type) {
- pointer.dispose();
- pointer = null
- }
- if (!pointer) {
- pointer = that[methodName](type);
- pointer.setup(parameters)
- }
- if (pointer) {
- type = options.type || type;
- settings = _extend(true, {}, themeOption._default, themeOption[type], commonOption, pointerOption),
- settings.spindleSize = null;
- settings.animation = that._animationSettings;
- settings.containerBackgroundColor = that._containerBackgroundColor;
- that._updateIndicatorSettings(settings);
- pointer.render(settings);
- pointer._index = i;
- pointer._trackerInfo = {index: i};
- newPointers.push(pointer)
- }
- });
- that[fieldName] = newPointers;
- return newPointers
- }
- function accessPointerValue(that, pointers, values, index, value) {
- if (value !== undefined) {
- if (values[index] !== undefined) {
- values[index] = that._processValue(value, values[index]);
- pointers[index] && pointers[index].value(values[index]);
- that._resizing || that.hideLoadingIndicator()
- }
- return that
- }
- else
- return values[index]
- }
- function compareArrays(array1, array2) {
- if (array1 === array2)
- return true;
- if (_isArray(array1) && _isArray(array2) && array1.length === array2.length) {
- for (var i = 0, ii = array1.length; i < ii; ++i)
- if (_abs(array1[i] - array2[i]) > 1E-8)
- return false;
- return true
- }
- return false
- }
- DX.viz.gauges.__internals.ValueIndicatorsSet = DX.Class.inherit({
- ctor: function(parameters) {
- var that = this;
- that._parameters = parameters;
- that._createIndicator = that._parameters.createIndicator || _noop;
- that._root = that._parameters.renderer.createGroup({'class': that._parameters.className});
- that._indicatorParameters = that._indicatorParameters || {
- renderer: that._parameters.renderer,
- translator: that._parameters.translator,
- owner: that._root,
- tracker: that._parameters.tracker,
- className: that._parameters.indicatorClassName
- };
- that._indicators = []
- },
- dispose: function() {
- var that = this;
- _each(that._indicators, function(_, indicator) {
- indicator.dispose()
- });
- that._parameters = that._createIndicator = that._root = that._options = that._indicators = that._colorPalette = that._palette = null;
- return that
- },
- clean: function() {
- var that = this;
- that._root.detach();
- that._sample && that._sample.clean().dispose();
- _each(that._indicators, function(_, indicator) {
- indicator.clean()
- });
- that._sample = that._options = that._palette = null;
- return that
- },
- render: function(options, isRecreate) {
- var that = this;
- that._options = options;
- that._sample = that._createIndicator();
- that._sample && that._sample.setup(that._indicatorParameters).render(options);
- that.enabled = that._sample && that._sample.enabled;
- that._palette = _isDefined(options.palette) ? new DX.viz.core.Palette(options.palette) : null;
- if (that.enabled) {
- that._root.append(that._parameters.owner);
- that._generatePalette(that._indicators.length);
- that._indicators = _map(that._indicators, function(indicator, i) {
- if (isRecreate) {
- indicator.dispose();
- indicator = that._createIndicator();
- indicator.setup(that._indicatorParameters);
- indicator._trackerInfo = {
- type: that._parameters.trackerType,
- index: i
- }
- }
- indicator.render(that._getIndicatorOptions(i));
- return indicator
- })
- }
- return that
- },
- resize: function(layout) {
- var that = this;
- that._layout = layout;
- _each(that._indicators, function(_, indicator) {
- indicator.resize(layout)
- });
- return that
- },
- measure: function(layout) {
- return this._sample.measure(layout)
- },
- _getIndicatorOptions: function(index) {
- var result = this._options;
- if (this._colorPalette)
- result = _extend({}, result, {color: this._colorPalette[index]});
- return result
- },
- _generatePalette: function(count) {
- var that = this,
- colors = null;
- if (that._palette) {
- colors = [];
- that._palette.reset();
- var i = 0;
- for (; i < count; ++i)
- colors.push(that._palette.getNextColor())
- }
- that._colorPalette = colors
- },
- _adjustIndicatorsCount: function(count) {
- var that = this,
- indicators = that._indicators,
- i,
- ii,
- indicatorOptions,
- indicator,
- indicatorsLen = indicators.length,
- palette = that._parameters.palette;
- if (indicatorsLen > count) {
- for (i = count, ii = indicatorsLen; i < ii; ++i)
- indicators[i].clean().dispose();
- that._indicators = indicators.slice(0, count);
- that._generatePalette(indicators.length)
- }
- else if (indicatorsLen < count) {
- that._generatePalette(count);
- for (i = indicatorsLen, ii = count; i < ii; ++i) {
- indicator = that._createIndicator();
- indicator.setup(that._indicatorParameters);
- indicator._trackerInfo = {
- type: that._parameters.trackerType,
- index: i
- };
- indicator.render(that._getIndicatorOptions(i)).resize(that._layout);
- indicators.push(indicator)
- }
- }
- },
- values: function(arg, _noAnimation) {
- var that = this;
- if (!that.enabled)
- return;
- if (arg !== undefined) {
- if (!_isArray(arg))
- arg = _isFinite(arg) ? [Number(arg)] : null;
- if (arg) {
- that._adjustIndicatorsCount(arg.length);
- _each(that._indicators, function(i, indicator) {
- indicator.value(arg[i], _noAnimation)
- })
- }
- return that
- }
- return _map(that._indicators, function(indicator) {
- return indicator.value()
- })
- }
- })
- })(DevExpress, jQuery);
- /*! Module viz-gauges, file circularGauge.js */
- (function(DX, $, undefined) {
- var factory = DX.viz.gauges.__factory;
- var isFinite = window.isFinite,
- Number = window.Number,
- normalizeAngle = DX.utils.normalizeAngle,
- getCosAndSin = DX.utils.getCosAndSin,
- abs = Math.abs,
- max = Math.max,
- min = Math.min,
- round = Math.round,
- slice = Array.prototype.slice,
- $extend = $.extend,
- $each = $.each;
- var PI = Math.PI;
- function getSides(startAngle, endAngle) {
- var startCosSin = getCosAndSin(startAngle),
- endCosSin = getCosAndSin(endAngle),
- startCos = startCosSin.cos,
- startSin = startCosSin.sin,
- endCos = endCosSin.cos,
- endSin = endCosSin.sin;
- return {
- left: startSin <= 0 && endSin >= 0 || startSin <= 0 && endSin <= 0 && startCos <= endCos || startSin >= 0 && endSin >= 0 && startCos >= endCos ? -1 : min(startCos, endCos, 0),
- right: startSin >= 0 && endSin <= 0 || startSin >= 0 && endSin >= 0 && startCos >= endCos || startSin <= 0 && endSin <= 0 && startCos <= endCos ? 1 : max(startCos, endCos, 0),
- up: startCos <= 0 && endCos >= 0 || startCos <= 0 && endCos <= 0 && startSin >= endSin || startCos >= 0 && endCos >= 0 && startSin <= endSin ? -1 : -max(startSin, endSin, 0),
- down: startCos >= 0 && endCos <= 0 || startCos >= 0 && endCos >= 0 && startSin <= endSin || startCos <= 0 && endCos <= 0 && startSin >= endSin ? 1 : -min(startSin, endSin, 0)
- }
- }
- DX.viz.gauges.CircularGauge = DX.viz.gauges.Gauge.inherit({
- _rootClass: 'dxg-circular-gauge',
- _selectMode: function() {
- this.callBase.apply(this, arguments);
- if (typeof this.indicatorValue === 'function')
- this._createValueIndicatorInHardMode = function(type) {
- return factory.createCircularValueIndicatorInHardMode(type)
- }
- },
- _setupCodomain: function() {
- var that = this,
- geometry = that.option('geometry') || {},
- startAngle = geometry.startAngle,
- endAngle = geometry.endAngle,
- sides;
- startAngle = isFinite(startAngle) ? normalizeAngle(startAngle) : 225;
- endAngle = isFinite(endAngle) ? normalizeAngle(endAngle) : -45;
- if (abs(startAngle - endAngle) < 1) {
- endAngle -= 360;
- sides = {
- left: -1,
- up: -1,
- right: 1,
- down: 1
- }
- }
- else {
- startAngle < endAngle && (endAngle -= 360);
- sides = getSides(startAngle, endAngle)
- }
- that._area = {
- x: 0,
- y: 0,
- radius: 100,
- startCoord: startAngle,
- endCoord: endAngle,
- scaleRadius: geometry.scaleRadius > 0 ? Number(geometry.scaleRadius) : undefined,
- sides: sides
- };
- that._translator.setCodomain(startAngle, endAngle)
- },
- _measureMainElements: function(elements) {
- var that = this,
- maxRadius = 0,
- minRadius = Infinity,
- maxHorizontalOffset = 0,
- maxVerticalOffset = 0,
- maxInverseHorizontalOffset = 0,
- maxInverseVerticalOffset = 0;
- $each(elements, function(_, element) {
- var bounds = element.measure({radius: that._area.radius - (Number(element._options.offset) || 0)});
- bounds.min > 0 && (minRadius = min(minRadius, bounds.min));
- bounds.max > 0 && (maxRadius = max(maxRadius, bounds.max));
- bounds.horizontalOffset > 0 && (maxHorizontalOffset = max(maxHorizontalOffset, bounds.max + bounds.horizontalOffset));
- bounds.verticalOffset > 0 && (maxVerticalOffset = max(maxVerticalOffset, bounds.max + bounds.verticalOffset));
- bounds.inverseHorizontalOffset > 0 && (maxInverseHorizontalOffset = max(maxInverseHorizontalOffset, bounds.inverseHorizontalOffset));
- bounds.inverseVerticalOffset > 0 && (maxInverseVerticalOffset = max(maxInverseVerticalOffset, bounds.inverseVerticalOffset))
- });
- maxHorizontalOffset = max(maxHorizontalOffset - maxRadius, 0);
- maxVerticalOffset = max(maxVerticalOffset - maxRadius, 0);
- return {
- minRadius: minRadius,
- maxRadius: maxRadius,
- horizontalMargin: maxHorizontalOffset,
- verticalMargin: maxVerticalOffset,
- inverseHorizontalMargin: maxInverseHorizontalOffset,
- inverseVerticalMargin: maxInverseVerticalOffset
- }
- },
- _applyMainLayout: function(elements) {
- var that = this,
- measurements = that._measureMainElements(elements),
- area = that._area,
- sides = area.sides,
- margins = {
- left: (sides.left < -0.1 ? measurements.horizontalMargin : measurements.inverseHorizontalMargin) || 0,
- right: (sides.right > 0.1 ? measurements.horizontalMargin : measurements.inverseHorizontalMargin) || 0,
- top: (sides.up < -0.1 ? measurements.verticalMargin : measurements.inverseVerticalMargin) || 0,
- bottom: (sides.down > 0.1 ? measurements.verticalMargin : measurements.inverseVerticalMargin) || 0
- },
- rect = that._layoutManager.selectRectByAspectRatio((sides.down - sides.up) / (sides.right - sides.left), margins),
- radius = min(rect.width() / (sides.right - sides.left), rect.height() / (sides.down - sides.up)),
- x,
- y;
- var scaler = (measurements.maxRadius - area.radius + area.scaleRadius) / radius;
- if (0 < scaler && scaler < 1) {
- rect = rect.scale(scaler);
- radius *= scaler
- }
- radius = radius - measurements.maxRadius + area.radius;
- x = rect.left - rect.width() * sides.left / (sides.right - sides.left);
- y = rect.top - rect.height() * sides.up / (sides.down - sides.up);
- area.x = round(x);
- area.y = round(y);
- area.radius = radius;
- rect.left -= margins.left;
- rect.right += margins.right;
- rect.top -= margins.top;
- rect.bottom += margins.bottom;
- that._layoutManager.setRect(rect)
- },
- _updateElementPosition: function(element) {
- element.resize({
- x: this._area.x,
- y: this._area.y,
- radius: round(this._area.radius - (Number(element._options.offset) || 0))
- })
- },
- _createScale: function(parameters) {
- return factory.createCircularScale(parameters)
- },
- _createRangeContainer: function(parameters) {
- return factory.createCircularRangeContainer(parameters)
- },
- _createValueIndicator: function(type) {
- return factory.createCircularValueIndicator(type)
- },
- _createSubvalueIndicator: function(type) {
- return factory.createCircularSubvalueIndicator(type)
- },
- _getApproximateScreenRange: function() {
- var that = this,
- area = that._area,
- r = min(that._width / (area.sides.right - area.sides.left), that._height / (area.sides.down - area.sides.up));
- r > area.totalRadius && (r = area.totalRadius);
- r = 0.8 * r;
- return -that._translator.getCodomainRange() * r * PI / 180
- },
- _getDefaultContainerSize: function() {
- return {
- width: 300,
- height: 300
- }
- },
- _getPreset: function() {
- var preset = this.option('preset'),
- result;
- if (preset === 'preset2')
- result = {
- commonNeedleSettings: {type: 'twocolorrectangle'},
- commonMarkerSettings: {type: 'triangle'}
- };
- else if (preset === 'preset3')
- result = {
- commonNeedleSettings: {type: 'rectangle'},
- commonMarkerSettings: {type: 'triangle'}
- };
- else
- result = {
- commonNeedleSettings: {type: 'rectangle'},
- commonMarkerSettings: {type: 'textcloud'}
- };
- return result
- },
- _createNeedle: function(type) {
- return factory.createCircularNeedle(type)
- },
- _createMarker: function(type) {
- return factory.createCircularMarker(type)
- },
- _createRangeBar: function() {
- return factory.createCircularRangeBar()
- },
- _prepareObsoleteSpindle: function() {
- var that = this,
- spindleOption = that.option('spindle') || {},
- visible = that._needles && ('visible' in spindleOption ? !!spindleOption.visible : true);
- if (visible) {
- var themeOption = that._themeManager.theme().valueIndicator._default,
- size = spindleOption.size || themeOption.spindleSize;
- visible = size > 0
- }
- if (visible) {
- var gapSize = spindleOption.gapSize || themeOption.spindleGapSize,
- color = spindleOption.color || themeOption.color;
- gapSize = gapSize <= size ? gapSize : size;
- that._spindle = that._spindle || that._renderer.createGroup({'class': 'dxg-value-indicator'});
- that._spindle.append(that._root);
- that._spindleOuter = that._spindleOuter || that._renderer.createCircle(0, 0, 0, {
- 'class': 'dxg-spindle-border',
- stroke: 'none',
- strokeWidth: 0
- }).append(that._spindle);
- that._spindleInner = that._spindleInner || that._renderer.createCircle(0, 0, 0, {
- 'class': 'dxg-spindle-hole',
- stroke: 'none',
- strokeWidth: 0
- }).append(that._spindle);
- that._spindleOuter.applySettings({
- cx: that._area.x,
- cy: that._area.y,
- r: size / 2,
- fill: color
- });
- that._spindleInner.applySettings({
- cx: that._area.x,
- cy: that._area.y,
- r: gapSize / 2,
- fill: that._containerBackgroundColor
- });
- return {
- enabled: true,
- _options: {offset: 0},
- measure: function(layout) {
- return {}
- },
- resize: function(layout) {
- that._spindleOuter.applySettings({
- cx: layout.x,
- cy: layout.y
- });
- that._spindleInner.applySettings({
- cx: layout.x,
- cy: layout.y
- });
- return that
- }
- }
- }
- else {
- that._spindle && that._spindle.remove();
- delete that._spindle;
- delete that._spindleOuter;
- delete that._spindleInner;
- return null
- }
- }
- });
- DX.viz.gauges.CircularGauge.prototype._factory = DX.utils.clone(DX.viz.gauges.__internals.BaseGauge.prototype._factory);
- DX.viz.gauges.CircularGauge.prototype._factory.createThemeManager = function() {
- var themeManager = new DX.viz.gauges.__internals.ThemeManager;
- themeManager._subTheme = '_circular';
- return themeManager
- }
- })(DevExpress, jQuery);
- /*! Module viz-gauges, file linearGauge.js */
- (function(DX, $, undefined) {
- var factory = DX.viz.gauges.__factory;
- var _String = String,
- _Number = Number,
- max = Math.max,
- min = Math.min,
- round = Math.round,
- slice = Array.prototype.slice,
- $extend = $.extend,
- $each = $.each;
- DX.viz.gauges.LinearGauge = DX.viz.gauges.Gauge.inherit({
- _rootClass: 'dxg-linear-gauge',
- _selectMode: function() {
- this.callBase.apply(this, arguments);
- if (typeof this.indicatorValue === 'function')
- this._createValueIndicatorInHardMode = function(type) {
- return factory.createLinearValueIndicatorInHardMode(type)
- }
- },
- _setupCodomain: function() {
- var that = this,
- geometry = that.option('geometry') || {},
- vertical = _String(geometry.orientation).toLowerCase() === 'vertical';
- that._area = {
- vertical: vertical,
- x: 0,
- y: 0,
- startCoord: -100,
- endCoord: 100,
- scaleSize: geometry.scaleSize > 0 ? _Number(geometry.scaleSize) : undefined
- };
- that._scale.vertical = vertical;
- that._rangeContainer.vertical = vertical
- },
- _measureMainElements: function(elements) {
- var that = this,
- minBound = 1000,
- maxBound = 0,
- indent = 0;
- $each(elements, function(_, element) {
- var bounds = element.measure({
- x: that._area.x + (_Number(element._options.offset) || 0),
- y: that._area.y + (_Number(element._options.offset) || 0)
- });
- maxBound = max(maxBound, bounds.max);
- minBound = min(minBound, bounds.min);
- bounds.indent > 0 && (indent = max(indent, bounds.indent))
- });
- return {
- minBound: minBound,
- maxBound: maxBound,
- indent: indent
- }
- },
- _applyMainLayout: function(elements) {
- var that = this,
- measurements = that._measureMainElements(elements),
- area = that._area,
- rect,
- offset,
- counterSize = area.scaleSize + 2 * measurements.indent;
- if (area.vertical) {
- rect = that._layoutManager.selectRectBySizes({
- width: measurements.maxBound - measurements.minBound,
- height: counterSize
- });
- offset = rect.horizontalMiddle() - (measurements.minBound + measurements.maxBound) / 2;
- area.startCoord = rect.bottom - measurements.indent;
- area.endCoord = rect.top + measurements.indent;
- area.x = round(area.x + offset)
- }
- else {
- rect = that._layoutManager.selectRectBySizes({
- height: measurements.maxBound - measurements.minBound,
- width: counterSize
- });
- offset = rect.verticalMiddle() - (measurements.minBound + measurements.maxBound) / 2;
- area.startCoord = rect.left + measurements.indent;
- area.endCoord = rect.right - measurements.indent;
- area.y = round(area.y + offset)
- }
- that._translator.setCodomain(area.startCoord, area.endCoord);
- that._layoutManager.setRect(rect)
- },
- _updateElementPosition: function(element) {
- element.resize({
- x: round(this._area.x + (_Number(element._options.offset) || 0)),
- y: round(this._area.y + (_Number(element._options.offset) || 0))
- })
- },
- _createScale: function(parameters) {
- return factory.createLinearScale(parameters)
- },
- _createRangeContainer: function(parameters) {
- return factory.createLinearRangeContainer(parameters)
- },
- _createValueIndicator: function(type) {
- return factory.createLinearValueIndicator(type)
- },
- _createSubvalueIndicator: function(type) {
- return factory.createLinearSubvalueIndicator(type)
- },
- _getApproximateScreenRange: function() {
- var that = this,
- area = that._area,
- s = area.vertical ? that._height : that._width;
- s > area.totalSize && (s = area.totalSize);
- s = s * 0.8;
- return s
- },
- _getDefaultContainerSize: function() {
- var geometry = this.option('geometry') || {};
- if (geometry.orientation === 'vertical')
- return {
- width: 100,
- height: 300
- };
- else
- return {
- width: 300,
- height: 100
- }
- },
- _getPreset: function() {
- var preset = this.option('preset'),
- result;
- if (preset === 'preset2')
- result = {
- commonNeedleSettings: {type: 'rhombus'},
- commonMarkerSettings: {type: 'triangle'}
- };
- else
- result = {
- commonNeedleSettings: {type: 'circle'},
- commonMarkerSettings: {type: 'textcloud'}
- };
- return result
- },
- _createNeedle: function(type) {
- return factory.createLinearNeedle(type)
- },
- _createMarker: function(type) {
- return factory.createLinearMarker(type)
- },
- _createRangeBar: function() {
- return factory.createLinearRangeBar()
- }
- });
- DX.viz.gauges.LinearGauge.prototype._factory = DX.utils.clone(DX.viz.gauges.__internals.BaseGauge.prototype._factory);
- DX.viz.gauges.LinearGauge.prototype._factory.createThemeManager = function() {
- var themeManager = new DX.viz.gauges.__internals.ThemeManager;
- themeManager._subTheme = '_linear';
- return themeManager
- }
- })(DevExpress, jQuery);
- /*! Module viz-gauges, file barGauge.js */
- (function(DX, $, undefined) {
- var PI = Math.PI;
- var _Number = window.Number,
- _isFinite = window.isFinite,
- _abs = Math.abs,
- _round = Math.round,
- _floor = Math.floor,
- _min = Math.min,
- _max = Math.max,
- _isArray = DX.utils.isArray,
- _convertAngleToRendererSpace = DX.utils.convertAngleToRendererSpace,
- _getCosAndSin = DX.utils.getCosAndSin,
- _noop = $.noop,
- _extend = $.extend,
- _getSampleText = DX.viz.gauges.__internals.getSampleText,
- _formatValue = DX.viz.gauges.__internals.formatValue;
- var _Rectangle = DX.viz.core.Rectangle,
- _Palette = DX.viz.core.Palette;
- DX.viz.gauges.BarGauge = DX.viz.gauges.__internals.BaseGauge.inherit({
- _rootClass: 'dxbg-bar-gauge',
- _init: function() {
- var that = this;
- that.callBase.apply(that, arguments);
- that._barsGroup = that._renderer.createGroup({'class': 'dxbg-bars'});
- that._values = [];
- that._context = {
- renderer: that._renderer,
- translator: that._translator,
- tracker: that._tracker,
- group: that._barsGroup
- };
- that._animateStep = function(pos) {
- var bars = that._bars,
- i = 0,
- ii = bars.length;
- for (; i < ii; ++i)
- bars[i].animate(pos)
- };
- that._animateComplete = function() {
- var bars = that._bars,
- i = 0,
- ii = bars.length;
- for (; i < ii; ++i)
- bars[i].endAnimation()
- }
- },
- _dispose: function() {
- var that = this;
- that.callBase.apply(that, arguments);
- that._barsGroup = that._values = that._context = that._animateStep = that._animateComplete = null
- },
- _setupDomain: function() {
- var that = this,
- startValue = that.option('startValue'),
- endValue = that.option('endValue');
- _isFinite(startValue) || (startValue = 0);
- _isFinite(endValue) || (endValue = 100);
- that._translator.setDomain(startValue, endValue);
- that._baseValue = that._translator.adjust(that.option('baseValue'));
- _isFinite(that._baseValue) || (that._baseValue = startValue < endValue ? startValue : endValue)
- },
- _calculateSizeCore: function() {
- var that = this,
- size = that.option('size') || {};
- if (_Number(size.width) === 0 || _Number(size.height) === 0) {
- that._width = that._height = 0;
- that._rootRect = new _Rectangle
- }
- else {
- that._width = size.width > 0 ? _Number(size.width) : that._element().width() || 300;
- that._height = size.height > 0 ? _Number(size.height) : that._element().height() || 300;
- that._rootRect = new _Rectangle({
- left: 0,
- top: 0,
- right: that._width,
- bottom: that._height
- })
- }
- },
- _setupCodomain: DX.viz.gauges.CircularGauge.prototype._setupCodomain,
- _getApproximateScreenRange: function() {
- var that = this,
- sides = that._area.sides,
- width = that._width / (sides.right - sides.left),
- height = that._height / (sides.down - sides.up),
- r = width < height ? width : height;
- return -that._translator.getCodomainRange() * r * PI / 180
- },
- _setupAnimationSettings: function() {
- this.callBase();
- if (this._animationSettings)
- _extend(this._animationSettings, {
- step: this._animateStep,
- complete: this._animateComplete
- })
- },
- _cleanContent: function() {
- var that = this;
- that._barsGroup.detach();
- that._animationSettings && that._barsGroup.stopAnimation();
- var i = 0,
- ii = that._bars ? that._bars.length : 0;
- for (; i < ii; ++i)
- that._bars[i].dispose();
- that._palette = that._bars = null
- },
- _renderContent: function() {
- var that = this,
- labelOptions = that.option('label');
- that._barsGroup.append(that._root);
- that._context.textEnabled = labelOptions === undefined || labelOptions && (!('visible' in labelOptions) || labelOptions.visible);
- if (that._context.textEnabled) {
- that._context.textColor = labelOptions && labelOptions.font && labelOptions.font.color || null;
- labelOptions = _extend(true, {}, that._themeManager.theme().label, labelOptions);
- that._context.formatOptions = {
- format: labelOptions.format !== undefined || labelOptions.precision !== undefined ? labelOptions.format : that._defaultFormatOptions.format,
- precision: labelOptions.format !== undefined || labelOptions.precision !== undefined ? labelOptions.precision : that._defaultFormatOptions.precision,
- customizeText: labelOptions.customizeText
- };
- that._context.textOptions = {
- font: _extend({}, that._themeManager.theme().label.font, labelOptions.font, {color: null}),
- align: 'center'
- };
- that._textIndent = labelOptions.indent > 0 ? _Number(labelOptions.indent) : 0;
- that._context.lineWidth = labelOptions.connectorWidth > 0 ? _Number(labelOptions.connectorWidth) : 0;
- that._context.lineColor = labelOptions.connectorColor || null;
- var text = that._renderer.createText(_getSampleText(that._translator, that._context.formatOptions), 0, 0, that._context.textOptions).append(that._barsGroup),
- bbox = text.getBBox();
- text.detach();
- that._context.textVerticalOffset = -bbox.y - bbox.height / 2;
- that._context.textWidth = bbox.width;
- that._context.textHeight = bbox.height
- }
- DX.viz.gauges.CircularGauge.prototype._applyMainLayout.call(that);
- that._renderBars()
- },
- _measureMainElements: function() {
- var result = {maxRadius: this._area.radius};
- if (this._context.textEnabled) {
- result.horizontalMargin = this._context.textWidth;
- result.verticalMargin = this._context.textHeight
- }
- return result
- },
- _renderBars: function() {
- var that = this,
- options = _extend({}, that._themeManager.theme(), that.option());
- that._palette = new _Palette(options.palette, {
- stepHighlight: 50,
- theme: that._themeManager.themeName()
- });
- var relativeInnerRadius = options.relativeInnerRadius > 0 && options.relativeInnerRadius < 1 ? _Number(options.relativeInnerRadius) : 0.1,
- radius = that._area.radius;
- if (that._context.textEnabled) {
- that._textIndent = _round(_min(that._textIndent, radius / 2));
- radius -= that._textIndent
- }
- that._outerRadius = _round(radius);
- that._innerRadius = _round(radius * relativeInnerRadius);
- that._barSpacing = options.barSpacing > 0 ? _Number(options.barSpacing) : 0;
- _extend(that._context, {
- backgroundColor: options.backgroundColor,
- x: that._area.x,
- y: that._area.y,
- startAngle: that._area.startCoord,
- endAngle: that._area.endCoord,
- baseAngle: that._translator.translate(that._baseValue)
- });
- that._bars = [];
- that._updateValues(that.option('values'))
- },
- _arrangeBars: function(count) {
- var that = this,
- radius = that._outerRadius - that._innerRadius;
- that._context.barSize = count > 0 ? _max((radius - (count - 1) * that._barSpacing) / count, 1) : 0;
- var spacing = count > 1 ? _max(_min((radius - count * that._context.barSize) / (count - 1), that._barSpacing), 0) : 0,
- _count = _min(_floor((radius + spacing) / that._context.barSize), count);
- that._setBarsCount(_count);
- radius = that._outerRadius;
- that._context.textRadius = radius + that._textIndent;
- that._palette.reset();
- var unitOffset = that._context.barSize + spacing,
- i = 0;
- for (; i < _count; ++i, radius -= unitOffset)
- that._bars[i].arrange({
- radius: radius,
- color: that._palette.getNextColor()
- })
- },
- _setBarsCount: function(count) {
- var that = this,
- i,
- ii;
- if (that._bars.length > count) {
- for (i = count, ii = that._bars.length; i < ii; ++i)
- that._bars[i].dispose();
- that._bars.splice(count, ii - count)
- }
- else if (that._bars.length < count)
- for (i = that._bars.length, ii = count; i < ii; ++i)
- that._bars.push(new BarWrapper(i, that._context));
- if (that._bars.length > 0) {
- if (that._dummyBackground) {
- that._dummyBackground.detach();
- that._dummyBackground = null
- }
- }
- else {
- if (!that._dummyBackground)
- that._dummyBackground = that._renderer.createArc().append(that._barsGroup);
- that._dummyBackground.applySettings({
- x: that._context.x,
- y: that._context.y,
- outerRadius: that._outerRadius,
- innerRadius: that._innerRadius,
- startAngle: that._context.endAngle,
- endAngle: that._context.startAngle,
- fill: that._context.backgroundColor
- })
- }
- },
- _updateBars: function() {
- var that = this,
- i = 0,
- ii = that._bars.length;
- for (; i < ii; ++i)
- that._bars[i].setValue(that._values[i])
- },
- _animateBars: function() {
- var that = this,
- i = 0,
- ii = that._bars.length;
- if (ii > 0) {
- for (; i < ii; ++i)
- that._bars[i].beginAnimation(that._values[i]);
- that._barsGroup.animate({_: 0}, that._animationSettings)
- }
- },
- _updateValues: function(values, noAnimation) {
- var that = this,
- list = _isArray(values) && values || _isFinite(values) && [values] || [],
- i = 0,
- ii = list.length,
- value;
- that._values = [];
- for (; i < ii; ++i) {
- value = that._translator.adjust(list[i]);
- _isFinite(value) && that._values.push(value)
- }
- that._animationSettings && that._barsGroup.stopAnimation();
- if (that._bars) {
- that._arrangeBars(that._values.length);
- if (that._animationSettings && !that._noAnimation)
- that._animateBars();
- else
- that._updateBars()
- }
- if (!that._resizing) {
- that.option('values', that._values);
- that.hideLoadingIndicator()
- }
- },
- values: function(arg) {
- if (arg !== undefined) {
- this._updateValues(arg);
- return this
- }
- else
- return this._values.slice(0)
- },
- _optionChanged: function(name, newValue, oldValue) {
- switch (name) {
- case'values':
- this._updateValues(newValue);
- break;
- default:
- this.callBase.apply(this, arguments);
- break
- }
- },
- _optionValuesEqual: function(name, oldValue, newValue) {
- switch (name) {
- case'values':
- return compareArrays(oldValue, newValue);
- default:
- return this.callBase.apply(this, arguments)
- }
- }
- });
- var ThemeManager = DX.viz.gauges.__internals.ThemeManager.inherit({
- _themeSection: 'barGauge',
- _initializeTheme: function() {
- var that = this;
- that._initializeFont(that._theme.label.font);
- that._initializeFont(that._theme.title.font);
- that._initializeFont(that._theme.tooltip.font);
- that._initializeFont(that._theme.loadingIndicator.font)
- }
- });
- DX.viz.gauges.BarGauge.prototype._factory = DX.utils.clone(DX.viz.gauges.__internals.BaseGauge.prototype._factory);
- DX.viz.gauges.BarGauge.prototype._factory.createThemeManager = function() {
- return new ThemeManager
- };
- function BarWrapper(index, context) {
- var that = this;
- that._context = context;
- that._background = context.renderer.createArc().append(context.group);
- that._background.applySettings({fill: context.backgroundColor});
- that._bar = context.renderer.createArc().append(context.group);
- if (context.textEnabled) {
- that._line = context.renderer.createPath([], {strokeWidth: context.lineWidth}).append(context.group);
- that._text = context.renderer.createText('', 0, 0, context.textOptions).append(context.group)
- }
- that._tracker = context.renderer.createArc();
- context.tracker.attach(that._tracker, that, {index: index});
- that._index = index;
- that._angle = context.baseAngle;
- that._settings = {
- x: context.x,
- y: context.y,
- startAngle: context.baseAngle,
- endAngle: context.baseAngle
- }
- }
- _extend(BarWrapper.prototype, {
- dispose: function() {
- var that = this;
- that._background.detach();
- that._bar.detach();
- if (that._context.textEnabled) {
- that._line.detach();
- that._text.detach()
- }
- that._context.tracker.detach(that._tracker);
- that._context = that._settings = that._background = that._bar = that._line = that._text = that._tracker = null;
- return that
- },
- arrange: function(options) {
- var that = this;
- that._settings.outerRadius = options.radius;
- that._settings.innerRadius = options.radius - that._context.barSize;
- that._background.applySettings(_extend({}, that._settings, {
- startAngle: that._context.endAngle,
- endAngle: that._context.startAngle
- }));
- that._bar.applySettings(that._settings);
- that._tracker.applySettings(that._settings);
- that._color = options.color;
- that._bar.applySettings({fill: options.color});
- if (that._context.textEnabled) {
- that._line.applySettings({
- points: [that._context.x, that._context.y - that._settings.innerRadius, that._context.x, that._context.y - that._context.textRadius],
- stroke: that._context.lineColor || options.color
- });
- that._text.applySettings({font: {color: that._context.textColor || options.color}})
- }
- return that
- },
- getTooltipParameters: function() {
- var that = this,
- cossin = _getCosAndSin((that._angle + that._context.baseAngle) / 2);
- return {
- x: _round(that._context.x + (that._settings.outerRadius + that._settings.innerRadius) / 2 * cossin.cos),
- y: _round(that._context.y - (that._settings.outerRadius + that._settings.innerRadius) / 2 * cossin.sin),
- offset: 0,
- color: that._color,
- value: that._value
- }
- },
- setAngle: function(angle) {
- var that = this;
- that._angle = angle;
- setAngles(that._settings, that._context.baseAngle, that._angle);
- that._bar.applySettings(that._settings);
- that._tracker.applySettings(that._settings);
- if (that._context.textEnabled) {
- that._line.rotate(_convertAngleToRendererSpace(that._angle), that._context.x, that._context.y);
- var cossin = _getCosAndSin(that._angle);
- that._text.applySettings({
- text: _formatValue(that._value, that._context.formatOptions, {index: that._index}),
- x: that._context.x + (that._context.textRadius + that._context.textWidth * 0.6) * cossin.cos,
- y: that._context.y - (that._context.textRadius + that._context.textHeight * 0.6) * cossin.sin + that._context.textVerticalOffset
- })
- }
- return that
- },
- setValue: function(value) {
- this._value = value;
- return this.setAngle(this._context.translator.translate(value))
- },
- beginAnimation: function(value) {
- var that = this;
- that._value = value;
- var angle = that._context.translator.translate(value);
- if (!compareFloats(that._angle, angle)) {
- that._start = that._angle;
- that._delta = angle - that._angle;
- that._tracker.applySettings({visibility: 'hidden'});
- if (that._context.textEnabled) {
- that._line.applySettings({visibility: 'hidden'});
- that._text.applySettings({visibility: 'hidden'})
- }
- }
- else
- that.animate = _noop
- },
- animate: function(pos) {
- var that = this;
- that._angle = that._start + that._delta * pos;
- setAngles(that._settings, that._context.baseAngle, that._angle);
- that._bar.applySettings(that._settings)
- },
- endAnimation: function() {
- var that = this;
- if (that._delta !== undefined) {
- if (compareFloats(that._angle, that._start + that._delta)) {
- that._tracker.applySettings({visibility: null});
- if (that._context.textEnabled) {
- that._line.applySettings({visibility: null});
- that._text.applySettings({visibility: null})
- }
- that.setAngle(that._angle)
- }
- }
- else
- delete that.animate;
- delete that._start;
- delete that._delta
- }
- });
- function setAngles(target, angle1, angle2) {
- target.startAngle = angle1 < angle2 ? angle1 : angle2;
- target.endAngle = angle1 < angle2 ? angle2 : angle1
- }
- function compareFloats(value1, value2) {
- return _abs(value1 - value2) < 0.0001
- }
- function compareArrays(array1, array2) {
- if (array1 === array2)
- return true;
- if (_isArray(array1) && _isArray(array2) && array1.length === array2.length) {
- for (var i = 0, ii = array1.length; i < ii; ++i)
- if (!compareFloats(array1[i], array2[i]))
- return false;
- return true
- }
- return false
- }
- var __BarWrapper = BarWrapper;
- DX.viz.gauges.__tests.BarWrapper = __BarWrapper;
- DX.viz.gauges.__tests.stubBarWrapper = function(barWrapperType) {
- BarWrapper = barWrapperType
- };
- DX.viz.gauges.__tests.restoreBarWrapper = function() {
- BarWrapper = __BarWrapper
- };
- DX.registerComponent('dxBarGauge', DX.viz.gauges.BarGauge)
- })(DevExpress, jQuery);
- /*! Module viz-gauges, file tracker.js */
- (function(DX, $, undefined) {
- var _setTimeout = window.setTimeout,
- _clearTimeout = window.clearTimeout,
- _extend = $.extend,
- _abs = Math.abs;
- var TOOLTIP_SHOW_DELAY = 300,
- TOOLTIP_HIDE_DELAY = 300,
- TOOLTIP_TOUCH_SHOW_DELAY = 400,
- TOOLTIP_TOUCH_HIDE_DELAY = 300;
- DX.viz.gauges.__internals.Tracker = DX.Class.inherit({
- ctor: function(parameters) {
- DX.utils.debug.assertParam(parameters, 'parameters');
- DX.utils.debug.assertParam(parameters.renderer, 'parameters.renderer');
- DX.utils.debug.assertParam(parameters.container, 'parameters.container');
- var that = this;
- that._container = parameters.container;
- that._element = parameters.renderer.createGroup({
- 'class': 'dxg-tracker',
- stroke: 'none',
- strokeWidth: 0,
- fill: '#000000',
- opacity: 0.0001
- });
- that._showTooltipCallback = function() {
- that._showTooltipTimeout = null;
- var target = that._tooltipEvent.target;
- that._targetEvent = null;
- if (that._tooltipTarget !== target) {
- that._tooltipTarget = target;
- that._callbacks['tooltip-show']()
- }
- };
- that._hideTooltipCallback = function() {
- that._hideTooltipTimeout = null;
- that._targetEvent = null;
- if (that._tooltipTarget) {
- that._callbacks['tooltip-hide']();
- that._tooltipTarget = null
- }
- };
- that._dispose = function() {
- that._showTooltipCallback = that._hideTooltipCallback = that._dispose = null
- };
- that._DEBUG_showTooltipTimeoutSet = that._DEBUG_showTooltipTimeoutCleared = that._DEBUG_hideTooltipTimeoutSet = that._DEBUG_hideTooltipTimeoutCleared = 0
- },
- dispose: function() {
- var that = this;
- that._dispose();
- that.deactivate();
- that._element.off();
- that._container = that._element = that._context = that._callbacks = null;
- return that
- },
- activate: function() {
- this._element.append(this._container);
- return this
- },
- deactivate: function() {
- this._element.detach();
- this._element.clear();
- return this
- },
- attach: function(element, target, info) {
- element.data({
- target: target,
- info: info
- });
- element.append(this._element);
- return this
- },
- detach: function(element) {
- element.detach();
- element.removeData();
- return this
- },
- setTooltipState: function(state) {
- var that = this,
- data;
- that._element.off(tooltipMouseEvents).off(tooltipTouchEvents);
- if (state) {
- data = {tracker: that};
- that._element.on(tooltipMouseEvents, data).on(tooltipTouchEvents, data)
- }
- return that
- },
- setCallbacks: function(callbacks) {
- this._callbacks = callbacks;
- return this
- },
- _showTooltip: function(event, delay) {
- var that = this,
- data = $(event.target).data();
- if (that._tooltipTarget === event.target || that._callbacks['tooltip-prepare'](data.target, data.info)) {
- that._hideTooltipTimeout && ++that._DEBUG_hideTooltipTimeoutCleared;
- _clearTimeout(that._hideTooltipTimeout);
- that._hideTooltipTimeout = null;
- _clearTimeout(that._showTooltipTimeout);
- that._tooltipEvent = event;
- ++that._DEBUG_showTooltipTimeoutSet;
- that._showTooltipTimeout = _setTimeout(that._showTooltipCallback, delay)
- }
- },
- _hideTooltip: function(delay) {
- var that = this;
- that._showTooltipTimeout && ++that._DEBUG_showTooltipTimeoutCleared;
- _clearTimeout(that._showTooltipTimeout);
- that._showTooltipTimeout = null;
- _clearTimeout(that._hideTooltipTimeout);
- ++that._DEBUG_hideTooltipTimeoutSet;
- that._hideTooltipTimeout = _setTimeout(that._hideTooltipCallback, delay)
- }
- });
- var tooltipMouseEvents = {
- 'mouseover.gauge-tooltip': handleTooltipMouseOver,
- 'mouseout.gauge-tooltip': handleTooltipMouseOut
- };
- var tooltipMouseMoveEvents = {'mousemove.gauge-tooltip': handleTooltipMouseMove};
- var tooltipTouchEvents = {'touchstart.gauge-tooltip': handleTooltipTouchStart};
- function handleTooltipMouseOver(event) {
- var tracker = event.data.tracker;
- tracker._x = event.pageX;
- tracker._y = event.pageY;
- tracker._element.off(tooltipMouseMoveEvents).on(tooltipMouseMoveEvents, event.data);
- tracker._showTooltip(event, TOOLTIP_SHOW_DELAY)
- }
- function handleTooltipMouseMove(event) {
- var tracker = event.data.tracker;
- if (tracker._showTooltipTimeout && _abs(event.pageX - tracker._x) > 4 || _abs(event.pageY - tracker._y) > 4) {
- tracker._x = event.pageX;
- tracker._y = event.pageY;
- tracker._showTooltip(event, TOOLTIP_SHOW_DELAY)
- }
- }
- function handleTooltipMouseOut(event) {
- var tracker = event.data.tracker;
- tracker._element.off(tooltipMouseMoveEvents);
- tracker._hideTooltip(TOOLTIP_HIDE_DELAY)
- }
- var active_touch_tooltip_tracker = null;
- DX.viz.gauges.__internals.Tracker._DEBUG_reset = function() {
- active_touch_tooltip_tracker = null
- };
- function handleTooltipTouchStart(event) {
- event.preventDefault();
- var tracker = active_touch_tooltip_tracker;
- if (tracker && tracker !== event.data.tracker)
- tracker._hideTooltip(TOOLTIP_TOUCH_HIDE_DELAY);
- tracker = active_touch_tooltip_tracker = event.data.tracker;
- tracker._showTooltip(event, TOOLTIP_TOUCH_SHOW_DELAY);
- tracker._touch = true
- }
- function handleTooltipDocumentTouchStart(event) {
- var tracker = active_touch_tooltip_tracker;
- if (tracker) {
- if (!tracker._touch) {
- tracker._hideTooltip(TOOLTIP_TOUCH_HIDE_DELAY);
- active_touch_tooltip_tracker = null
- }
- tracker._touch = null
- }
- }
- function handleTooltipDocumentTouchEnd(event) {
- var tracker = active_touch_tooltip_tracker;
- if (tracker)
- if (tracker._showTooltipTimeout) {
- tracker._hideTooltip(TOOLTIP_TOUCH_HIDE_DELAY);
- active_touch_tooltip_tracker = null
- }
- }
- $(window.document).on({
- 'touchstart.gauge-tooltip': handleTooltipDocumentTouchStart,
- 'touchend.gauge-tooltip': handleTooltipDocumentTouchEnd
- })
- })(DevExpress, jQuery);
- /*! Module viz-gauges, file dxCircularGauge.js */
- (function(DX, undefined) {
- DX.registerComponent("dxCircularGauge", DX.viz.gauges.CircularGauge)
- })(DevExpress);
- /*! Module viz-gauges, file dxLinearGauge.js */
- (function(DX, undefined) {
- DX.registerComponent("dxLinearGauge", DX.viz.gauges.LinearGauge)
- })(DevExpress);
- DevExpress.MOD_VIZ_GAUGES = true
- }
- if (!DevExpress.MOD_VIZ_RANGESELECTOR) {
- if (!DevExpress.MOD_VIZ_CORE)
- throw Error('Required module is not referenced: viz-core');
- /*! Module viz-rangeselector, file namespaces.js */
- (function(DevExpress) {
- DevExpress.viz.rangeSelector = {utils: {}}
- })(DevExpress);
- /*! Module viz-rangeselector, file utils.js */
- (function($, DX, undefined) {
- var rangeSelector = DX.viz.rangeSelector,
- utils = rangeSelector.utils,
- dxUtils = DX.utils;
- var INVISIBLE_POS = -1000;
- var findLessOrEqualValueIndex = function(values, value) {
- if (!values || values.length === 0)
- return -1;
- var minIndex = 0,
- maxIndex = values.length - 1,
- index = 0;
- while (maxIndex - minIndex > 1) {
- var index = minIndex + maxIndex >> 1;
- if (values[index] > value)
- maxIndex = index;
- else
- minIndex = index
- }
- return values[maxIndex] <= value ? maxIndex : minIndex
- };
- var findLessOrEqualValue = function(values, value) {
- var index = findLessOrEqualValueIndex(values, value);
- if (values && index >= 0 && index < values.length)
- return values[index];
- return value
- };
- var findNearValue = function(values, value) {
- var index = findLessOrEqualValueIndex(values, value);
- if (values && index >= 0 && index < values.length) {
- if (index + 1 < values.length)
- if (dxUtils.isDate(value)) {
- if (values[index + 1].getTime() - value.getTime() < value.getTime() - values[index].getTime())
- index++
- }
- else if (values[index + 1] - value < value - values[index])
- index++;
- return values[index]
- }
- return value
- };
- var findGreaterOrEqualValue = function(values, value) {
- var index = findLessOrEqualValueIndex(values, value);
- if (values && index >= 0 && index < values.length) {
- if (values[index] < value && index + 1 < values.length)
- index++;
- return values[index]
- }
- return value
- };
- var getInterval = function(valueMin, valueMax, delta) {
- var result,
- minDateDaysCount,
- maxDateDaysCount,
- daysCount,
- prevMaxDaysCount;
- if (dxUtils.isDate(valueMin)) {
- if (delta === 'year' || delta === 'quarter' || delta === 'month')
- return {months: valueMax.getFullYear() * 12 + valueMax.getMonth() - valueMin.getFullYear() * 12 - valueMin.getMonth()};
- else
- return {milliseconds: valueMax.valueOf() - valueMin.valueOf()};
- return result
- }
- else
- return valueMax - valueMin
- };
- var getRootOffsetLeft = function(renderer) {
- return dxUtils.getRootOffset(renderer).left || 0
- };
- var getEventPageX = function(eventArgs) {
- var result = 0;
- if (eventArgs.pageX)
- result = eventArgs.pageX;
- else if (eventArgs.originalEvent && eventArgs.originalEvent.pageX)
- result = eventArgs.originalEvent.pageX;
- if (eventArgs.originalEvent && eventArgs.originalEvent.touches)
- if (eventArgs.originalEvent.touches.length > 0)
- result = eventArgs.originalEvent.touches[0].pageX;
- else if (eventArgs.originalEvent.changedTouches.length > 0)
- result = eventArgs.originalEvent.changedTouches[0].pageX;
- return result
- };
- var getTextBBox = function(renderer, text, fontOptions) {
- var textElement = renderer.createText(text, INVISIBLE_POS, INVISIBLE_POS, {font: fontOptions}).append();
- var textBBox = textElement.getBBox();
- textElement.remove();
- return textBBox
- };
- utils.findLessOrEqualValue = findLessOrEqualValue;
- utils.findNearValue = findNearValue;
- utils.findGreaterOrEqualValue = findGreaterOrEqualValue;
- utils.getInterval = getInterval;
- utils.getRootOffsetLeft = getRootOffsetLeft;
- utils.getEventPageX = getEventPageX;
- utils.getTextBBox = getTextBBox
- })(jQuery, DevExpress);
- /*! Module viz-rangeselector, file baseVisualElement.js */
- (function(DX) {
- DevExpress.viz.rangeSelector.BaseVisualElement = DX.Class.inherit({
- ctor: function(renderer) {
- this._renderer = renderer;
- this._isDrawn = false
- },
- applyOptions: function(options) {
- this._options = options || {};
- this._applyOptions(this._options)
- },
- _applyOptions: function(options){},
- redraw: function(group) {
- var that = this;
- if (!that._isDrawn) {
- that._isDrawn = !(that._draw(group || that._group) === false);
- if (group)
- that._group = group
- }
- else
- that._update(group || that._group)
- },
- isDrawn: function() {
- return !!this._isDrawn
- },
- isInitialized: function() {
- return !!this._options
- },
- _draw: function(group){},
- _update: function(group) {
- group.clear();
- this._draw(group)
- }
- })
- })(DevExpress);
- /*! Module viz-rangeselector, file rangeSelector.js */
- (function($, DX, undefined) {
- var rangeSelector = DX.viz.rangeSelector,
- utils = DX.utils,
- dataUtils = DX.data.utils,
- rangeSelectorUtils = rangeSelector.utils,
- ParseUtils = DX.viz.core.ParseUtils,
- formatHelper = DX.formatHelper,
- core = DX.viz.core,
- _max = Math.max,
- _isDefined = utils.isDefined;
- rangeSelector.consts = {
- fontHeightRatio: 0.55,
- emptySliderMarkerText: '. . .'
- };
- rangeSelector.formatValue = function(value, formatOptions) {
- var formatObject = {
- value: value,
- valueText: formatHelper.format(value, formatOptions.format, formatOptions.precision)
- };
- return String(utils.isFunction(formatOptions.customizeText) ? formatOptions.customizeText.call(formatObject, formatObject) : formatObject.valueText)
- };
- rangeSelector.RangeSelector = core.BaseWidget.inherit(function() {
- var SCALE_TEXT_SPACING = 5;
- var defaultRangeSelectorOptions = {
- size: undefined,
- margin: {
- left: 0,
- top: 0,
- right: 0,
- bottom: 0
- },
- scale: {
- showCustomBoundaryTicks: true,
- showMinorTicks: true,
- startValue: undefined,
- endValue: undefined,
- minorTickCount: undefined,
- minorTickInterval: undefined,
- majorTickInterval: undefined,
- useTicksAutoArrangement: true,
- setTicksAtUnitBeginning: true,
- minRange: undefined,
- maxRange: undefined,
- placeholderHeight: undefined,
- valueType: undefined,
- label: {
- visible: true,
- format: undefined,
- precision: undefined,
- customizeText: undefined
- },
- marker: {
- visible: true,
- label: {
- format: undefined,
- precision: undefined,
- customizeText: undefined
- }
- },
- logarithmBase: 10
- },
- selectedRange: undefined,
- sliderMarker: {
- visible: true,
- format: undefined,
- precision: undefined,
- customizeText: undefined,
- placeholderSize: undefined
- },
- behavior: {
- snapToTicks: true,
- animationEnabled: true,
- moveSelectedRangeByClick: true,
- manualRangeSelectionEnabled: true,
- allowSlidersSwap: true,
- callSelectedRangeChanged: "onMovingComplete"
- },
- background: {
- color: "#C0BAE1",
- visible: true,
- image: {
- url: undefined,
- location: 'full'
- }
- },
- dataSource: undefined,
- dataSourceField: 'arg',
- redrawOnResize: true,
- theme: undefined,
- selectedRangeChanged: null
- };
- var calculateMarkerSize = function(renderer, value, sliderMarkerOptions) {
- var formattedText = value === undefined ? rangeSelector.consts.emptySliderMarkerText : rangeSelector.formatValue(value, sliderMarkerOptions),
- textBBox = rangeSelectorUtils.getTextBBox(renderer, formattedText, sliderMarkerOptions.font);
- return {
- width: Math.ceil(textBBox.width) + 2 * sliderMarkerOptions.padding,
- height: Math.ceil(textBBox.height * rangeSelector.consts.fontHeightRatio) + 2 * sliderMarkerOptions.padding + sliderMarkerOptions.pointerSize
- }
- };
- var calculateScaleLabelHalfWidth = function(renderer, value, scaleOptions) {
- var formattedText = rangeSelector.formatValue(value, scaleOptions.label),
- textBBox = rangeSelectorUtils.getTextBBox(renderer, formattedText, scaleOptions.label.font);
- return Math.ceil(textBBox.width / 2)
- };
- var calculateRangeContainerCanvas = function(size, margin, sliderMarkerSpacing) {
- var canvas = {
- left: margin.left + sliderMarkerSpacing.left,
- top: margin.top + sliderMarkerSpacing.top,
- width: size.width - margin.left - margin.right - sliderMarkerSpacing.left - sliderMarkerSpacing.right,
- height: size.height - margin.top - margin.bottom - sliderMarkerSpacing.top - sliderMarkerSpacing.bottom
- };
- if (canvas.width <= 0)
- canvas.width = 1;
- return canvas
- };
- var parseSliderMarkersPlaceholderSize = function(placeholderSize) {
- var placeholderWidthLeft,
- placeholderWidthRight,
- placeholderHeight;
- if (utils.isNumber(placeholderSize))
- placeholderWidthLeft = placeholderWidthRight = placeholderHeight = placeholderSize;
- else if (placeholderSize) {
- if (utils.isNumber(placeholderSize.height))
- placeholderHeight = placeholderSize.height;
- if (utils.isNumber(placeholderSize.width))
- placeholderWidthLeft = placeholderWidthRight = placeholderSize.width;
- else if (placeholderSize.width) {
- if (utils.isNumber(placeholderSize.width.left))
- placeholderWidthLeft = placeholderSize.width.left;
- if (utils.isNumber(placeholderSize.width.right))
- placeholderWidthRight = placeholderSize.width.right
- }
- }
- return {
- widthLeft: placeholderWidthLeft,
- widthRight: placeholderWidthRight,
- height: placeholderHeight
- }
- };
- var calculateSliderMarkersSpacing = function(renderer, size, scale, sliderMarkerOptions) {
- var leftMarkerSize,
- leftScaleLabelWidth = 0,
- rightScaleLabelWidth = 0,
- rightMarkerSize,
- placeholderWidthLeft = 0,
- placeholderWidthRight = 0,
- placeholderHeight = 0,
- parsedPlaceholderSize,
- markerMaxWidth;
- parsedPlaceholderSize = parseSliderMarkersPlaceholderSize(sliderMarkerOptions.placeholderSize);
- placeholderWidthLeft = parsedPlaceholderSize.widthLeft || 0;
- placeholderWidthRight = parsedPlaceholderSize.widthRight || 0;
- placeholderHeight = parsedPlaceholderSize.height || 0;
- if (sliderMarkerOptions.visible) {
- leftMarkerSize = calculateMarkerSize(renderer, scale.startValue, sliderMarkerOptions);
- rightMarkerSize = calculateMarkerSize(renderer, scale.endValue, sliderMarkerOptions);
- markerMaxWidth = _max(leftMarkerSize.width, rightMarkerSize.width);
- if (!placeholderWidthLeft)
- placeholderWidthLeft = markerMaxWidth;
- if (!placeholderWidthRight)
- placeholderWidthRight = markerMaxWidth;
- if (!placeholderHeight)
- placeholderHeight = _max(leftMarkerSize.height, rightMarkerSize.height)
- }
- if (scale.label.visible) {
- leftScaleLabelWidth = calculateScaleLabelHalfWidth(renderer, scale.startValue, scale);
- rightScaleLabelWidth = calculateScaleLabelHalfWidth(renderer, scale.endValue, scale)
- }
- placeholderWidthLeft = _max(placeholderWidthLeft, leftScaleLabelWidth);
- placeholderWidthRight = _max(placeholderWidthRight, rightScaleLabelWidth);
- return {
- left: placeholderWidthLeft,
- right: placeholderWidthRight,
- top: placeholderHeight,
- bottom: 0
- }
- };
- var clearContainer = function(container) {
- if (container)
- container.empty()
- };
- var getContainer = function(that) {
- return that._element()
- };
- var createRangeContainer = function(rangeContainerOptions) {
- return rangeSelector.rangeSelectorFactory.createRangeContainer(rangeContainerOptions)
- };
- var createTranslator = function(range, canvas) {
- return {
- x: core.CoreFactory.createTranslator2D(range.arg, canvas, {direction: "horizontal"}),
- y: core.CoreFactory.createTranslator2D(range.val, canvas)
- }
- };
- var createTranslatorCanvas = function(sizeOptions, rangeContainerCanvas, scaleLabelsAreaHeight) {
- return {
- left: rangeContainerCanvas.left,
- top: rangeContainerCanvas.top,
- right: sizeOptions.width - rangeContainerCanvas.width - rangeContainerCanvas.left,
- bottom: sizeOptions.height - rangeContainerCanvas.height - rangeContainerCanvas.top + scaleLabelsAreaHeight,
- width: sizeOptions.width,
- height: sizeOptions.height
- }
- };
- var createRenderer = function(that) {
- var renderer = that.option('renderer');
- if (renderer)
- return renderer;
- return core.CoreFactory.createRenderer({
- pathModified: that.option('pathModified'),
- rtl: that.option('rtlEnabled')
- })
- };
- var createThemeManager = function(theme) {
- return rangeSelector.rangeSelectorFactory.createThemeManager(theme)
- };
- var calculateValueType = function(firstValue, secondValue) {
- var types = [$.type(firstValue), $.type(secondValue)];
- $.inArray();
- return $.inArray('date', types) != -1 ? 'datetime' : $.inArray('number', types) != -1 ? 'numeric' : ''
- };
- var createSeriesDataSource = function(that) {
- var seriesDataSource,
- dataSource = that._dataSource && that._dataSource.items(),
- scaleOptions = that.option('scale'),
- chartOptions = that.option('chart') || {},
- valueType = scaleOptions.valueType;
- if (!valueType)
- valueType = calculateValueType(scaleOptions.startValue, scaleOptions.endValue);
- if (dataSource || chartOptions.series) {
- seriesDataSource = new rangeSelector.SeriesDataSource({
- renderer: that.renderer,
- dataSource: dataSource,
- valueType: (valueType || '').toLowerCase(),
- axisType: scaleOptions.type,
- chart: chartOptions,
- dataSourceField: that.option('dataSourceField'),
- backgroundColor: that._userBackgroundColor,
- incidentOccured: that._incidentOccured
- });
- checkLogarithmicOptions(chartOptions.valueAxis, seriesDataSource.themeManager.theme().valueAxis.logarithmBase, that._incidentOccured)
- }
- return seriesDataSource
- };
- var calculateTranslatorRange = function(that, seriesDataSource, scaleOptions) {
- var translatorRange,
- minValue,
- maxValue,
- inverted = false,
- isEqualDates;
- if (_isDefined(scaleOptions.startValue) && _isDefined(scaleOptions.endValue)) {
- inverted = scaleOptions.inverted = scaleOptions.startValue > scaleOptions.endValue;
- minValue = inverted ? scaleOptions.endValue : scaleOptions.startValue;
- maxValue = inverted ? scaleOptions.startValue : scaleOptions.endValue
- }
- else if (_isDefined(scaleOptions.startValue) || _isDefined(scaleOptions.endValue)) {
- minValue = scaleOptions.startValue;
- maxValue = scaleOptions.endValue
- }
- translatorRange = seriesDataSource ? seriesDataSource.getBoundRange() : {
- arg: new core.Range,
- val: new core.Range({isValueRange: true})
- };
- isEqualDates = utils.isDate(minValue) && utils.isDate(maxValue) && minValue.getTime() === maxValue.getTime();
- if (minValue !== maxValue && !isEqualDates)
- translatorRange.arg.addRange({
- invert: inverted,
- min: minValue,
- max: maxValue,
- minVisible: minValue,
- maxVisible: maxValue,
- dataType: scaleOptions.valueType
- });
- translatorRange.arg.addRange({
- base: scaleOptions.logarithmBase,
- axisType: scaleOptions.type
- });
- if (!translatorRange.arg.isDefined()) {
- if (isEqualDates)
- scaleOptions.valueType = 'numeric';
- translatorRange.arg.setStubData(scaleOptions.valueType)
- }
- return translatorRange
- };
- var calculateScaleAreaHeight = function(renderer, scaleOptions, visibleMarkers) {
- var textBBox,
- visibleLabels = scaleOptions.label.visible;
- if (scaleOptions.placeholderHeight)
- return scaleOptions.placeholderHeight;
- else {
- textBBox = rangeSelectorUtils.getTextBBox(renderer, '0', scaleOptions.label.font);
- return (visibleLabels ? scaleOptions.label.topIndent + textBBox.height : 0) + (visibleMarkers ? scaleOptions.marker.topIndent + scaleOptions.marker.separatorHeight : 0)
- }
- };
- var getTicksInfo = function(that, scaleOptions, translators, screenDelta) {
- var isEmpty = scaleOptions.isEmpty,
- tickProvider = core.CoreFactory.getTickProvider(),
- minorTicksOptions,
- majorTicksOptions,
- startValue,
- endValue,
- businessRange = translators.x.getBusinessRange();
- minorTicksOptions = {
- tickInterval: isEmpty ? 0 : that.option('scale').minorTickInterval,
- showCustomBoundaryTicks: scaleOptions.showCustomBoundaryTicks,
- minorTickCount: scaleOptions.minorTickCount
- };
- majorTicksOptions = {
- textOptions: {
- align: 'center',
- font: scaleOptions.label.font
- },
- renderer: that.renderer,
- getText: function(value) {
- return rangeSelector.formatValue(value, scaleOptions.label)
- },
- translator: translators.x,
- isStartTickGenerated: !_isDefined(that.option('scale').majorTickInterval),
- tickInterval: scaleOptions.majorTickInterval,
- textSpacing: SCALE_TEXT_SPACING,
- setTicksAtUnitBeginning: scaleOptions.setTicksAtUnitBeginning,
- useTicksAutoArrangement: scaleOptions.useTicksAutoArrangement,
- hideLabels: isEmpty
- };
- startValue = isEmpty ? businessRange.min : scaleOptions.startValue;
- endValue = isEmpty ? businessRange.max : scaleOptions.endValue;
- return tickProvider.getFullTicks(startValue, endValue, screenDelta, majorTicksOptions, minorTicksOptions, {
- axisType: scaleOptions.type,
- dataType: scaleOptions.valueType,
- base: scaleOptions.logarithmBase
- })
- };
- var updateTickIntervals = function(scaleOptions, screenDelta, incidentOccured) {
- var tickProvider = core.CoreFactory.getTickProvider(),
- tickIntervals = tickProvider.getTickIntervals(scaleOptions.startValue, scaleOptions.endValue, screenDelta, {
- tickInterval: scaleOptions.majorTickInterval,
- incidentOccured: incidentOccured
- }, {
- tickInterval: scaleOptions.minorTickInterval,
- incidentOccured: incidentOccured
- }, {
- axisType: scaleOptions.type,
- dataType: scaleOptions.valueType,
- base: scaleOptions.logarithmBase
- });
- scaleOptions.minorTickInterval = tickIntervals.minorTickInterval;
- scaleOptions.majorTickInterval = tickIntervals.majorTickInterval
- };
- var updateScaleOptions = function(that, seriesDataSource, translatorRange, screenDelta, scaleOptions) {
- var minVisibleX = _isDefined(translatorRange.arg.minVisible) ? translatorRange.arg.minVisible : translatorRange.arg.min,
- maxVisibleX = _isDefined(translatorRange.arg.maxVisible) ? translatorRange.arg.maxVisible : translatorRange.arg.max,
- isEmptyInterval;
- if (seriesDataSource && !seriesDataSource.isEmpty()) {
- scaleOptions.startValue = scaleOptions.inverted ? maxVisibleX : minVisibleX;
- scaleOptions.endValue = scaleOptions.inverted ? minVisibleX : maxVisibleX
- }
- isEmptyInterval = utils.isDate(scaleOptions.startValue) && utils.isDate(scaleOptions.endValue) && scaleOptions.startValue.getTime() === scaleOptions.endValue.getTime() || scaleOptions.startValue === scaleOptions.endValue;
- scaleOptions.isEmpty = !_isDefined(scaleOptions.startValue) || !_isDefined(scaleOptions.endValue) || isEmptyInterval || scaleOptions.valueType === 'string';
- if (scaleOptions.isEmpty)
- scaleOptions.startValue = scaleOptions.endValue = undefined;
- else {
- updateTickIntervals(scaleOptions, screenDelta, that._incidentOccured);
- if (scaleOptions.valueType === 'datetime' && !_isDefined(scaleOptions.label.format))
- if (!scaleOptions.marker.visible)
- scaleOptions.label.format = formatHelper.getDateFormatByTickInterval(scaleOptions.startValue, scaleOptions.endValue, scaleOptions.majorTickInterval);
- else
- scaleOptions.label.format = utils.getDateUnitInterval(scaleOptions.majorTickInterval)
- }
- };
- var prepareSliderMarkersOptions = function(that, scaleOptions, screenDelta) {
- var sliderMarkerOptions = $.extend(true, {}, that.option('sliderMarker')),
- businessInterval;
- if (!sliderMarkerOptions.format) {
- if (!that.option('behavior').snapToTicks && utils.isNumber(scaleOptions.startValue)) {
- businessInterval = Math.abs(scaleOptions.endValue - scaleOptions.startValue);
- sliderMarkerOptions.format = 'fixedPoint';
- sliderMarkerOptions.precision = utils.getSignificantDigitPosition(businessInterval / screenDelta)
- }
- if (scaleOptions.valueType === 'datetime')
- if (!scaleOptions.marker.visible) {
- if (_isDefined(scaleOptions.startValue) && _isDefined(scaleOptions.endValue))
- sliderMarkerOptions.format = formatHelper.getDateFormatByTickInterval(scaleOptions.startValue, scaleOptions.endValue, scaleOptions.minorTickInterval !== 0 ? scaleOptions.minorTickInterval : scaleOptions.majorTickInterval)
- }
- else
- sliderMarkerOptions.format = utils.getDateUnitInterval(_isDefined(scaleOptions.minorTickInterval) && scaleOptions.minorTickInterval !== 0 ? scaleOptions.minorTickInterval : scaleOptions.majorTickInterval)
- }
- return sliderMarkerOptions
- };
- var showScaleMarkers = function(scaleOptions) {
- return scaleOptions.valueType == 'datetime' && scaleOptions.marker.visible
- };
- var updateTranslatorRangeInterval = function(translatorRange, scaleOptions) {
- var intervalX = scaleOptions.minorTickInterval || scaleOptions.majorTickInterval;
- translatorRange = translatorRange.arg.addRange({interval: intervalX})
- };
- var checkLogarithmicOptions = function(options, logarithmBase, incidentOccured) {
- if (!options)
- return;
- if (options.type === 'logarithmic' && options.logarithmBase <= 0 || options.logarithmBase && !$.isNumeric(options.logarithmBase)) {
- options.logarithmBase = logarithmBase;
- incidentOccured('E2104')
- }
- else if (options.type !== 'logarithmic')
- options.logarithmBase = undefined
- };
- var prepareScaleOptions = function(that, seriesDataSource) {
- var scaleOptions = $.extend(true, {}, that.option('scale')),
- incidentOccured = that._incidentOccured,
- parsedValue = 0,
- parseUtils = new ParseUtils({incidentOccured: incidentOccured}),
- valueType = parseUtils.correctValueType((scaleOptions.valueType || '').toLowerCase());
- if (seriesDataSource)
- valueType = seriesDataSource.getCalculatedValueType() || valueType;
- if (!valueType)
- valueType = calculateValueType(scaleOptions.startValue, scaleOptions.endValue) || 'numeric';
- scaleOptions.valueType = valueType;
- if (scaleOptions.valueType === 'string') {
- that._incidentOccured("E2201");
- return scaleOptions
- }
- var parser = parseUtils.getParser(valueType, 'scale');
- if (_isDefined(scaleOptions.startValue)) {
- parsedValue = parser(scaleOptions.startValue);
- if (_isDefined(parsedValue))
- scaleOptions.startValue = parsedValue;
- else {
- scaleOptions.startValue = undefined;
- that._incidentOccured("E2202", ["start"])
- }
- }
- if (_isDefined(scaleOptions.endValue)) {
- parsedValue = parser(scaleOptions.endValue);
- if (_isDefined(parsedValue))
- scaleOptions.endValue = parsedValue;
- else {
- scaleOptions.endValue = undefined;
- that._incidentOccured("E2202", ["end"])
- }
- }
- checkLogarithmicOptions(scaleOptions, defaultRangeSelectorOptions.scale.logarithmBase, that._incidentOccured);
- if (!scaleOptions.type)
- scaleOptions.type = 'continuous';
- scaleOptions.parser = parser;
- return scaleOptions
- };
- var correctSizeOptions = function(that, sizeOptions, scaleOptions) {
- var size = that.option('size') || {};
- if (!sizeOptions.height && size.height !== 0)
- if (scaleOptions.valueType === 'datetime' && scaleOptions.marker.visible !== false)
- sizeOptions.height = 160;
- else
- sizeOptions.height = 120;
- if (!sizeOptions.width && size.width !== 0)
- sizeOptions.width = 400
- };
- var applyOptions = function(that) {
- var rangeContainerCanvas,
- seriesDataSource,
- translatorRange,
- scaleLabelsAreaHeight,
- sizeOptions,
- sliderMarkerSpacing,
- sliderMarkerOptions,
- selectedRange,
- $container = that.container;
- that._isUpdating = true;
- sizeOptions = calculateSize(that);
- that._actualSize = sizeOptions;
- seriesDataSource = createSeriesDataSource(that);
- that._scaleOptions = prepareScaleOptions(that, seriesDataSource);
- correctSizeOptions(that, sizeOptions, that._scaleOptions);
- if (!sizeOptions.width || !sizeOptions.height || !$container.is(':visible')) {
- that.stopRedraw = true;
- that._incidentOccured("W2001", [that.NAME]);
- return
- }
- else
- that.stopRedraw = false;
- updateRendererSize(that, sizeOptions);
- that._updateLoadIndicator(undefined, that.canvas.width, that.canvas.height);
- translatorRange = calculateTranslatorRange(that, seriesDataSource, that._scaleOptions);
- updateScaleOptions(that, seriesDataSource, translatorRange, sizeOptions.width, that._scaleOptions);
- updateTranslatorRangeInterval(translatorRange, that._scaleOptions);
- sliderMarkerOptions = prepareSliderMarkersOptions(that, that._scaleOptions, sizeOptions.width);
- selectedRange = initSelection(that, that._scaleOptions);
- sliderMarkerSpacing = calculateSliderMarkersSpacing(that.renderer, sizeOptions, that._scaleOptions, sliderMarkerOptions);
- rangeContainerCanvas = calculateRangeContainerCanvas(sizeOptions, that.option('margin'), sliderMarkerSpacing);
- scaleLabelsAreaHeight = calculateScaleAreaHeight(that.renderer, that._scaleOptions, showScaleMarkers(that._scaleOptions));
- that.translators = createTranslator(translatorRange, createTranslatorCanvas(sizeOptions, rangeContainerCanvas, scaleLabelsAreaHeight));
- that._scaleOptions.ticksInfo = getTicksInfo(that, that._scaleOptions, that.translators, rangeContainerCanvas.width);
- that._testTicksInfo = that._scaleOptions.ticksInfo;
- that._selectedRange = selectedRange;
- if (seriesDataSource)
- seriesDataSource.adjustSeriesDimensions(that.translators);
- that.rangeContainer.applyOptions({
- canvas: rangeContainerCanvas,
- scaleLabelsAreaHeight: scaleLabelsAreaHeight,
- sliderMarkerSpacing: sliderMarkerSpacing,
- translators: that.translators,
- selectedRange: selectedRange,
- scale: that._scaleOptions,
- behavior: that.option('behavior'),
- background: that.option('background'),
- chart: that.option('chart'),
- seriesDataSource: seriesDataSource,
- sliderMarker: sliderMarkerOptions,
- sliderHandle: that.option('sliderHandle'),
- shutter: that.option('shutter'),
- selectedRangeChanged: createSelectedRangeChangedFunction(that),
- setSelectedRange: function(selectedRange) {
- that.setSelectedRange(selectedRange)
- }
- });
- that._isUpdating = false
- };
- var createSelectedRangeChangedFunction = function(that) {
- return function(selectedRange, blockSelectedRangeChanged) {
- var selectedRangeChanged = that.option('selectedRangeChanged');
- that.option('selectedRange', selectedRange);
- if (selectedRangeChanged && !blockSelectedRangeChanged)
- setTimeout(function() {
- selectedRangeChanged.call(null, selectedRange)
- })
- }
- };
- var calculateSize = function(that) {
- var $container = that.container,
- size = that.option('size') || {},
- result = {
- width: size.width,
- height: size.height
- };
- if ($container) {
- if (!result.width)
- result.width = $container.width();
- if (!result.height)
- result.height = $container.height()
- }
- that.canvas = result;
- return result
- };
- var updateRendererSize = function(that, size) {
- var renderer = that.renderer;
- if (renderer.isInitialized())
- renderer.getRoot().applySettings({
- width: size.width,
- height: size.height
- });
- else {
- renderer.recreateCanvas(size.width, size.height);
- renderer.draw(that.container[0])
- }
- };
- var prepareChartThemeOptions = function(that, options) {
- var chartTheme,
- chartOption = that.option('chart') || {};
- if (!chartOption.theme && options && options.theme) {
- chartTheme = options.theme;
- if (chartTheme) {
- if (typeof chartTheme === 'object') {
- chartTheme = chartTheme.chart || {};
- chartTheme.name = options.theme.name
- }
- chartOption.theme = chartTheme
- }
- }
- };
- var initSelection = function(that, scaleOptions) {
- var selectedRangeOptions = that.option('selectedRange'),
- startValue,
- endValue,
- parser = scaleOptions.parser || function() {
- return null
- },
- parseValue = function(value, entity) {
- var parsedValue,
- result = scaleOptions[entity];
- if (_isDefined(value))
- parsedValue = parser(value);
- if (!_isDefined(parsedValue))
- that._incidentOccured("E2203", [entity]);
- else
- result = parsedValue;
- return result
- };
- if (!selectedRangeOptions)
- return {
- startValue: scaleOptions.startValue,
- endValue: scaleOptions.endValue
- };
- else {
- startValue = parseValue(selectedRangeOptions.startValue, 'startValue');
- startValue = that.rangeContainer.slidersContainer.truncateSelectedRange(startValue, scaleOptions);
- endValue = parseValue(selectedRangeOptions.endValue, 'endValue');
- endValue = that.rangeContainer.slidersContainer.truncateSelectedRange(endValue, scaleOptions);
- return {
- startValue: startValue,
- endValue: endValue
- }
- }
- };
- var _isSizeChanged = function(that) {
- var actualSize = that._actualSize,
- newSize = calculateSize(that);
- return actualSize && (actualSize.width !== newSize.width || actualSize.height !== newSize.height)
- };
- return {
- isSizeChanged: function() {
- return _isSizeChanged(this)
- },
- _setDefaultOptions: function() {
- this.callBase();
- this.option(defaultRangeSelectorOptions)
- },
- _dataSourceOptions: function() {
- return {
- paginate: false,
- _preferSync: true
- }
- },
- _init: function() {
- var that = this;
- that.container = getContainer(that);
- clearContainer(that.container);
- that.renderer = createRenderer(that);
- that.rangeContainer = createRangeContainer(that.renderer);
- that.callBase();
- that._reinitDataSource()
- },
- _reinitDataSource: function() {
- this._refreshDataSource()
- },
- _dispose: function() {
- var that = this,
- disposeObject = function(propName) {
- that[propName] && that[propName].dispose(),
- that[propName] = null
- };
- that.callBase();
- disposeObject("renderer");
- that.translators = null;
- disposeObject("rangeContainer")
- },
- _initOptions: function(options) {
- var that = this,
- themeManager;
- that._optionsInitializing = true;
- options = options || {};
- that._userOptions = $.extend(true, {}, options);
- themeManager = createThemeManager(options.theme);
- themeManager.setBackgroundColor(options.containerBackgroundColor);
- that.option(themeManager.applyRangeSelectorTheme(options));
- prepareChartThemeOptions(that, options);
- if (options.background)
- that._userBackgroundColor = options.background.color
- },
- _refresh: function() {
- var that = this,
- callBase = that.callBase;
- that._endLoading(function() {
- callBase.call(that)
- })
- },
- _render: function(isResizing) {
- var that = this,
- currentAnimationEnabled,
- behaviorOptions;
- that._optionsInitializing = false;
- applyOptions(that);
- if (!that.stopRedraw) {
- if (isResizing) {
- behaviorOptions = that.option('behavior');
- currentAnimationEnabled = behaviorOptions.animationEnabled;
- behaviorOptions.animationEnabled = false;
- that.rangeContainer.redraw();
- behaviorOptions.animationEnabled = currentAnimationEnabled
- }
- else
- that.rangeContainer.redraw();
- !isResizing && (!that._dataSource || that._dataSource && that._dataSource.isLoaded()) && that.hideLoadingIndicator()
- }
- that._drawn();
- that.__rendered && that.__rendered()
- },
- _optionChanged: function(name, value, prevValue) {
- var that = this;
- if (!that._optionsInitializing)
- dataUtils.compileSetter(name)(that._userOptions, value, {
- functionsAsIs: true,
- merge: true
- });
- if (name === "dataSource") {
- that._reinitDataSource();
- that._invalidate()
- }
- else if (name === "selectedRange")
- that.setSelectedRange(that.option('selectedRange'));
- else if (name === "selectedRangeChanged")
- that.rangeContainer.slidersContainer.selectedRangeChanged = createSelectedRangeChangedFunction(that);
- else if (name === 'containerBackgroundColor' || name === 'theme') {
- that._initOptions(that._userOptions);
- that._invalidate()
- }
- else
- that.callBase(name, value, prevValue)
- },
- _resize: function() {
- if (_isSizeChanged(this))
- this._render(true)
- },
- _handleDataSourceChanged: function() {
- var that = this;
- that._endLoading(function() {
- if (that.renderer.isInitialized())
- that._render()
- })
- },
- getSelectedRange: function() {
- var that = this;
- var selectedRange = that.rangeContainer.slidersContainer.getSelectedRange();
- return {
- startValue: selectedRange.startValue,
- endValue: selectedRange.endValue
- }
- },
- setSelectedRange: function(selectedRange) {
- var that = this;
- if (that._isUpdating || !selectedRange)
- return;
- var oldSelectedRange = that.rangeContainer.slidersContainer.getSelectedRange();
- if (oldSelectedRange && oldSelectedRange.startValue === selectedRange.startValue && oldSelectedRange.endValue === selectedRange.endValue)
- return;
- that.rangeContainer.slidersContainer.setSelectedRange(selectedRange)
- },
- resetSelectedRange: function(blockSelectedRangeChanged) {
- var that = this;
- that.setSelectedRange({
- startValue: that._scaleOptions.startValue,
- endValue: that._scaleOptions.endValue,
- blockSelectedRangeChanged: blockSelectedRangeChanged
- })
- },
- render: function(isResizing) {
- this._render(isResizing);
- return this
- }
- }
- }()).include(DX.ui.DataHelperMixin)
- })(jQuery, DevExpress);
- /*! Module viz-rangeselector, file rangeContainer.js */
- (function($, DX, undefined) {
- var rangeSelector = DX.viz.rangeSelector;
- rangeSelector.RangeContainer = rangeSelector.BaseVisualElement.inherit(function() {
- var ctor = function(renderer) {
- this.callBase(renderer);
- this.slidersContainer = createSlidersContainer(renderer);
- this.rangeView = createRangeView(renderer);
- this.scale = createScale(renderer)
- };
- var _applyOptions = function(options) {
- var that = this,
- isEmpty = options.scale.isEmpty,
- viewCanvas = {
- left: options.canvas.left,
- top: options.canvas.top,
- width: options.canvas.width,
- height: options.canvas.height >= options.scaleLabelsAreaHeight ? options.canvas.height - options.scaleLabelsAreaHeight : 0
- };
- that._viewCanvas = viewCanvas;
- that.slidersContainer.applyOptions({
- canvas: viewCanvas,
- translator: options.translators.x,
- scale: options.scale,
- selectedRange: options.selectedRange,
- sliderMarker: options.sliderMarker,
- sliderHandle: options.sliderHandle,
- shutter: options.shutter,
- behavior: options.behavior,
- selectedRangeChanged: options.selectedRangeChanged,
- isEmpty: isEmpty
- });
- that.rangeView.applyOptions({
- canvas: viewCanvas,
- translators: options.translators,
- background: options.background,
- chart: options.chart,
- seriesDataSource: options.seriesDataSource,
- behavior: options.behavior,
- isEmpty: isEmpty
- });
- that.scale.applyOptions({
- canvas: options.canvas,
- translator: options.translators.x,
- scale: options.scale,
- hideLabels: isEmpty,
- scaleLabelsAreaHeight: options.scaleLabelsAreaHeight,
- setSelectedRange: options.setSelectedRange
- })
- };
- var createSlidersContainer = function(options) {
- return rangeSelector.rangeSelectorFactory.createSlidersContainer(options)
- };
- var createScale = function(options) {
- return rangeSelector.rangeSelectorFactory.createScale(options)
- };
- var createRangeView = function(options) {
- return rangeSelector.rangeSelectorFactory.createRangeView(options)
- };
- var _createClipRectCanvas = function(canvas, sliderMarkerSpacing) {
- return {
- left: canvas.left - sliderMarkerSpacing.left,
- top: canvas.top - sliderMarkerSpacing.top,
- width: canvas.width + sliderMarkerSpacing.right + sliderMarkerSpacing.left,
- height: canvas.height + sliderMarkerSpacing.bottom + sliderMarkerSpacing.top
- }
- };
- var _draw = function() {
- var that = this,
- containerGroup,
- rangeViewGroup,
- slidersContainerGroup,
- scaleGroup,
- trackersGroup,
- clipRectCanvas = _createClipRectCanvas(that._options.canvas, that._options.sliderMarkerSpacing),
- viewCanvas = that._viewCanvas;
- that._clipRect = that._renderer.createClipRect(clipRectCanvas.left, clipRectCanvas.top, clipRectCanvas.width, clipRectCanvas.height).append();
- containerGroup = that._renderer.createGroup({
- 'class': 'rangeContainer',
- clipId: that._clipRect.id
- }).append();
- that._viewClipRect = that._renderer.createClipRect(viewCanvas.left, viewCanvas.top, viewCanvas.width, viewCanvas.height).append();
- rangeViewGroup = that._renderer.createGroup({
- 'class': 'view',
- clipId: that._viewClipRect.id
- });
- rangeViewGroup.append(containerGroup);
- that.rangeView.redraw(rangeViewGroup);
- slidersContainerGroup = that._renderer.createGroup({'class': 'slidersContainer'});
- slidersContainerGroup.append(containerGroup);
- that.slidersContainer.redraw(slidersContainerGroup);
- scaleGroup = that._renderer.createGroup({'class': 'scale'});
- scaleGroup.append(containerGroup);
- that.scale.redraw(scaleGroup);
- trackersGroup = that._renderer.createGroup({'class': 'trackers'});
- trackersGroup.append(containerGroup);
- that._trackersGroup = trackersGroup;
- that.slidersContainer.appendTrackers(trackersGroup)
- };
- var _update = function() {
- var that = this,
- clipRectCanvas = _createClipRectCanvas(that._options.canvas, that._options.sliderMarkerSpacing),
- viewCanvas = that._viewCanvas;
- that._clipRect.updateRectangle({
- x: clipRectCanvas.left,
- y: clipRectCanvas.top,
- width: clipRectCanvas.width,
- height: clipRectCanvas.height
- });
- that._viewClipRect.updateRectangle({
- x: viewCanvas.left,
- y: viewCanvas.top,
- width: viewCanvas.width,
- height: viewCanvas.height
- });
- that.rangeView.redraw();
- that.slidersContainer.redraw();
- that.slidersContainer.appendTrackers(that._trackersGroup);
- that.scale.redraw()
- };
- var dispose = function() {
- this.slidersContainer.dispose();
- this.slidersContainer = null
- };
- var prototypeObject = {
- createSlidersContainer: createSlidersContainer,
- createScale: createScale,
- ctor: ctor,
- dispose: dispose,
- _applyOptions: _applyOptions,
- _draw: _draw,
- _update: _update
- };
- return prototypeObject
- }())
- })(jQuery, DevExpress);
- /*! Module viz-rangeselector, file scale.js */
- (function($, DX, undefined) {
- var rangeSelector = DX.viz.rangeSelector,
- formatHelper = DX.formatHelper,
- utils = DX.utils;
- var SCALE_TEXT_SPACING = 5;
- rangeSelector.Scale = rangeSelector.BaseVisualElement.inherit({
- _setupDateUnitInterval: function(scaleOptions) {
- var key,
- hasObjectSingleField = function(object) {
- var fieldsCounter = 0;
- $.each(object, function() {
- return ++fieldsCounter < 2
- });
- return fieldsCounter === 1
- },
- millisecTickInterval,
- majorTickInterval = scaleOptions.ticksInfo.majorTickInterval,
- majorTicks = scaleOptions.ticksInfo.majorTicks;
- if (scaleOptions.valueType === 'datetime') {
- if (utils.isObject(majorTickInterval) && !hasObjectSingleField(majorTickInterval))
- utils.logger.warn('More than one field is specified within the object assigned to the "tickInterval" option. Assign an object with a single field specified (days, hours or a similar one).');
- if (majorTicks && majorTicks.autoArrangementStep > 1) {
- if (utils.isString(majorTickInterval))
- majorTickInterval = utils.getDateIntervalByString(majorTickInterval);
- for (key in majorTickInterval)
- if (majorTickInterval.hasOwnProperty(key)) {
- majorTickInterval[key] *= majorTicks.autoArrangementStep;
- millisecTickInterval = utils.convertDateTickIntervalToMilliseconds(majorTickInterval)
- }
- majorTickInterval = utils.convertMillisecondsToDateUnits(millisecTickInterval)
- }
- this.dateUnitInterval = utils.getDateUnitInterval(majorTickInterval)
- }
- },
- _prepareDatesDifferences: function(datesDifferences, tickInterval) {
- var deleteDifferent = tickInterval,
- dateUnitInterval,
- i;
- if (deleteDifferent === 'week')
- deleteDifferent = 'day';
- if (deleteDifferent === 'quarter')
- deleteDifferent = 'month';
- if (datesDifferences[deleteDifferent])
- for (i = 0; i < utils.dateUnitIntervals.length; i++) {
- dateUnitInterval = utils.dateUnitIntervals[i];
- if (datesDifferences[dateUnitInterval]) {
- datesDifferences[dateUnitInterval] = false;
- datesDifferences.count--
- }
- if (dateUnitInterval === deleteDifferent)
- break
- }
- },
- _getMarkerDate: function(date, tickInterval) {
- var markerDate = new Date(date.getTime()),
- month = 0;
- switch (tickInterval) {
- case'quarter':
- month = formatHelper.getFirstQuarterMonth(date.getMonth());
- case'month':
- markerDate.setMonth(month);
- case'week':
- case'day':
- markerDate.setDate(1);
- case'hour':
- markerDate.setHours(0, 0, 0, 0);
- break;
- case'millisecond':
- markerDate.setMilliseconds(0);
- break;
- case'second':
- markerDate.setSeconds(0, 0);
- break;
- case'minute':
- markerDate.setMinutes(0, 0, 0);
- break
- }
- return markerDate
- },
- _drawDateMarker: function(date, options) {
- var labelPosX,
- labelPosY,
- dateFormated,
- scaleOptions,
- textElement;
- if (options.x === null)
- return;
- scaleOptions = this._options.scale;
- this.lineOptions['class'] = 'dx-range-selector-date-marker';
- this._renderer.createLine(options.x, options.y, options.x, options.y + scaleOptions.marker.separatorHeight, this.lineOptions).append(options.group);
- dateFormated = this._getLabel(date, options.label);
- labelPosX = options.x + scaleOptions.tick.width + scaleOptions.marker.textLeftIndent;
- labelPosY = options.y + scaleOptions.marker.textTopIndent + scaleOptions.label.font.size;
- this.textOptions.align = 'left';
- textElement = this._renderer.createText(dateFormated, labelPosX, labelPosY, this.textOptions).append(options.group);
- return labelPosX + textElement.getBBox().width
- },
- _drawDateMarkers: function(dates, group) {
- var dateMarker,
- i,
- datesDifferences,
- markerDate,
- posX,
- prevMarkerRightX = -1;
- if (this._options.scale.valueType !== 'datetime' || !this.visibleMarkers)
- return;
- var markerDatePositions = [];
- if (dates.length > 1) {
- for (i = 1; i < dates.length; i++) {
- datesDifferences = utils.getDatesDifferences(dates[i - 1], dates[i]);
- this._prepareDatesDifferences(datesDifferences, this.dateUnitInterval);
- if (datesDifferences.count > 0) {
- markerDate = this._getMarkerDate(dates[i], this.dateUnitInterval);
- this.markerDates = this.markerDates || [];
- this.markerDates.push(markerDate);
- posX = this.translator.translate(markerDate);
- if (posX > prevMarkerRightX) {
- posX !== null && markerDatePositions.push({
- date: markerDate,
- posX: posX
- });
- prevMarkerRightX = this._drawDateMarker(markerDate, {
- group: group,
- y: this._options.canvas.top + this._options.canvas.height - this.markersAreaHeight + this._options.scale.marker.topIndent,
- x: posX,
- label: this._getLabelFormatOptions(formatHelper.getDateFormatByDifferences(datesDifferences))
- })
- }
- }
- }
- this._initializeMarkersEvents(markerDatePositions, group)
- }
- },
- _getLabelFormatOptions: function(formatString) {
- if (!utils.isDefined(this._options.scale.marker.label.format))
- return $.extend({}, this._options.scale.marker.label, {format: formatString});
- return this._options.scale.marker.label
- },
- _calculateRangeByMarkerPosition: function(posX, markerDatePositions, scaleOptions) {
- var selectedRange = {},
- i,
- position;
- for (i = 0; i < markerDatePositions.length; i++) {
- position = markerDatePositions[i];
- if (!scaleOptions.inverted) {
- if (posX >= position.posX)
- selectedRange.startValue = position.date;
- else if (!selectedRange.endValue)
- selectedRange.endValue = position.date
- }
- else if (posX < position.posX)
- selectedRange.endValue = position.date;
- else if (!selectedRange.startValue)
- selectedRange.startValue = position.date
- }
- selectedRange.startValue = selectedRange.startValue || scaleOptions.startValue;
- selectedRange.endValue = selectedRange.endValue || scaleOptions.endValue;
- return selectedRange
- },
- _initializeMarkersEvents: function(markerDatePositions, group) {
- var that = this,
- markersAreaTop = this._options.canvas.top + this._options.canvas.height - this.markersAreaHeight + this._options.scale.marker.topIndent,
- markersTracker,
- svgOffsetLeft,
- index,
- posX,
- selectedRange;
- if (markerDatePositions.length > 0) {
- markersTracker = that._renderer.createRect(that._options.canvas.left, markersAreaTop, that._options.canvas.width, that._options.scale.marker.separatorHeight, 0, {
- fill: 'grey',
- stroke: 'grey',
- opacity: 0.0001
- });
- markersTracker.append(group);
- markersTracker.on(rangeSelector.events.start, function(e) {
- svgOffsetLeft = rangeSelector.utils.getRootOffsetLeft(that._renderer);
- posX = rangeSelector.utils.getEventPageX(e) - svgOffsetLeft;
- selectedRange = that._calculateRangeByMarkerPosition(posX, markerDatePositions, that._options.scale);
- that._options.setSelectedRange(selectedRange)
- });
- that._markersTracker = markersTracker
- }
- },
- _getLabel: function(value, options) {
- var formatObject = {
- value: value,
- valueText: formatHelper.format(value, options.format, options.precision)
- };
- return String(utils.isFunction(options.customizeText) ? options.customizeText.call(formatObject, formatObject) : formatObject.valueText)
- },
- _drawLabel: function(value, group) {
- var textY = this._options.canvas.top + this._options.canvas.height - this.markersAreaHeight,
- textElement = this._renderer.createText(this._getLabel(value, this._options.scale.label), this.translator.translate(value), textY, this.textOptions);
- textElement.append(group);
- this.textElements = this.textElements || [];
- this.textElements.push(textElement)
- },
- _drawTick: function(value, group) {
- this.lineOptions['class'] = 'dx-range-selector-tick';
- var secondY = this._options.canvas.top + this._options.canvas.height - this.scaleLabelsAreaHeight,
- posX = this.translator.translate(value),
- tickElement = this._renderer.createLine(posX, this._options.canvas.top, posX, secondY, this.lineOptions).append(group);
- this.tickElements = this.tickElements || [];
- this.tickElements.push(tickElement)
- },
- _redraw: function(group, isOptimize) {
- var that = this,
- scaleOptions = that._options.scale,
- ticksGroup = that._renderer.createGroup(),
- labelsGroup = that._renderer.createGroup().append(group),
- majorTicks = scaleOptions.ticksInfo.majorTicks,
- minorTicks = scaleOptions.ticksInfo.minorTicks,
- customBoundaryTicks = scaleOptions.ticksInfo.customBoundaryTicks,
- hideLabels = that._options.hideLabels || majorTicks.hideLabels || !scaleOptions.label.visible,
- i;
- for (i = 0; i < majorTicks.length; i++) {
- if (!hideLabels)
- that._drawLabel(majorTicks[i], labelsGroup);
- that._drawTick(majorTicks[i], ticksGroup)
- }
- if (scaleOptions.showMinorTicks)
- for (i = 0; i < minorTicks.length; i++)
- that._drawTick(minorTicks[i], ticksGroup);
- for (i = 0; i < customBoundaryTicks.length; i++)
- that._drawTick(customBoundaryTicks[i], ticksGroup);
- ticksGroup.append(group);
- that._drawDateMarkers(majorTicks, labelsGroup)
- },
- _applyOptions: function(options) {
- var scaleOptions = options.scale,
- labelsAreaHeight;
- this.textOptions = {
- align: 'center',
- 'class': 'dx-range-selector-scale',
- font: scaleOptions.label.font,
- style: {'-webkit-user-select': 'none'}
- };
- this.lineOptions = {
- strokeWidth: scaleOptions.tick.width,
- stroke: scaleOptions.tick.color,
- strokeOpacity: scaleOptions.tick.opacity
- };
- this._setupDateUnitInterval(scaleOptions);
- this.visibleMarkers = scaleOptions.marker.visible === undefined ? true : scaleOptions.marker.visible;
- labelsAreaHeight = scaleOptions.label.visible ? scaleOptions.label.topIndent + scaleOptions.label.font.size : 0;
- this.scaleLabelsAreaHeight = options.scaleLabelsAreaHeight;
- this.markersAreaHeight = this.scaleLabelsAreaHeight - labelsAreaHeight;
- this.translator = options.translator
- },
- _draw: function(group) {
- this._redraw(group, false)
- },
- _update: function(group) {
- var callBase = this.callBase;
- if (this._markersTracker)
- this._markersTracker.off(rangeSelector.events.start, '**');
- this.callBase = callBase;
- this.callBase(group)
- }
- })
- })(jQuery, DevExpress);
- /*! Module viz-rangeselector, file rangeFactory.js */
- (function($, DX, undefined) {
- var rangeSelector = DX.viz.rangeSelector,
- renderers = DX.viz.renderers;
- rangeSelector.rangeSelectorFactory = function() {
- return {
- createRangeContainer: function(rangeContainerOptions) {
- return new rangeSelector.RangeContainer(rangeContainerOptions)
- },
- createSlidersContainer: function(options) {
- return new rangeSelector.SlidersContainer(options)
- },
- createScale: function(options) {
- return new rangeSelector.Scale(options)
- },
- createSliderMarker: function(options) {
- return new rangeSelector.SliderMarker(options)
- },
- createRangeView: function(options) {
- return new rangeSelector.RangeView(options)
- },
- createThemeManager: function(options) {
- return new rangeSelector.ThemeManager(options)
- },
- createSlider: function(renderer, sliderIndex) {
- return new rangeSelector.Slider(renderer, sliderIndex)
- },
- createSlidersEventsManager: function(renderer, slidersController, processSelectionChanged) {
- return new rangeSelector.SlidersEventsManager(renderer, slidersController, processSelectionChanged)
- },
- createSlidersController: function(sliders) {
- return new rangeSelector.SlidersController(sliders)
- }
- }
- }()
- })(jQuery, DevExpress);
- /*! Module viz-rangeselector, file slidersContainer.js */
- (function($, DX, undefined) {
- var rangeSelector = DX.viz.rangeSelector,
- utils = DX.utils;
- var msPointerEnabled = window.navigator.msPointerEnabled || window.navigator.pointerEnabled;
- var isNumber = DX.utils.isNumber;
- var isDate = DX.utils.isDate;
- var START_VALUE_INDEX = 0,
- END_VALUE_INDEX = 1;
- rangeSelector.SlidersContainer = rangeSelector.BaseVisualElement.inherit(function() {
- var prototypeObject = {
- getController: function() {
- return this._controller
- },
- _drawAreaTracker: function(group) {
- var that = this,
- areaTracker,
- selectedAreaTracker;
- areaTracker = that._renderer.createRect(that._options.canvas.left, that._options.canvas.top, that._options.canvas.width, that._options.canvas.height, 0, {
- fill: 'grey',
- stroke: 'grey',
- opacity: 0.0001
- });
- areaTracker.append(group);
- selectedAreaTracker = that._renderer.createRect(that._options.canvas.left, that._options.canvas.top, that._options.canvas.width, that._options.canvas.height, 0, {
- fill: 'grey',
- stroke: 'grey',
- opacity: 0.0001,
- style: {cursor: 'pointer'}
- });
- selectedAreaTracker.append(group);
- that._controller.setAreaTrackers(areaTracker, selectedAreaTracker)
- },
- dispose: function() {
- this._eventsManager.dispose();
- this._eventManager = null
- },
- _processSelectionChanged: function(moving, blockSelectedRangeChanged) {
- var that = this,
- equalLastSelectedRange = function(selectedRange) {
- return selectedRange && that._lastSelectedRange.startValue === selectedRange.startValue && that._lastSelectedRange.endValue === selectedRange.endValue
- },
- selectedRange = that.getSelectedRange();
- if ((!moving || (that._options.behavior.callSelectedRangeChanged || '').toLowerCase() === "onmoving") && that._options.selectedRangeChanged && !equalLastSelectedRange(selectedRange)) {
- that._updateLastSelectedRange(selectedRange);
- if (typeof that._options.selectedRangeChanged === 'function')
- that._options.selectedRangeChanged.call(null, selectedRange, blockSelectedRangeChanged);
- if (!moving && !equalLastSelectedRange(selectedRange))
- that.setSelectedRange(selectedRange)
- }
- },
- _updateLastSelectedRange: function(selectedRange) {
- selectedRange = selectedRange || this._options.selectedRange;
- this._lastSelectedRange = {
- startValue: selectedRange.startValue,
- endValue: selectedRange.endValue
- }
- },
- _createSlider: function(sliderIndex) {
- return rangeSelector.rangeSelectorFactory.createSlider(this._renderer, sliderIndex)
- },
- _createSlidersController: function(sliders) {
- return rangeSelector.rangeSelectorFactory.createSlidersController(sliders)
- },
- _createSlidersEventsManager: function(controller) {
- var that = this;
- return rangeSelector.rangeSelectorFactory.createSlidersEventsManager(that._renderer, controller, function(moving) {
- that._processSelectionChanged(moving)
- })
- },
- ctor: function(renderer) {
- var that = this,
- sliders;
- that.callBase(renderer);
- sliders = [that._createSlider(START_VALUE_INDEX), that._createSlider(END_VALUE_INDEX)];
- that._controller = that._createSlidersController(sliders);
- that._eventsManager = that._createSlidersEventsManager(that._controller);
- that._lastSelectedRange = {}
- },
- getSelectedRange: function() {
- return this._controller.getSelectedRange()
- },
- truncateSelectedRange: function(value, scaleOptions) {
- var min = scaleOptions.startValue > scaleOptions.endValue ? scaleOptions.endValue : scaleOptions.startValue,
- max = scaleOptions.startValue > scaleOptions.endValue ? scaleOptions.startValue : scaleOptions.endValue;
- if (value < min)
- value = min;
- if (value > max)
- value = max;
- return value
- },
- setSelectedRange: function(selectedRange) {
- var that = this,
- scale = that._options.scale,
- startValue,
- endValue,
- currentSelectedRange = that._options.selectedRange;
- if (selectedRange) {
- startValue = selectedRange.startValue;
- endValue = selectedRange.endValue
- }
- if (isNumber(scale.startValue) && isNumber(startValue) || isDate(scale.startValue) && isDate(startValue))
- currentSelectedRange.startValue = startValue;
- if (isNumber(scale.endValue) && isNumber(endValue) || isDate(scale.endValue) && isDate(endValue))
- currentSelectedRange.endValue = endValue;
- currentSelectedRange.startValue = that.truncateSelectedRange(currentSelectedRange.startValue, scale);
- currentSelectedRange.endValue = that.truncateSelectedRange(currentSelectedRange.endValue, scale);
- that._controller.applySelectedRange(currentSelectedRange);
- that._controller.applyPosition();
- that._processSelectionChanged(false, selectedRange && selectedRange.blockSelectedRangeChanged)
- },
- appendTrackers: function(group) {
- this._controller.appendTrackers(group)
- },
- _applyOptions: function(options) {
- var that = this;
- that._controller.applyOptions({
- translator: options.translator,
- canvas: options.canvas,
- sliderMarker: options.sliderMarker,
- sliderHandle: options.sliderHandle,
- shutter: options.shutter,
- scale: options.scale,
- behavior: options.behavior
- });
- that._eventsManager.applyOptions({behavior: options.behavior})
- },
- _draw: function(group) {
- var that = this,
- rootElement;
- if (msPointerEnabled) {
- rootElement = that._renderer.getRoot();
- rootElement && (rootElement.element.style.msTouchAction = "pinch-zoom")
- }
- that._controller.redraw(group);
- that._drawAreaTracker(group);
- that._eventsManager.initialize();
- that._update()
- },
- _update: function() {
- var that = this,
- isEmpty = that._options.isEmpty;
- that._eventsManager.setEnabled(!isEmpty);
- that._controller.applySelectedRange(isEmpty ? {} : that._options.selectedRange);
- that._controller.applyPosition(that.isDrawn());
- that._updateLastSelectedRange();
- that._controller.redraw()
- }
- };
- return prototypeObject
- }())
- })(jQuery, DevExpress);
- /*! Module viz-rangeselector, file slidersController.js */
- (function($, DX, undefined) {
- var rangeSelector = DX.viz.rangeSelector,
- utils = DX.utils;
- var START_VALUE_INDEX = 0,
- END_VALUE_INDEX = 1;
- rangeSelector.SlidersController = DX.Class.inherit(function() {
- return {
- ctor: function(sliders) {
- this._sliders = sliders;
- sliders[START_VALUE_INDEX].setAnotherSlider(sliders[END_VALUE_INDEX]);
- sliders[END_VALUE_INDEX].setAnotherSlider(sliders[START_VALUE_INDEX])
- },
- setAreaTrackers: function(areaTracker, selectedAreaTracker) {
- this._areaTracker = areaTracker;
- this._selectedAreaTracker = selectedAreaTracker
- },
- applyOptions: function(options) {
- var that = this,
- values = null;
- that._options = options;
- that.getSlider(START_VALUE_INDEX).applyOptions(options);
- that.getSlider(END_VALUE_INDEX).applyOptions(options);
- if (options.behavior.snapToTicks) {
- values = options.scale.ticksInfo.fullTicks;
- if (values.length > 1 && values[0] > values[values.length - 1])
- values = values.reverse()
- }
- that.getSlider(START_VALUE_INDEX).setAvailableValues(values);
- that.getSlider(END_VALUE_INDEX).setAvailableValues(values)
- },
- processDocking: function(sliderIndex) {
- var that = this;
- if (sliderIndex !== undefined)
- that.getSlider(sliderIndex).processDocking();
- else {
- that.getSlider(START_VALUE_INDEX).processDocking();
- that.getSlider(END_VALUE_INDEX).processDocking()
- }
- that.setTrackersCursorStyle('default');
- that.applyAreaTrackersPosition()
- },
- getSelectedRangeInterval: function() {
- var that = this,
- type = that._options.scale.type,
- base = that._options.scale.logarithmBase,
- startValue = that.getSlider(START_VALUE_INDEX).getValue(),
- endValue = that.getSlider(END_VALUE_INDEX).getValue();
- if (type === 'logarithmic')
- return rangeSelector.utils.getInterval(utils.getLog(startValue, base), utils.getLog(endValue, base));
- else
- return rangeSelector.utils.getInterval(startValue, endValue)
- },
- moveSliders: function(postitionDelta, selectedRangeInterval) {
- var that = this;
- that.getSlider(START_VALUE_INDEX).setPosition(that.getSlider(START_VALUE_INDEX).getPosition() + postitionDelta, false, selectedRangeInterval);
- that.applyPosition(true)
- },
- moveSlider: function(sliderIndex, fastSwap, position, offsetPosition, startOffsetPosition, startOffsetPositionChangedCallback) {
- var that = this,
- slider = that.getSlider(sliderIndex),
- anotherSlider = slider.getAnotherSlider(),
- anotherSliderIndex = anotherSlider.getIndex(),
- doSwap;
- if (slider.canSwap())
- if (sliderIndex === START_VALUE_INDEX ? position > anotherSlider.getPosition() : position < anotherSlider.getPosition()) {
- doSwap = fastSwap;
- if (!fastSwap)
- if (Math.abs(offsetPosition) >= Math.abs(startOffsetPosition) && offsetPosition * startOffsetPosition < 0) {
- doSwap = true;
- position += 2 * startOffsetPosition;
- startOffsetPositionChangedCallback(-startOffsetPosition)
- }
- if (doSwap) {
- that.swapSliders();
- anotherSlider.applyPosition(true)
- }
- }
- slider.setPosition(position, true);
- slider.applyPosition(true);
- that.applyAreaTrackersPosition();
- that.setTrackersCursorStyle('w-resize')
- },
- applySelectedAreaCenterPosition: function(pos) {
- var that = this,
- slidersContainerHalfWidth = (that.getSlider(END_VALUE_INDEX).getPosition() - that.getSlider(START_VALUE_INDEX).getPosition()) / 2,
- selectedRangeInterval = that.getSelectedRangeInterval();
- that.getSlider(START_VALUE_INDEX).setPosition(pos - slidersContainerHalfWidth, false, selectedRangeInterval);
- that.applyPosition();
- that.processDocking()
- },
- processManualSelection: function(startPosition, endPosition, eventArgs) {
- var that = this,
- animateSliderIndex,
- movingSliderIndex,
- positionRange = [Math.min(startPosition, endPosition), Math.max(startPosition, endPosition)];
- animateSliderIndex = startPosition < endPosition ? START_VALUE_INDEX : END_VALUE_INDEX;
- movingSliderIndex = startPosition < endPosition ? END_VALUE_INDEX : START_VALUE_INDEX;
- that.getSlider(movingSliderIndex).setPosition(positionRange[movingSliderIndex]);
- that.getSlider(animateSliderIndex).setPosition(positionRange[animateSliderIndex]);
- that.getSlider(movingSliderIndex).setPosition(positionRange[movingSliderIndex], true);
- that.getSlider(movingSliderIndex).startEventHandler(eventArgs);
- that.getSlider(animateSliderIndex).processDocking();
- that.getSlider(movingSliderIndex).applyPosition(true)
- },
- applySelectedRange: function(selectedRange) {
- var that = this,
- inverted = that._options.scale.inverted;
- utils.debug.assertParam(selectedRange, 'selectedRange not passed');
- if (!inverted && selectedRange.startValue > selectedRange.endValue || inverted && selectedRange.startValue < selectedRange.endValue) {
- that.getSlider(START_VALUE_INDEX).setValue(selectedRange.endValue);
- that.getSlider(END_VALUE_INDEX).setValue(selectedRange.startValue)
- }
- else {
- that.getSlider(START_VALUE_INDEX).setValue(selectedRange.startValue);
- that.getSlider(END_VALUE_INDEX).setValue(selectedRange.endValue)
- }
- },
- getSelectedRange: function() {
- var that = this;
- return {
- startValue: that.getSlider(START_VALUE_INDEX).getValue(),
- endValue: that.getSlider(END_VALUE_INDEX).getValue()
- }
- },
- swapSliders: function() {
- var that = this;
- that._sliders.reverse();
- that.getSlider(START_VALUE_INDEX).changeLocation();
- that.getSlider(END_VALUE_INDEX).changeLocation()
- },
- applyAreaTrackersPosition: function() {
- var that = this,
- selectedRange = that.getSelectedRange(),
- scaleOptions = that._options.scale,
- width = that.getSlider(END_VALUE_INDEX).getPosition() - that.getSlider(START_VALUE_INDEX).getPosition(),
- options = {
- x: that.getSlider(START_VALUE_INDEX).getPosition(),
- width: width < 0 ? 0 : width,
- y: that._options.canvas.top,
- height: that._options.canvas.height,
- style: {cursor: scaleOptions.endValue - scaleOptions.startValue === selectedRange.endValue - selectedRange.startValue ? 'default' : 'pointer'}
- };
- that._selectedAreaTracker.applySettings(options);
- that._areaTracker.applySettings({
- x: that._options.canvas.left,
- width: that._options.canvas.width,
- y: that._options.canvas.top,
- height: that._options.canvas.height
- })
- },
- applyPosition: function(disableAnimation) {
- var that = this;
- that.getSlider(START_VALUE_INDEX).applyPosition(disableAnimation);
- that.getSlider(END_VALUE_INDEX).applyPosition(disableAnimation);
- that.applyAreaTrackersPosition()
- },
- redraw: function(group) {
- var that = this;
- that.getSlider(START_VALUE_INDEX).redraw(group);
- that.getSlider(END_VALUE_INDEX).redraw(group)
- },
- appendTrackers: function(group) {
- var that = this;
- if (that._areaTracker && that._selectedAreaTracker) {
- that._areaTracker.append(group);
- that._selectedAreaTracker.append(group)
- }
- that.getSlider(START_VALUE_INDEX).appendTrackers(group);
- that.getSlider(END_VALUE_INDEX).appendTrackers(group)
- },
- getSlider: function(sliderIndex) {
- return this._sliders[sliderIndex]
- },
- getAreaTracker: function() {
- return this._areaTracker
- },
- getSelectedAreaTracker: function() {
- return this._selectedAreaTracker
- },
- setTrackersCursorStyle: function(style) {
- var that = this;
- that._selectedAreaTracker.applySettings({style: {cursor: style}});
- that._areaTracker.applySettings({style: {cursor: style}})
- }
- }
- }())
- })(jQuery, DevExpress);
- /*! Module viz-rangeselector, file slidersEventsManager.js */
- (function($, DX, undefined) {
- var rangeSelector = DX.viz.rangeSelector,
- utils = DX.utils,
- MIN_MANUAL_SELECTING_WIDTH = 10,
- START_VALUE_INDEX = 0,
- END_VALUE_INDEX = 1,
- addNamespace = DX.ui.events.addNamespace,
- setEvents = function() {
- var win = window;
- win = DX.viz.rangeSelector.mockWindow || window;
- var touchSupport = "ontouchstart" in win,
- msPointerEnabled = win.navigator.msPointerEnabled,
- pointerEnabled = win.navigator.pointerEnabled;
- rangeSelector.events = {
- start: pointerEnabled ? "pointerdown" : msPointerEnabled ? "MSPointerDown" : touchSupport ? "touchstart mousedown" : "mousedown",
- move: pointerEnabled ? "pointermove" : msPointerEnabled ? "MSPointerMove" : touchSupport ? "touchmove mousemove" : "mousemove",
- end: pointerEnabled ? "pointerup pointercancel" : msPointerEnabled ? "MSPointerUp MSPointerCancel" : touchSupport ? "touchend mouseup" : "mouseup"
- }
- },
- _SlidersEventManager,
- getEventPageX = rangeSelector.utils.getEventPageX,
- rangeSelectorCount = 0;
- setEvents();
- var isLeftButtonPressed = function(event) {
- var e = event || window.event,
- originalEvent = e.originalEvent,
- touches = e.touches,
- pointerType = originalEvent ? originalEvent.pointerType : false,
- eventTouches = originalEvent ? originalEvent.touches : false,
- isIE8LeftClick = e.which === undefined && e.button === 1,
- isMSPointerLeftClick = originalEvent && pointerType !== undefined && (pointerType === (originalEvent.MSPOINTER_TYPE_TOUCH || 'touch') || pointerType === (originalEvent.MSPOINTER_TYPE_MOUSE || 'mouse') && originalEvent.buttons === 1),
- isLeftClick = isIE8LeftClick || e.which === 1,
- isTouches = touches && touches.length > 0 || eventTouches && eventTouches.length > 0;
- return isLeftClick || isMSPointerLeftClick || isTouches
- };
- var isMultiTouches = function(event) {
- var originalEvent = event.originalEvent,
- touches = event.touches,
- eventTouches = originalEvent ? originalEvent.touches : false;
- return touches && touches.length > 1 || eventTouches && eventTouches.length > 1 || null
- };
- var isTouchEventArgs = function(e) {
- return e && e.type && e.type.indexOf('touch') === 0
- };
- _SlidersEventManager = rangeSelector.SlidersEventsManager = function(renderer, slidersController, processSelectionChanged) {
- var that = this,
- uniqueNS = that._uniqueNS = 'dx-range-selector_' + rangeSelectorCount++,
- rangeSelectorEvents = rangeSelector.events;
- that._renderer = renderer;
- that._slidersController = slidersController;
- that._processSelectionChanged = processSelectionChanged;
- that._enabled = true;
- that._eventsNames = {
- start: addNamespace(rangeSelectorEvents.start, uniqueNS),
- move: addNamespace(rangeSelectorEvents.move, uniqueNS),
- end: addNamespace(rangeSelectorEvents.end, uniqueNS)
- }
- };
- _SlidersEventManager.prototype = {
- constructor: _SlidersEventManager,
- _getRootOffsetLeft: function() {
- return rangeSelector.utils.getRootOffsetLeft(this._renderer)
- },
- _initializeSliderEvents: function(sliderIndex) {
- var that = this,
- renderer = that._renderer,
- isTouchEvent,
- slidersController = that._slidersController,
- processSelectionChanged = that._processSelectionChanged,
- slider = slidersController.getSlider(sliderIndex),
- anotherSlider = slider.getAnotherSlider(),
- fastSwap,
- startOffsetPosition,
- splitterMoving,
- sliderEndHandler = function(e) {
- if (splitterMoving) {
- splitterMoving = false;
- slidersController.processDocking();
- processSelectionChanged(false)
- }
- },
- sliderMoveHandler = function(e) {
- var doSwap,
- pageX,
- offsetPosition,
- svgOffsetLeft = that._getRootOffsetLeft(),
- position,
- sliderIndex = slider.getIndex();
- if (isTouchEvent !== isTouchEventArgs(e))
- return;
- if (!isLeftButtonPressed(e, true) && splitterMoving) {
- splitterMoving = false;
- slidersController.processDocking();
- processSelectionChanged(false)
- }
- else if (splitterMoving) {
- if (!isMultiTouches(e)) {
- this.preventedDefault = true;
- e.preventDefault()
- }
- pageX = getEventPageX(e);
- position = pageX - startOffsetPosition - svgOffsetLeft;
- offsetPosition = pageX - slider.getPosition() - svgOffsetLeft;
- slidersController.moveSlider(sliderIndex, fastSwap, position, offsetPosition, startOffsetPosition, function(newStartOffsetPosition) {
- startOffsetPosition = newStartOffsetPosition
- });
- processSelectionChanged(true)
- }
- },
- eventsNames = that._eventsNames;
- slider.startEventHandler = function(e) {
- if (!that._enabled || !isLeftButtonPressed(e) || splitterMoving)
- return;
- fastSwap = this === slider.getSliderTracker().element;
- splitterMoving = true;
- isTouchEvent = isTouchEventArgs(e);
- startOffsetPosition = getEventPageX(e) - slider.getPosition() - that._getRootOffsetLeft();
- if (!isMultiTouches(e)) {
- this.preventedDefault = true;
- e.stopPropagation();
- e.preventDefault()
- }
- };
- slider.on(eventsNames.start, slider.startEventHandler);
- $(document).on(eventsNames.end, sliderEndHandler).on(eventsNames.move, sliderMoveHandler);
- slider.__moveEventHandler = sliderMoveHandler
- },
- _initializeAreaEvents: function() {
- var that = this,
- renderer = that._renderer,
- isTouchEvent,
- slidersController = that._slidersController,
- processSelectionChanged = that._processSelectionChanged,
- areaTracker = slidersController.getAreaTracker(),
- unselectedAreaProcessing = false,
- splitterMoving = false,
- startPageX,
- areaEndHandler = function(e) {
- var pageX;
- if (unselectedAreaProcessing) {
- pageX = getEventPageX(e);
- if (that._options.behavior.moveSelectedRangeByClick && Math.abs(startPageX - pageX) < MIN_MANUAL_SELECTING_WIDTH)
- slidersController.applySelectedAreaCenterPosition(pageX - that._getRootOffsetLeft());
- unselectedAreaProcessing = false;
- processSelectionChanged(false)
- }
- },
- areaMoveHandler = function(e) {
- var pageX,
- startPosition,
- endPosition,
- svgOffsetLeft = that._getRootOffsetLeft();
- if (isTouchEvent !== isTouchEventArgs(e))
- return;
- if (unselectedAreaProcessing && !isLeftButtonPressed(e)) {
- unselectedAreaProcessing = false;
- processSelectionChanged(false)
- }
- if (unselectedAreaProcessing) {
- pageX = getEventPageX(e);
- if (that._options.behavior.manualRangeSelectionEnabled && Math.abs(startPageX - pageX) >= MIN_MANUAL_SELECTING_WIDTH) {
- startPosition = startPageX - svgOffsetLeft;
- endPosition = pageX - svgOffsetLeft;
- slidersController.processManualSelection(startPosition, endPosition, e);
- unselectedAreaProcessing = false;
- processSelectionChanged(true)
- }
- }
- },
- eventsNames = that._eventsNames;
- areaTracker.on(eventsNames.start, function(e) {
- if (!that._enabled || !isLeftButtonPressed(e) || unselectedAreaProcessing)
- return;
- unselectedAreaProcessing = true;
- isTouchEvent = isTouchEventArgs(e);
- startPageX = getEventPageX(e)
- });
- $(document).on(eventsNames.end, areaEndHandler).on(eventsNames.move, areaMoveHandler);
- that.__areaMoveEventHandler = areaMoveHandler
- },
- _initializeSelectedAreaEvents: function() {
- var that = this,
- renderer = that._renderer,
- isTouchEvent,
- slidersController = that._slidersController,
- processSelectionChanged = that._processSelectionChanged,
- selectedAreaTracker = slidersController.getSelectedAreaTracker(),
- selectedAreaMoving = false,
- offsetStartPosition,
- selectedRangeInterval,
- selectedAreaEndHandler = function(e) {
- if (selectedAreaMoving) {
- selectedAreaMoving = false;
- slidersController.processDocking();
- processSelectionChanged(false)
- }
- },
- selectedAreaMoveHandler = function(e) {
- var positionDelta,
- pageX;
- if (isTouchEvent !== isTouchEventArgs(e))
- return;
- if (selectedAreaMoving && !isLeftButtonPressed(e)) {
- selectedAreaMoving = false;
- slidersController.processDocking();
- processSelectionChanged(false)
- }
- if (selectedAreaMoving) {
- if (!isMultiTouches(e)) {
- this.preventedDefault = true;
- e.preventDefault()
- }
- pageX = getEventPageX(e);
- positionDelta = pageX - slidersController.getSlider(START_VALUE_INDEX).getPosition() - offsetStartPosition;
- slidersController.moveSliders(positionDelta, selectedRangeInterval);
- processSelectionChanged(true)
- }
- },
- eventsNames = that._eventsNames;
- selectedAreaTracker.on(eventsNames.start, function(e) {
- if (!that._enabled || !isLeftButtonPressed(e) || selectedAreaMoving)
- return;
- selectedAreaMoving = true;
- isTouchEvent = isTouchEventArgs(e);
- offsetStartPosition = getEventPageX(e) - slidersController.getSlider(START_VALUE_INDEX).getPosition();
- selectedRangeInterval = slidersController.getSelectedRangeInterval();
- if (!isMultiTouches(e)) {
- this.preventedDefault = true;
- e.stopPropagation();
- e.preventDefault()
- }
- });
- $(document).on(eventsNames.end, selectedAreaEndHandler).on(eventsNames.move, selectedAreaMoveHandler);
- that.__selectedAreaMoveEventHandler = selectedAreaMoveHandler
- },
- applyOptions: function(options) {
- this._options = options
- },
- dispose: function() {
- $(document).off('.' + this._uniqueNS)
- },
- initialize: function() {
- var that = this;
- if (!that._renderer.isInitialized())
- return;
- that._initializeSelectedAreaEvents(that);
- that._initializeAreaEvents();
- that._initializeSliderEvents(START_VALUE_INDEX);
- that._initializeSliderEvents(END_VALUE_INDEX)
- },
- setEnabled: function(enabled) {
- this._enabled = enabled
- }
- };
- rangeSelector.__setEvents = setEvents
- })(jQuery, DevExpress);
- /*! Module viz-rangeselector, file slider.js */
- (function($, DX, undefined) {
- var rangeSelector = DX.viz.rangeSelector,
- utils = DX.utils;
- var touchSupport = "ontouchstart" in window;
- var msPointerEnabled = window.navigator.msPointerEnabled || window.navigator.pointerEnabled;
- var animationOptions = {duration: 250};
- var SPLITTER_WIDTH = 8,
- TOUCH_SPLITTER_WIDTH = 20,
- START_VALUE_INDEX = 0,
- END_VALUE_INDEX = 1;
- rangeSelector.Slider = rangeSelector.BaseVisualElement.inherit(function() {
- return {
- getText: function() {
- if (this._marker)
- return this._marker.getText()
- },
- getAvailableValues: function() {
- return this._values
- },
- getShutter: function() {
- return this._shutter
- },
- getMarker: function() {
- return this._marker
- },
- _createSlider: function() {
- var that = this,
- sliderHandle,
- sliderGroup,
- sliderHandleOptions = that._options.sliderHandle;
- sliderGroup = that._renderer.createGroup({'class': 'slider'});
- sliderGroup.applySettings({
- translateX: that._options.canvas.left,
- translateY: that._options.canvas.top
- });
- sliderHandle = that._renderer.createLine(0, 0, 0, that._options.canvas.height, {
- 'class': 'dx-range-selector-slider',
- strokeWidth: sliderHandleOptions.width,
- stroke: sliderHandleOptions.color,
- strokeOpacity: sliderHandleOptions.opacity
- });
- sliderHandle.append(sliderGroup);
- sliderGroup.setValid = function(correct) {
- sliderHandle.applySettings({stroke: correct ? that._options.sliderHandle.color : that._options.sliderMarker.invalidRangeColor})
- };
- sliderGroup.updateHeight = function() {
- sliderHandle.applySettings({points: [0, 0, 0, that._options.canvas.height]})
- };
- sliderGroup.applyOptions = function(options) {
- sliderHandle.applySettings(options)
- };
- sliderGroup.__line = sliderHandle;
- return sliderGroup
- },
- _createSliderTracker: function() {
- var that = this,
- sliderHandleWidth = that._options.sliderHandle.width,
- splitterWidth = SPLITTER_WIDTH < sliderHandleWidth ? sliderHandleWidth : SPLITTER_WIDTH,
- sliderWidth = touchSupport || msPointerEnabled ? TOUCH_SPLITTER_WIDTH : splitterWidth,
- sliderTracker,
- sliderTrackerGroup;
- sliderTracker = that._renderer.createRect(-sliderWidth / 2, 0, sliderWidth, that._options.canvas.height, 0, {
- fill: 'grey',
- stroke: 'grey',
- opacity: 0.0001,
- style: {cursor: 'w-resize'}
- });
- sliderTrackerGroup = that._renderer.createGroup({'class': 'sliderTracker'});
- sliderTrackerGroup.applySettings({
- translateX: 0,
- translateY: that._options.canvas.top
- });
- sliderTracker.append(sliderTrackerGroup);
- sliderTrackerGroup.updateHeight = function() {
- sliderTracker.applySettings({height: that._options.canvas.height})
- };
- sliderTrackerGroup.__rect = sliderTracker;
- return sliderTrackerGroup
- },
- _drawSliderTracker: function(group) {
- var that = this,
- sliderTracker = that._createSliderTracker();
- if (sliderTracker) {
- sliderTracker.append(group);
- that._sliderTracker = sliderTracker
- }
- },
- _createSliderMarker: function(options) {
- return rangeSelector.rangeSelectorFactory.createSliderMarker(options)
- },
- _setPosition: function(position, correctByMinMaxRange) {
- var that = this,
- correctedPosition = that._correctPosition(position),
- value = that._options.translator.untranslate(correctedPosition);
- that.setValue(value, correctByMinMaxRange, false);
- that._position = correctedPosition
- },
- _setPositionForBothSliders: function(startPosition, interval) {
- var that = this,
- anotherSlider,
- startValue,
- endValue,
- endPosition,
- type = that._options.scale.type,
- base = that._options.scale.logarithmBase,
- inverted = that._options.scale.inverted;
- var getNextValue = function(value, isNegative) {
- var lgPower;
- if (type === 'logarithmic') {
- lgPower = utils.addInterval(utils.adjustValue(utils.getLog(value, base)), interval, isNegative);
- return utils.raiseTo(lgPower, base)
- }
- else
- return utils.addInterval(value, interval, isNegative)
- };
- anotherSlider = that.getAnotherSlider();
- startPosition = that._correctBounds(startPosition);
- startValue = that._options.translator.untranslate(startPosition);
- endValue = getNextValue(startValue);
- if (!inverted && endValue > that._options.scale.endValue || inverted && endValue < that._options.scale.endValue) {
- endValue = that._options.scale.endValue;
- endPosition = that._options.canvas.left + that._options.canvas.width;
- startValue = getNextValue(endValue, true);
- startPosition = that._options.translator.translate(startValue)
- }
- else
- endPosition = that._options.translator.translate(endValue);
- if (that._values)
- if (!inverted ? startValue < that._values[0] : startValue > that._values[that._values.length - 1]) {
- startValue = that._correctBusinessValueByAvailableValues(startValue, false);
- endValue = getNextValue(startValue)
- }
- else {
- endValue = that._correctBusinessValueByAvailableValues(endValue, false);
- startValue = getNextValue(endValue, true)
- }
- anotherSlider.setValue(endValue, undefined, false);
- that.setValue(startValue, undefined, false);
- that._position = startPosition;
- anotherSlider._position = endPosition
- },
- _correctPosition: function(position) {
- var that = this,
- correctedPosition = that._correctInversion(position);
- correctedPosition = that._correctBounds(correctedPosition);
- return correctedPosition
- },
- _correctInversion: function(position) {
- var that = this,
- correctedPosition = position,
- anotherSliderPosition = that.getAnotherSlider().getPosition(),
- slidersInverted = that.getIndex() === START_VALUE_INDEX ? position > anotherSliderPosition : position < anotherSliderPosition;
- if (slidersInverted)
- correctedPosition = anotherSliderPosition;
- return correctedPosition
- },
- _correctBounds: function(position) {
- var that = this,
- correctedPosition = position,
- canvas = that._options.canvas;
- if (position < canvas.left)
- correctedPosition = canvas.left;
- if (position > canvas.left + canvas.width)
- correctedPosition = canvas.left + canvas.width;
- return correctedPosition
- },
- _correctBusinessValue: function(businessValue, correctByMinMaxRange, skipCorrection) {
- var that = this,
- result = that._correctBusinessValueByAvailableValues(businessValue, skipCorrection);
- if (correctByMinMaxRange)
- result = that._correctBusinessValueByMinMaxRangeFromAnotherSlider(result);
- result = that._correctBusinessValueByMinRangeFromStartEndValues(result);
- return result
- },
- _correctBusinessValueByAvailableValues: function(businessValue, skipCorrection) {
- var values = this._values;
- if (!skipCorrection && values)
- return rangeSelector.utils.findNearValue(values, businessValue);
- return businessValue
- },
- _correctBusinessValueByMinMaxRangeFromAnotherSlider: function(businessValue) {
- var that = this,
- result = businessValue,
- scale = that._options.scale,
- values = that._values,
- sliderIndex = that.getIndex(),
- anotherBusinessValue = that.getAnotherSlider().getValue(),
- isValid = true,
- minValue,
- maxValue;
- if (!scale.inverted && sliderIndex === START_VALUE_INDEX || scale.inverted && sliderIndex === END_VALUE_INDEX) {
- if (scale.maxRange)
- minValue = that._addInterval(anotherBusinessValue, scale.maxRange, true);
- if (scale.minRange)
- maxValue = that._addInterval(anotherBusinessValue, scale.minRange, true)
- }
- else {
- if (scale.maxRange)
- maxValue = that._addInterval(anotherBusinessValue, scale.maxRange);
- if (scale.minRange)
- minValue = that._addInterval(anotherBusinessValue, scale.minRange)
- }
- if (maxValue !== undefined && result > maxValue) {
- result = values ? rangeSelector.utils.findLessOrEqualValue(values, maxValue) : maxValue;
- isValid = false
- }
- else if (minValue !== undefined && result < minValue) {
- result = values ? rangeSelector.utils.findGreaterOrEqualValue(values, minValue) : minValue;
- isValid = false
- }
- that._setValid(isValid);
- return result
- },
- _addInterval: function(value, interval, isNegative) {
- var result,
- type = this._options.scale.type,
- base = type === "logarithmic" && this._options.scale.logarithmBase;
- if (base) {
- var power = utils.addInterval(utils.getLog(value, base), interval, isNegative);
- result = Math.pow(base, power)
- }
- else
- result = utils.addInterval(value, interval, isNegative);
- return result
- },
- _correctBusinessValueByMinRangeFromStartEndValues: function(businessValue) {
- var that = this,
- values = that._values,
- startValue,
- endValue,
- isValid = true,
- scale = that._options.scale,
- result = businessValue;
- if (scale.minRange)
- if (that.getIndex() === END_VALUE_INDEX) {
- startValue = that._addInterval(scale.startValue, scale.minRange, scale.inverted);
- if (!scale.inverted && result < startValue || scale.inverted && result > startValue)
- result = startValue
- }
- else if (that.getIndex() === START_VALUE_INDEX) {
- endValue = that._addInterval(scale.endValue, scale.minRange, !scale.inverted);
- if (!scale.inverted && result > endValue || scale.inverted && result < endValue)
- result = endValue
- }
- return result
- },
- _applySliderPosition: function(position, disableAnimation) {
- var that = this,
- isAnimation = that._options.behavior.animationEnabled && !disableAnimation,
- top = that._options.canvas.top,
- slider = that._slider;
- if (isAnimation || slider.inAnimation) {
- slider.inAnimation = true;
- slider.animate({translate: {
- x: position,
- y: top
- }}, isAnimation ? animationOptions : {duration: 0}, function() {
- slider.inAnimation = false
- });
- that._sliderTracker.animate({translate: {
- x: position,
- y: top
- }}, isAnimation ? animationOptions : {duration: 0})
- }
- else {
- that._slider.applySettings({
- translateX: position,
- translateY: top
- });
- that._sliderTracker.applySettings({
- translateX: position,
- translateY: top
- })
- }
- that._sliderTracker.updateHeight();
- that._slider.updateHeight()
- },
- _applyShutterPosition: function(position, disableAnimation) {
- var that = this,
- shutterSettings,
- shutter = that._shutter,
- isAnimation = that._options.behavior.animationEnabled && !disableAnimation,
- sliderIndex = that.getIndex();
- if (sliderIndex == START_VALUE_INDEX)
- shutterSettings = {
- x: that._options.canvas.left,
- y: that._options.canvas.top,
- width: position - that._options.canvas.left,
- height: that._options.canvas.height
- };
- else if (sliderIndex == END_VALUE_INDEX)
- shutterSettings = {
- x: position + 1,
- y: that._options.canvas.top,
- width: that._options.canvas.left + that._options.canvas.width - position,
- height: that._options.canvas.height
- };
- if (shutterSettings)
- if (isAnimation || shutter.inAnimation) {
- shutter.inAnimation = true;
- shutter.animate(shutterSettings, isAnimation ? animationOptions : {duration: 0}, function() {
- shutter.inAnimation = false
- })
- }
- else
- shutter.applySettings(shutterSettings)
- },
- _setValid: function(isValid) {
- var that = this;
- if (that._marker)
- that._marker.setValid(isValid);
- that._slider.setValid(isValid)
- },
- _setText: function(text) {
- var that = this;
- if (that._marker)
- that._marker.setText(text)
- },
- ctor: function(renderer, index) {
- var that = this;
- that.callBase(renderer);
- that._index = index
- },
- getIndex: function() {
- return this._index
- },
- setAvailableValues: function(values) {
- this._values = values
- },
- setAnotherSlider: function(slider) {
- this._anotherSlider = slider
- },
- getAnotherSlider: function(slider) {
- return this._anotherSlider
- },
- appendTrackers: function(group) {
- var that = this;
- if (that._sliderTracker)
- that._sliderTracker.append(group)
- },
- getSliderTracker: function() {
- return this._sliderTracker
- },
- changeLocation: function() {
- var that = this;
- if (that._marker)
- that._marker.changeLocation();
- that._index = this._index === START_VALUE_INDEX ? END_VALUE_INDEX : START_VALUE_INDEX;
- that._lastPosition = null
- },
- setPosition: function(position, correctByMinMaxRange, selectedRangeInterval) {
- var that = this,
- slider;
- if (selectedRangeInterval !== undefined) {
- slider = that.getIndex() === START_VALUE_INDEX ? that : that.getAnotherSlider();
- slider._setPositionForBothSliders(position, selectedRangeInterval)
- }
- else
- that._setPosition(position, correctByMinMaxRange)
- },
- getPosition: function() {
- return this._position
- },
- _applyOptions: function(options) {
- this._lastPosition = null
- },
- setValue: function(value, correctByMinMaxRange, skipCorrection) {
- var that = this;
- if (value === undefined) {
- that._value = undefined;
- that._valuePosition = that._position = that.getIndex() === START_VALUE_INDEX ? that._options.canvas.left : that._options.canvas.left + that._options.canvas.width;
- that._setText(rangeSelector.consts.emptySliderMarkerText)
- }
- else {
- that._value = that._correctBusinessValue(value, correctByMinMaxRange, utils.isDefined(skipCorrection) ? !!skipCorrection : true);
- that._valuePosition = that._position = that._options.translator.translate(that._value);
- that._setText(rangeSelector.formatValue(that._value, that._options.sliderMarker))
- }
- },
- getValue: function() {
- return this._value
- },
- canSwap: function() {
- var that = this,
- scale = that._options.scale,
- startValue,
- endValue,
- anotherSliderValue;
- if (that._options.behavior.allowSlidersSwap) {
- if (scale.minRange) {
- anotherSliderValue = that.getAnotherSlider().getValue();
- if (that.getIndex() === START_VALUE_INDEX) {
- endValue = utils.addInterval(scale.endValue, scale.minRange, !scale.inverted);
- if (!scale.inverted && anotherSliderValue > endValue || scale.inverted && anotherSliderValue < endValue)
- return false
- }
- else {
- startValue = utils.addInterval(scale.startValue, scale.minRange, scale.inverted);
- if (!scale.inverted && anotherSliderValue < startValue || scale.inverted && anotherSliderValue > startValue)
- return false
- }
- }
- return true
- }
- return false
- },
- processDocking: function() {
- var that = this;
- that._position = that._valuePosition;
- that.applyPosition(false);
- that._setValid(true)
- },
- applyPosition: function(disableAnimation) {
- var that = this,
- position = that.getPosition();
- if (that._lastPosition !== position) {
- that._applySliderPosition(position, disableAnimation);
- that._applyShutterPosition(position, disableAnimation);
- that._lastPosition = position
- }
- },
- on: function(event, handler) {
- var that = this;
- that._sliderTracker.on(event, handler);
- if (that._marker)
- that._marker.getTracker().on(event, handler)
- },
- _update: function() {
- var that = this;
- that._marker && that._marker.applyOptions(that._options.sliderMarker);
- that._shutter && that._shutter.applySettings({
- fill: that._options.shutter.color,
- fillOpacity: that._options.shutter.opacity
- });
- that._slider && that._slider.applyOptions({
- strokeWidth: that._options.sliderHandle.width,
- stroke: that._options.sliderHandle.color,
- strokeOpacity: that._options.sliderHandle.opacity
- })
- },
- _draw: function(group) {
- var that = this,
- slider,
- marker,
- sliderAreaGroup,
- shutter,
- startPos,
- startWidth,
- index = that.getIndex();
- sliderAreaGroup = that._renderer.createGroup({'class': 'sliderArea'});
- sliderAreaGroup.append(group);
- if (index === START_VALUE_INDEX)
- shutter = that._renderer.createRect(that._options.canvas.left, that._options.canvas.top, 0, that._options.canvas.height, 0);
- else if (index === END_VALUE_INDEX)
- shutter = that._renderer.createRect(that._options.canvas.left, that._options.canvas.top, that._options.canvas.width, that._options.canvas.height, 0);
- if (shutter) {
- shutter.append(sliderAreaGroup);
- slider = that._createSlider();
- if (slider)
- slider.append(sliderAreaGroup);
- if (that._options.sliderMarker.visible) {
- marker = that._createSliderMarker({
- renderer: that._renderer,
- isLeftPointer: index === END_VALUE_INDEX,
- sliderMarkerOptions: that._options.sliderMarker
- });
- marker.draw(slider)
- }
- that._shutter = shutter;
- that._slider = slider;
- that._marker = marker
- }
- that._drawSliderTracker(group)
- }
- }
- }())
- })(jQuery, DevExpress);
- /*! Module viz-rangeselector, file sliderMarker.js */
- (function($, DX, undefined) {
- var rangeSelector = DX.viz.rangeSelector,
- _SliderMarker;
- _SliderMarker = rangeSelector.SliderMarker = function(options) {
- var that = this;
- that._renderer = options.renderer;
- that._text = options.text;
- that._isLeftPointer = options.isLeftPointer;
- that._options = options.sliderMarkerOptions;
- that._isValid = true;
- initializeAreaPoints(that, {
- width: 10,
- height: 10
- })
- };
- var applyOptions = function(options) {
- this._options = options;
- this.update()
- };
- var getRectSize = function(that, textSize) {
- return {
- width: Math.round(2 * that._options.padding + textSize.width),
- height: Math.round(2 * that._options.padding + textSize.height * rangeSelector.consts.fontHeightRatio)
- }
- };
- var initializeAreaPoints = function(that, textSize) {
- var rectSize = getRectSize(that, textSize);
- that._points = [];
- if (that._isLeftPointer) {
- that._points.push({
- x: 0,
- y: 0
- });
- that._points.push({
- x: rectSize.width,
- y: 0
- });
- that._points.push({
- x: rectSize.width,
- y: rectSize.height
- });
- that._points.push({
- x: that._options.pointerSize,
- y: rectSize.height
- });
- that._points.push({
- x: 0,
- y: rectSize.height + that._options.pointerSize
- })
- }
- else {
- that._points.push({
- x: 0,
- y: 0
- });
- that._points.push({
- x: rectSize.width,
- y: 0
- });
- that._points.push({
- x: rectSize.width,
- y: rectSize.height + that._options.pointerSize
- });
- that._points.push({
- x: rectSize.width - that._options.pointerSize,
- y: rectSize.height
- });
- that._points.push({
- x: 0,
- y: rectSize.height
- })
- }
- };
- var getPointerPosition = function(that, textSize) {
- var rectSize = getRectSize(that, textSize);
- if (that._isLeftPointer)
- return {
- x: 0,
- y: rectSize.height + that._options.pointerSize
- };
- else
- return {
- x: rectSize.width - 1,
- y: rectSize.height + that._options.pointerSize
- }
- };
- var draw = function(group) {
- var that = this;
- var padding = that._options.padding;
- that._sliderMarkerGroup = that._renderer.createGroup({'class': 'sliderMarker'});
- that._sliderMarkerGroup.append(group);
- that._area = that._renderer.createArea(that.points, {fill: that._options.color});
- that._area.append(that._sliderMarkerGroup);
- that._label = that._renderer.createText(that._text, padding, padding, {
- font: that._options.font,
- align: 'left',
- style: {'-webkit-user-select': 'none'}
- });
- that._label.append(that._sliderMarkerGroup);
- that._tracker = that._renderer.createRect(0, 0, 2 * padding, 2 * padding + that._options.pointerSize, 0, {
- fill: 'grey',
- stroke: 'grey',
- opacity: 0.0001,
- style: {cursor: 'pointer'}
- });
- that._tracker.append(that._sliderMarkerGroup);
- that._drawn = true;
- that.update()
- };
- var getTextSize = function(that) {
- var textSize = that._label.getBBox();
- if (!that._textHeight && isFinite(textSize.height))
- that._textHeight = textSize.height;
- return {
- width: textSize.width,
- height: that._textHeight
- }
- };
- var update = function(stop) {
- var that = this,
- textSize,
- rectSize,
- pointerPosition;
- that._interval && clearInterval(that._interval);
- delete that._interval;
- if (!that._drawn)
- return;
- that._label.updateText(that._text);
- textSize = getTextSize(that);
- if (!stop) {
- that._textSize = that._textSize || textSize;
- that._textSize = textSize.width > that._textSize.width || textSize.height > that._textSize.height ? textSize : that._textSize;
- textSize = that._textSize;
- that._interval = setInterval(function() {
- update.call(that, [true])
- }, 75)
- }
- else {
- delete that._textSize;
- that._textSize = textSize
- }
- rectSize = getRectSize(that, textSize);
- pointerPosition = getPointerPosition(that, textSize);
- that._sliderMarkerGroup.applySettings({
- translateX: -pointerPosition.x,
- translateY: -pointerPosition.y
- });
- initializeAreaPoints(that, textSize);
- that._area.applySettings({
- points: that._points,
- fill: that._isValid ? that._options.color : that._options.invalidRangeColor
- });
- that._tracker.applySettings({
- width: rectSize.width,
- height: rectSize.height + that._options.pointerSize
- });
- that._label.applySettings({
- x: that._options.padding,
- y: rectSize.height - that._options.padding
- })
- };
- var getText = function() {
- var that = this;
- return that._text
- };
- var setText = function(value) {
- var that = this;
- if (that._text !== value) {
- that._text = value;
- that.update()
- }
- };
- var setValid = function(isValid) {
- var that = this;
- that._isValid = isValid;
- that.update()
- };
- var changeLocation = function() {
- var that = this;
- that._isLeftPointer = !that._isLeftPointer;
- that.update()
- };
- var getTracker = function() {
- var that = this;
- return that._tracker
- };
- _SliderMarker.prototype = {
- constructor: _SliderMarker,
- draw: draw,
- update: update,
- getText: getText,
- setText: setText,
- changeLocation: changeLocation,
- applyOptions: applyOptions,
- getTracker: getTracker,
- setValid: setValid
- }
- })(jQuery, DevExpress);
- /*! Module viz-rangeselector, file rangeView.js */
- (function($, DX, undefined) {
- var rangeSelector = DX.viz.rangeSelector;
- rangeSelector.RangeView = rangeSelector.BaseVisualElement.inherit(function() {
- return {_draw: function(group) {
- var that = this,
- viewRect,
- viewImage,
- backgroundColor,
- series,
- i,
- showChart,
- canvas,
- options = that._options,
- seriesOptions,
- isEmpty = options.isEmpty;
- showChart = options.seriesDataSource && options.seriesDataSource.isShowChart() && !isEmpty;
- canvas = options.canvas;
- if (showChart)
- backgroundColor = options.seriesDataSource.getBackgroundColor();
- else if (!isEmpty && options.background.visible)
- backgroundColor = options.background.color;
- if (options.background.visible && backgroundColor) {
- viewRect = that._renderer.createRect(canvas.left, canvas.top, canvas.width + 1, canvas.height, 0, {
- fill: backgroundColor,
- 'class': 'dx-range-selector-background'
- });
- viewRect.append(group)
- }
- if (options.background.visible && options.background.image && options.background.image.url) {
- viewImage = that._renderer.createImage(canvas.left, canvas.top, canvas.width + 1, canvas.height, options.background.image.url, {location: options.background.image.location});
- viewImage.append(group)
- }
- if (showChart) {
- series = options.seriesDataSource.getSeries();
- options.seriesDataSource.adjustSeriesDimensions(options.translators, options.chart.useAggregation);
- for (i = 0; i < series.length; i++) {
- seriesOptions = series[i].getOptions();
- seriesOptions.seriesGroup = group;
- seriesOptions.labelsGroup = group;
- series[i].draw(options.translators, options.behavior && options.behavior.animationEnabled && that._renderer.animationEnabled())
- }
- }
- }}
- }())
- })(jQuery, DevExpress);
- /*! Module viz-rangeselector, file seriesDataSource.js */
- (function($, DX, undefined) {
- var rangeSelector = DX.viz.rangeSelector,
- charts = DX.viz.charts,
- core = DX.viz.core,
- coreFactory = core.CoreFactory,
- utils = DX.utils;
- rangeSelector.SeriesDataSource = DX.Class.inherit(function() {
- var createThemeManager = function(chartOptions) {
- return charts.factory.createThemeManager(chartOptions, 'rangeSelector.chart')
- };
- var isArrayOfSimpleTypes = function(data) {
- return $.isArray(data) && data.length > 0 && (utils.isNumber(data[0]) || utils.isDate(data[0]))
- };
- var convertToArrayOfObjects = function(data) {
- return $.map(data, function(item, i) {
- return {
- arg: item,
- val: i
- }
- })
- };
- var calculateSeries = function(that, options, templatedSeries) {
- var series = [],
- particularSeriesOptions,
- seriesTheme,
- data,
- parsedData,
- chartThemeManager = that.themeManager,
- hasSeriesTemplate = !!chartThemeManager.getOptions('seriesTemplate'),
- allSeriesOptions = hasSeriesTemplate ? templatedSeries : options.chart.series,
- seriesValueType = options.chart.valueAxis && options.chart.valueAxis.valueType,
- dataSourceField,
- i;
- that.teamplateData = [];
- if (options.dataSource && !allSeriesOptions) {
- if (isArrayOfSimpleTypes(options.dataSource))
- options.dataSource = convertToArrayOfObjects(options.dataSource);
- dataSourceField = options.dataSourceField || 'arg';
- allSeriesOptions = {
- argumentField: dataSourceField,
- valueField: dataSourceField
- };
- that._hideChart = true
- }
- allSeriesOptions = $.isArray(allSeriesOptions) ? allSeriesOptions : allSeriesOptions ? [allSeriesOptions] : [];
- that._backgroundColor = options.backgroundColor !== undefined ? options.backgroundColor : chartThemeManager.getOptions("backgroundColor");
- for (i = 0; i < allSeriesOptions.length; i++) {
- particularSeriesOptions = $.extend(true, {
- argumentType: options.valueType,
- argumentAxisType: options.axisType,
- valueType: dataSourceField ? options.valueType : seriesValueType,
- incidentOccured: options.incidentOccured
- }, allSeriesOptions[i]);
- particularSeriesOptions.rotated = false;
- data = particularSeriesOptions.data || options.dataSource;
- seriesTheme = chartThemeManager.getOptions("series", particularSeriesOptions);
- seriesTheme.argumentField = seriesTheme.argumentField || options.dataSourceField;
- if (data && data.length > 0) {
- var newSeries = coreFactory.createSeries(options.renderer, seriesTheme);
- series.push(newSeries)
- }
- if (hasSeriesTemplate) {
- $.each(data, function(_, data) {
- $.each(newSeries.getTeamplatedFields(), function(_, field) {
- data[field.teamplateField] = data[field.originalField]
- });
- that.teamplateData.push(data)
- });
- newSeries.updateTeamplateFieldNames()
- }
- }
- data = hasSeriesTemplate ? that.teamplateData : data;
- that._dataValidator = charts.factory.createDataValidator(data, [series], options.incidentOccured, chartThemeManager.getOptions("dataPrepareSettings"));
- parsedData = that._dataValidator.validate();
- for (i = 0; i < series.length; i++) {
- var particularSeries = series[i];
- particularSeries.updateData(parsedData)
- }
- return series
- };
- var processSeriesFamilies = function(series, equalBarWidth, minBubbleSize, maxBubbleSize) {
- var families = [],
- types = [];
- $.each(series, function(i, item) {
- if ($.inArray(item.type, types) === -1)
- types.push(item.type)
- });
- $.each(types, function(_, type) {
- var family = new coreFactory.createSeriesFamily({
- type: type,
- equalBarWidth: equalBarWidth,
- minBubbleSize: minBubbleSize,
- maxBubbleSize: maxBubbleSize
- });
- family.add(series);
- family.adjustSeriesValues();
- families.push(family)
- });
- return families
- };
- var prototypeObject = {
- ctor: function(options) {
- var that = this,
- templatedSeries,
- seriesTemplate,
- themeManager = that.themeManager = createThemeManager(options.chart),
- topIndent = themeManager.getOptions('topIndent'),
- bottomIndent = themeManager.getOptions('bottomIndent');
- that._indent = {
- top: topIndent >= 0 && topIndent < 1 ? topIndent : 0,
- bottom: bottomIndent >= 0 && bottomIndent < 1 ? bottomIndent : 0
- };
- that._valueAxis = themeManager.getOptions('valueAxisRangeSelector') || {};
- that._hideChart = false;
- seriesTemplate = themeManager.getOptions('seriesTemplate');
- if (options.dataSource && seriesTemplate)
- templatedSeries = utils.processSeriesTemplate(seriesTemplate, options.dataSource);
- that._series = calculateSeries(that, options, templatedSeries);
- that._seriesFamilies = processSeriesFamilies(that._series, themeManager.getOptions('equalBarWidth'), themeManager.getOptions('minBubbleSize'), themeManager.getOptions('maxBubbleSize'))
- },
- adjustSeriesDimensions: function(translators, useAggregation) {
- var that = this;
- if (useAggregation)
- $.each(that._series || [], function(_, s) {
- s.resamplePoints(translators)
- });
- $.each(that._seriesFamilies, function() {
- this.adjustSeriesDimensions(translators)
- })
- },
- getBoundRange: function() {
- var that = this,
- rangeData,
- valueAxisMin = that._valueAxis.min,
- valueAxisMax = that._valueAxis.max,
- valRange = new core.Range({
- isValueRange: true,
- min: valueAxisMin,
- minVisible: valueAxisMin,
- max: valueAxisMax,
- maxVisible: valueAxisMax,
- axisType: that._valueAxis.type,
- base: that._valueAxis.logarithmBase
- }),
- argRange = new core.Range({}),
- rangeYSize,
- rangeVisibleSizeY,
- i,
- minIndent,
- maxIndent;
- for (i = 0; i < that._series.length; i++) {
- rangeData = that._series[i].getRangeData();
- valRange.addRange(rangeData.val);
- argRange.addRange(rangeData.arg)
- }
- if (valRange.isDefined() && argRange.isDefined()) {
- minIndent = that._valueAxis.inverted ? that._indent.top : that._indent.bottom;
- maxIndent = that._valueAxis.inverted ? that._indent.bottom : that._indent.top;
- rangeYSize = valRange.max - valRange.min;
- rangeVisibleSizeY = ($.isNumeric(valRange.maxVisible) ? valRange.maxVisible : valRange.max) - ($.isNumeric(valRange.minVisible) ? valRange.minVisible : valRange.min);
- if (utils.isDate(valRange.min))
- valRange.min = new Date(valRange.min.valueOf() - rangeYSize * minIndent);
- else
- valRange.min -= rangeYSize * minIndent;
- if (utils.isDate(valRange.max))
- valRange.max = new Date(valRange.max.valueOf() + rangeYSize * maxIndent);
- else
- valRange.max += rangeYSize * maxIndent;
- if ($.isNumeric(rangeVisibleSizeY)) {
- valRange.maxVisible = valRange.maxVisible ? valRange.maxVisible + rangeVisibleSizeY * maxIndent : undefined;
- valRange.minVisible = valRange.minVisible ? valRange.minVisible - rangeVisibleSizeY * minIndent : undefined
- }
- valRange.invert = that._valueAxis.inverted
- }
- return {
- arg: argRange,
- val: valRange
- }
- },
- getSeries: function() {
- var that = this;
- return that._series
- },
- getBackgroundColor: function() {
- var that = this;
- return that._backgroundColor
- },
- isEmpty: function() {
- var that = this;
- return that.getSeries().length === 0
- },
- isShowChart: function() {
- var that = this;
- return !that.isEmpty() && !that._hideChart
- },
- getCalculatedValueType: function() {
- var that = this,
- result;
- if (that._series.length)
- result = that._series[0].argumentType;
- return result
- }
- };
- return prototypeObject
- }())
- })(jQuery, DevExpress);
- /*! Module viz-rangeselector, file themeManager.js */
- (function($, DX, undefined) {
- DX.viz.rangeSelector = DX.viz.rangeSelector;
- DX.viz.rangeSelector.ThemeManager = DX.viz.core.BaseThemeManager.inherit({
- _themeSection: 'rangeSelector',
- ctor: function(userTheme) {
- this.setTheme(userTheme)
- },
- _initializeTheme: function() {
- this._initializeFont(this._theme.scale.label.font);
- this._initializeFont(this._theme.sliderMarker.font);
- this._initializeFont(this._theme.loadingIndicator.font)
- },
- applyRangeSelectorTheme: function(userOptions) {
- var that = this,
- chart = userOptions.chart,
- dataSource = userOptions.dataSource,
- result;
- delete userOptions.dataSource;
- delete userOptions.chart;
- result = $.extend(true, {}, that._theme, userOptions);
- result.dataSource = dataSource;
- if (chart)
- result.chart = chart;
- return result
- },
- setBackgroundColor: function(containerBackgroundColor) {
- var theme = this._theme;
- if (containerBackgroundColor)
- theme.containerBackgroundColor = containerBackgroundColor;
- theme.shutter.color = theme.shutter.color || theme.containerBackgroundColor
- }
- })
- })(jQuery, DevExpress);
- /*! Module viz-rangeselector, file dxRangeSelector.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- viz = DX.viz;
- DX.registerComponent("dxRangeSelector", viz.rangeSelector.RangeSelector)
- })(jQuery, DevExpress);
- DevExpress.MOD_VIZ_RANGESELECTOR = true
- }
- if (!DevExpress.MOD_VIZ_VECTORMAP) {
- if (!DevExpress.MOD_VIZ_CORE)
- throw Error('Required module is not referenced: viz-core');
- /*! Module viz-vectormap, file map.js */
- (function(DX, $, undefined) {
- DX.viz.map = {};
- var _Number = window.Number,
- _isFunction = DX.utils.isFunction,
- _getRootOffset = DX.utils.getRootOffset;
- var DEFAULT_WIDTH = 800,
- DEFAULT_HEIGHT = 400;
- var DATA_KEY = DX.viz.map.__DATA_KEY = 'vectormap-data';
- DX.viz.map.Map = DX.viz.core.BaseWidget.inherit({
- _init: function() {
- var that = this;
- that.callBase.apply(that, arguments);
- that.renderer = that._renderer = that._factory.createRenderer({
- width: 1,
- height: 1,
- pathModified: that.option('pathModified'),
- rtl: that.option('rtlEnabled')
- });
- that.renderer.draw(that._element().get(0));
- that._root = that._renderer.getRoot();
- that._root.applySettings({
- 'class': 'dxm',
- stroke: 'none',
- strokeWidth: 0,
- fill: 'none',
- align: 'center',
- cursor: 'default',
- style: {overflow: 'hidden'}
- });
- that._themeManager = that._factory.createThemeManager();
- that._projection = that._factory.createProjection();
- that._tracker = that._factory.createTracker({root: that._root});
- that._background = that._renderer.createRect(0, 0, 0, 0, 0, {'class': 'dxm-background'}).data(DATA_KEY, {type: 'background'});
- that._areasManager = that._factory.createAreasManager({
- container: that._root,
- renderer: that._renderer,
- projection: that._projection,
- themeManager: that._themeManager,
- tracker: that._tracker,
- ready: function() {
- that.hideLoadingIndicator()
- }
- });
- that._areasManager.setData(that.option('mapData'));
- that._markersManager = that._factory.createMarkersManager({
- container: that._root,
- renderer: that._renderer,
- projection: that._projection,
- themeManager: that._themeManager,
- tracker: that._tracker
- });
- that._markersManager.setData(that.option('markers'));
- that._controlBar = that._factory.createControlBar({
- container: that._root,
- renderer: that._renderer,
- context: that,
- resetCallback: controlResetCallback,
- beginMoveCallback: controlBeginMoveCallback,
- endMoveCallback: controlEndMoveCallback,
- moveCallback: controlMoveCallback,
- zoomCallback: controlZoomCallback
- });
- that._legend = that._factory.createLegend({
- container: that._root,
- renderer: that._renderer,
- themeManager: that._themeManager
- });
- that._tooltip = that._factory.createTooltip({
- container: that._root,
- renderer: that._renderer,
- tracker: that._tracker
- });
- that._projection.setBounds(that.option('bounds')).setMaxZoom(that.option('maxZoomFactor')).setZoom(that.option('zoomFactor')).setCenter(that.option('center'));
- that._themeManager.setTheme(that.option('theme'));
- that._themeManager.patchRtlSettings(that.option('rtlEnabled'));
- that._setClickCallback(that.option('click'));
- that._setCenterChangedCallback(that.option('centerChanged'));
- that._setZoomFactorChangedCallback(that.option('zoomFactorChanged'));
- that._setTrackerCallbacks()
- },
- _dispose: function() {
- var that = this;
- that.callBase.apply(that, arguments);
- that._resetTrackerCallbacks();
- that._themeManager.dispose();
- that._tracker.dispose();
- that._areasManager.dispose();
- that._markersManager.dispose();
- that._controlBar.dispose();
- that._legend.dispose();
- that._tooltip.dispose();
- that._renderer.dispose();
- that._disposeLoadIndicator();
- that._renderer = that._themeManager = that._projection = that._tracker = that._root = that._background = that._areasManager = that._markersManager = that._controlBar = that._legend = that._tooltip = that._centerChangedCallback = that._zoomFactorChangedCallback = null
- },
- _setTrackerCallbacks: function() {
- var that = this,
- renderer = that._renderer,
- managers = {
- area: that._areasManager,
- marker: that._markersManager
- },
- projection = that._projection,
- controlBar = that._controlBar,
- tooltip = that._tooltip,
- xdrag,
- ydrag,
- isControlDrag = false;
- that._tracker.setCallbacks({
- click: function(arg) {
- var offset = _getRootOffset(renderer);
- arg.$event.x = arg.x - offset.left;
- arg.$event.y = arg.y - offset.top;
- var manager = managers[arg.data.type];
- if (manager)
- manager.raiseClick(arg.data.index, arg.$event);
- if (manager || arg.data.type === 'background')
- that._raiseClick(arg.$event)
- },
- start: function(arg) {
- isControlDrag = arg.data.type === 'control-bar';
- if (isControlDrag) {
- arg.data = arg.data.index;
- controlBar.processStart(arg)
- }
- else {
- xdrag = arg.x;
- ydrag = arg.y;
- projection.snapCenter()
- }
- },
- move: function(arg) {
- if (isControlDrag) {
- arg.data = arg.data.index;
- controlBar.processMove(arg)
- }
- else {
- projection.moveCenter(xdrag - arg.x, ydrag - arg.y);
- xdrag = arg.x;
- ydrag = arg.y;
- that._applyTranslate()
- }
- },
- end: function(arg) {
- if (isControlDrag) {
- arg.data = arg.data.index;
- controlBar.processEnd(arg)
- }
- else
- projection.isCenterChanged() && that._raiseCenterChanged();
- isControlDrag = false
- },
- zoom: function(arg) {
- controlBar.processZoom(arg)
- },
- 'hover-on': function(arg) {
- var manager = managers[arg.data.type];
- if (manager)
- manager.hoverItem(arg.data.index, true)
- },
- 'hover-off': function(arg) {
- var manager = managers[arg.data.type];
- if (manager)
- manager.hoverItem(arg.data.index, false)
- },
- 'focus-on': function(arg, done) {
- var result = false;
- if (tooltip.enabled()) {
- var proxy = managers[arg.data.type] ? managers[arg.data.type].getProxyItem(arg.data.index) : null;
- if (!!proxy && tooltip.prepare(proxy, {offset: 12})) {
- var offset = _getRootOffset(renderer);
- tooltip.show().move(arg.x - offset.left, arg.y - offset.top);
- result = true
- }
- }
- done(result)
- },
- 'focus-move': function(arg) {
- var offset = _getRootOffset(renderer);
- tooltip.move(arg.x - offset.left, arg.y - offset.top)
- },
- 'focus-off': function(arg) {
- tooltip.hide()
- }
- });
- that._resetTrackerCallbacks = function() {
- that._resetTrackerCallbacks = that = renderer = managers = projection = controlBar = tooltip = null
- }
- },
- _adjustSize: function(force) {
- var that = this,
- size = that.option('size') || {},
- width = size.width >= 0 ? _Number(size.width) : that._element().width(),
- height = size.height >= 0 ? _Number(size.height) : that._element().height(),
- hidden = false;
- if (width === 0)
- if (_Number(size.width) === 0)
- hidden = true;
- else
- width = DEFAULT_WIDTH;
- if (height === 0)
- if (_Number(size.height) === 0)
- hidden = true;
- else
- height = DEFAULT_HEIGHT;
- if (hidden || !that._element().is(':visible')) {
- that._incidentOccured("W2001", [that.NAME]);
- that._width = that._height = 0;
- return false
- }
- var needResize = that._width !== width || that._height !== height || force;
- if (needResize) {
- that._width = width;
- that._height = height;
- that._renderer.resize(width, height);
- that._projection.setSize(width, height);
- that._legend.applyLayout(width, height);
- that._tooltip.setSize(width, height);
- that._background.applySettings({
- x: 0,
- y: 0,
- width: width,
- height: height
- });
- that._applyTranslate();
- that._updateLoadIndicator(undefined, width, height)
- }
- return needResize
- },
- _clean: function() {
- var that = this;
- that._tracker.clean();
- that._background.detach();
- that._areasManager.clean();
- that._markersManager.clean();
- that._controlBar.clean();
- that._legend.clean();
- that._tooltip.clean()
- },
- _render: function() {
- var that = this;
- if (!that._adjustSize(true))
- return;
- that._tooltip.update(that._themeManager.getTooltipSettings(that.option('tooltip')));
- that._tracker.setOptions(that.option('interaction') || {});
- that._controlBar.setZoomPartition(that._projection.getZoomScalePartition()).setZoom(that._projection.getScaledZoom()).setOptions(that._themeManager.getControlBarSettings(that.option('controlBar')), that.option('interaction'));
- that._background.applySettings(that._themeManager.getBackgroundSettings(that.option('background')));
- that._background.append(that._root);
- that._areasManager.render(that.option('areaSettings'));
- that._markersManager.render(that.option('markerSettings'));
- that._controlBar.render();
- that._legend.render(that._themeManager.getLegendSettings(that.option('legend')));
- that._tooltip.render();
- that._tracker.render();
- that._drawn()
- },
- _optionChanged: function(name, value) {
- var that = this;
- switch (name) {
- case'theme':
- that._themeManager.setTheme(value);
- that._themeManager.patchRtlSettings(that.option('rtlEnabled'));
- that._invalidate();
- break;
- case'click':
- that._setClickCallback(value);
- break;
- case'centerChanged':
- that._setCenterChangedCallback(value);
- break;
- case'zoomFactorChanged':
- that._setZoomFactorChangedCallback(value);
- break;
- case'mapData':
- that._areasManager.setData(value);
- break;
- case'markers':
- that._markersManager.setData(value);
- break;
- case'bounds':
- that._projection.setBounds(value);
- that._invalidate();
- break;
- case'maxZoomFactor':
- that._projection.setMaxZoom(value);
- that._invalidate();
- break;
- case'zoomFactor':
- that._updateZoomFactor(value);
- break;
- case'center':
- that._updateCenter(value);
- break;
- default:
- that.callBase.apply(that, arguments);
- break
- }
- },
- _getLoadIndicatorOption: function() {
- return this._themeManager.getLoadIndicatorSettings(this.option('loadingIndicator'))
- },
- _setClickCallback: function(callback) {
- this._clickCallback = _isFunction(callback) ? callback : null
- },
- _setCenterChangedCallback: function(callback) {
- var that = this;
- that._centerChangedCallback = _isFunction(callback) ? function() {
- that._centerChangedCallback && callback.call(that, that._projection.getCenter())
- } : null
- },
- _setZoomFactorChangedCallback: function(callback) {
- var that = this;
- that._zoomFactorChangedCallback = _isFunction(callback) ? function() {
- that._zoomFactorChangedCallback && callback.call(that, that._projection.getZoom())
- } : null
- },
- _raiseClick: function(arg) {
- var that = this;
- that._clickCallback && setTimeout(function() {
- that._clickCallback && that._clickCallback.call(that, arg)
- }, 0)
- },
- _raiseCenterChanged: function() {
- this._centerChangedCallback && setTimeout(this._centerChangedCallback, 0)
- },
- _raiseZoomFactorChanged: function() {
- this._zoomFactorChangedCallback && setTimeout(this._zoomFactorChangedCallback, 0)
- },
- _updateCenter: function(center, _noEvent) {
- this._projection.snapCenter().setCenter(center);
- if (this._projection.isCenterChanged()) {
- this._applyTransform();
- _noEvent || this._raiseCenterChanged()
- }
- },
- _updateZoomFactor: function(zoomFactor, _noEvent) {
- var that = this;
- that._projection.snapZoom().setZoom(zoomFactor);
- if (that._projection.isZoomChanged()) {
- that._controlBar.setZoom(that._projection.getScaledZoom());
- that._applyTransform(true);
- _noEvent || that._raiseZoomFactorChanged()
- }
- },
- _updateViewport: function(viewport, _noEvent) {
- var that = this;
- that._projection.snapCenter().snapZoom().setViewport(viewport);
- that._applyTransform(that._projection.isZoomChanged());
- if (that._projection.isCenterChanged())
- _noEvent || that._raiseCenterChanged();
- if (that._projection.isZoomChanged()) {
- that._controlBar.setZoom(that._projection.getScaledZoom());
- _noEvent || that._raiseZoomFactorChanged()
- }
- },
- _resize: function() {
- if (this._adjustSize())
- this._applyTransform(true)
- },
- _applyTranslate: function() {
- var transform = this._projection.getTransform();
- this._areasManager.transform(transform);
- this._markersManager.transform(transform)
- },
- _applyTransform: function(redraw, _noTrackerReset) {
- _noTrackerReset || this._tracker.reset();
- this._applyTranslate();
- if (redraw) {
- this._areasManager.redraw();
- this._markersManager.redraw()
- }
- },
- _refresh: function() {
- var that = this,
- callBase = that.callBase;
- that._endLoading(function() {
- callBase.call(that)
- })
- },
- render: function() {
- var that = this;
- if (that._width === 0 && that._height === 0)
- that._refresh();
- else
- that._resize();
- return that
- },
- getAreas: function() {
- return this._areasManager.getProxyItems()
- },
- getMarkers: function() {
- return this._markersManager.getProxyItems()
- },
- clearAreaSelection: function(_noEvent) {
- this._areasManager.clearSelection(_noEvent);
- return this
- },
- clearMarkerSelection: function(_noEvent) {
- this._markersManager.clearSelection(_noEvent);
- return this
- },
- clearSelection: function(_noEvent) {
- return this.clearAreaSelection(_noEvent).clearMarkerSelection(_noEvent)
- },
- center: function(value, _noEvent) {
- if (value === undefined)
- return this._projection.getCenter();
- else {
- this._updateCenter(value, _noEvent);
- return this
- }
- },
- zoomFactor: function(value, _noEvent) {
- if (value === undefined)
- return this._projection.getZoom();
- else {
- this._updateZoomFactor(value, _noEvent);
- return this
- }
- },
- viewport: function(value, _noEvent) {
- if (value === undefined)
- return this._projection.getViewport();
- else {
- this._updateViewport(value, _noEvent);
- return this
- }
- },
- convertCoordinates: function(x, y) {
- return this._projection.fromScreenPointStrict(x, y)
- },
- showLoadingIndicator: function() {
- this._showLoadIndicator(this._themeManager.getLoadIndicatorSettings(this.option('loadingIndicator')), {
- width: this._width,
- height: this._height
- })
- },
- _factory: {
- createRenderer: function(options) {
- return new DX.viz.renderers.Renderer(options)
- },
- createTooltip: function(parameters) {
- return new Tooltip(parameters)
- },
- createLegend: function(parameters) {
- return new Legend(parameters)
- }
- }
- });
- var Tooltip = DX.viz.core.Tooltip.inherit({
- ctor: function(parameters) {
- var that = this;
- that._container = parameters.container;
- that._root = parameters.renderer.createGroup({'class': 'dxm-tooltip'});
- that.callBase(null, that._root, parameters.renderer);
- that._tracker = parameters.tracker;
- that._enabled = false
- },
- dispose: function() {
- var that = this;
- that._container = that._root = that._tracker = null;
- return that.callBase.apply(that, arguments)
- },
- clean: function() {
- this._root.detach();
- return this
- },
- render: function() {
- this._root.append(this._container);
- return this
- }
- });
- var Legend = DX.viz.core.Legend.inherit({
- ctor: function(parameters) {
- var that = this;
- that._container = parameters.container;
- that._root = parameters.renderer.createGroup({'class': 'dxm-legend'});
- that._themeManager = parameters.themeManager;
- that.callBase(null, null, parameters.renderer, that._root)
- },
- dispose: function() {
- var that = this;
- that._container = that._root = that._themeManager = null;
- return that.callBase.apply(that, arguments)
- },
- clean: function() {
- this._root.detach();
- return this
- },
- render: function(options) {
- var that = this,
- items = [],
- i = 0,
- ii = options.items ? options.items.length : 0;
- for (; i < ii; ++i)
- items.push(that._themeManager.getLegendItemSettings(options.items[i] || {}));
- that.update(items, options);
- that._root.append(that._container);
- return that.applyLayout(that._size.width, that._size.height)
- },
- applyLayout: function(width, height) {
- var that = this,
- layoutOptions;
- that.setSize({
- width: width,
- height: height
- });
- that.draw();
- layoutOptions = that.getLayoutOptions();
- if (layoutOptions) {
- var left,
- top;
- if (layoutOptions.horizontalAlignment === 'left')
- left = 0;
- else if (layoutOptions.horizontalAlignment === 'center')
- left = width / 2 - layoutOptions.width / 2;
- else
- left = width - layoutOptions.width;
- if (layoutOptions.verticalAlignment === 'top')
- top = 0;
- else
- top = height - layoutOptions.height;
- that.shift(left, top)
- }
- return that
- }
- });
- function projectAreaDefault(dataItem) {
- return this._projection.projectArea(dataItem.coordinates)
- }
- function projectAreaGeoJson(dataItem) {
- if (dataItem.geometry) {
- var type = dataItem.geometry.type,
- coordinates = dataItem.geometry.coordinates;
- if (coordinates && (type === 'Polygon' || type === 'MultiPolygon')) {
- type === 'MultiPolygon' && (coordinates = [].concat.apply([], coordinates));
- return this._projection.projectArea(coordinates)
- }
- }
- return []
- }
- function controlResetCallback() {
- var projection = this._projection,
- isCenterChanged,
- isZoomChanged;
- projection.snapCenter().snapZoom().setCenter(null).setZoom(null);
- isCenterChanged = projection.isCenterChanged();
- isZoomChanged = projection.isZoomChanged();
- if (isCenterChanged || isZoomChanged)
- this._applyTransform(isZoomChanged, true);
- isCenterChanged && this._raiseCenterChanged();
- isZoomChanged && this._raiseZoomFactorChanged()
- }
- function controlBeginMoveCallback() {
- this._projection.snapCenter()
- }
- function controlEndMoveCallback() {
- this._projection.isCenterChanged() && this._raiseCenterChanged()
- }
- function controlMoveCallback(dx, dy) {
- this._projection.moveCenter(dx, dy);
- this._applyTranslate()
- }
- function controlZoomCallback(zoom, x, y) {
- var that = this,
- keepPosition = x !== undefined && y !== undefined,
- coords,
- screenPosition;
- if (keepPosition) {
- screenPosition = _getRootOffset(that._renderer);
- screenPosition = [x - screenPosition.left, y - screenPosition.top];
- coords = that._projection.fromScreenPoint(screenPosition[0], screenPosition[1])
- }
- that._projection.snapZoom().setScaledZoom(zoom);
- if (that._projection.isZoomChanged()) {
- keepPosition && that._projection.snapCenter().setCenterByPoint(coords, screenPosition);
- that._applyTransform(true, true);
- that._raiseZoomFactorChanged();
- keepPosition && that._projection.isCenterChanged() && that._raiseCenterChanged()
- }
- }
- DX.registerComponent('dxVectorMap', DX.viz.map.Map);
- DX.viz.map._internal = {};
- DX.viz.map.sources = {};
- DX.viz.map._tests = {};
- DX.viz.map._tests.Legend = Legend;
- DX.viz.map._tests.Tooltip = Tooltip
- })(DevExpress, jQuery);
- /*! Module viz-vectormap, file projection.js */
- (function(DX, $, undefined) {
- var _Number = Number,
- _isFinite = isFinite,
- _min = Math.min,
- _max = Math.max,
- _abs = Math.abs,
- _tan = Math.tan,
- _atan = Math.atan,
- _exp = Math.exp,
- _round = Math.round,
- _ln = Math.log,
- _pow = Math.pow,
- _isArray = DX.utils.isArray,
- _buildPath = DX.viz.renderers.buildPath;
- var PI = Math.PI,
- QUARTER_PI = PI / 4,
- PI_TO_360 = PI / 360,
- TWO_TO_LN2 = 2 / Math.LN2;
- var DEFAULT_MIN_ZOOM = 1,
- DEFAULT_MAX_ZOOM = 1 << 8;
- var MERCATOR_MIN_LON = -180,
- MERCATOR_MAX_LON = 180,
- MERCATOR_MIN_LAT = -85.0511,
- MERCATOR_MAX_LAT = 85.0511;
- var mercator = {
- aspectRatio: 1,
- project: function(coordinates) {
- var lon = coordinates[0],
- lat = coordinates[1];
- return [lon <= MERCATOR_MIN_LON ? -1 : lon >= MERCATOR_MAX_LON ? +1 : lon / 180, lat <= MERCATOR_MIN_LAT ? +1 : lat >= MERCATOR_MAX_LAT ? -1 : -_ln(_tan(QUARTER_PI + lat * PI_TO_360)) / PI]
- },
- unproject: function(coordinates) {
- var x = coordinates[0],
- y = coordinates[1];
- return [x <= -1 ? MERCATOR_MIN_LON : x >= +1 ? MERCATOR_MAX_LON : 180 * x, y <= -1 ? MERCATOR_MAX_LAT : y >= +1 ? MERCATOR_MIN_LAT : (_atan(_exp(-PI * coordinates[1])) - QUARTER_PI) / PI_TO_360]
- }
- };
- function createProjectUnprojectMethods(p1, p2, delta) {
- var x0 = (p1[0] + p2[0]) / 2 - delta / 2,
- y0 = (p1[1] + p2[1]) / 2 - delta / 2,
- k = 2 / delta;
- return {
- project: function(coordinates) {
- var p = mercator.project(coordinates);
- return [-1 + (p[0] - x0) * k, -1 + (p[1] - y0) * k]
- },
- unproject: function(coordinates) {
- var p = [x0 + (coordinates[0] + 1) / k, y0 + (coordinates[1] + 1) / k];
- return mercator.unproject(p)
- }
- }
- }
- function floatsEqual(f1, f2) {
- return _abs(f1 - f2) < 1E-8
- }
- function truncate(value, min, max, fallback) {
- var _value = _Number(value);
- if (_value < min)
- _value = min;
- else if (_value > max)
- _value = max;
- else if (!(min <= _value && _value <= max))
- _value = fallback;
- return _value
- }
- function truncateQuad(quad, min, max) {
- return {
- lt: [truncate(quad[0], min[0], max[0], min[0]), truncate(quad[1], min[1], max[1], min[1])],
- rb: [truncate(quad[2], min[0], max[0], max[0]), truncate(quad[3], min[1], max[1], max[1])]
- }
- }
- function parseBounds(bounds) {
- var p1 = mercator.unproject([-1, -1]),
- p2 = mercator.unproject([+1, +1]),
- min = [_min(p1[0], p2[0]), _min(p1[1], p2[1])],
- max = [_max(p1[0], p2[0]), _max(p1[1], p2[1])],
- quad = bounds;
- if (quad && quad.minLon)
- quad = [quad.minLon, quad.minLat, quad.maxLon, quad.maxLat];
- if (quad)
- quad = truncateQuad(quad, min, max);
- return {
- minBase: min,
- maxBase: max,
- min: quad ? [_min(quad.lt[0], quad.rb[0]), _min(quad.lt[1], quad.rb[1])] : min,
- max: quad ? [_max(quad.lt[0], quad.rb[0]), _max(quad.lt[1], quad.rb[1])] : max
- }
- }
- function selectCenterValue(value1, value2, center1, center2) {
- var result;
- if (value1 > -1 && value2 >= +1)
- result = center1;
- else if (value1 <= -1 && value2 < +1)
- result = center2;
- else
- result = (center1 + center2) / 2;
- return result
- }
- function Projection() {
- this.setBounds(null)
- }
- Projection.prototype = {
- constructor: Projection,
- _minZoom: DEFAULT_MIN_ZOOM,
- _maxZoom: DEFAULT_MAX_ZOOM,
- _zoom: DEFAULT_MIN_ZOOM,
- setSize: function(width, height) {
- var that = this;
- that._x0 = width / 2;
- that._y0 = height / 2;
- if (width / height <= mercator.aspectRatio) {
- that._xradius = width / 2;
- that._yradius = width / 2 / mercator.aspectRatio
- }
- else {
- that._xradius = height / 2 * mercator.aspectRatio;
- that._yradius = height / 2
- }
- return that
- },
- setBounds: function(bounds) {
- var that = this,
- _bounds = parseBounds(bounds);
- that._minBase = _bounds.minBase;
- that._maxBase = _bounds.maxBase;
- that._minBound = _bounds.min;
- that._maxBound = _bounds.max;
- var p1 = mercator.project(_bounds.min),
- p2 = mercator.project(_bounds.max),
- delta = _min(truncate(_abs(p2[0] - p1[0]), 0.1, 2, 2), truncate(_abs(p2[1] - p1[1]), 0.1, 2, 2)),
- methods = delta < 2 ? createProjectUnprojectMethods(p1, p2, delta) : mercator;
- that._project = methods.project;
- that._unproject = methods.unproject;
- var minv = that._project(_bounds.minBase),
- maxv = that._project(_bounds.maxBase);
- that._minv = [_min(minv[0], maxv[0]), _min(minv[1], maxv[1])];
- that._maxv = [_max(minv[0], maxv[0]), _max(minv[1], maxv[1])];
- that._defaultCenter = that._unproject([0, 0]);
- return that.setCenter(that._defaultCenter)
- },
- _toScreen: function(coordinates) {
- return [this._x0 + this._xradius * coordinates[0], this._y0 + this._yradius * coordinates[1]]
- },
- _fromScreen: function(coordinates) {
- return [(coordinates[0] - this._x0) / this._xradius, (coordinates[1] - this._y0) / this._yradius]
- },
- _toTransformed: function(coordinates) {
- return [coordinates[0] * this._zoom + this._dxcenter, coordinates[1] * this._zoom + this._dycenter, ]
- },
- _toTransformedFast: function(coordinates) {
- return [coordinates[0] * this._zoom, coordinates[1] * this._zoom]
- },
- _fromTransformed: function(coordinates) {
- return [(coordinates[0] - this._dxcenter) / this._zoom, (coordinates[1] - this._dycenter) / this._zoom]
- },
- _adjustCenter: function() {
- var that = this,
- center = that._project(that._center);
- that._dxcenter = -center[0] * that._zoom;
- that._dycenter = -center[1] * that._zoom
- },
- projectArea: function(coordinates) {
- var i = 0,
- ii = _isArray(coordinates) ? coordinates.length : 0,
- subcoords,
- j,
- jj,
- subresult,
- result = [];
- for (; i < ii; ++i) {
- subcoords = coordinates[i];
- subresult = [];
- for (j = 0, jj = _isArray(subcoords) ? subcoords.length : 0; j < jj; ++j)
- subresult.push(this._project(subcoords[j]));
- result.push(subresult)
- }
- return result
- },
- projectPoint: function(coordinates) {
- return coordinates ? this._project(coordinates) : []
- },
- getAreaCoordinates: function(data) {
- var k = 0,
- kk = data.length,
- partialData,
- i,
- ii,
- list = [],
- partialPath,
- point;
- for (; k < kk; ++k) {
- partialData = data[k];
- partialPath = [];
- for (i = 0, ii = partialData.length; i < ii; ++i) {
- point = this._toScreen(this._toTransformedFast(partialData[i]));
- partialPath.push(point[0], point[1])
- }
- list.push(_buildPath(partialPath))
- }
- return list.join(' ')
- },
- getPointCoordinates: function(data) {
- var point = this._toScreen(this._toTransformedFast(data));
- return {
- x: _round(point[0]),
- y: _round(point[1])
- }
- },
- getZoom: function() {
- return this._zoom
- },
- setZoom: function(zoom) {
- var that = this;
- that._zoom = truncate(zoom, that._minZoom, that._maxZoom, that._minZoom);
- that._adjustCenter();
- return that
- },
- getScaledZoom: function() {
- return _round((this._scale.length - 1) * _ln(this._zoom) / _ln(this._maxZoom))
- },
- setScaledZoom: function(scaledZoom) {
- return this.setZoom(this._scale[_round(scaledZoom)])
- },
- getZoomScalePartition: function() {
- return this._scale.length - 1
- },
- _setupScaling: function() {
- var that = this,
- k = _round(TWO_TO_LN2 * _ln(that._maxZoom));
- k = k > 4 ? k : 4;
- var step = _pow(that._maxZoom, 1 / k),
- zoom = that._minZoom,
- i = 1;
- that._scale = [zoom];
- for (; i <= k; ++i)
- that._scale.push(zoom *= step)
- },
- setMaxZoom: function(maxZoom) {
- var that = this;
- that._minZoom = DEFAULT_MIN_ZOOM;
- that._maxZoom = truncate(maxZoom, that._minZoom, _Number.MAX_VALUE, DEFAULT_MAX_ZOOM);
- that._setupScaling();
- if (that._zoom > that._maxZoom)
- that.setZoom(that._maxZoom);
- return that
- },
- getMinZoom: function() {
- return this._minZoom
- },
- getMaxZoom: function() {
- return this._maxZoom
- },
- getCenter: function() {
- return [this._center[0], this._center[1]]
- },
- setCenter: function(center) {
- var _center = _isArray(center) ? center : null;
- _center = _center || center && (center.lon || center.lat) && [center.lon, center.lat] || [];
- var that = this;
- that._center = [truncate(_center[0], that._minBound[0], that._maxBound[0], that._defaultCenter[0]), truncate(_center[1], that._minBound[1], that._maxBound[1], that._defaultCenter[1])];
- that._adjustCenter();
- return that
- },
- setCenterByPoint: function(coordinates, screenPosition) {
- var that = this,
- p = that._project(coordinates),
- q = that._fromScreen(screenPosition);
- return that.setCenter(that._unproject([-q[0] / that._zoom + p[0], -q[1] / that._zoom + p[1]]))
- },
- moveCenter: function(screenDx, screenDy) {
- var that = this,
- current = that._toScreen(that._toTransformed(that._project(that._center))),
- center = that._unproject(that._fromTransformed(that._fromScreen([current[0] + screenDx, current[1] + screenDy])));
- return that.setCenter(center)
- },
- getViewport: function() {
- var p1 = this._unproject(this._fromTransformed([-1, -1])),
- p2 = this._unproject(this._fromTransformed([+1, +1]));
- return [p1[0], p1[1], p2[0], p2[1]]
- },
- setViewport: function(viewport) {
- var that = this;
- if (!_isArray(viewport))
- return that.setZoom(that._minZoom).setCenter(that._defaultCenter);
- var _viewport = truncateQuad(viewport, that._minBase, that._maxBase),
- lt = that._project(_viewport.lt),
- rb = that._project(_viewport.rb),
- l = _min(lt[0], rb[0]),
- t = _min(lt[1], rb[1]),
- r = _max(lt[0], rb[0]),
- b = _max(lt[1], rb[1]),
- zoom = 2 / _max(r - l, b - t),
- xc = selectCenterValue(l, r, -1 - zoom * l, +1 - zoom * r),
- yc = selectCenterValue(t, b, -1 - zoom * t, +1 - zoom * b);
- return that.setZoom(zoom).setCenter(that._unproject([-xc / zoom, -yc / zoom]))
- },
- getTransform: function() {
- return {
- translateX: this._dxcenter * this._xradius,
- translateY: this._dycenter * this._yradius
- }
- },
- fromScreenPoint: function(x, y) {
- return this._unproject(this._fromTransformed(this._fromScreen([x, y])))
- },
- fromScreenPointStrict: function(x, y) {
- var that = this,
- p = that._fromTransformed(that._fromScreen([x, y])),
- q = that._unproject(p);
- return [p[0] >= that._minv[0] && p[0] <= that._maxv[0] ? q[0] : NaN, p[1] >= that._minv[1] && p[1] <= that._maxv[1] ? q[1] : NaN]
- },
- snapCenter: function() {
- this._snappedCenter = this.getCenter();
- return this
- },
- isCenterChanged: function() {
- var center = this.getCenter();
- return !floatsEqual(this._snappedCenter[0], center[0]) || !floatsEqual(this._snappedCenter[1], center[1])
- },
- snapZoom: function() {
- this._snappedZoom = this.getZoom();
- return this
- },
- isZoomChanged: function() {
- return !floatsEqual(this._snappedZoom, this.getZoom())
- }
- };
- DX.viz.map._tests.Projection = Projection;
- DX.viz.map._tests.mercator = mercator;
- DX.viz.map._tests._DEBUG_stubMercator = function(stub) {
- mercator = stub
- };
- DX.viz.map._tests._DEBUG_restoreMercator = function() {
- mercator = DX.viz.map._tests.mercator
- };
- DX.viz.map.Map.prototype._factory.createProjection = function() {
- return new Projection
- }
- })(DevExpress, jQuery);
- /*! Module viz-vectormap, file controlBar.js */
- (function(DX, undefined) {
- var _buildPath = DX.viz.renderers.buildPath,
- _setTimeout = setTimeout,
- _clearTimeout = clearTimeout,
- _round = Math.round,
- _pow = Math.pow,
- _ln = Math.log;
- var _LN2 = Math.LN2;
- var COMMAND_RESET = 'command-reset',
- COMMAND_MOVE_UP = 'command-move-up',
- COMMAND_MOVE_RIGHT = 'command-move-right',
- COMMAND_MOVE_DOWN = 'command-move-down',
- COMMAND_MOVE_LEFT = 'command-move-left',
- COMMAND_ZOOM_IN = 'command-zoom-in',
- COMMAND_ZOOM_OUT = 'command-zoom-out',
- COMMAND_ZOOM_DRAG = 'command-zoom-drag';
- var _DATA_KEY = DX.viz.map.__DATA_KEY,
- EVENT_TARGET_TYPE = 'control-bar';
- var COMMAND_TO_TYPE_MAP = {};
- COMMAND_TO_TYPE_MAP[COMMAND_RESET] = ResetCommand;
- COMMAND_TO_TYPE_MAP[COMMAND_MOVE_UP] = COMMAND_TO_TYPE_MAP[COMMAND_MOVE_RIGHT] = COMMAND_TO_TYPE_MAP[COMMAND_MOVE_DOWN] = COMMAND_TO_TYPE_MAP[COMMAND_MOVE_LEFT] = MoveCommand;
- COMMAND_TO_TYPE_MAP[COMMAND_ZOOM_IN] = COMMAND_TO_TYPE_MAP[COMMAND_ZOOM_OUT] = ZoomCommand;
- COMMAND_TO_TYPE_MAP[COMMAND_ZOOM_DRAG] = ZoomDragCommand;
- var ControlBar = DX.Class.inherit({
- ctor: function(parameters) {
- var that = this;
- that._container = parameters.container;
- that._createElements(parameters.renderer);
- var context = parameters.context,
- resetCallback = parameters.resetCallback,
- beginMoveCallback = parameters.beginMoveCallback,
- endMoveCallback = parameters.endMoveCallback,
- moveCallback = parameters.moveCallback,
- zoomCallback = parameters.zoomCallback;
- parameters = null;
- that._reset = function() {
- resetCallback.call(context)
- };
- that._beginMove = function() {
- beginMoveCallback.call(context)
- };
- that._endMove = function() {
- endMoveCallback.call(context)
- };
- that._move = function(dx, dy) {
- moveCallback.call(context, dx, dy)
- };
- that._zoom = function(zoom, x, y) {
- zoomCallback.call(context, zoom, x, y)
- };
- that._dispose = function() {
- this._reset = this._move = this._zoom = this._dispose = context = resetCallback = moveCallback = zoomCallback = null
- }
- },
- _createElements: function(renderer) {
- var that = this;
- that._root = renderer.createGroup({'class': 'dxm-control-bar'});
- that._buttonsGroup = renderer.createGroup({'class': 'dxm-control-buttons'}).append(that._root);
- that._trackersGroup = renderer.createGroup({
- stroke: 'none',
- strokeWidth: 0,
- fill: '#000000',
- opacity: 0.0001,
- cursor: 'pointer'
- }).append(that._root);
- var options = {
- bigCircleSize: 58,
- smallCircleSize: 28,
- buttonSize: 10,
- arrowButtonOffset: 20,
- incdecButtonSize: 11,
- incButtonOffset: 66,
- decButtonOffset: 227,
- sliderLineStartOffset: 88.5,
- sliderLineEndOffset: 205.5,
- sliderLength: 20,
- sliderWidth: 8,
- trackerGap: 4
- };
- that._createButtons(renderer, options);
- that._createTrackers(renderer, options);
- that._root.applySettings({
- translateX: 50.5,
- translateY: 50.5
- })
- },
- _createButtons: function(renderer, options) {
- var group = this._buttonsGroup,
- size = options.buttonSize / 2,
- offset1 = options.arrowButtonOffset - size,
- offset2 = options.arrowButtonOffset,
- incdecButtonSize = options.incdecButtonSize / 2;
- renderer.createCircle(0, 0, options.bigCircleSize / 2).append(group);
- renderer.createCircle(0, 0, size).append(group);
- renderer.createPath([-size, -offset1, 0, -offset2, size, -offset1]).append(group);
- renderer.createPath([offset1, -size, offset2, 0, offset1, size]).append(group);
- renderer.createPath([size, offset1, 0, offset2, -size, offset1]).append(group);
- renderer.createPath([-offset1, size, -offset2, 0, -offset1, -size]).append(group);
- renderer.createCircle(0, options.incButtonOffset, options.smallCircleSize / 2).append(group);
- renderer.createSimplePath({d: _buildPath([-incdecButtonSize, options.incButtonOffset, incdecButtonSize, options.incButtonOffset]) + ' ' + _buildPath([0, options.incButtonOffset - incdecButtonSize, 0, options.incButtonOffset + incdecButtonSize])}).append(group);
- renderer.createCircle(0, options.decButtonOffset, options.smallCircleSize / 2).append(group);
- renderer.createSimplePath({d: _buildPath([-incdecButtonSize, options.decButtonOffset, incdecButtonSize, options.decButtonOffset])}).append(group);
- renderer.createSimplePath({d: _buildPath([0, options.sliderLineStartOffset, 0, options.sliderLineEndOffset])}).append(group);
- this._zoomDrag = renderer.createRect(-options.sliderLength / 2, options.sliderLineEndOffset - options.sliderWidth / 2, options.sliderLength, options.sliderWidth).append(group);
- this._sliderLineLength = options.sliderLineEndOffset - options.sliderLineStartOffset
- },
- _createTrackers: function(renderer, options) {
- var group = this._trackersGroup,
- size = _round((options.arrowButtonOffset - options.trackerGap) / 2),
- offset1 = options.arrowButtonOffset - size,
- offset2 = _round(_pow(options.bigCircleSize * options.bigCircleSize / 4 - size * size, 0.5)),
- size2 = offset2 - offset1,
- element;
- renderer.createRect(-size, -size, size * 2, size * 2).append(group).data(_DATA_KEY, {
- index: COMMAND_RESET,
- type: EVENT_TARGET_TYPE
- });
- renderer.createRect(-size, -offset2, size * 2, size2).append(group).data(_DATA_KEY, {
- index: COMMAND_MOVE_UP,
- type: EVENT_TARGET_TYPE
- });
- renderer.createRect(offset1, -size, size2, size * 2).append(group).data(_DATA_KEY, {
- index: COMMAND_MOVE_RIGHT,
- type: EVENT_TARGET_TYPE
- });
- renderer.createRect(-size, offset1, size * 2, size2).append(group).data(_DATA_KEY, {
- index: COMMAND_MOVE_DOWN,
- type: EVENT_TARGET_TYPE
- });
- renderer.createRect(-offset2, -size, size2, size * 2).append(group).data(_DATA_KEY, {
- index: COMMAND_MOVE_LEFT,
- type: EVENT_TARGET_TYPE
- });
- renderer.createCircle(0, options.incButtonOffset, options.smallCircleSize / 2).append(group).data(_DATA_KEY, {
- index: COMMAND_ZOOM_IN,
- type: EVENT_TARGET_TYPE
- });
- renderer.createCircle(0, options.decButtonOffset, options.smallCircleSize / 2).append(group).data(_DATA_KEY, {
- index: COMMAND_ZOOM_OUT,
- type: EVENT_TARGET_TYPE
- });
- this._zoomDragCover = renderer.createRect(-options.sliderLength / 2, options.sliderLineEndOffset - options.sliderWidth / 2, options.sliderLength, options.sliderWidth).append(group).data(_DATA_KEY, {
- index: COMMAND_ZOOM_DRAG,
- type: EVENT_TARGET_TYPE
- })
- },
- dispose: function() {
- var that = this;
- delete that._container;
- that._dispose();
- that._root.clear();
- delete that._root;
- delete that._buttonsGroup;
- delete that._zoomDrag;
- delete that._zoomDragCover;
- return that
- },
- setZoomPartition: function(partition) {
- this._zoomPartition = partition;
- this._sliderUnitLength = this._sliderLineLength / partition;
- return this
- },
- setZoom: function(zoom) {
- this._adjustZoom(zoom);
- return this
- },
- setOptions: function(options, interactionOptions) {
- options = options || {};
- interactionOptions = interactionOptions || {};
- this._dragAndZoomEnabled = interactionOptions.dragAndZoomEnabled !== undefined ? !!interactionOptions.dragAndZoomEnabled : true;
- this._enabled = this._dragAndZoomEnabled && (options.enabled !== undefined ? !!options.enabled : true);
- this._buttonsGroup.applySettings(options.shape);
- return this
- },
- clean: function() {
- this._enabled && this._root.detach();
- return this
- },
- render: function() {
- this._enabled && this._root.append(this._container);
- return this
- },
- _adjustZoom: function(zoom) {
- var that = this;
- that._zoomFactor = _round(zoom);
- that._zoomFactor >= 0 || (that._zoomFactor = 0);
- that._zoomFactor <= that._zoomPartition || (that._zoomFactor = that._zoomPartition);
- var transform = {translateY: -that._zoomFactor * that._sliderUnitLength};
- that._zoomDrag.applySettings(transform);
- that._zoomDragCover.applySettings(transform)
- },
- _applyZoom: function(x, y) {
- this._zoom(this._zoomFactor, x, y)
- },
- processStart: function(arg) {
- if (this._dragAndZoomEnabled) {
- var commandType = COMMAND_TO_TYPE_MAP[arg.data];
- this._command = new commandType(this, arg)
- }
- return this
- },
- processMove: function(arg) {
- if (this._dragAndZoomEnabled)
- this._command.update(arg);
- return this
- },
- processEnd: function(arg) {
- if (this._dragAndZoomEnabled)
- this._command.finish(arg);
- return this
- },
- processZoom: function(arg) {
- var that = this,
- zoomFactor;
- if (that._dragAndZoomEnabled) {
- if (arg.delta)
- zoomFactor = arg.delta;
- else if (arg.ratio)
- zoomFactor = _ln(arg.ratio) / _LN2;
- that._adjustZoom(that._zoomFactor + zoomFactor);
- that._applyZoom(arg.x, arg.y)
- }
- return that
- }
- });
- function disposeCommand(command) {
- delete command._owner;
- command.update = function(){};
- command.finish = function(){}
- }
- function ResetCommand(owner, arg) {
- this._owner = owner;
- this._command = arg.data
- }
- ResetCommand.prototype.update = function(arg) {
- arg.data !== this._command && disposeCommand(this)
- };
- ResetCommand.prototype.finish = function() {
- this._owner._reset();
- this._owner._adjustZoom(0);
- disposeCommand(this)
- };
- function MoveCommand(owner, arg) {
- this._command = arg.data;
- var timeout = null,
- interval = 100,
- dx = 0,
- dy = 0;
- switch (this._command) {
- case COMMAND_MOVE_UP:
- dy = -10;
- break;
- case COMMAND_MOVE_RIGHT:
- dx = 10;
- break;
- case COMMAND_MOVE_DOWN:
- dy = 10;
- break;
- case COMMAND_MOVE_LEFT:
- dx = -10;
- break
- }
- function callback() {
- owner._move(dx, dy);
- timeout = _setTimeout(callback, interval)
- }
- this._stop = function() {
- _clearTimeout(timeout);
- owner._endMove();
- this._stop = owner = callback = null;
- return this
- };
- arg = null;
- owner._beginMove();
- callback()
- }
- MoveCommand.prototype.update = function(arg) {
- this._command !== arg.data && this.finish()
- };
- MoveCommand.prototype.finish = function() {
- disposeCommand(this._stop())
- };
- function ZoomCommand(owner, arg) {
- this._owner = owner;
- this._command = arg.data;
- var timeout = null,
- interval = 150,
- dzoom = this._command === COMMAND_ZOOM_IN ? 1 : -1;
- function callback() {
- owner._adjustZoom(owner._zoomFactor + dzoom);
- timeout = _setTimeout(callback, interval)
- }
- this._stop = function() {
- _clearTimeout(timeout);
- this._stop = owner = callback = null;
- return this
- };
- arg = null;
- callback()
- }
- ZoomCommand.prototype.update = function(arg) {
- this._command !== arg.data && this.finish()
- };
- ZoomCommand.prototype.finish = function() {
- this._owner._applyZoom();
- disposeCommand(this._stop())
- };
- function ZoomDragCommand(owner, arg) {
- this._owner = owner;
- this._zoomFactor = owner._zoomFactor;
- this._pos = arg.y
- }
- ZoomDragCommand.prototype.update = function(arg) {
- var owner = this._owner;
- owner._adjustZoom(this._zoomFactor + owner._zoomPartition * (this._pos - arg.y) / owner._sliderLineLength)
- };
- ZoomDragCommand.prototype.finish = function() {
- this._owner._applyZoom();
- disposeCommand(this)
- };
- DX.viz.map._tests.ControlBar = ControlBar;
- DX.viz.map.Map.prototype._factory.createControlBar = function(parameters) {
- return new ControlBar(parameters)
- }
- })(DevExpress);
- /*! Module viz-vectormap, file tracker.js */
- (function(DX, $, undefined) {
- var _addNamespace = DX.ui.events.addNamespace,
- _abs = Math.abs,
- _sqrt = Math.sqrt,
- _round = Math.round,
- _max = Math.max,
- _min = Math.min,
- _now = $.now,
- _extend = $.extend;
- var _NAME = DX.viz.map.Map.prototype.NAME,
- _DATA_KEY = DX.viz.map.__DATA_KEY;
- var $doc = $(document);
- var EVENTS = {};
- setupEvents();
- var EVENT_START = 'start',
- EVENT_MOVE = 'move',
- EVENT_END = 'end',
- EVENT_ZOOM = 'zoom',
- EVENT_HOVER_ON = 'hover-on',
- EVENT_HOVER_OFF = 'hover-off',
- EVENT_CLICK = 'click',
- EVENT_FOCUS_ON = 'focus-on',
- EVENT_FOCUS_MOVE = 'focus-move',
- EVENT_FOCUS_OFF = 'focus-off';
- var CLICK_TIME_THRESHOLD = 500,
- CLICK_COORD_THRESHOLD = 5,
- DRAG_COORD_THRESHOLD_MOUSE = 5,
- DRAG_COORD_THRESHOLD_TOUCH = 10,
- FOCUS_ON_DELAY_MOUSE = 300,
- FOCUS_OFF_DELAY_MOUSE = 300,
- FOCUS_ON_DELAY_TOUCH = 300,
- FOCUS_OFF_DELAY_TOUCH = 400,
- FOCUS_COORD_THRESHOLD_MOUSE = 5;
- function Tracker(parameters) {
- this._root = parameters.root;
- this._callbacks = {};
- this._createEventHandlers();
- this._focus = new Focus(this._callbacks)
- }
- _extend(Tracker.prototype, {
- dispose: function() {
- var that = this;
- that._focus.dispose();
- that._root = that._callbacks = that._focus = that._rootClickEvents = that._$docClickEvents = that._rootZoomEvents = that._$docZoomEvents = that._rootHoverEvents = that._$docHoverEvents = that._rootFocusEvents = that._$docFocusEvents = null;
- return that
- },
- _createEventHandlers: function() {
- var that = this;
- that._rootClickEvents = {};
- that._rootClickEvents[EVENTS.start] = function(event) {
- var isTouch = isTouchEvent(event);
- if (isTouch && !that._isTouchEnabled)
- return;
- event.preventDefault();
- var coords = getEventCoords(event);
- that._clickState = {
- x: coords.x,
- y: coords.y,
- time: _now()
- }
- };
- that._$docClickEvents = {};
- that._$docClickEvents[EVENTS.end] = function(event) {
- var state = that._clickState;
- if (!state)
- return;
- var isTouch = isTouchEvent(event);
- if (isTouch && !that._isTouchEnabled)
- return;
- if (_now() - state.time <= CLICK_TIME_THRESHOLD) {
- var coords = getEventCoords(event);
- if (_abs(coords.x - state.x) <= CLICK_COORD_THRESHOLD && _abs(coords.y - state.y) <= CLICK_COORD_THRESHOLD)
- that._callbacks[EVENT_CLICK]({
- data: $(event.target).data(_DATA_KEY) || {},
- x: coords.x,
- y: coords.y,
- $event: event
- })
- }
- that._clickState = null
- };
- that._rootDragEvents = {};
- that._rootDragEvents[EVENTS.start] = function(event) {
- var isTouch = isTouchEvent(event);
- if (isTouch && !that._isTouchEnabled)
- return;
- var coords = getEventCoords(event);
- that._dragState = {
- x: coords.x,
- y: coords.y,
- data: $(event.target).data(_DATA_KEY) || {}
- };
- if (that._isDragEnabled)
- that._callbacks[EVENT_START]({
- data: that._dragState.data,
- x: coords.x,
- y: coords.y
- })
- };
- that._$docDragEvents = {};
- that._$docDragEvents[EVENTS.move] = function(event) {
- var state = that._dragState;
- if (!state)
- return;
- var isTouch = isTouchEvent(event);
- if (isTouch && !that._isTouchEnabled)
- return;
- var coords = getEventCoords(event),
- threshold = isTouch ? DRAG_COORD_THRESHOLD_TOUCH : DRAG_COORD_THRESHOLD_MOUSE;
- if (state.active || _abs(coords.x - state.x) > threshold || _abs(coords.y - state.y) > threshold) {
- state.x = coords.x;
- state.y = coords.y;
- state.active = true;
- state.data = $(event.target).data(_DATA_KEY) || {};
- if (that._isDragEnabled)
- that._callbacks[EVENT_MOVE]({
- data: state.data,
- x: coords.x,
- y: coords.y
- })
- }
- };
- that._$docDragEvents[EVENTS.end] = function(event) {
- var state = that._dragState;
- if (!state)
- return;
- var isTouch = isTouchEvent(event);
- if (isTouch && !that._isTouchEnabled)
- return;
- that._endDragging()
- };
- that._rootZoomEvents = {};
- that._rootZoomEvents[EVENTS.wheel] = function(event) {
- if (!that._isWheelEnabled)
- return;
- event.preventDefault();
- if (that._zoomState)
- return;
- var delta = event.originalEvent.wheelDelta / 120 || event.originalEvent.detail / -3 || 0;
- if (delta === 0)
- return;
- delta = delta > 0 ? _min(_round(delta) || +1, +4) : _max(_round(delta) || -1, -4);
- var coords = getEventCoords(event);
- if (that._isZoomEnabled)
- that._callbacks[EVENT_ZOOM]({
- delta: delta,
- x: coords.x,
- y: coords.y
- });
- that._zoomState = setTimeout(function() {
- that._zoomState = null
- }, 50)
- };
- that._rootZoomEvents[EVENTS.start] = function(event) {
- var isTouch = isTouchEvent(event);
- if (!isTouch || !that._isTouchEnabled)
- return;
- var state = that._zoomState = that._zoomState || {};
- if (state.pointer1 && state.pointer2)
- return;
- var coords;
- if (state.pointer1 === undefined) {
- state.pointer1 = getPointerId(event) || 0;
- coords = getMultitouchEventCoords(event, state.pointer1);
- state.x1 = state.x1_0 = coords.x;
- state.y1 = state.y1_0 = coords.y
- }
- if (state.pointer2 === undefined) {
- var pointer2 = getPointerId(event) || 1;
- if (pointer2 !== state.pointer1) {
- coords = getMultitouchEventCoords(event, pointer2);
- if (coords) {
- state.x2 = state.x2_0 = coords.x;
- state.y2 = state.y2_0 = coords.y;
- state.pointer2 = pointer2;
- state.ready = true;
- that._endDragging()
- }
- }
- }
- };
- that._$docZoomEvents = {};
- that._$docZoomEvents[EVENTS.move] = function(event) {
- var state = that._zoomState;
- if (!state)
- return;
- var isTouch = isTouchEvent(event);
- if (!isTouch || !that._isTouchEnabled)
- return;
- var coords;
- if (state.pointer1 !== undefined) {
- coords = getMultitouchEventCoords(event, state.pointer1);
- if (coords) {
- state.x1 = coords.x;
- state.y1 = coords.y
- }
- }
- if (state.pointer2 !== undefined) {
- coords = getMultitouchEventCoords(event, state.pointer2);
- if (coords) {
- state.x2 = coords.x;
- state.y2 = coords.y
- }
- }
- };
- that._$docZoomEvents[EVENTS.end] = function(event) {
- var state = that._zoomState;
- if (!state)
- return;
- var isTouch = isTouchEvent(event);
- if (!isTouch || !that._isTouchEnabled)
- return;
- if (state.ready) {
- var startDistance = getDistance(state.x1_0, state.y1_0, state.x2_0, state.y2_0),
- currentDistance = getDistance(state.x1, state.y1, state.x2, state.y2);
- if (that._isZoomEnabled)
- that._callbacks[EVENT_ZOOM]({
- ratio: currentDistance / startDistance,
- x: (state.x1_0 + state.x2_0) / 2,
- y: (state.y1_0 + state.y2_0) / 2
- })
- }
- that._zoomState = null
- };
- that._rootHoverEvents = {};
- that._rootHoverEvents[EVENTS.over] = function(event) {
- if (that._hoverTarget === event.target)
- return;
- var isTouch = isTouchEvent(event);
- if (isTouch)
- return;
- var data = $(event.target).data(_DATA_KEY);
- if (!data)
- return;
- that._hoverTarget && that._endHovering();
- that._hoverTarget = event.target;
- that._hoverState = {data: data};
- that._callbacks[EVENT_HOVER_ON]({data: data})
- };
- that._$docHoverEvents = {};
- that._$docHoverEvents[EVENTS.out] = function(event) {
- var state = that._hoverState;
- if (!state)
- return;
- var isTouch = isTouchEvent(event);
- if (isTouch)
- return;
- var data = $(event.target).data(_DATA_KEY);
- if (!data)
- return;
- that._endHovering()
- };
- that._rootFocusEvents = {};
- that._rootFocusEvents[EVENTS.start] = function(event) {
- var isTouch = isTouchEvent(event);
- if (!isTouch || !that._isTouchEnabled)
- return;
- var data = $(event.target).data(_DATA_KEY);
- if (!data)
- return;
- that._focus.turnOff(FOCUS_OFF_DELAY_TOUCH);
- that._focus.turnOn(event.target, data, getEventCoords(event), FOCUS_ON_DELAY_TOUCH);
- that._skip$docEvent = true
- };
- that._rootFocusEvents[EVENTS.over] = function(event) {
- if (that._focusTarget === event.target)
- return;
- that._focusTarget = event.target;
- var isTouch = isTouchEvent(event);
- if (isTouch)
- return;
- var data = $(event.target).data(_DATA_KEY);
- if (!data)
- return;
- if (that._focusTarget)
- that._focus.turnOff(FOCUS_OFF_DELAY_MOUSE);
- var coords = getEventCoords(event);
- if (that._focus.active)
- that._focus.move(event.target, data, coords);
- else
- that._focus.turnOn(event.target, data, coords, FOCUS_ON_DELAY_MOUSE)
- };
- that._$docFocusEvents = {};
- that._$docFocusEvents[EVENTS.start] = function(event) {
- that._focusTarget = event.target;
- var isTouch = isTouchEvent(event);
- if (!isTouch || !that._isTouchEnabled)
- return;
- if (!that._skip$docEvent)
- that._focus.turnOff(FOCUS_OFF_DELAY_TOUCH);
- that._skip$docEvent = null
- };
- that._$docFocusEvents[EVENTS.move] = function(event) {
- if (that._focus.disabled)
- return;
- if (that._focusTarget !== event.target)
- return;
- var isTouch = isTouchEvent(event);
- if (isTouch && !that._isTouchEnabled)
- return;
- var data = $(event.target).data(_DATA_KEY);
- if (!data)
- return;
- var coords = getEventCoords(event);
- if (isTouch) {
- if (that._dragState && that._dragState.active || that._zoomState && that._zoomState.ready)
- that._focus.cancel()
- }
- else if (that._focus.active)
- if (that._dragState && that._dragState.active) {
- that._focus.cancel();
- that._focus.turnOn(event.target, data, coords, FOCUS_ON_DELAY_MOUSE * 4)
- }
- else
- that._focus.move(event.target, data, coords);
- else if (_abs(coords.x - that._focus.x) > FOCUS_COORD_THRESHOLD_MOUSE || _abs(coords.y - that._focus.y) > FOCUS_COORD_THRESHOLD_MOUSE)
- that._focus.turnOn(event.target, data, coords, FOCUS_ON_DELAY_MOUSE)
- };
- that._$docFocusEvents[EVENTS.end] = function(event) {
- if (that._focus.disabled)
- return;
- var isTouch = isTouchEvent(event);
- if (!isTouch || !that._isTouchEnabled)
- return;
- that._focusTarget = null;
- if (!that._focus.active)
- that._focus.turnOff(FOCUS_OFF_DELAY_TOUCH);
- else if (that._focus.changing)
- that._focus.cancel()
- };
- that._$docFocusEvents[EVENTS.out] = function(event) {
- if (that._focus.disabled)
- return;
- var isTouch = isTouchEvent(event);
- if (isTouch)
- return;
- that._focusTarget = null;
- var data = $(event.target).data(_DATA_KEY);
- if (!data)
- return;
- that._focus.turnOff(FOCUS_OFF_DELAY_MOUSE)
- }
- },
- _endDragging: function() {
- var that = this,
- state = that._dragState;
- that._dragState = null;
- if (state && that._isDragEnabled)
- that._callbacks[EVENT_END]({
- data: state.data,
- x: state.x,
- y: state.y
- })
- },
- _endHovering: function() {
- var that = this,
- state = that._hoverState;
- that._hoverState = that._hoverTarget = null;
- if (state)
- that._callbacks[EVENT_HOVER_OFF]({data: state.data})
- },
- reset: function() {
- var that = this;
- that._clickState = null;
- that._endDragging();
- that._endHovering();
- that._focus.cancel();
- that._focusTarget = null;
- return that
- },
- setCallbacks: function(callbacks) {
- _extend(this._callbacks, callbacks);
- return this
- },
- setOptions: function(options) {
- this._isTouchEnabled = options.touchEnabled === undefined || !!options.touchEnabled;
- this._isWheelEnabled = options.wheelEnabled === undefined || !!options.wheelEnabled;
- this._isDragEnabled = options.dragAndZoomEnabled === undefined || !!options.dragAndZoomEnabled;
- this._isZoomEnabled = options.dragAndZoomEnabled === undefined || !!options.dragAndZoomEnabled;
- return this
- },
- clean: function() {
- var that = this;
- if (that._isTouchEnabled) {
- that._root.applySettings({style: {
- 'touch-action': '',
- '-ms-touch-action': '',
- '-webkit-user-select': ''
- }});
- that._root.off(_addNamespace('MSHoldVisual', _NAME)).off(_addNamespace('contextmenu', _NAME))
- }
- that._detachEventHandlers();
- that.reset();
- return that
- },
- render: function() {
- var that = this;
- if (that._isTouchEnabled) {
- that._root.applySettings({style: {
- 'touch-action': 'none',
- '-ms-touch-action': 'none',
- '-webkit-user-select': 'none'
- }});
- that._root.on(_addNamespace('MSHoldVisual', _NAME), function(event) {
- event.preventDefault()
- }).on(_addNamespace('contextmenu', _NAME), function(event) {
- isTouchEvent(event) && event.preventDefault()
- })
- }
- that._attachEventHandlers();
- return that
- },
- _attachEventHandlers: function() {
- var that = this;
- that._root.on(that._rootClickEvents).on(that._rootDragEvents).on(that._rootZoomEvents).on(that._rootHoverEvents).on(that._rootFocusEvents);
- $doc.on(that._$docClickEvents).on(that._$docDragEvents).on(that._$docZoomEvents).on(that._$docHoverEvents).on(that._$docFocusEvents)
- },
- _detachEventHandlers: function() {
- var that = this;
- that._root.off(that._rootClickEvents).off(that._rootDragEvents).off(that._rootZoomEvents).off(that._rootHoverEvents).off(that._rootFocusEvents);
- $doc.off(that._$docClickEvents).off(that._$docDragEvents).off(that._$docZoomEvents).off(that._$docHoverEvents).off(that._$docFocusEvents)
- }
- });
- function Focus(callbacks) {
- this._callbacks = callbacks;
- this.disabled = true
- }
- _extend(Focus.prototype, {
- dispose: function() {
- var that = this;
- clearTimeout(that._onTimer);
- clearTimeout(that._offTimer);
- that._callbacks = that._onTimer = that._offTimer = that.active = that._data = null
- },
- _createCallback: function(target, data, coords) {
- var that = this;
- return function() {
- if (that.active === target) {
- that._callbacks[EVENT_FOCUS_MOVE]({
- data: that._data,
- x: coords.x,
- y: coords.y
- });
- onCheck(true)
- }
- else
- that._callbacks[EVENT_FOCUS_ON]({
- data: data,
- x: coords.x,
- y: coords.y
- }, onCheck)
- };
- function onCheck(result) {
- that.changing = null;
- that.disabled = !result;
- if (result) {
- that._data = data;
- that.active = target;
- clearTimeout(that._offTimer);
- that._offTimer = null
- }
- }
- },
- turnOn: function(target, data, coords, timeout) {
- var that = this;
- that.disabled = false;
- that.x = coords.x;
- that.y = coords.y;
- clearTimeout(that._onTimer);
- that.changing = true;
- that._onTimer = setTimeout(that._createCallback(target, data, coords), timeout)
- },
- move: function(target, data, coords) {
- this.x = coords.x;
- this.y = coords.y;
- this._createCallback(target, data, coords)()
- },
- turnOff: function(timeout) {
- var that = this;
- if (that.active)
- that._offTimer = that._offTimer || setTimeout(function() {
- that._offTimer = null;
- that._callbacks[EVENT_FOCUS_OFF]({data: that._data});
- that._data = that.active = null;
- that.disabled = true
- }, timeout);
- else {
- clearTimeout(that._onTimer);
- that._onTimer = null;
- that.disabled = true
- }
- },
- cancel: function() {
- var that = this;
- if (that.active)
- that._callbacks[EVENT_FOCUS_OFF]({data: that._data});
- clearTimeout(that._onTimer);
- clearTimeout(that._offTimer);
- that._data = that.active = that._onTimer = that._offTimer = null;
- that.disabled = true
- }
- });
- DX.viz.map._tests.Tracker = Tracker;
- DX.viz.map._tests._DEBUG_forceEventMode = function(mode) {
- setupEvents(mode)
- };
- DX.viz.map._tests.Focus = Focus;
- DX.viz.map._tests._DEBUG_stubFocusType = function(focusType) {
- Focus = focusType
- };
- DX.viz.map._tests._DEBUG_restoreFocusType = function() {
- Focus = DX.viz.map._tests.Focus
- };
- DX.viz.map.Map.prototype._factory.createTracker = function(parameters) {
- return new Tracker(parameters)
- };
- function getDistance(x1, y1, x2, y2) {
- return _sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2))
- }
- function isTouchEvent(event) {
- var type = event.originalEvent.type,
- pointerType = event.originalEvent.pointerType;
- return /^touch/.test(type) || /^MSPointer/.test(type) && pointerType !== 4 || /^pointer/.test(type) && pointerType !== 'mouse'
- }
- function selectItem(flags, items) {
- var i = 0,
- ii = flags.length,
- item;
- for (; i < ii; ++i)
- if (flags[i]) {
- item = items[i];
- break
- }
- return _addNamespace(item || items[i], _NAME)
- }
- function setupEvents() {
- var flags = [navigator.pointerEnabled, navigator.msPointerEnabled, 'ontouchstart' in window];
- if (arguments.length)
- flags = [arguments[0] === 'pointer', arguments[0] === 'MSPointer', arguments[0] === 'touch'];
- EVENTS = {
- start: selectItem(flags, ['pointerdown', 'MSPointerDown', 'touchstart mousedown', 'mousedown']),
- move: selectItem(flags, ['pointermove', 'MSPointerMove', 'touchmove mousemove', 'mousemove']),
- end: selectItem(flags, ['pointerup', 'MSPointerUp', 'touchend mouseup', 'mouseup']),
- over: selectItem(flags, ['pointerover', 'MSPointerOver', 'mouseover', 'mouseover']),
- out: selectItem(flags, ['pointerout', 'MSPointerOut', 'mouseout', 'mouseout']),
- wheel: selectItem([], ['mousewheel DOMMouseScroll'])
- }
- }
- function getEventCoords(event) {
- var originalEvent = event.originalEvent,
- touch = originalEvent.touches && originalEvent.touches[0] || {};
- return {
- x: touch.pageX || originalEvent.pageX || event.pageX,
- y: touch.pageY || originalEvent.pageY || event.pageY
- }
- }
- function getPointerId(event) {
- return event.originalEvent.pointerId
- }
- function getMultitouchEventCoords(event, pointerId) {
- var originalEvent = event.originalEvent;
- if (originalEvent.pointerId !== undefined)
- originalEvent = originalEvent.pointerId === pointerId ? originalEvent : null;
- else
- originalEvent = originalEvent.touches[pointerId];
- return originalEvent ? {
- x: originalEvent.pageX || event.pageX,
- y: originalEvent.pageY || event.pageY
- } : null
- }
- })(DevExpress, jQuery);
- /*! Module viz-vectormap, file themeManager.js */
- (function(DX, $, undefined) {
- var _Number = Number,
- _extend = $.extend,
- _each = $.each;
- var ThemeManager = DX.viz.core.BaseThemeManager.inherit({
- _themeSection: 'map',
- _initializeTheme: function() {
- var that = this;
- that._initializeFont(that._theme.marker.font);
- that._initializeFont(that._theme.tooltip.font);
- that._initializeFont(that._theme.legend.font);
- that._initializeFont(that._theme.loadingIndicator.font)
- },
- dispose: function() {
- var that = this;
- that.callBase.apply(that, arguments);
- that._areasPalette = that._markersPalette = null;
- return that
- },
- getBackgroundSettings: function(options) {
- var theme = this._theme.background,
- merged = _extend({}, theme, options);
- return {
- strokeWidth: merged.borderWidth,
- stroke: merged.borderColor,
- fill: merged.color
- }
- },
- getCommonAreaSettings: function(options) {
- var settings = _extend({}, this._theme.area, options);
- this._areasPalette = new DX.viz.core.GradientPalette(settings.palette, settings.paletteSize);
- this._DEBUG_areasPalette = this._areasPalette;
- return settings
- },
- getAreaSettings: function(commonSettings, options) {
- options = options || {};
- var settings = _extend({}, commonSettings, options);
- settings.borderWidth = _Number(settings.borderWidth) || 0;
- settings.borderColor = settings.borderColor || null;
- if (options.color === undefined && options.paletteIndex >= 0)
- settings.color = this._areasPalette.getColor(options.paletteIndex);
- settings.color = settings.color || null;
- settings.hoveredBorderWidth = _Number(settings.hoveredBorderWidth) || settings.borderWidth;
- settings.hoveredBorderColor = settings.hoveredBorderColor || settings.borderColor;
- settings.hoveredColor = settings.hoveredColor || settings.color;
- settings.selectedBorderWidth = _Number(settings.selectedBorderWidth) || settings.borderWidth;
- settings.selectedBorderColor = settings.selectedBorderColor || settings.borderColor;
- settings.selectedColor = settings.selectedColor || settings.color;
- return settings
- },
- getCommonMarkerSettings: function(options) {
- options = options || {};
- var theme = this._theme.marker,
- allSettings = {};
- _each(theme, function(name) {
- if (name[0] === '_') {
- var partialTheme = theme[name] || {},
- partialOptions = options[name] || {},
- settings = _extend({}, theme, partialTheme, options, partialOptions);
- settings.font = _extend({}, theme.font, partialTheme.font, options.font, partialOptions.font);
- allSettings[name.substr(1)] = settings
- }
- });
- this._markersPalette = new DX.viz.core.Palette(options.palette || theme.palette, {
- stepHighlight: 50,
- theme: this.themeName()
- });
- this._DEBUG_markersPalette = this._markersPalette;
- return allSettings
- },
- getMarkerSettings: function(commonSettings, options, type) {
- options = options || {};
- var common = commonSettings[type],
- settings = _extend({}, common, options);
- settings.font = _extend({}, common.font, options.font);
- settings.borderWidth = _Number(settings.borderWidth) || 0;
- settings.borderColor = settings.borderColor || null;
- settings.color = settings.color || null;
- settings.opacity = settings.opacity || null;
- settings.hoveredBorderWidth = _Number(settings.hoveredBorderWidth) || settings.borderWidth;
- settings.hoveredBorderColor = settings.hoveredBorderColor || settings.borderColor;
- settings.hoveredColor = settings.hoveredColor || settings.color;
- settings.hoveredOpacity = settings.hoveredOpacity || settings.opacity;
- settings.selectedBorderWidth = _Number(settings.selectedBorderWidth) || settings.borderWidth;
- settings.selectedBorderColor = settings.selectedBorderColor || settings.borderColor;
- settings.selectedColor = settings.selectedColor || settings.color;
- settings.selectedOpacity = settings.selectedOpacity || settings.opacity;
- return settings
- },
- getMarkerColors: function(count) {
- var i = 0,
- colors = [];
- for (; i < count; ++i)
- colors.push(this._markersPalette.getNextColor());
- this._markersPalette.reset();
- return colors
- },
- getControlBarSettings: function(options) {
- var theme = this._theme.controlBar,
- merged = _extend({}, theme, options);
- return _extend({}, options, {shape: {
- strokeWidth: merged.borderWidth,
- stroke: merged.borderColor,
- fill: merged.color
- }})
- },
- getLoadIndicatorSettings: function(options) {
- var theme = this._theme.loadingIndicator;
- return _extend(true, {}, theme, options)
- },
- getTooltipSettings: function(options) {
- var theme = this._theme.tooltip,
- merged = _extend({}, theme, options),
- borderOptions = _extend({}, theme.border, options && options.border, options && !options.border && {color: options.borderColor});
- return _extend({}, options, {
- color: merged.color,
- border: borderOptions,
- text: {
- strokeWidth: 0,
- stroke: 'none',
- fill: 'none',
- font: _extend({}, theme.font, merged.font),
- 'class': 'dxm-tooltip-text'
- },
- arrowLength: merged.arrowLength,
- paddingLeftRight: merged.paddingLeftRight,
- paddingTopBottom: merged.paddingTopBottom,
- opacity: merged.opacity,
- shadow: _extend({}, theme.shadow, merged.shadow)
- })
- },
- getLegendSettings: function(options) {
- return _extend(true, {}, this._theme.legend, options)
- },
- getLegendItemSettings: function(item) {
- var color = item.color;
- if (color === undefined && item.paletteIndex >= 0)
- color = this._areasPalette.getColor(item.paletteIndex);
- return {
- text: item.text,
- color: color
- }
- },
- patchRtlSettings: function(rtlEnabledOption) {
- var theme = this._theme;
- if (rtlEnabledOption || theme.rtlEnabled && rtlEnabledOption !== false)
- $.extend(true, theme, theme._rtl)
- }
- });
- DX.viz.map._tests.ThemeManager = ThemeManager;
- DX.viz.map.Map.prototype._factory.createThemeManager = function() {
- return new ThemeManager
- }
- })(DevExpress, jQuery);
- /*! Module viz-vectormap, file mapItemsManager.js */
- (function(DX, $, undefined) {
- var _String = String,
- _isString = DX.utils.isString,
- _isArray = DX.utils.isArray,
- _isFunction = DX.utils.isFunction,
- _extend = $.extend,
- _each = $.each,
- _map = $.map;
- var SELECTION_MODE_NONE = 'none',
- SELECTION_MODE_SINGLE = 'single',
- SELECTION_MODE_MULTIPLE = 'multiple';
- var MapItemsManager = DX.Class.inherit({
- _rootClass: null,
- ctor: function(parameters) {
- var that = this;
- that._container = parameters.container;
- that._renderer = parameters.renderer;
- that._projection = parameters.projection;
- that._themeManager = parameters.themeManager;
- that._tracker = parameters.tracker;
- that._ready = parameters.ready;
- that._root = that._renderer.createGroup({'class': that._rootClass});
- that._items = [];
- that._context = {
- renderer: that._renderer,
- root: that._root,
- projection: that._projection,
- selectItem: function(index, state, noCallback) {
- that.selectItem(index, state, noCallback)
- }
- }
- },
- dispose: function() {
- var that = this;
- that._container = that._renderer = that._projection = that._themeManager = that._tracker = that._ready = that._root = that._source = that._context = null;
- return that
- },
- clean: function() {
- var that = this;
- that._rendered = false;
- that._root.detach();
- that._customizeCallback = that._clickCallback = that._selectionChangedCallback = null;
- that._destroyItems();
- return that
- },
- render: function(options) {
- options = options || {};
- var that = this;
- that._rendered = true;
- that._customizeCallback = _isFunction(options.customize) ? options.customize : null;
- that._clickCallback = _isFunction(options.click) ? options.click : null;
- that._selectionChangedCallback = _isFunction(options.selectionChanged) ? options.selectionChanged : null;
- that._hoverEnabled = 'hoverEnabled' in options ? !!options.hoverEnabled : true;
- var selectionMode = _String(options.selectionMode).toLowerCase();
- that._selectionMode = selectionMode === SELECTION_MODE_NONE || selectionMode === SELECTION_MODE_SINGLE || selectionMode === SELECTION_MODE_MULTIPLE ? selectionMode : SELECTION_MODE_SINGLE;
- that._root.append(that._container);
- if (that._source !== null)
- that._createItems();
- return that
- },
- _destroyItems: function() {
- var that = this;
- that._root.clear();
- _each(that._items, function(_, item) {
- item.clean().dispose()
- });
- that._items = [];
- that._selectedItems = null
- },
- _getItemSettings: null,
- _createItem: null,
- _isItemSelected: null,
- _arrangeItems: null,
- _createItems: function() {
- var that = this;
- that._selectedItems = that._selectionMode === SELECTION_MODE_MULTIPLE ? {} : null;
- var selectedList = [];
- _each(_isArray(that._source) ? that._source : [], function(i, dataItem) {
- dataItem = dataItem || {};
- var settings = that._customizeCallback && that._customizeCallback.call(dataItem, dataItem) || {};
- var source = {
- item: dataItem,
- coords: that._getItemCoordinates(dataItem),
- attrs: that._getItemAttributes(dataItem)
- };
- settings = that._getItemSettings(source, settings);
- var item = that._createItem(settings);
- item.init(that._context, source, i).render(settings).locate();
- that._items.push(item);
- if (that._isItemSelected(source, settings))
- selectedList.push(i)
- });
- if (that._selectionMode !== SELECTION_MODE_NONE && selectedList.length > 0) {
- if (that._selectionMode === SELECTION_MODE_SINGLE)
- selectedList = [selectedList[selectedList.length - 1]];
- _each(selectedList, function(_, index) {
- that.selectItem(index, true, true)
- })
- }
- that._arrangeItems();
- that._ready && that._ready()
- },
- _processSource: null,
- setData: function(data) {
- var that = this;
- that._source = null;
- if (_isString(data))
- $.getJSON(data).done(updateSource).fail(function(_0, _1, error) {
- updateSource(null)
- });
- else
- updateSource(data);
- return that;
- function updateSource(source) {
- that._source = that._processSource(source) || 0;
- if (that._rendered) {
- that._tracker.reset();
- that._destroyItems();
- that._createItems()
- }
- }
- },
- transform: function(transform) {
- this._root.applySettings(transform);
- return this
- },
- redraw: function() {
- _each(this._items, function(_, item) {
- item.locate()
- });
- return this
- },
- hoverItem: function(index, state) {
- if (this._hoverEnabled)
- this._items[index].setHovered(!!state);
- return this
- },
- _raiseSelectionChanged: function(item) {
- var that = this;
- if (that._selectionChangedCallback)
- setTimeout(function() {
- that._selectionChangedCallback && that._selectionChangedCallback.call(item.proxy, item.proxy)
- }, 0)
- },
- selectItem: function(index, state, noCallback) {
- var that = this;
- if (that._selectionMode === SELECTION_MODE_NONE)
- return that;
- var item = that._items[index],
- previous = item.selected;
- item.setSelected(!!state);
- if (item.selected === previous)
- return that;
- if (!noCallback)
- that._raiseSelectionChanged(item);
- if (item.selected && that._selectionMode === SELECTION_MODE_SINGLE && that._selectedItems) {
- that._selectedItems.setSelected(false);
- if (!noCallback)
- that._raiseSelectionChanged(that._selectedItems);
- that._selectedItems = null
- }
- if (that._selectionMode === SELECTION_MODE_SINGLE)
- that._selectedItems = item.selected ? item : null;
- else if (item.selected)
- that._selectedItems[index] = item;
- else
- delete that._selectedItems[index];
- return that
- },
- clearSelection: function() {
- var that = this;
- if (that._selectionMode === SELECTION_MODE_NONE)
- return that;
- if (that._selectionMode === SELECTION_MODE_SINGLE) {
- if (that._selectedItems) {
- that._selectedItems.setSelected(false);
- that._raiseSelectionChanged(that._selectedItems);
- that._selectedItems = null
- }
- }
- else
- _each(that._selectedItems, function(i, item) {
- item.setSelected(false);
- that._raiseSelectionChanged(item);
- delete that._selectedItems[i]
- });
- return that
- },
- raiseClick: function(index, $event) {
- var that = this,
- item = that._items[index];
- if (that._clickCallback)
- setTimeout(function() {
- that._clickCallback && that._clickCallback.call(item.proxy, item.proxy, $event)
- }, 0);
- return that
- },
- getProxyItems: function() {
- return _map(this._items, function(item) {
- return item.proxy
- })
- },
- getProxyItem: function(index) {
- return this._items[index].proxy
- }
- });
- DX.viz.map._internal.mapItemBehavior = {
- init: function(ctx, src, index) {
- var that = this;
- that._ctx = ctx;
- that._src = src;
- that._coords = that._project(ctx.projection, src.coords);
- that._data = {
- index: index,
- type: that._type
- };
- that.hovered = that.selected = false;
- that.proxy = createProxy(that, src.attrs, ctx.selectItem);
- that.proxy.type = that._type;
- that._init();
- return that
- },
- dispose: function() {
- disposeItem(this.proxy);
- disposeItem(this);
- return this
- },
- locate: function() {
- var that = this;
- that._locate(that._transform(that._ctx.projection, that._coords));
- return that
- },
- clean: function() {
- this._root.detach();
- return this
- },
- render: function(settings) {
- var that = this;
- that._root = that._createRoot().append(that._ctx.root);
- that._render(settings);
- return that
- },
- setHovered: function(state) {
- var that = this;
- that.hovered = !!state;
- that._onHover();
- if (!that.selected)
- if (that.hovered)
- that._setHoveredState();
- else
- that._setDefaultState();
- return that
- },
- setSelected: function(state) {
- var that = this;
- that.selected = !!state;
- if (that.selected)
- that._setSelectedState();
- else
- that.setHovered(that.hovered);
- return that
- }
- };
- function createProxy(item, attributes, selectItem) {
- attributes = attributes || {};
- return {
- attribute: function(name) {
- return name !== undefined ? attributes[name] : _extend({}, attributes)
- },
- selected: function(state, _noEvent) {
- if (state !== undefined) {
- if (item.selected !== !!state)
- selectItem(item._data.index, !!state, _noEvent);
- return this
- }
- else
- return item.selected
- }
- }
- }
- function disposeItem(item) {
- _each(item, function(name) {
- item[name] = null
- })
- }
- DX.viz.map._tests.MapItemsManager = MapItemsManager;
- DX.viz.map.Map.prototype._factory.MapItemsManager = MapItemsManager
- })(DevExpress, jQuery);
- /*! Module viz-vectormap, file areasManager.js */
- (function(DX, $, undefined) {
- var _DATA_KEY = DX.viz.map.__DATA_KEY;
- var AreasManager = DX.viz.map.Map.prototype._factory.MapItemsManager.inherit({
- _rootClass: 'dxm-areas',
- _processSource: function(source) {
- var isGeoJson = source && source.type === 'FeatureCollection';
- this._getItemCoordinates = isGeoJson ? getCoordinatesGeoJson : getCoordinatesDefault;
- this._getItemAttributes = isGeoJson ? getAttributesGeoJson : getAttributesDefault;
- return isGeoJson ? source.features : source
- },
- clean: function() {
- this._commonSettings = null;
- return this.callBase.apply(this, arguments)
- },
- render: function(options) {
- this._commonSettings = this._themeManager.getCommonAreaSettings(options || {});
- return this.callBase.apply(this, arguments)
- },
- _getItemSettings: function(_, options) {
- return this._themeManager.getAreaSettings(this._commonSettings, options)
- },
- _createItem: function() {
- return new Area
- },
- _isItemSelected: function(source, settings) {
- return source.attrs.isSelected || settings.isSelected
- },
- _arrangeItems: $.noop
- });
- function getCoordinatesDefault(dataItem) {
- return dataItem.coordinates
- }
- function getCoordinatesGeoJson(dataItem) {
- var coordinates;
- if (dataItem.geometry) {
- var type = dataItem.geometry.type;
- coordinates = dataItem.geometry.coordinates;
- if (coordinates && (type === 'Polygon' || type === 'MultiPolygon'))
- type === 'MultiPolygon' && (coordinates = [].concat.apply([], coordinates));
- else
- coordinates = undefined
- }
- return coordinates
- }
- function getAttributesDefault(dataItem) {
- return dataItem.attributes
- }
- function getAttributesGeoJson(dataItem) {
- return dataItem.properties
- }
- function Area(){}
- $.extend(Area.prototype, DX.viz.map._internal.mapItemBehavior, {
- _type: 'area',
- _project: function(projection, coords) {
- return projection.projectArea(coords)
- },
- _init: $.noop,
- _createRoot: function() {
- return this._ctx.renderer.createSimplePath()
- },
- _render: function(settings) {
- var that = this;
- that._styles = {
- normal: {
- 'class': 'dxm-area',
- stroke: settings.borderColor,
- strokeWidth: settings.borderWidth,
- fill: settings.color
- },
- hovered: {
- 'class': 'dxm-area dxm-area-hovered',
- stroke: settings.hoveredBorderColor,
- strokeWidth: settings.hoveredBorderWidth,
- fill: settings.hoveredColor
- },
- selected: {
- 'class': 'dxm-area dxm-area-selected',
- stroke: settings.selectedBorderColor,
- strokeWidth: settings.selectedBorderWidth,
- fill: settings.selectedColor
- }
- };
- that._root.applySettings(that._styles.normal).data(_DATA_KEY, that._data);
- return that
- },
- _transform: function(projection, coords) {
- return projection.getAreaCoordinates(coords)
- },
- _locate: function(coords) {
- this._root.applySettings({d: coords})
- },
- _onHover: $.noop,
- _setDefaultState: function() {
- this._root.applySettings(this._styles.normal).toBackground()
- },
- _setHoveredState: function() {
- this._root.applySettings(this._styles.hovered).toForeground()
- },
- _setSelectedState: function() {
- this._root.applySettings(this._styles.selected).toForeground()
- }
- });
- DX.viz.map._tests.AreasManager = AreasManager;
- DX.viz.map._tests.Area = Area;
- DX.viz.map.Map.prototype._factory.createAreasManager = function(parameters) {
- return new AreasManager(parameters)
- }
- })(DevExpress, jQuery);
- /*! Module viz-vectormap, file markersManager.js */
- (function(DX, $, undefined) {
- var _Number = Number,
- _String = String,
- _isFinite = isFinite,
- _round = Math.round,
- _max = Math.max,
- _min = Math.min,
- _extend = $.extend,
- _isArray = DX.utils.isArray,
- _processCircleSettings = DX.viz.renderers.processCircleSettings;
- var CLASS_DEFAULT = 'dxm-marker',
- CLASS_HOVERED = 'dxm-marker dxm-marker-hovered',
- CLASS_SELECTED = 'dxm-marker dxm-marker-selected',
- TRACKER_SETTINGS = {
- stroke: 'none',
- strokeWidth: 0,
- fill: '#000000',
- opacity: 0.0001
- };
- var _DATA_KEY = DX.viz.map.__DATA_KEY;
- var DEFAULT_MARKER_TYPE = 'dot',
- MARKER_TYPES = {};
- var MarkersManager = DX.viz.map.Map.prototype._factory.MapItemsManager.inherit({
- _rootClass: 'dxm-markers',
- ctor: function() {
- var that = this;
- that.callBase.apply(that, arguments);
- that._context.getColors = function(count) {
- return that._themeManager.getMarkerColors(count)
- };
- that._filter = that._renderer.createFilter('shadow').applySettings({
- x: '-40%',
- y: '-40%',
- width: '180%',
- height: '200%',
- color: '#000000',
- opacity: 0.2,
- dx: 0,
- dy: 1,
- blur: 1
- }).append()
- },
- dispose: function() {
- this._filter.dispose();
- this._filter = null;
- return this.callBase.apply(this, arguments)
- },
- _getItemCoordinates: function(dataItem) {
- return dataItem.coordinates
- },
- _getItemAttributes: function(dataItem) {
- return dataItem.attributes
- },
- _processSource: function(source) {
- return source
- },
- clean: function() {
- var that = this;
- that._commonSettings = null;
- return that.callBase.apply(that, arguments)
- },
- render: function(options) {
- var that = this;
- that._commonSettings = that._themeManager.getCommonMarkerSettings(options);
- that._commonSettings._filter = that._filter.ref;
- that._commonType = parseMarkerType(options && options.type);
- return that.callBase.apply(that, arguments)
- },
- _arrangeBubbles: function() {
- var markers = this._items,
- bubbles = [],
- i,
- ii = markers.length,
- marker,
- values = [];
- for (i = 0; i < ii; ++i) {
- marker = markers[i];
- if (marker.type === 'bubble') {
- bubbles.push(marker);
- if (marker.value !== null)
- values.push(marker.value)
- }
- }
- var minValue = _min.apply(null, values),
- maxValue = _max.apply(null, values),
- deltaValue = maxValue - minValue || 1;
- for (i = 0, ii = bubbles.length; i < ii; ++i) {
- marker = bubbles[i];
- marker.setSize(marker.value !== null ? (marker.value - minValue) / deltaValue : 0)
- }
- },
- _getItemSettings: function(source, options) {
- var type = parseMarkerType(source.item.type, this._commonType),
- style = _extend(source.item.style, options);
- style = this._themeManager.getMarkerSettings(this._commonSettings, style, type);
- _extend(source.item, {text: source.item.text || style.text});
- style._type = type;
- return style
- },
- _createItem: function(settings) {
- return new MARKER_TYPES[settings._type]
- },
- _isItemSelected: function(source, settings) {
- return source.item.isSelected || settings.isSelected
- },
- _arrangeItems: function() {
- this._arrangeBubbles()
- },
- addMarker: function(dataItem) {
- var that = this,
- index = that._items.length,
- marker = that._createItem(dataItem, index);
- that._items.push(marker);
- if (marker._selected)
- that.selectItem(index, true, true);
- that._arrangeItems();
- return that
- }
- });
- var baseMarkerBehavior = _extend({}, DX.viz.map._internal.mapItemBehavior, {
- _type: 'marker',
- _project: function(projection, coords) {
- return projection.projectPoint(coords)
- },
- _init: function() {
- this.proxy.coordinates = createCoordinatesGetter(this._src.coords);
- this.proxy.text = this._src.item.text
- },
- _createRoot: function() {
- return this._ctx.renderer.createGroup()
- },
- _render: function(settings) {
- var that = this;
- that._root.applySettings({'class': CLASS_DEFAULT});
- that._create(settings, that._ctx.renderer, that._root);
- that._createText(settings, that._ctx.renderer, that._root);
- return that
- },
- _createText: function(settings, renderer, root) {
- var that = this;
- if (!that._src.item.text)
- return;
- var rootbox = that._root.getBBox(),
- text = renderer.createText(that._src.item.text, 0, 0, {
- align: 'center',
- font: settings.font
- }).append(root),
- textBox = text.getBBox(),
- x = _round(-textBox.x + rootbox.width / 2) + 2,
- y = _round(-textBox.y - textBox.height / 2) - 1;
- text.applySettings({
- x: x,
- y: y
- });
- renderer.createRect(x + textBox.x - 1, y + textBox.y - 1, textBox.width + 2, textBox.height + 2, 0, TRACKER_SETTINGS).data(_DATA_KEY, that._data).append(root)
- },
- _transform: function(projection, coords) {
- return projection.getPointCoordinates(coords)
- },
- _locate: function(coords) {
- this._root.applySettings({
- translateX: coords.x,
- translateY: coords.y
- })
- },
- _onHover: function() {
- this.hovered && this._root.toForeground()
- },
- _setDefaultState: function() {
- this._root.applySettings({'class': CLASS_DEFAULT}).toBackground();
- this._applyDefault()
- },
- _setHoveredState: function() {
- this._root.applySettings({'class': CLASS_HOVERED});
- this._applyHovered()
- },
- _setSelectedState: function() {
- this._root.applySettings({'class': CLASS_SELECTED}).toForeground();
- this._applySelected()
- }
- });
- function createCoordinatesGetter(coordinates) {
- return function() {
- return [_Number(coordinates[0]), _Number(coordinates[1])]
- }
- }
- function DotMarker(){}
- _extend(DotMarker.prototype, baseMarkerBehavior, {
- type: 'dot',
- _create: function(style, renderer, root) {
- var that = this,
- size = style.size > 0 ? _Number(style.size) : 0,
- hoveredSize = size,
- selectedSize = size + (style.selectedStep > 0 ? _Number(style.selectedStep) : 0),
- hoveredBackSize = hoveredSize + (style.backStep > 0 ? _Number(style.backStep) : 0),
- selectedBackSize = selectedSize + (style.backStep > 0 ? _Number(style.backStep) : 0),
- settings = _processCircleSettings(0, 0, size, style.borderWidth);
- that._dotDefault = {
- cx: settings.cx,
- cy: settings.cy,
- r: settings.r,
- stroke: style.borderColor,
- strokeWidth: style.borderWidth,
- fill: style.color,
- filter: style.shadow ? style._filter : null
- };
- that._dotHovered = {
- cx: settings.cx,
- cy: settings.cy,
- r: hoveredSize / 2,
- stroke: style.hoveredBorderColor,
- strokeWidth: style.hoveredBorderWidth,
- fill: style.hoveredColor
- };
- that._dotSelected = {
- cx: settings.cx,
- cy: settings.cy,
- r: selectedSize / 2,
- stroke: style.selectedBorderColor,
- strokeWidth: style.selectedBorderWidth,
- fill: style.selectedColor
- };
- that._backDefault = {
- cx: settings.cx,
- cy: settings.cy,
- r: settings.r,
- stroke: 'none',
- strokeWidth: 0,
- fill: style.backColor,
- opacity: style.backOpacity
- };
- that._backHovered = {
- cx: settings.cx,
- cy: settings.cy,
- r: hoveredBackSize / 2,
- stroke: 'none',
- strokeWidth: 0,
- fill: style.backColor,
- opacity: style.backOpacity
- };
- that._backSelected = {
- cx: settings.cx,
- cy: settings.cy,
- r: selectedBackSize / 2,
- stroke: 'none',
- strokeWidth: 0,
- fill: style.backColor,
- opacity: style.backOpacity
- };
- that._back = renderer.createCircle().applySettings(that._backDefault).data(_DATA_KEY, that._data).append(root);
- that._dot = renderer.createCircle().applySettings(that._dotDefault).data(_DATA_KEY, that._data).append(root)
- },
- _destroy: function() {
- this._back = this._dot = null
- },
- _applyDefault: function() {
- this._back.applySettings(this._backDefault);
- this._dot.applySettings(this._dotDefault)
- },
- _applyHovered: function() {
- this._back.applySettings(this._backHovered);
- this._dot.applySettings(this._dotHovered)
- },
- _applySelected: function() {
- this._back.applySettings(this._backSelected);
- this._dot.applySettings(this._dotSelected)
- }
- });
- function BubbleMarker(){}
- _extend(BubbleMarker.prototype, baseMarkerBehavior, {
- type: 'bubble',
- _create: function(style, renderer, root) {
- var that = this;
- that._minSize = style.minSize > 0 ? _Number(style.minSize) : 0;
- that._maxSize = style.maxSize > that._minSize ? _Number(style.maxSize) : that._minSize;
- that.value = _isFinite(that._src.item.value) ? _Number(that._src.item.value) : null;
- that._default = {
- stroke: style.borderColor,
- strokeWidth: style.borderWidth,
- fill: style.color,
- opacity: style.opacity
- };
- that._hovered = {
- stroke: style.hoveredBorderColor,
- strokeWidth: style.hoveredBorderWidth,
- fill: style.hoveredColor,
- opacity: style.hoveredOpacity
- };
- that._selected = {
- stroke: style.selectedBorderColor,
- strokeWidth: style.selectedBorderWidth,
- fill: style.selectedColor,
- opacity: style.selectedOpacity
- };
- that._bubble = renderer.createCircle(0, 0, style.maxSize / 2).applySettings(that._default).data(_DATA_KEY, that._data).append(root)
- },
- _destroy: function() {
- this._bubble = null
- },
- _applyDefault: function() {
- this._bubble.applySettings(this._default)
- },
- _applyHovered: function() {
- this._bubble.applySettings(this._hovered)
- },
- _applySelected: function() {
- this._bubble.applySettings(this._selected)
- },
- setSize: function(ratio) {
- var that = this,
- settings = _processCircleSettings(0, 0, that._minSize + ratio * (that._maxSize - that._minSize), that._default.strokeWidth);
- that._default.cx = that._hovered.cx = that._selected.cx = settings.cx;
- that._default.cy = that._hovered.cy = that._selected.cy = settings.cy;
- that._default.r = that._hovered.r = that._selected.r = settings.r;
- that._bubble.applySettings(settings);
- return that
- }
- });
- function PieMarker(){}
- _extend(PieMarker.prototype, baseMarkerBehavior, {
- type: 'pie',
- _create: function(style, renderer, root) {
- var that = this,
- settings = _processCircleSettings(0, 0, style.size > 0 ? _Number(style.size) : 0, style.borderWidth);
- that._pieDefault = {opacity: style.opacity};
- that._pieHovered = {opacity: style.hoveredOpacity};
- that._pieSelected = {opacity: style.selectedOpacity};
- that._borderDefault = {
- stroke: style.borderColor,
- strokeWidth: style.borderWidth
- };
- that._borderHovered = {
- stroke: style.hoveredBorderColor,
- strokeWidth: style.hoveredBorderWidth
- };
- that._borderSelected = {
- stroke: style.selectedBorderColor,
- strokeWidth: style.selectedBorderWidth
- };
- var srcValues = that._src.item.values,
- i = 0,
- ii = _isArray(srcValues) ? srcValues.length : 0,
- values = [],
- value,
- sum = 0;
- for (; i < ii; ++i) {
- value = _Number(srcValues[i]);
- if (_isFinite(value)) {
- values.push(value);
- sum += value
- }
- }
- that._pie = renderer.createGroup(that._pieDefault);
- var translator = new DX.viz.core.Translator1D(0, sum, 90, 450),
- startAngle = translator.translate(0),
- endAngle,
- colors = that._ctx.getColors(values.length);
- for (value = 0, i = 0, ii = values.length; i < ii; ++i) {
- value += values[i];
- endAngle = translator.translate(value);
- renderer.createArc(settings.cx, settings.cy, settings.r, 0, startAngle, endAngle, {fill: colors[i]}).data(_DATA_KEY, that._data).append(that._pie);
- startAngle = endAngle
- }
- that._pie.append(root);
- that._border = renderer.createCircle(settings.cx, settings.cy, settings.r, that._borderDefault).data(_DATA_KEY, that._data).append(root)
- },
- _destroy: function() {
- this._pie = this._border = null
- },
- _applyDefault: function() {
- this._pie.applySettings(this._pieDefault);
- this._border.applySettings(this._borderDefault)
- },
- _applyHovered: function() {
- this._pie.applySettings(this._pieHovered);
- this._border.applySettings(this._borderHovered)
- },
- _applySelected: function() {
- this._pie.applySettings(this._pieSelected);
- this._border.applySettings(this._borderSelected)
- }
- });
- function ImageMarker(){}
- _extend(ImageMarker.prototype, baseMarkerBehavior, {
- type: 'image',
- _create: function(style, renderer, root) {
- var that = this,
- size = style.size > 0 ? _Number(style.size) : 0,
- hoveredSize = size + (style.hoveredStep > 0 ? _Number(style.hoveredStep) : 0),
- selectedSize = size + (style.selectedStep > 0 ? _Number(style.selectedStep) : 0);
- that._default = {
- x: -size / 2,
- y: -size / 2,
- width: size,
- height: size
- };
- that._hovered = {
- x: -hoveredSize / 2,
- y: -hoveredSize / 2,
- width: hoveredSize,
- height: hoveredSize
- };
- that._selected = {
- x: -selectedSize / 2,
- y: -selectedSize / 2,
- width: selectedSize,
- height: selectedSize
- };
- that._image = renderer.createImage().applySettings(that._default).applySettings({
- href: that._src.item.url,
- location: 'center'
- }).append(root);
- that._tracker = renderer.createRect().applySettings(that._default).applySettings(TRACKER_SETTINGS).data(_DATA_KEY, that._data).append(root)
- },
- _destroy: function() {
- this._image = this._tracker = null
- },
- _applyDefault: function() {
- this._image.applySettings(this._default);
- this._tracker.applySettings(this._default)
- },
- _applyHovered: function() {
- this._image.applySettings(this._hovered);
- this._tracker.applySettings(this._hovered)
- },
- _applySelected: function() {
- this._image.applySettings(this._selected);
- this._tracker.applySettings(this._selected)
- }
- });
- MARKER_TYPES['dot'] = DotMarker;
- MARKER_TYPES['bubble'] = BubbleMarker;
- MARKER_TYPES['pie'] = PieMarker;
- MARKER_TYPES['image'] = ImageMarker;
- function parseMarkerType(type, defaultType) {
- return MARKER_TYPES[type] && type || defaultType || DEFAULT_MARKER_TYPE
- }
- var __originalDefaultMarkerType = DEFAULT_MARKER_TYPE,
- __originalMarkerTypes = $.extend({}, MARKER_TYPES);
- DX.viz.map._tests.stubMarkerTypes = function(markerTypes, defaultMarkerType) {
- DEFAULT_MARKER_TYPE = defaultMarkerType;
- MARKER_TYPES = markerTypes
- };
- DX.viz.map._tests.restoreMarkerTypes = function() {
- DEFAULT_MARKER_TYPE = __originalDefaultMarkerType;
- MARKER_TYPES = __originalMarkerTypes
- };
- DX.viz.map._tests.baseMarkerBehavior = baseMarkerBehavior;
- DX.viz.map._tests.MarkersManager = MarkersManager;
- DX.viz.map._tests.DotMarker = DotMarker;
- DX.viz.map._tests.BubbleMarker = BubbleMarker;
- DX.viz.map._tests.PieMarker = PieMarker;
- DX.viz.map._tests.ImageMarker = ImageMarker;
- DX.viz.map.Map.prototype._factory.createMarkersManager = function(parameters) {
- return new MarkersManager(parameters)
- }
- })(DevExpress, jQuery);
- DevExpress.MOD_VIZ_VECTORMAP = true
- }
- if (!DevExpress.MOD_VIZ_SPARKLINES) {
- if (!DevExpress.MOD_VIZ_CORE)
- throw Error('Required module is not referenced: viz-core');
- /*! Module viz-sparklines, file baseSparkline.js */
- (function($, DX) {
- var TOOLTIP_MARGIN = 100,
- TOOLTIP_ARROW_MARGIN = 10,
- DEFAULT_LINE_SPACING = 6,
- DEFAULT_EVENTS_DELAY = 200,
- TOUCH_EVENTS_DELAY = 1000,
- _extend = $.extend,
- _abs = Math.abs,
- _Number = Number,
- _round = Math.round,
- core = DX.viz.core,
- CoreFactory = core.CoreFactory;
- function DEFAULT_CUSTOMIZE_TOOLTIP(customizeObject) {
- return {text: customizeObject.valueText.join('<br/>')}
- }
- DX.viz.sparklines = {};
- DX.viz.sparklines.DEFAULT_CUSTOMIZE_TOOLTIP = DEFAULT_CUSTOMIZE_TOOLTIP;
- DX.viz.sparklines.BaseSparkline = core.BaseWidget.inherit({
- render: function() {
- this._refresh();
- return this
- },
- _rendererType: DX.viz.renderers.Renderer,
- _clean: function() {
- if (this._tooltipShown) {
- this._tooltip.dispose();
- this._tooltip = null;
- this._tooltipShown = null;
- this._tooltipGroup.clear()
- }
- this._tooltipContainer.detach();
- this._cleanWidgetElements()
- },
- _optionChanged: function(optionName, value) {
- if (optionName === 'size' && this._allOptions) {
- this._clean();
- this._canvas = this._calculateCanvas();
- this._renderer.resize(this._canvas.width, this._canvas.height);
- if (!this._isContainerVisible())
- return;
- this._allOptions.size = value;
- this._redrawWidgetElements();
- this._prepareTooltipContainer()
- }
- else if (optionName === 'dataSource' && this._allOptions)
- this._refreshDataSource();
- else
- this.callBase.apply(this, arguments)
- },
- _init: function() {
- this.callBase();
- this._canvas = this._calculateCanvas();
- this._renderer = new this._rendererType({
- cssClass: this._widgetClass + ' ' + this._widgetClass + '-' + this._widgetType,
- pathModified: this.option('pathModified'),
- rtl: this.option('rtlEnabled')
- });
- this._renderer.recreateCanvas(this._canvas.width, this._canvas.height);
- this._createHtmlElements();
- this._createTooltipGroups();
- this._initTooltipEvents();
- this._drawContainer()
- },
- _dispose: function() {
- var that = this;
- that.callBase();
- that._disposeWidgetElements();
- that._disposeTooltipEvents();
- that._renderer.dispose();
- that._tooltipRenderer.dispose();
- that._translatorX = null;
- that._translatorY = null;
- delete that._renderer;
- delete that._tooltipRenderer;
- delete that._tooltipTrackerGroup;
- delete that._tooltipGroup;
- delete that._tooltipContainer
- },
- _render: function() {
- var that = this;
- that._canvas = that._calculateCanvas();
- that._renderer.resize(that._canvas.width, that._canvas.height);
- if (!that._isContainerVisible()) {
- that._incidentOccured('W2001', [that.NAME]);
- return
- }
- that._prepareOptions();
- that._createWidgetElements();
- that._drawWidgetElements();
- that._drawn()
- },
- _isContainerVisible: function() {
- var that = this,
- canvas = that._canvas,
- enoughWidth = canvas.width - canvas.left - canvas.right > 0,
- enoughHeight = canvas.height - canvas.top - canvas.bottom > 0;
- return canvas.height && canvas.width && enoughHeight && enoughWidth
- },
- _createWidgetElements: function() {
- this._createRange();
- this._createTranslator()
- },
- _prepareOptions: function(defaultOptions) {
- var that = this,
- userOptions = that.option() || {},
- options,
- defaultTheme,
- theme;
- defaultTheme = core.findTheme('default');
- defaultTheme = defaultTheme[this._widgetType];
- options = _extend(true, {}, defaultOptions, userOptions);
- if (typeof options.theme === 'string') {
- theme = core.findTheme(options.theme);
- theme = theme[this._widgetType]
- }
- else
- theme = options.theme;
- return _extend(true, {}, defaultTheme, theme, options)
- },
- _calculateCanvas: function() {
- var that = this,
- canvas = {},
- sizeOptions = that.option('size') || {},
- marginOptions = that.option('margin') || {},
- defaultSize = that._defaultSize,
- container = that._element(),
- width = sizeOptions.width >= 0 ? _Number(sizeOptions.width) : container.width(),
- height = sizeOptions.height >= 0 ? _Number(sizeOptions.height) : container.height();
- if (!width && _Number(sizeOptions.width) !== 0)
- width = defaultSize.width;
- if (!height && _Number(sizeOptions.height) !== 0)
- height = defaultSize.height;
- return {
- width: width,
- height: height,
- top: _Number(marginOptions.top) || defaultSize.top,
- bottom: _Number(marginOptions.bottom) || defaultSize.bottom,
- left: _Number(marginOptions.left) || defaultSize.left,
- right: _Number(marginOptions.right) || defaultSize.right
- }
- },
- _createTooltipGroups: function() {
- var that = this,
- renderer,
- root,
- widgetClass = that._widgetClass;
- that._tooltipRenderer = renderer = new that._rendererType({
- cssClass: widgetClass + ' ' + widgetClass + '-tooltip',
- pathModified: this.option('pathModified'),
- rtl: this.option('rtlEnabled')
- });
- renderer.recreateCanvas(1, 1);
- that._tooltipContainer = $('<div style="position: relative">');
- renderer.draw(that._tooltipContainer[0]);
- root = renderer.getRoot();
- that._tooltipGroup = renderer.createGroup({
- 'class': widgetClass + '-tooltip-group',
- style: {'z-index': '1'}
- }).append(root);
- that._tooltipTrackerGroup = renderer.createGroup({'class': widgetClass + '-tooltip-tracker-group'}).append(root);
- that._tooltipTracker = that._createTooltipTracker().append(that._tooltipTrackerGroup)
- },
- _createTooltipTracker: function() {
- return this._tooltipRenderer.createRect(0, 0, 0, 0, 0, {
- fill: 'grey',
- opacity: 0
- })
- },
- _initTooltipEvents: function() {
- var that = this,
- data = {
- widget: that,
- container: that._tooltipTracker
- };
- that._showTooltipCallback = function() {
- that._showTooltipTimeout = null;
- if (!that._tooltipShown) {
- that._tooltipShown = true;
- that._showTooltip()
- }
- that._DEBUG_showCallback && that._DEBUG_showCallback()
- };
- that._hideTooltipCallback = function() {
- that._hideTooltipTimeout = null;
- if (that._tooltipShown) {
- that._tooltipShown = false;
- that._hideTooltip()
- }
- that._DEBUG_hideCallback && that._DEBUG_hideCallback()
- };
- that._disposeCallbacks = function() {
- that = that._showTooltipCallback = that._hideTooltipCallback = that._disposeCallbacks = null
- };
- that._tooltipTracker.on(mouseEvents, data).on(touchEvents, data);
- that._tooltipTracker.on(menuEvents)
- },
- _disposeTooltipEvents: function() {
- clearTimeout(this._showTooltipTimeout);
- clearTimeout(this._hideTooltipTimeout);
- this._showTooltipTimeout = this._showTooltipTimeout = null;
- this._tooltipTracker.off();
- this._disposeCallbacks()
- },
- _drawContainer: function() {
- this._renderer.draw(this._element()[0])
- },
- _createTranslator: function() {
- this._translatorX = CoreFactory.createTranslator2D(this._ranges.arg, this._canvas, {direction: "horizontal"});
- this._translatorY = CoreFactory.createTranslator2D(this._ranges.val, this._canvas)
- },
- _prepareTooltipOptions: function() {
- var that = this,
- canvas = that._canvas,
- tooltipOpt = that._allOptions.tooltip,
- size = that._getTooltipSize(true),
- defaultOptions = {
- canvasWidth: size.width,
- canvasHeight: size.height,
- paddingLeftRight: tooltipOpt.paddingLeftRight,
- paddingTopBottom: tooltipOpt.paddingTopBottom,
- arrowLength: tooltipOpt.arrowLength,
- cloudHorizontalPosition: tooltipOpt.horizontalAlignment,
- cloudVerticalPosition: tooltipOpt.verticalAlignment,
- lineSpacing: tooltipOpt.font.lineSpacing !== undefined && tooltipOpt.font.lineSpacing !== null ? tooltipOpt.font.lineSpacing : DEFAULT_LINE_SPACING
- },
- autoJustify = !$.isFunction(that._allOptions.tooltip.customizeText) && !$.isFunction(that._allOptions.tooltip.customizeTooltip),
- options = $.extend(defaultOptions, that._allOptions.tooltip, {
- customizeTooltip: autoJustify ? DEFAULT_CUSTOMIZE_TOOLTIP : that._allOptions.tooltip.customizeTooltip,
- _justify: that._allOptions.tooltip._justify || autoJustify,
- _rtl: that.option('rtlEnabled')
- });
- that._tooltipOptions = {
- size: size,
- options: options
- };
- return options
- },
- _prepareTooltipContainer: function() {
- var that = this,
- canvas = that._canvas,
- width = canvas.width,
- height = canvas.height,
- renderer = that._tooltipRenderer;
- that._updateTooltipSizeToNormal();
- that._tooltipTracker.applySettings({
- width: width,
- height: height
- });
- that._tooltipContainer.appendTo(that._element());
- that._tooltipInitializated = false;
- that._canShowTooltip = that._allOptions.tooltip.enabled
- },
- _isTooltipVisible: function() {
- return this._tooltip.enabled() && this._tooltip.prepare(this._getTooltipData(), {offset: 0})
- },
- _createTooltip: function() {
- var that = this;
- that._tooltip = CoreFactory.createTooltip(that._prepareTooltipOptions(), that._tooltipGroup, that._tooltipRenderer);
- if (that._isTooltipVisible()) {
- that._tooltip.show();
- that._updateTooltipSizeToWide();
- that._checkTooltipSize();
- that._updateTooltipSizeToNormal()
- }
- else
- that._canShowTooltip = false
- },
- _doShowTooltip: function(delay) {
- var that = this;
- if (!that._canShowTooltip)
- return;
- ++that._DEBUG_clearHideTooltipTimeout;
- clearTimeout(that._hideTooltipTimeout);
- that._hideTooltipTimeout = null;
- clearTimeout(that._showTooltipTimeout);
- ++that._DEBUG_showTooltipTimeoutSet;
- that._showTooltipTimeout = setTimeout(that._showTooltipCallback, delay)
- },
- _doHideTooltip: function(delay) {
- var that = this;
- if (!that._canShowTooltip)
- return;
- ++that._DEBUG_clearShowTooltipTimeout;
- clearTimeout(that._showTooltipTimeout);
- that._showTooltipTimeout = null;
- clearTimeout(that._hideTooltipTimeout);
- ++that._DEBUG_hideTooltipTimeoutSet;
- that._hideTooltipTimeout = setTimeout(that._hideTooltipCallback, delay)
- },
- _getNormalTooltipSize: function() {
- var size = {};
- size.width = this._canvas.width;
- size.left = 0;
- size.tooltipLeft = _round(size.width / 2);
- return size
- },
- _getWideTooltipSize: function(leftWidthDelta, rightWidthDelta) {
- var that = this,
- canvas = that._canvas,
- horizontalPos = that._allOptions.tooltip.horizontalAlignment,
- widthDelta = leftWidthDelta + rightWidthDelta,
- size = {};
- size.width = canvas.width + widthDelta;
- size.left = -leftWidthDelta;
- if (horizontalPos === 'right')
- size.tooltipLeft = _round(canvas.width / 2);
- else if (horizontalPos === 'left')
- size.tooltipLeft = _round(canvas.width / 2) + widthDelta;
- else
- size.tooltipLeft = _round(size.width / 2);
- return size
- },
- _getTooltipSize: function(isNormal, leftWidthDelta, rightWidthDelta, heightDelta) {
- var that = this,
- canvas = that._canvas,
- isVerticalPosTop = !(that._allOptions.tooltip.verticalAlignment === 'bottom'),
- size = !isNormal && (leftWidthDelta || rightWidthDelta) ? that._getWideTooltipSize(leftWidthDelta, rightWidthDelta) : that._getNormalTooltipSize(),
- yDelta = heightDelta > 0 ? heightDelta + TOOLTIP_MARGIN : TOOLTIP_MARGIN;
- size.height = canvas.height + yDelta;
- size.top = isVerticalPosTop ? -size.height : -canvas.height;
- size.trackerY = isVerticalPosTop ? yDelta : 0;
- size.tooltipY = isVerticalPosTop ? _round(canvas.height / 2) + yDelta - TOOLTIP_ARROW_MARGIN : _round(canvas.height / 2);
- return size
- },
- _checkTooltipSize: function() {
- var that = this,
- tooltip = that._tooltip,
- options = that._tooltipOptions.options,
- tooltipBBox = tooltip.getBBox(),
- getWide = that._allOptions.tooltip.allowContainerResizing,
- leftDelta = -tooltipBBox.x,
- rightDelta = tooltipBBox.x + tooltipBBox.width - that._canvas.width,
- topDelta = tooltipBBox.height - TOOLTIP_MARGIN,
- size;
- if (leftDelta > 0 || rightDelta > 0 || topDelta > 0)
- if (getWide) {
- that._tooltipOptions.size = size = that._getTooltipSize(false, leftDelta > 0 ? leftDelta : 0, rightDelta > 0 ? rightDelta : 0, topDelta > 0 ? topDelta : 0);
- tooltip.setSize(size.width, size.height);
- that._updateTooltipSizeToWide()
- }
- else {
- that._canShowTooltip = false;
- tooltip.hide()
- }
- },
- _updateTooltipSizeToWide: function() {
- var that = this,
- size = that._tooltipOptions.size,
- renderer = that._tooltipRenderer;
- renderer.resize(size.width, size.height);
- renderer.getRoot().applySettings({style: {
- left: size.left,
- top: size.top,
- position: 'absolute',
- overflow: 'hidden'
- }});
- that._tooltipTracker.applySettings({
- y: size.trackerY,
- x: -size.left
- });
- that._tooltip.move(size.tooltipLeft, size.tooltipY)
- },
- _updateTooltipSizeToNormal: function() {
- var that = this,
- renderer = that._tooltipRenderer,
- canvas = that._canvas;
- renderer.resize(canvas.width, canvas.height);
- renderer.getRoot().applySettings({style: {
- left: 0,
- top: -canvas.height,
- position: 'absolute'
- }});
- that._tooltipTracker.applySettings({
- y: 0,
- x: 0
- })
- },
- _showTooltip: function() {
- if (!this._tooltipInitializated) {
- this._createTooltip();
- this._tooltipInitializated = true;
- if (!this._canShowTooltip)
- return
- }
- this._updateTooltipSizeToWide();
- this._tooltip.show()
- },
- _hideTooltip: function() {
- this._updateTooltipSizeToNormal();
- this._tooltip.hide()
- },
- showLoadingIndicator: $.noop
- });
- var menuEvents = {
- 'contextmenu.sparkline-tooltip': function(event) {
- if (DX.ui.events.isTouchEvent(event) || DX.ui.events.isPointerEvent(event))
- event.preventDefault()
- },
- 'MSHoldVisual.sparkline-tooltip': function(event) {
- event.preventDefault()
- }
- };
- var mouseEvents = {
- 'mouseover.sparkline-tooltip': function(event) {
- isPointerDownCalled = false;
- var widget = event.data.widget;
- widget._x = event.pageX;
- widget._y = event.pageY;
- widget._tooltipTracker.off(mouseMoveEvents).on(mouseMoveEvents, event.data);
- widget._doShowTooltip(DEFAULT_EVENTS_DELAY)
- },
- 'mouseout.sparkline-tooltip': function(event) {
- if (isPointerDownCalled)
- return;
- var widget = event.data.widget;
- widget._tooltipTracker.off(mouseMoveEvents);
- widget._doHideTooltip(DEFAULT_EVENTS_DELAY)
- }
- };
- var mouseMoveEvents = {'mousemove.sparkline-tooltip': function(event) {
- var widget = event.data.widget;
- if (widget._showTooltipTimeout && (_abs(widget._x - event.pageX) > 3 || _abs(widget._y - event.pageY) > 3)) {
- widget._x = event.pageX;
- widget._y = event.pageY;
- widget._doShowTooltip(DEFAULT_EVENTS_DELAY)
- }
- }};
- var active_touch_tooltip_widget = null,
- touchstartTooltipProcessing = function(event) {
- event.preventDefault();
- var widget = active_touch_tooltip_widget;
- if (widget && widget !== event.data.widget)
- widget._doHideTooltip(DEFAULT_EVENTS_DELAY);
- widget = active_touch_tooltip_widget = event.data.widget;
- widget._doShowTooltip(TOUCH_EVENTS_DELAY);
- widget._touch = true
- },
- touchstartDocumentProcessing = function() {
- var widget = active_touch_tooltip_widget;
- if (widget) {
- if (!widget._touch) {
- widget._doHideTooltip(DEFAULT_EVENTS_DELAY);
- active_touch_tooltip_widget = null
- }
- widget._touch = null
- }
- },
- touchendDocumentProcessing = function() {
- var widget = active_touch_tooltip_widget;
- if (widget)
- if (widget._showTooltipTimeout) {
- widget._doHideTooltip(DEFAULT_EVENTS_DELAY);
- active_touch_tooltip_widget = null
- }
- },
- isPointerDownCalled = false;
- var touchEvents = {
- 'pointerdown.sparkline-tooltip': function(event) {
- touchstartTooltipProcessing(event)
- },
- 'touchstart.sparkline-tooltip': function(event) {
- touchstartTooltipProcessing(event)
- }
- };
- $(document).on({
- 'pointerdown.sparkline-tooltip': function() {
- isPointerDownCalled = true;
- touchstartDocumentProcessing()
- },
- 'touchstart.sparkline-tooltip': function() {
- touchstartDocumentProcessing()
- },
- 'pointerup.sparkline-tooltip': function() {
- touchendDocumentProcessing()
- },
- 'touchend.sparkline-tooltip': function() {
- touchendDocumentProcessing()
- }
- });
- DX.viz.sparklines.BaseSparkline._DEBUG_reset = function() {
- active_touch_tooltip_widget = null
- }
- })(jQuery, DevExpress);
- /*! Module viz-sparklines, file sparkline.js */
- (function($, DX) {
- var viz = DX.viz,
- charts = viz.charts,
- core = viz.core,
- MIN_BAR_WIDTH = 1,
- MAX_BAR_WIDTH = 50,
- DEFAULT_BAR_INTERVAL = 4,
- DEFAULT_CANVAS_WIDTH = 250,
- DEFAULT_CANVAS_HEIGHT = 30,
- DEFAULT_HORIZONTAL_MARGIN = 5,
- DEFAULT_VERTICAL_MARGIN = 3,
- DEFAULT_OPTIONS = {
- disabled: false,
- theme: 'default',
- dataSource: [],
- size: {},
- margin: {},
- type: 'line',
- argumentField: 'arg',
- valueField: 'val',
- winlossThreshold: 0,
- showFirstLast: true,
- showMinMax: false,
- redrawOnResize: false
- },
- ALLOWED_TYPES = {
- line: true,
- spline: true,
- stepline: true,
- area: true,
- steparea: true,
- splinearea: true,
- bar: true,
- winloss: true
- },
- _map = $.map,
- _extend = $.extend,
- _abs = Math.abs,
- _round = Math.round,
- _isFinite = isFinite,
- _Number = Number,
- _String = String;
- viz.sparklines.Sparkline = viz.sparklines.BaseSparkline.inherit({
- _widgetType: 'sparkline',
- _widgetClass: 'dxsl',
- _defaultSize: {
- width: DEFAULT_CANVAS_WIDTH,
- height: DEFAULT_CANVAS_HEIGHT,
- left: DEFAULT_HORIZONTAL_MARGIN,
- right: DEFAULT_HORIZONTAL_MARGIN,
- top: DEFAULT_VERTICAL_MARGIN,
- bottom: DEFAULT_VERTICAL_MARGIN
- },
- _init: function() {
- this.callBase();
- this._refreshDataSource()
- },
- _handleDataSourceChanged: function() {
- if (this._initialized) {
- this._clean();
- this._createWidgetElements();
- this._drawWidgetElements()
- }
- },
- _dataSourceOptions: function() {
- return {
- paginate: false,
- _preferSync: true
- }
- },
- _redrawWidgetElements: function() {
- this._createTranslator();
- this._correctPoints();
- this._series.draw({
- x: this._translatorX,
- y: this._translatorY
- });
- this._seriesGroup.append(this._renderer.getRoot())
- },
- _disposeWidgetElements: function() {
- delete this._seriesGroup;
- delete this._seriesLabelGroup
- },
- _cleanWidgetElements: function() {
- this._seriesGroup.detach();
- this._seriesLabelGroup.detach();
- this._seriesGroup.clear();
- this._seriesLabelGroup.clear()
- },
- _createWidgetElements: function() {
- this._createSeries();
- this.callBase()
- },
- _drawWidgetElements: function() {
- if (this._dataSource && this._dataSource.isLoaded())
- this._drawSeries()
- },
- _prepareOptions: function() {
- this._allOptions = this.callBase(DEFAULT_OPTIONS);
- this._allOptions.type = _String(this._allOptions.type).toLowerCase();
- if (!ALLOWED_TYPES[this._allOptions.type])
- this._allOptions.type = 'line'
- },
- _createHtmlElements: function() {
- this._seriesGroup = this._renderer.createGroup({'class': 'dxsl-series'});
- this._seriesLabelGroup = this._renderer.createGroup({'class': 'dxsl-series-labels'})
- },
- _createSeries: function() {
- var that = this,
- renderer = that._renderer,
- dataValidator;
- that._prepareDataSource();
- that._prepareSeriesOptions();
- that._series = core.CoreFactory.createSeries(renderer, that._seriesOptions);
- dataValidator = charts.factory.createDataValidator(that._simpleDataSource, [[that._series]], that._incidentOccured, {
- checkTypeForAllData: false,
- convertToAxisDataType: true,
- sortingMethod: true
- });
- that._simpleDataSource = dataValidator.validate();
- that._series._options.customizePoint = that._getCustomizeFunction();
- that._series.updateData(that._simpleDataSource)
- },
- _parseNumericDataSource: function(data, argField, valField) {
- var ignoreEmptyPoints = this.option('ignoreEmptyPoints');
- return _map(data, function(dataItem, index) {
- var item = null,
- isDataNumber,
- value;
- if (dataItem !== undefined) {
- item = {};
- isDataNumber = _isFinite(dataItem);
- item[argField] = isDataNumber ? _String(index) : dataItem[argField];
- value = isDataNumber ? dataItem : dataItem[valField];
- item[valField] = value === null ? ignoreEmptyPoints ? undefined : value : _Number(value);
- item = item[argField] !== undefined && item[valField] !== undefined ? item : null
- }
- return item
- })
- },
- _parseWinlossDataSource: function(data, argField, valField) {
- var lowBarValue = -1,
- zeroBarValue = 0,
- highBarValue = 1,
- delta = 0.0001,
- target = this._allOptions.winlossThreshold;
- return _map(data, function(dataItem) {
- var item = {};
- item[argField] = dataItem[argField];
- if (_abs(dataItem[valField] - target) < delta)
- item[valField] = zeroBarValue;
- else if (dataItem[valField] > target)
- item[valField] = highBarValue;
- else
- item[valField] = lowBarValue;
- return item
- })
- },
- _prepareDataSource: function() {
- var that = this,
- options = that._allOptions,
- argField = options.argumentField,
- valField = options.valueField,
- dataSource = that._dataSource ? that._dataSource.items() : [],
- data = that._parseNumericDataSource(dataSource, argField, valField);
- if (options.type === 'winloss') {
- that._winlossDataSource = data;
- that._simpleDataSource = that._parseWinlossDataSource(data, argField, valField)
- }
- else
- that._simpleDataSource = data
- },
- _prepareSeriesOptions: function() {
- var that = this,
- options = that._allOptions,
- defaultPointOptions = {
- border: {},
- hoverStyle: {border: {}},
- selectionStyle: {border: {}}
- },
- customPointOptions = {
- size: options.pointSize,
- symbol: options.pointSymbol,
- border: {
- visible: true,
- width: 2
- },
- color: options.pointColor
- };
- that._seriesOptions = {
- visible: true,
- argumentField: options.argumentField,
- valueField: options.valueField,
- color: options.lineColor,
- width: options.lineWidth,
- widgetType: "chart"
- };
- that._seriesOptions.border = {
- color: that._seriesOptions.color,
- width: that._seriesOptions.width,
- visible: true
- };
- that._seriesOptions.type = options.type === 'winloss' ? 'bar' : options.type;
- if (options.type === 'winloss' || options.type === 'bar') {
- that._seriesOptions.argumentAxisType = 'discrete';
- that._seriesOptions.border.visible = false
- }
- if (~~options.type.indexOf('area') !== -1)
- that._seriesOptions.opacity = that._allOptions.areaOpacity;
- that._seriesOptions.seriesGroup = that._seriesGroup;
- that._seriesOptions.seriesLabelsGroup = that._seriesLabelGroup;
- that._seriesOptions.point = _extend(defaultPointOptions, customPointOptions);
- that._seriesOptions.point.visible = false
- },
- _createBarCustomizeFunction: function(pointIndexes) {
- var that = this,
- options = that._allOptions,
- winlossData = that._winlossDataSource;
- return function() {
- var index = this.index,
- isWinloss = options.type === 'winloss',
- target = isWinloss ? options.winlossThreshold : 0,
- value = isWinloss ? winlossData[index][options.valueField] : this.value,
- positiveColor = isWinloss ? options.winColor : options.barPositiveColor,
- negativeColor = isWinloss ? options.lossColor : options.barNegativeColor,
- color;
- if (value >= target)
- color = positiveColor;
- else
- color = negativeColor;
- if (index === pointIndexes.first || index === pointIndexes.last)
- color = options.firstLastColor;
- if (index === pointIndexes.min)
- color = options.minColor;
- if (index === pointIndexes.max)
- color = options.maxColor;
- return {color: color}
- }
- },
- _createLineCustomizeFunction: function(pointIndexes) {
- var that = this,
- options = that._allOptions;
- return function() {
- var color,
- index = this.index;
- if (index === pointIndexes.first || index === pointIndexes.last)
- color = options.firstLastColor;
- if (index === pointIndexes.min)
- color = options.minColor;
- if (index === pointIndexes.max)
- color = options.maxColor;
- return color ? {
- visible: true,
- border: {color: color}
- } : {}
- }
- },
- _getCustomizeFunction: function() {
- var that = this,
- options = that._allOptions,
- dataSource = that._winlossDataSource || that._simpleDataSource,
- drawnPointIndexes = that._getExtremumPointsIndexes(dataSource),
- customizeFunction;
- if (options.type === 'winloss' || options.type === 'bar')
- customizeFunction = that._createBarCustomizeFunction(drawnPointIndexes);
- else
- customizeFunction = that._createLineCustomizeFunction(drawnPointIndexes);
- return customizeFunction
- },
- _getExtremumPointsIndexes: function(data) {
- var that = this,
- options = that._allOptions,
- lastIndex = data.length - 1,
- indexes = {};
- that._minMaxIndexes = that._findMinMax(data);
- if (options.showFirstLast) {
- indexes.first = 0;
- indexes.last = lastIndex
- }
- if (options.showMinMax) {
- indexes.min = that._minMaxIndexes.minIndex;
- indexes.max = that._minMaxIndexes.maxIndex
- }
- return indexes
- },
- _findMinMax: function(data) {
- var that = this,
- valField = that._allOptions.valueField,
- firstItem = data[0] || {},
- firstValue = firstItem[valField] || 0,
- min = firstValue,
- max = firstValue,
- minIndex = 0,
- maxIndex = 0,
- dataLength = data.length,
- value,
- i;
- for (i = 1; i < dataLength; i++) {
- value = data[i][valField];
- if (value < min) {
- min = value;
- minIndex = i
- }
- if (value > max) {
- max = value;
- maxIndex = i
- }
- }
- return {
- minIndex: minIndex,
- maxIndex: maxIndex
- }
- },
- _createRange: function() {
- var that = this,
- series = that._series,
- isBarType = series.type === 'bar',
- DEFAULT_VALUE_RANGE_MARGIN = 0.15,
- DEFAULT_ARGUMENT_RANGE_MARGIN = isBarType ? 0.1 : 0,
- rangeData = series.getRangeData();
- that._ranges = {
- arg: new core.Range({
- stick: !isBarType && series.getPoints().length > 1,
- minValueMargin: DEFAULT_ARGUMENT_RANGE_MARGIN,
- maxValueMargin: DEFAULT_ARGUMENT_RANGE_MARGIN
- }),
- val: new core.Range({
- isValueRange: true,
- keepValueMargins: true,
- minValueMargin: DEFAULT_VALUE_RANGE_MARGIN,
- maxValueMargin: DEFAULT_VALUE_RANGE_MARGIN
- })
- };
- that._ranges.arg.addRange(rangeData.arg);
- that._ranges.val.addRange(rangeData.val);
- that._ranges.arg.applyValueMargins();
- that._ranges.val.applyValueMargins()
- },
- _getBarWidth: function(pointsCount) {
- var that = this,
- canvas = that._canvas,
- intervalWidth = pointsCount * DEFAULT_BAR_INTERVAL,
- rangeWidth = canvas.width - canvas.left - canvas.right - intervalWidth,
- width = _round(rangeWidth / pointsCount);
- if (width < MIN_BAR_WIDTH)
- width = MIN_BAR_WIDTH;
- if (width > MAX_BAR_WIDTH)
- width = MAX_BAR_WIDTH;
- return width
- },
- _correctPoints: function() {
- var that = this,
- seriesType = that._allOptions.type,
- seriesPoints = that._series.getPoints(),
- pointsLength = seriesPoints.length,
- barWidth,
- i;
- if (seriesType === 'bar' || seriesType === 'winloss') {
- barWidth = that._getBarWidth(pointsLength);
- for (i = 0; i < pointsLength; i++)
- seriesPoints[i].correctCoordinates({
- width: barWidth,
- offset: 0
- })
- }
- },
- _drawSeries: function() {
- var that = this;
- if (that._simpleDataSource.length !== 0) {
- that._correctPoints();
- that._series.draw({
- x: that._translatorX,
- y: that._translatorY
- });
- that._seriesGroup.append(that._renderer.getRoot());
- that._prepareTooltipContainer()
- }
- },
- _isTooltipVisible: function() {
- return this.callBase() && this._dataSource.length !== 0
- },
- _getTooltipData: function() {
- var that = this,
- options = that._allOptions,
- dataSource = that._winlossDataSource || that._simpleDataSource,
- tooltip = that._tooltip;
- if (dataSource.length === 0)
- return {};
- var minMax = that._minMaxIndexes,
- valueField = options.valueField,
- first = dataSource[0][valueField],
- last = dataSource[dataSource.length - 1][valueField],
- min = dataSource[minMax.minIndex][valueField],
- max = dataSource[minMax.maxIndex][valueField],
- formattedFirst = tooltip.formatValue(first),
- formattedLast = tooltip.formatValue(last),
- formattedMin = tooltip.formatValue(min),
- formattedMax = tooltip.formatValue(max),
- customizeObject = {
- firstValue: formattedFirst,
- lastValue: formattedLast,
- minValue: formattedMin,
- maxValue: formattedMax,
- originalFirstValue: first,
- originalLastValue: last,
- originalMinValue: min,
- originalMaxValue: max,
- valueText: ['Start:', formattedFirst, 'End:', formattedLast, 'Min:', formattedMin, 'Max:', formattedMax]
- };
- if (options.type === 'winloss') {
- customizeObject.originalThresholdValue = options.winlossThreshold;
- customizeObject.thresholdValue = tooltip.formatValue(options.winlossThreshold)
- }
- return customizeObject
- }
- }).include(DX.ui.DataHelperMixin)
- })(jQuery, DevExpress);
- /*! Module viz-sparklines, file bullet.js */
- (function($, DX) {
- var charts = DX.viz.charts,
- TARGET_MIN_Y = 0.02,
- TARGET_MAX_Y = 0.98,
- BAR_VALUE_MIN_Y = 0.1,
- BAR_VALUE_MAX_Y = 0.9,
- DEFAULT_CANVAS_WIDTH = 300,
- DEFAULT_CANVAS_HEIGHT = 30,
- DEFAULT_HORIZONTAL_MARGIN = 1,
- DEFAULT_VERTICAL_MARGIN = 2,
- DEFAULT_OPTIONS = {
- disabled: false,
- theme: 'default',
- size: {},
- margin: {}
- },
- _String = String,
- _Number = Number,
- _round = Math.round,
- _isFinite = isFinite;
- DX.viz.sparklines.Bullet = DX.viz.sparklines.BaseSparkline.inherit({
- _widgetType: 'bullet',
- _widgetClass: 'dxb',
- _defaultSize: {
- width: DEFAULT_CANVAS_WIDTH,
- height: DEFAULT_CANVAS_HEIGHT,
- left: DEFAULT_HORIZONTAL_MARGIN,
- right: DEFAULT_HORIZONTAL_MARGIN,
- top: DEFAULT_VERTICAL_MARGIN,
- bottom: DEFAULT_VERTICAL_MARGIN
- },
- _disposeWidgetElements: function() {
- delete this._zeroLevelPath;
- delete this._targetPath;
- delete this._barValuePath
- },
- _redrawWidgetElements: function() {
- this._createTranslator();
- this._drawBarValue();
- this._drawTarget();
- this._drawZeroLevel()
- },
- _cleanWidgetElements: function() {
- this._zeroLevelPath.detach();
- this._targetPath.detach();
- this._barValuePath.detach()
- },
- _drawWidgetElements: function() {
- this._drawBullet()
- },
- _createHtmlElements: function() {
- var renderer = this._renderer;
- this._zeroLevelPath = renderer.createPath(undefined, {'class': 'dxb-zero-level'});
- this._targetPath = renderer.createPath(undefined, {'class': 'dxb-target'});
- this._barValuePath = renderer.createPath(undefined, {'class': 'dxb-bar-value'})
- },
- _prepareOptions: function() {
- var that = this,
- options,
- startScaleValue,
- endScaleValue,
- level,
- value,
- target;
- that._allOptions = options = that.callBase(DEFAULT_OPTIONS);
- if (that._allOptions.value === undefined)
- that._allOptions.value = 0;
- if (that._allOptions.target === undefined)
- that._allOptions.target = 0;
- options.value = value = _Number(options.value);
- options.target = target = _Number(options.target);
- if (that._allOptions.startScaleValue === undefined) {
- that._allOptions.startScaleValue = target < value ? target : value;
- that._allOptions.startScaleValue = that._allOptions.startScaleValue < 0 ? that._allOptions.startScaleValue : 0
- }
- if (that._allOptions.endScaleValue === undefined)
- that._allOptions.endScaleValue = target > value ? target : value;
- options.startScaleValue = startScaleValue = _Number(options.startScaleValue);
- options.endScaleValue = endScaleValue = _Number(options.endScaleValue);
- if (endScaleValue < startScaleValue) {
- level = endScaleValue;
- that._allOptions.endScaleValue = startScaleValue;
- that._allOptions.startScaleValue = level;
- that._allOptions.inverted = true
- }
- },
- _createRange: function() {
- var that = this,
- options = that._allOptions;
- that._ranges = {
- arg: {
- invert: options.inverted,
- min: options.startScaleValue,
- max: options.endScaleValue,
- axisType: "continuous",
- dataType: "numeric"
- },
- val: {
- min: 0,
- max: 1,
- axisType: "continuous",
- dataType: "numeric"
- }
- }
- },
- _drawBullet: function() {
- var that = this,
- options = that._allOptions,
- isValidBounds = options.startScaleValue !== options.endScaleValue,
- isValidMin = _isFinite(options.startScaleValue),
- isValidMax = _isFinite(options.endScaleValue),
- isValidValue = _isFinite(options.value),
- isValidTarget = _isFinite(options.target);
- if (isValidBounds && isValidMax && isValidMin && isValidTarget && isValidValue) {
- this._drawBarValue();
- this._drawTarget();
- this._drawZeroLevel();
- this._prepareTooltipContainer()
- }
- },
- _getTargetParams: function() {
- var that = this,
- options = that._allOptions,
- translatorX = that._translatorX,
- translatorY = that._translatorY,
- minY = translatorY.translate(TARGET_MIN_Y),
- maxY = translatorY.translate(TARGET_MAX_Y),
- x = translatorX.translate(options.target),
- points = [{
- x: x,
- y: minY
- }, {
- x: x,
- y: maxY
- }];
- return {
- points: points,
- stroke: options.targetColor,
- strokeWidth: options.targetWidth
- }
- },
- _getBarValueParams: function() {
- var that = this,
- options = that._allOptions,
- translatorX = that._translatorX,
- translatorY = that._translatorY,
- startLevel = options.startScaleValue,
- endLevel = options.endScaleValue,
- value = options.value,
- y2 = translatorY.translate(BAR_VALUE_MIN_Y),
- y1 = translatorY.translate(BAR_VALUE_MAX_Y),
- x1,
- x2;
- if (value > 0) {
- x1 = startLevel <= 0 ? 0 : startLevel;
- x2 = value >= endLevel ? endLevel : value
- }
- else {
- x1 = endLevel >= 0 ? 0 : endLevel;
- x2 = value >= startLevel ? value : startLevel
- }
- x1 = translatorX.translate(x1);
- x2 = translatorX.translate(x2);
- return {
- points: [{
- x: x1,
- y: y1
- }, {
- x: x2,
- y: y1
- }, {
- x: x2,
- y: y2
- }, {
- x: x1,
- y: y2
- }],
- fill: options.color
- }
- },
- _getZeroLevelParams: function() {
- var that = this,
- options = that._allOptions,
- translatorX = that._translatorX,
- translatorY = that._translatorY,
- minY = translatorY.translate(TARGET_MIN_Y),
- maxY = translatorY.translate(TARGET_MAX_Y),
- x = translatorX.translate(0);
- return {
- points: [{
- x: x,
- y: minY
- }, {
- x: x,
- y: maxY
- }],
- stroke: options.targetColor,
- strokeWidth: 1
- }
- },
- _drawZeroLevel: function() {
- var that = this,
- options = that._allOptions,
- params;
- if (0 > options.endScaleValue || 0 < options.startScaleValue || !options.showZeroLevel)
- return;
- params = that._getZeroLevelParams();
- that._zeroLevelPath.applySettings(params);
- that._zeroLevelPath.append(that._renderer.getRoot())
- },
- _drawTarget: function() {
- var that = this,
- options = that._allOptions,
- target = options.target,
- startLevel = options.startScaleValue,
- endLevel = options.endScaleValue,
- params;
- if (target > endLevel || target < startLevel || !options.showTarget)
- return;
- params = that._getTargetParams();
- that._targetPath.applySettings(params);
- that._targetPath.append(that._renderer.getRoot())
- },
- _drawBarValue: function() {
- var that = this,
- params = that._getBarValueParams();
- that._barValuePath.applySettings(params);
- that._barValuePath.append(that._renderer.getRoot())
- },
- _getTooltipData: function() {
- var that = this,
- tooltip = that._tooltip,
- options = that._allOptions,
- value = options.value,
- target = options.target;
- return {
- originalValue: value,
- originalTarget: target,
- value: tooltip.formatValue(value),
- target: tooltip.formatValue(target),
- valueText: ['Actual Value:', value, 'Target Value:', target]
- }
- },
- _getNormalTooltipSize: function() {
- var size = {},
- bbox = this._barValuePath.getBBox();
- size.width = this._canvas.width;
- size.left = 0;
- size.tooltipLeft = bbox.x + _round(bbox.width / 2);
- return size
- },
- _getWideTooltipSize: function(leftWidthDelta, rightWidthDelta) {
- var that = this,
- bbox = that._barValuePath.getBBox(),
- horizontalPos = that._allOptions.tooltip.horizontalAlignment,
- size = {};
- size.width = leftWidthDelta + rightWidthDelta + that._canvas.width;
- size.left = -leftWidthDelta;
- if (horizontalPos === 'right')
- size.tooltipLeft = bbox.x + _round(bbox.width / 2);
- else if (horizontalPos === 'left')
- size.tooltipLeft = _round(bbox.width / 2) + leftWidthDelta + rightWidthDelta + bbox.x;
- else
- size.tooltipLeft = _round(bbox.width / 2) + bbox.x + leftWidthDelta;
- return size
- }
- })
- })(jQuery, DevExpress);
- /*! Module viz-sparklines, file dxSparkline.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- viz = DX.viz;
- DX.registerComponent("dxSparkline", viz.sparklines.Sparkline)
- })(jQuery, DevExpress);
- /*! Module viz-sparklines, file dxBullet.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- viz = DX.viz;
- DX.registerComponent("dxBullet", viz.sparklines.Bullet)
- })(jQuery, DevExpress);
- DevExpress.MOD_VIZ_SPARKLINES = true
- }
|