ui-grid.base.js 571 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529
  1. /*!
  2. * ui-grid - v4.3.1 - 2018-03-14
  3. * Copyright (c) 2018 ; License: MIT
  4. */
  5. (function () {
  6. 'use strict';
  7. angular.module('ui.grid.i18n', []);
  8. angular.module('ui.grid', ['ui.grid.i18n']);
  9. })();
  10. (function () {
  11. 'use strict';
  12. /**
  13. * @ngdoc object
  14. * @name ui.grid.service:uiGridConstants
  15. * @description Constants for use across many grid features
  16. *
  17. */
  18. angular.module('ui.grid').constant('uiGridConstants', {
  19. LOG_DEBUG_MESSAGES: true,
  20. LOG_WARN_MESSAGES: true,
  21. LOG_ERROR_MESSAGES: true,
  22. CUSTOM_FILTERS: /CUSTOM_FILTERS/g,
  23. COL_FIELD: /COL_FIELD/g,
  24. MODEL_COL_FIELD: /MODEL_COL_FIELD/g,
  25. TOOLTIP: /title=\"TOOLTIP\"/g,
  26. DISPLAY_CELL_TEMPLATE: /DISPLAY_CELL_TEMPLATE/g,
  27. TEMPLATE_REGEXP: /<.+>/,
  28. FUNC_REGEXP: /(\([^)]*\))?$/,
  29. DOT_REGEXP: /\./g,
  30. APOS_REGEXP: /'/g,
  31. BRACKET_REGEXP: /^(.*)((?:\s*\[\s*\d+\s*\]\s*)|(?:\s*\[\s*"(?:[^"\\]|\\.)*"\s*\]\s*)|(?:\s*\[\s*'(?:[^'\\]|\\.)*'\s*\]\s*))(.*)$/,
  32. COL_CLASS_PREFIX: 'ui-grid-col',
  33. ENTITY_BINDING: '$$this',
  34. events: {
  35. GRID_SCROLL: 'uiGridScroll',
  36. COLUMN_MENU_SHOWN: 'uiGridColMenuShown',
  37. ITEM_DRAGGING: 'uiGridItemDragStart', // For any item being dragged
  38. COLUMN_HEADER_CLICK: 'uiGridColumnHeaderClick'
  39. },
  40. // copied from http://www.lsauer.com/2011/08/javascript-keymap-keycodes-in-json.html
  41. keymap: {
  42. TAB: 9,
  43. STRG: 17,
  44. CAPSLOCK: 20,
  45. CTRL: 17,
  46. CTRLRIGHT: 18,
  47. CTRLR: 18,
  48. SHIFT: 16,
  49. RETURN: 13,
  50. ENTER: 13,
  51. BACKSPACE: 8,
  52. BCKSP: 8,
  53. ALT: 18,
  54. ALTR: 17,
  55. ALTRIGHT: 17,
  56. SPACE: 32,
  57. WIN: 91,
  58. MAC: 91,
  59. FN: null,
  60. PG_UP: 33,
  61. PG_DOWN: 34,
  62. UP: 38,
  63. DOWN: 40,
  64. LEFT: 37,
  65. RIGHT: 39,
  66. ESC: 27,
  67. DEL: 46,
  68. F1: 112,
  69. F2: 113,
  70. F3: 114,
  71. F4: 115,
  72. F5: 116,
  73. F6: 117,
  74. F7: 118,
  75. F8: 119,
  76. F9: 120,
  77. F10: 121,
  78. F11: 122,
  79. F12: 123
  80. },
  81. /**
  82. * @ngdoc object
  83. * @name ASC
  84. * @propertyOf ui.grid.service:uiGridConstants
  85. * @description Used in {@link ui.grid.class:GridOptions.columnDef#properties_sort columnDef.sort} and
  86. * {@link ui.grid.class:GridOptions.columnDef#properties_sortDirectionCycle columnDef.sortDirectionCycle}
  87. * to configure the sorting direction of the column
  88. */
  89. ASC: 'asc',
  90. /**
  91. * @ngdoc object
  92. * @name DESC
  93. * @propertyOf ui.grid.service:uiGridConstants
  94. * @description Used in {@link ui.grid.class:GridOptions.columnDef#properties_sort columnDef.sort} and
  95. * {@link ui.grid.class:GridOptions.columnDef#properties_sortDirectionCycle columnDef.sortDirectionCycle}
  96. * to configure the sorting direction of the column
  97. */
  98. DESC: 'desc',
  99. /**
  100. * @ngdoc object
  101. * @name filter
  102. * @propertyOf ui.grid.service:uiGridConstants
  103. * @description Used in {@link ui.grid.class:GridOptions.columnDef#properties_filter columnDef.filter}
  104. * to configure filtering on the column
  105. *
  106. * `SELECT` and `INPUT` are used with the `type` property of the filter, the rest are used to specify
  107. * one of the built-in conditions.
  108. *
  109. * Available `condition` options are:
  110. * - `uiGridConstants.filter.STARTS_WITH`
  111. * - `uiGridConstants.filter.ENDS_WITH`
  112. * - `uiGridConstants.filter.CONTAINS`
  113. * - `uiGridConstants.filter.GREATER_THAN`
  114. * - `uiGridConstants.filter.GREATER_THAN_OR_EQUAL`
  115. * - `uiGridConstants.filter.LESS_THAN`
  116. * - `uiGridConstants.filter.LESS_THAN_OR_EQUAL`
  117. * - `uiGridConstants.filter.NOT_EQUAL`
  118. *
  119. *
  120. * Available `type` options are:
  121. * - `uiGridConstants.filter.SELECT` - use a dropdown box for the cell header filter field
  122. * - `uiGridConstants.filter.INPUT` - use a text box for the cell header filter field
  123. */
  124. filter: {
  125. STARTS_WITH: 2,
  126. ENDS_WITH: 4,
  127. EXACT: 8,
  128. CONTAINS: 16,
  129. GREATER_THAN: 32,
  130. GREATER_THAN_OR_EQUAL: 64,
  131. LESS_THAN: 128,
  132. LESS_THAN_OR_EQUAL: 256,
  133. NOT_EQUAL: 512,
  134. SELECT: 'select',
  135. INPUT: 'input'
  136. },
  137. /**
  138. * @ngdoc object
  139. * @name aggregationTypes
  140. * @propertyOf ui.grid.service:uiGridConstants
  141. * @description Used in {@link ui.grid.class:GridOptions.columnDef#properties_aggregationType columnDef.aggregationType}
  142. * to specify the type of built-in aggregation the column should use.
  143. *
  144. * Available options are:
  145. * - `uiGridConstants.aggregationTypes.sum` - add the values in this column to produce the aggregated value
  146. * - `uiGridConstants.aggregationTypes.count` - count the number of rows to produce the aggregated value
  147. * - `uiGridConstants.aggregationTypes.avg` - average the values in this column to produce the aggregated value
  148. * - `uiGridConstants.aggregationTypes.min` - use the minimum value in this column as the aggregated value
  149. * - `uiGridConstants.aggregationTypes.max` - use the maximum value in this column as the aggregated value
  150. */
  151. aggregationTypes: {
  152. sum: 2,
  153. count: 4,
  154. avg: 8,
  155. min: 16,
  156. max: 32
  157. },
  158. /**
  159. * @ngdoc array
  160. * @name CURRENCY_SYMBOLS
  161. * @propertyOf ui.grid.service:uiGridConstants
  162. * @description A list of all presently circulating currency symbols that was copied from
  163. * https://en.wikipedia.org/wiki/Currency_symbol#List_of_presently-circulating_currency_symbols
  164. *
  165. * Can be used on {@link ui.grid.class:rowSorter} to create a number string regex that ignores currency symbols.
  166. */
  167. CURRENCY_SYMBOLS: ['¤', '؋', 'Ar', 'Ƀ', '฿', 'B/.', 'Br', 'Bs.', 'Bs.F.', 'GH₵', '¢', 'c', 'Ch.', '₡', 'C$', 'D', 'ден',
  168. 'دج', '.د.ب', 'د.ع', 'JD', 'د.ك', 'ل.د', 'дин', 'د.ت', 'د.م.', 'د.إ', 'Db', '$', '₫', 'Esc', '€', 'ƒ', 'Ft', 'FBu',
  169. 'FCFA', 'CFA', 'Fr', 'FRw', 'G', 'gr', '₲', 'h', '₴', '₭', 'Kč', 'kr', 'kn', 'MK', 'ZK', 'Kz', 'K', 'L', 'Le', 'лв',
  170. 'E', 'lp', 'M', 'KM', 'MT', '₥', 'Nfk', '₦', 'Nu.', 'UM', 'T$', 'MOP$', '₱', 'Pt.', '£', 'ج.م.', 'LL', 'LS', 'P', 'Q',
  171. 'q', 'R', 'R$', 'ر.ع.', 'ر.ق', 'ر.س', '៛', 'RM', 'p', 'Rf.', '₹', '₨', 'SRe', 'Rp', '₪', 'Ksh', 'Sh.So.', 'USh', 'S/',
  172. 'SDR', 'сом', '৳ ', 'WS$', '₮', 'VT', '₩', '¥', 'zł'],
  173. /**
  174. * @ngdoc object
  175. * @name scrollDirection
  176. * @propertyOf ui.grid.service:uiGridConstants
  177. * @description Set on {@link ui.grid.class:Grid#properties_scrollDirection Grid.scrollDirection},
  178. * to indicate the direction the grid is currently scrolling in
  179. *
  180. * Available options are:
  181. * - `uiGridConstants.scrollDirection.UP` - set when the grid is scrolling up
  182. * - `uiGridConstants.scrollDirection.DOWN` - set when the grid is scrolling down
  183. * - `uiGridConstants.scrollDirection.LEFT` - set when the grid is scrolling left
  184. * - `uiGridConstants.scrollDirection.RIGHT` - set when the grid is scrolling right
  185. * - `uiGridConstants.scrollDirection.NONE` - set when the grid is not scrolling, this is the default
  186. */
  187. scrollDirection: {
  188. UP: 'up',
  189. DOWN: 'down',
  190. LEFT: 'left',
  191. RIGHT: 'right',
  192. NONE: 'none'
  193. },
  194. /**
  195. * @ngdoc object
  196. * @name dataChange
  197. * @propertyOf ui.grid.service:uiGridConstants
  198. * @description Used with {@link ui.grid.core.api:PublicApi#methods_notifyDataChange PublicApi.notifyDataChange},
  199. * {@link ui.grid.class:Grid#methods_callDataChangeCallbacks Grid.callDataChangeCallbacks},
  200. * and {@link ui.grid.class:Grid#methods_registerDataChangeCallback Grid.registerDataChangeCallback}
  201. * to specify the type of the event(s).
  202. *
  203. * Available options are:
  204. * - `uiGridConstants.dataChange.ALL` - listeners fired on any of these events, fires listeners on all events.
  205. * - `uiGridConstants.dataChange.EDIT` - fired when the data in a cell is edited
  206. * - `uiGridConstants.dataChange.ROW` - fired when a row is added or removed
  207. * - `uiGridConstants.dataChange.COLUMN` - fired when the column definitions are modified
  208. * - `uiGridConstants.dataChange.OPTIONS` - fired when the grid options are modified
  209. */
  210. dataChange: {
  211. ALL: 'all',
  212. EDIT: 'edit',
  213. ROW: 'row',
  214. COLUMN: 'column',
  215. OPTIONS: 'options'
  216. },
  217. /**
  218. * @ngdoc object
  219. * @name scrollbars
  220. * @propertyOf ui.grid.service:uiGridConstants
  221. * @description Used with {@link ui.grid.class:GridOptions#properties_enableHorizontalScrollbar GridOptions.enableHorizontalScrollbar}
  222. * and {@link ui.grid.class:GridOptions#properties_enableVerticalScrollbar GridOptions.enableVerticalScrollbar}
  223. * to specify the scrollbar policy for that direction.
  224. *
  225. * Available options are:
  226. * - `uiGridConstants.scrollbars.NEVER` - never show scrollbars in this direction
  227. * - `uiGridConstants.scrollbars.ALWAYS` - always show scrollbars in this direction
  228. * - `uiGridConstants.scrollbars.WHEN_NEEDED` - shows scrollbars in this direction when needed
  229. */
  230. scrollbars: {
  231. NEVER: 0,
  232. ALWAYS: 1,
  233. WHEN_NEEDED: 2
  234. }
  235. });
  236. })();
  237. angular.module('ui.grid').directive('uiGridCell', ['$compile', '$parse', 'gridUtil', 'uiGridConstants', function ($compile, $parse, gridUtil, uiGridConstants) {
  238. var uiGridCell = {
  239. priority: 0,
  240. scope: false,
  241. require: '?^uiGrid',
  242. compile: function() {
  243. return {
  244. pre: function($scope, $elm, $attrs, uiGridCtrl) {
  245. function compileTemplate() {
  246. var compiledElementFn = $scope.col.compiledElementFn;
  247. compiledElementFn($scope, function(clonedElement, scope) {
  248. $elm.append(clonedElement);
  249. });
  250. }
  251. // If the grid controller is present, use it to get the compiled cell template function
  252. if (uiGridCtrl && $scope.col.compiledElementFn) {
  253. compileTemplate();
  254. }
  255. // No controller, compile the element manually (for unit tests)
  256. else {
  257. if ( uiGridCtrl && !$scope.col.compiledElementFn ){
  258. // gridUtil.logError('Render has been called before precompile. Please log a ui-grid issue');
  259. $scope.col.getCompiledElementFn()
  260. .then(function (compiledElementFn) {
  261. compiledElementFn($scope, function(clonedElement, scope) {
  262. $elm.append(clonedElement);
  263. });
  264. }).catch(angular.noop);
  265. }
  266. else {
  267. var html = $scope.col.cellTemplate
  268. .replace(uiGridConstants.MODEL_COL_FIELD, 'row.entity.' + gridUtil.preEval($scope.col.field))
  269. .replace(uiGridConstants.COL_FIELD, 'grid.getCellValue(row, col)');
  270. var cellElement = $compile(html)($scope);
  271. $elm.append(cellElement);
  272. }
  273. }
  274. },
  275. post: function($scope, $elm, $attrs, uiGridCtrl) {
  276. var initColClass = $scope.col.getColClass(false);
  277. $elm.addClass(initColClass);
  278. var classAdded;
  279. var updateClass = function( grid ){
  280. var contents = $elm;
  281. if ( classAdded ){
  282. contents.removeClass( classAdded );
  283. classAdded = null;
  284. }
  285. if (angular.isFunction($scope.col.cellClass)) {
  286. classAdded = $scope.col.cellClass($scope.grid, $scope.row, $scope.col, $scope.rowRenderIndex, $scope.colRenderIndex);
  287. }
  288. else {
  289. classAdded = $scope.col.cellClass;
  290. }
  291. contents.addClass(classAdded);
  292. };
  293. if ($scope.col.cellClass) {
  294. updateClass();
  295. }
  296. // Register a data change watch that would get triggered whenever someone edits a cell or modifies column defs
  297. var dataChangeDereg = $scope.grid.registerDataChangeCallback( updateClass, [uiGridConstants.dataChange.COLUMN, uiGridConstants.dataChange.EDIT]);
  298. // watch the col and row to see if they change - which would indicate that we've scrolled or sorted or otherwise
  299. // changed the row/col that this cell relates to, and we need to re-evaluate cell classes and maybe other things
  300. var cellChangeFunction = function( n, o ){
  301. if ( n !== o ) {
  302. if ( classAdded || $scope.col.cellClass ){
  303. updateClass();
  304. }
  305. // See if the column's internal class has changed
  306. var newColClass = $scope.col.getColClass(false);
  307. if (newColClass !== initColClass) {
  308. $elm.removeClass(initColClass);
  309. $elm.addClass(newColClass);
  310. initColClass = newColClass;
  311. }
  312. }
  313. };
  314. // TODO(c0bra): Turn this into a deep array watch
  315. /* shouldn't be needed any more given track by col.name
  316. var colWatchDereg = $scope.$watch( 'col', cellChangeFunction );
  317. */
  318. var rowWatchDereg = $scope.$watch( 'row', cellChangeFunction );
  319. var deregisterFunction = function() {
  320. dataChangeDereg();
  321. // colWatchDereg();
  322. rowWatchDereg();
  323. };
  324. $scope.$on( '$destroy', deregisterFunction );
  325. $elm.on( '$destroy', deregisterFunction );
  326. }
  327. };
  328. }
  329. };
  330. return uiGridCell;
  331. }]);
  332. (function(){
  333. angular.module('ui.grid')
  334. .service('uiGridColumnMenuService', [ 'i18nService', 'uiGridConstants', 'gridUtil',
  335. function ( i18nService, uiGridConstants, gridUtil ) {
  336. /**
  337. * @ngdoc service
  338. * @name ui.grid.service:uiGridColumnMenuService
  339. *
  340. * @description Services for working with column menus, factored out
  341. * to make the code easier to understand
  342. */
  343. var service = {
  344. /**
  345. * @ngdoc method
  346. * @methodOf ui.grid.service:uiGridColumnMenuService
  347. * @name initialize
  348. * @description Sets defaults, puts a reference to the $scope on
  349. * the uiGridController
  350. * @param {$scope} $scope the $scope from the uiGridColumnMenu
  351. * @param {controller} uiGridCtrl the uiGridController for the grid
  352. * we're on
  353. *
  354. */
  355. initialize: function( $scope, uiGridCtrl ){
  356. $scope.grid = uiGridCtrl.grid;
  357. // Store a reference to this link/controller in the main uiGrid controller
  358. // to allow showMenu later
  359. uiGridCtrl.columnMenuScope = $scope;
  360. // Save whether we're shown or not so the columns can check
  361. $scope.menuShown = false;
  362. },
  363. /**
  364. * @ngdoc method
  365. * @methodOf ui.grid.service:uiGridColumnMenuService
  366. * @name setColMenuItemWatch
  367. * @description Setup a watch on $scope.col.menuItems, and update
  368. * menuItems based on this. $scope.col needs to be set by the column
  369. * before calling the menu.
  370. * @param {$scope} $scope the $scope from the uiGridColumnMenu
  371. * @param {controller} uiGridCtrl the uiGridController for the grid
  372. * we're on
  373. *
  374. */
  375. setColMenuItemWatch: function ( $scope ){
  376. var deregFunction = $scope.$watch('col.menuItems', function (n) {
  377. if (typeof(n) !== 'undefined' && n && angular.isArray(n)) {
  378. n.forEach(function (item) {
  379. if (typeof(item.context) === 'undefined' || !item.context) {
  380. item.context = {};
  381. }
  382. item.context.col = $scope.col;
  383. });
  384. $scope.menuItems = $scope.defaultMenuItems.concat(n);
  385. }
  386. else {
  387. $scope.menuItems = $scope.defaultMenuItems;
  388. }
  389. });
  390. $scope.$on( '$destroy', deregFunction );
  391. },
  392. /**
  393. * @ngdoc boolean
  394. * @name enableSorting
  395. * @propertyOf ui.grid.class:GridOptions.columnDef
  396. * @description (optional) True by default. When enabled, this setting adds sort
  397. * widgets to the column header, allowing sorting of the data in the individual column.
  398. */
  399. /**
  400. * @ngdoc method
  401. * @methodOf ui.grid.service:uiGridColumnMenuService
  402. * @name sortable
  403. * @description determines whether this column is sortable
  404. * @param {$scope} $scope the $scope from the uiGridColumnMenu
  405. *
  406. */
  407. sortable: function( $scope ) {
  408. if ( $scope.grid.options.enableSorting && typeof($scope.col) !== 'undefined' && $scope.col && $scope.col.enableSorting) {
  409. return true;
  410. }
  411. else {
  412. return false;
  413. }
  414. },
  415. /**
  416. * @ngdoc method
  417. * @methodOf ui.grid.service:uiGridColumnMenuService
  418. * @name isActiveSort
  419. * @description determines whether the requested sort direction is current active, to
  420. * allow highlighting in the menu
  421. * @param {$scope} $scope the $scope from the uiGridColumnMenu
  422. * @param {string} direction the direction that we'd have selected for us to be active
  423. *
  424. */
  425. isActiveSort: function( $scope, direction ){
  426. return (typeof($scope.col) !== 'undefined' && typeof($scope.col.sort) !== 'undefined' &&
  427. typeof($scope.col.sort.direction) !== 'undefined' && $scope.col.sort.direction === direction);
  428. },
  429. /**
  430. * @ngdoc method
  431. * @methodOf ui.grid.service:uiGridColumnMenuService
  432. * @name suppressRemoveSort
  433. * @description determines whether we should suppress the removeSort option
  434. * @param {$scope} $scope the $scope from the uiGridColumnMenu
  435. *
  436. */
  437. suppressRemoveSort: function( $scope ) {
  438. if ($scope.col && $scope.col.suppressRemoveSort) {
  439. return true;
  440. }
  441. else {
  442. return false;
  443. }
  444. },
  445. /**
  446. * @ngdoc boolean
  447. * @name enableHiding
  448. * @propertyOf ui.grid.class:GridOptions.columnDef
  449. * @description (optional) True by default. When set to false, this setting prevents a user from hiding the column
  450. * using the column menu or the grid menu.
  451. */
  452. /**
  453. * @ngdoc method
  454. * @methodOf ui.grid.service:uiGridColumnMenuService
  455. * @name hideable
  456. * @description determines whether a column can be hidden, by checking the enableHiding columnDef option
  457. * @param {$scope} $scope the $scope from the uiGridColumnMenu
  458. *
  459. */
  460. hideable: function( $scope ) {
  461. if (typeof($scope.col) !== 'undefined' && $scope.col && $scope.col.colDef && $scope.col.colDef.enableHiding === false ) {
  462. return false;
  463. }
  464. else {
  465. return true;
  466. }
  467. },
  468. /**
  469. * @ngdoc method
  470. * @methodOf ui.grid.service:uiGridColumnMenuService
  471. * @name getDefaultMenuItems
  472. * @description returns the default menu items for a column menu
  473. * @param {$scope} $scope the $scope from the uiGridColumnMenu
  474. *
  475. */
  476. getDefaultMenuItems: function( $scope ){
  477. return [
  478. {
  479. title: function(){return i18nService.getSafeText('sort.ascending');},
  480. icon: 'ui-grid-icon-sort-alt-up',
  481. action: function($event) {
  482. $event.stopPropagation();
  483. $scope.sortColumn($event, uiGridConstants.ASC);
  484. },
  485. shown: function () {
  486. return service.sortable( $scope );
  487. },
  488. active: function() {
  489. return service.isActiveSort( $scope, uiGridConstants.ASC);
  490. }
  491. },
  492. {
  493. title: function(){return i18nService.getSafeText('sort.descending');},
  494. icon: 'ui-grid-icon-sort-alt-down',
  495. action: function($event) {
  496. $event.stopPropagation();
  497. $scope.sortColumn($event, uiGridConstants.DESC);
  498. },
  499. shown: function() {
  500. return service.sortable( $scope );
  501. },
  502. active: function() {
  503. return service.isActiveSort( $scope, uiGridConstants.DESC);
  504. }
  505. },
  506. {
  507. title: function(){return i18nService.getSafeText('sort.remove');},
  508. icon: 'ui-grid-icon-cancel',
  509. action: function ($event) {
  510. $event.stopPropagation();
  511. $scope.unsortColumn();
  512. },
  513. shown: function() {
  514. return service.sortable( $scope ) &&
  515. typeof($scope.col) !== 'undefined' && (typeof($scope.col.sort) !== 'undefined' &&
  516. typeof($scope.col.sort.direction) !== 'undefined') && $scope.col.sort.direction !== null &&
  517. !service.suppressRemoveSort( $scope );
  518. }
  519. },
  520. {
  521. title: function(){return i18nService.getSafeText('column.hide');},
  522. icon: 'ui-grid-icon-cancel',
  523. shown: function() {
  524. return service.hideable( $scope );
  525. },
  526. action: function ($event) {
  527. $event.stopPropagation();
  528. $scope.hideColumn();
  529. }
  530. }
  531. ];
  532. },
  533. /**
  534. * @ngdoc method
  535. * @methodOf ui.grid.service:uiGridColumnMenuService
  536. * @name getColumnElementPosition
  537. * @description gets the position information needed to place the column
  538. * menu below the column header
  539. * @param {$scope} $scope the $scope from the uiGridColumnMenu
  540. * @param {GridCol} column the column we want to position below
  541. * @param {element} $columnElement the column element we want to position below
  542. * @returns {hash} containing left, top, offset, height, width
  543. *
  544. */
  545. getColumnElementPosition: function( $scope, column, $columnElement ){
  546. var positionData = {};
  547. positionData.left = $columnElement[0].offsetLeft;
  548. positionData.top = $columnElement[0].offsetTop;
  549. positionData.parentLeft = $columnElement[0].offsetParent.offsetLeft;
  550. // Get the grid scrollLeft
  551. positionData.offset = 0;
  552. if (column.grid.options.offsetLeft) {
  553. positionData.offset = column.grid.options.offsetLeft;
  554. }
  555. positionData.height = gridUtil.elementHeight($columnElement, true);
  556. positionData.width = gridUtil.elementWidth($columnElement, true);
  557. return positionData;
  558. },
  559. /**
  560. * @ngdoc method
  561. * @methodOf ui.grid.service:uiGridColumnMenuService
  562. * @name repositionMenu
  563. * @description Reposition the menu below the new column. If the menu has no child nodes
  564. * (i.e. it's not currently visible) then we guess it's width at 100, we'll be called again
  565. * later to fix it
  566. * @param {$scope} $scope the $scope from the uiGridColumnMenu
  567. * @param {GridCol} column the column we want to position below
  568. * @param {hash} positionData a hash containing left, top, offset, height, width
  569. * @param {element} $elm the column menu element that we want to reposition
  570. * @param {element} $columnElement the column element that we want to reposition underneath
  571. *
  572. */
  573. repositionMenu: function( $scope, column, positionData, $elm, $columnElement ) {
  574. var menu = $elm[0].querySelectorAll('.ui-grid-menu');
  575. // It's possible that the render container of the column we're attaching to is
  576. // offset from the grid (i.e. pinned containers), we need to get the difference in the offsetLeft
  577. // between the render container and the grid
  578. var renderContainerElm = gridUtil.closestElm($columnElement, '.ui-grid-render-container');
  579. var renderContainerOffset = renderContainerElm.getBoundingClientRect().left - $scope.grid.element[0].getBoundingClientRect().left;
  580. var containerScrollLeft = renderContainerElm.querySelectorAll('.ui-grid-viewport')[0].scrollLeft;
  581. // repositionMenu is now always called after it's visible in the DOM,
  582. // allowing us to simply get the width every time the menu is opened
  583. var myWidth = gridUtil.elementWidth(menu, true);
  584. var paddingRight = column.lastMenuPaddingRight ? column.lastMenuPaddingRight : ( $scope.lastMenuPaddingRight ? $scope.lastMenuPaddingRight : 10);
  585. if ( menu.length !== 0 ){
  586. var mid = menu[0].querySelectorAll('.ui-grid-menu-mid');
  587. if ( mid.length !== 0 ) {
  588. // TODO(c0bra): use padding-left/padding-right based on document direction (ltr/rtl), place menu on proper side
  589. // Get the column menu right padding
  590. paddingRight = parseInt(gridUtil.getStyles(angular.element(menu)[0])['paddingRight'], 10);
  591. $scope.lastMenuPaddingRight = paddingRight;
  592. column.lastMenuPaddingRight = paddingRight;
  593. }
  594. }
  595. var left = positionData.left + renderContainerOffset - containerScrollLeft + positionData.parentLeft + positionData.width + paddingRight;
  596. if (left < positionData.offset + myWidth) {
  597. left = Math.max(positionData.left - containerScrollLeft + positionData.parentLeft - paddingRight + myWidth, positionData.offset + myWidth);
  598. }
  599. $elm.css('left', left + 'px');
  600. $elm.css('top', (positionData.top + positionData.height) + 'px');
  601. }
  602. };
  603. return service;
  604. }])
  605. .directive('uiGridColumnMenu', ['$timeout', 'gridUtil', 'uiGridConstants', 'uiGridColumnMenuService', '$document',
  606. function ($timeout, gridUtil, uiGridConstants, uiGridColumnMenuService, $document) {
  607. /**
  608. * @ngdoc directive
  609. * @name ui.grid.directive:uiGridColumnMenu
  610. * @description Provides the column menu framework, leverages uiGridMenu underneath
  611. *
  612. */
  613. var uiGridColumnMenu = {
  614. priority: 0,
  615. scope: true,
  616. require: '^uiGrid',
  617. templateUrl: 'ui-grid/uiGridColumnMenu',
  618. replace: true,
  619. link: function ($scope, $elm, $attrs, uiGridCtrl) {
  620. uiGridColumnMenuService.initialize( $scope, uiGridCtrl );
  621. $scope.defaultMenuItems = uiGridColumnMenuService.getDefaultMenuItems( $scope );
  622. // Set the menu items for use with the column menu. The user can later add additional items via the watch
  623. $scope.menuItems = $scope.defaultMenuItems;
  624. uiGridColumnMenuService.setColMenuItemWatch( $scope );
  625. /**
  626. * @ngdoc method
  627. * @methodOf ui.grid.directive:uiGridColumnMenu
  628. * @name showMenu
  629. * @description Shows the column menu. If the menu is already displayed it
  630. * calls the menu to ask it to hide (it will animate), then it repositions the menu
  631. * to the right place whilst hidden (it will make an assumption on menu width),
  632. * then it asks the menu to show (it will animate), then it repositions the menu again
  633. * once we can calculate it's size.
  634. * @param {GridCol} column the column we want to position below
  635. * @param {element} $columnElement the column element we want to position below
  636. */
  637. $scope.showMenu = function(column, $columnElement, event) {
  638. // Swap to this column
  639. $scope.col = column;
  640. // Get the position information for the column element
  641. var colElementPosition = uiGridColumnMenuService.getColumnElementPosition( $scope, column, $columnElement );
  642. if ($scope.menuShown) {
  643. // we want to hide, then reposition, then show, but we want to wait for animations
  644. // we set a variable, and then rely on the menu-hidden event to call the reposition and show
  645. $scope.colElement = $columnElement;
  646. $scope.colElementPosition = colElementPosition;
  647. $scope.hideThenShow = true;
  648. $scope.$broadcast('hide-menu', { originalEvent: event });
  649. } else {
  650. $scope.menuShown = true;
  651. $scope.colElement = $columnElement;
  652. $scope.colElementPosition = colElementPosition;
  653. $scope.$broadcast('show-menu', { originalEvent: event });
  654. }
  655. };
  656. /**
  657. * @ngdoc method
  658. * @methodOf ui.grid.directive:uiGridColumnMenu
  659. * @name hideMenu
  660. * @description Hides the column menu.
  661. * @param {boolean} broadcastTrigger true if we were triggered by a broadcast
  662. * from the menu itself - in which case don't broadcast again as we'll get
  663. * an infinite loop
  664. */
  665. $scope.hideMenu = function( broadcastTrigger ) {
  666. $scope.menuShown = false;
  667. if ( !broadcastTrigger ){
  668. $scope.$broadcast('hide-menu');
  669. }
  670. };
  671. $scope.$on('menu-hidden', function() {
  672. $elm[0].removeAttribute('style');
  673. if ( $scope.hideThenShow ){
  674. delete $scope.hideThenShow;
  675. $scope.$broadcast('show-menu');
  676. $scope.menuShown = true;
  677. } else {
  678. $scope.hideMenu( true );
  679. if ($scope.col) {
  680. //Focus on the menu button
  681. gridUtil.focus.bySelector($document, '.ui-grid-header-cell.' + $scope.col.getColClass()+ ' .ui-grid-column-menu-button', $scope.col.grid, false);
  682. }
  683. }
  684. });
  685. $scope.$on('menu-shown', function() {
  686. $timeout( function() {
  687. uiGridColumnMenuService.repositionMenu( $scope, $scope.col, $scope.colElementPosition, $elm, $scope.colElement );
  688. //automatically set the focus to the first button element in the now open menu.
  689. gridUtil.focus.bySelector($document, '.ui-grid-menu-items .ui-grid-menu-item', true);
  690. delete $scope.colElementPosition;
  691. delete $scope.columnElement;
  692. });
  693. });
  694. /* Column methods */
  695. $scope.sortColumn = function (event, dir) {
  696. event.stopPropagation();
  697. $scope.grid.sortColumn($scope.col, dir, true)
  698. .then(function () {
  699. $scope.grid.refresh();
  700. $scope.hideMenu();
  701. }).catch(angular.noop);
  702. };
  703. $scope.unsortColumn = function () {
  704. $scope.col.unsort();
  705. $scope.grid.refresh();
  706. $scope.hideMenu();
  707. };
  708. // Since we are hiding this column the default hide action will fail so we need to focus somewhere else.
  709. var setFocusOnHideColumn = function(){
  710. $timeout(function() {
  711. // Get the UID of the first
  712. var focusToGridMenu = function(){
  713. return gridUtil.focus.byId('grid-menu', $scope.grid);
  714. };
  715. var thisIndex;
  716. $scope.grid.columns.some(function(element, index){
  717. if (angular.equals(element, $scope.col)) {
  718. thisIndex = index;
  719. return true;
  720. }
  721. });
  722. var previousVisibleCol;
  723. // Try and find the next lower or nearest column to focus on
  724. $scope.grid.columns.some(function(element, index){
  725. if (!element.visible){
  726. return false;
  727. } // This columns index is below the current column index
  728. else if ( index < thisIndex){
  729. previousVisibleCol = element;
  730. } // This elements index is above this column index and we haven't found one that is lower
  731. else if ( index > thisIndex && !previousVisibleCol) {
  732. // This is the next best thing
  733. previousVisibleCol = element;
  734. // We've found one so use it.
  735. return true;
  736. } // We've reached an element with an index above this column and the previousVisibleCol variable has been set
  737. else if (index > thisIndex && previousVisibleCol) {
  738. // We are done.
  739. return true;
  740. }
  741. });
  742. // If found then focus on it
  743. if (previousVisibleCol){
  744. var colClass = previousVisibleCol.getColClass();
  745. gridUtil.focus.bySelector($document, '.ui-grid-header-cell.' + colClass+ ' .ui-grid-header-cell-primary-focus', true).then(angular.noop, function(reason){
  746. if (reason !== 'canceled'){ // If this is canceled then don't perform the action
  747. //The fallback action is to focus on the grid menu
  748. return focusToGridMenu();
  749. }
  750. }).catch(angular.noop);
  751. } else {
  752. // Fallback action to focus on the grid menu
  753. focusToGridMenu();
  754. }
  755. });
  756. };
  757. $scope.hideColumn = function () {
  758. $scope.col.colDef.visible = false;
  759. $scope.col.visible = false;
  760. $scope.grid.queueGridRefresh();
  761. $scope.hideMenu();
  762. $scope.grid.api.core.notifyDataChange( uiGridConstants.dataChange.COLUMN );
  763. $scope.grid.api.core.raise.columnVisibilityChanged( $scope.col );
  764. // We are hiding so the default action of focusing on the button that opened this menu will fail.
  765. setFocusOnHideColumn();
  766. };
  767. },
  768. controller: ['$scope', function ($scope) {
  769. var self = this;
  770. $scope.$watch('menuItems', function (n) {
  771. self.menuItems = n;
  772. });
  773. }]
  774. };
  775. return uiGridColumnMenu;
  776. }]);
  777. })();
  778. (function(){
  779. 'use strict';
  780. angular.module('ui.grid').directive('uiGridFilter', ['$compile', '$templateCache', 'i18nService', 'gridUtil', function ($compile, $templateCache, i18nService, gridUtil) {
  781. return {
  782. compile: function() {
  783. return {
  784. pre: function ($scope, $elm, $attrs, controllers) {
  785. $scope.col.updateFilters = function( filterable ){
  786. $elm.children().remove();
  787. if ( filterable ) {
  788. var template = $scope.col.filterHeaderTemplate;
  789. if (template === undefined && $scope.col.providedFilterHeaderTemplate !== '') {
  790. if ($scope.col.filterHeaderTemplatePromise) {
  791. $scope.col.filterHeaderTemplatePromise.then(function () {
  792. template = $scope.col.filterHeaderTemplate;
  793. $elm.append($compile(template)($scope));
  794. });
  795. }
  796. }
  797. else {
  798. $elm.append($compile(template)($scope));
  799. }
  800. }
  801. };
  802. $scope.$on( '$destroy', function() {
  803. delete $scope.col.updateFilters;
  804. });
  805. },
  806. post: function ($scope, $elm, $attrs, controllers){
  807. $scope.aria = i18nService.getSafeText('headerCell.aria');
  808. $scope.removeFilter = function(colFilter, index){
  809. colFilter.term = null;
  810. //Set the focus to the filter input after the action disables the button
  811. gridUtil.focus.bySelector($elm, '.ui-grid-filter-input-' + index);
  812. };
  813. }
  814. };
  815. }
  816. };
  817. }]);
  818. })();
  819. (function () {
  820. 'use strict';
  821. angular.module('ui.grid').directive('uiGridFooterCell', ['$timeout', 'gridUtil', 'uiGridConstants', '$compile',
  822. function ($timeout, gridUtil, uiGridConstants, $compile) {
  823. var uiGridFooterCell = {
  824. priority: 0,
  825. scope: {
  826. col: '=',
  827. row: '=',
  828. renderIndex: '='
  829. },
  830. replace: true,
  831. require: '^uiGrid',
  832. compile: function compile(tElement, tAttrs, transclude) {
  833. return {
  834. pre: function ($scope, $elm, $attrs, uiGridCtrl) {
  835. var template = $scope.col.footerCellTemplate;
  836. if (template === undefined && $scope.col.providedFooterCellTemplate !== '') {
  837. if ($scope.col.footerCellTemplatePromise) {
  838. $scope.col.footerCellTemplatePromise.then(function () {
  839. template = $scope.col.footerCellTemplate;
  840. $elm.append($compile(template)($scope));
  841. });
  842. }
  843. }
  844. else {
  845. $elm.append($compile(template)($scope));
  846. }
  847. },
  848. post: function ($scope, $elm, $attrs, uiGridCtrl) {
  849. //$elm.addClass($scope.col.getColClass(false));
  850. $scope.grid = uiGridCtrl.grid;
  851. var initColClass = $scope.col.getColClass(false);
  852. $elm.addClass(initColClass);
  853. // apply any footerCellClass
  854. var classAdded;
  855. var updateClass = function( grid ){
  856. var contents = $elm;
  857. if ( classAdded ){
  858. contents.removeClass( classAdded );
  859. classAdded = null;
  860. }
  861. if (angular.isFunction($scope.col.footerCellClass)) {
  862. classAdded = $scope.col.footerCellClass($scope.grid, $scope.row, $scope.col, $scope.rowRenderIndex, $scope.colRenderIndex);
  863. }
  864. else {
  865. classAdded = $scope.col.footerCellClass;
  866. }
  867. contents.addClass(classAdded);
  868. };
  869. if ($scope.col.footerCellClass) {
  870. updateClass();
  871. }
  872. $scope.col.updateAggregationValue();
  873. // Watch for column changes so we can alter the col cell class properly
  874. /* shouldn't be needed any more, given track by col.name
  875. $scope.$watch('col', function (n, o) {
  876. if (n !== o) {
  877. // See if the column's internal class has changed
  878. var newColClass = $scope.col.getColClass(false);
  879. if (newColClass !== initColClass) {
  880. $elm.removeClass(initColClass);
  881. $elm.addClass(newColClass);
  882. initColClass = newColClass;
  883. }
  884. }
  885. });
  886. */
  887. // Register a data change watch that would get triggered whenever someone edits a cell or modifies column defs
  888. var dataChangeDereg = $scope.grid.registerDataChangeCallback( updateClass, [uiGridConstants.dataChange.COLUMN]);
  889. // listen for visible rows change and update aggregation values
  890. $scope.grid.api.core.on.rowsRendered( $scope, $scope.col.updateAggregationValue );
  891. $scope.grid.api.core.on.rowsRendered( $scope, updateClass );
  892. $scope.$on( '$destroy', dataChangeDereg );
  893. }
  894. };
  895. }
  896. };
  897. return uiGridFooterCell;
  898. }]);
  899. })();
  900. (function () {
  901. 'use strict';
  902. angular.module('ui.grid').directive('uiGridFooter', ['$templateCache', '$compile', 'uiGridConstants', 'gridUtil', '$timeout', function ($templateCache, $compile, uiGridConstants, gridUtil, $timeout) {
  903. return {
  904. restrict: 'EA',
  905. replace: true,
  906. // priority: 1000,
  907. require: ['^uiGrid', '^uiGridRenderContainer'],
  908. scope: true,
  909. compile: function ($elm, $attrs) {
  910. return {
  911. pre: function ($scope, $elm, $attrs, controllers) {
  912. var uiGridCtrl = controllers[0];
  913. var containerCtrl = controllers[1];
  914. $scope.grid = uiGridCtrl.grid;
  915. $scope.colContainer = containerCtrl.colContainer;
  916. containerCtrl.footer = $elm;
  917. var footerTemplate = $scope.grid.options.footerTemplate;
  918. gridUtil.getTemplate(footerTemplate)
  919. .then(function (contents) {
  920. var template = angular.element(contents);
  921. var newElm = $compile(template)($scope);
  922. $elm.append(newElm);
  923. if (containerCtrl) {
  924. // Inject a reference to the footer viewport (if it exists) into the grid controller for use in the horizontal scroll handler below
  925. var footerViewport = $elm[0].getElementsByClassName('ui-grid-footer-viewport')[0];
  926. if (footerViewport) {
  927. containerCtrl.footerViewport = footerViewport;
  928. }
  929. }
  930. }).catch(angular.noop);
  931. },
  932. post: function ($scope, $elm, $attrs, controllers) {
  933. var uiGridCtrl = controllers[0];
  934. var containerCtrl = controllers[1];
  935. // gridUtil.logDebug('ui-grid-footer link');
  936. var grid = uiGridCtrl.grid;
  937. // Don't animate footer cells
  938. gridUtil.disableAnimations($elm);
  939. containerCtrl.footer = $elm;
  940. var footerViewport = $elm[0].getElementsByClassName('ui-grid-footer-viewport')[0];
  941. if (footerViewport) {
  942. containerCtrl.footerViewport = footerViewport;
  943. }
  944. }
  945. };
  946. }
  947. };
  948. }]);
  949. })();
  950. (function () {
  951. 'use strict';
  952. angular.module('ui.grid').directive('uiGridGridFooter', ['$templateCache', '$compile', 'uiGridConstants', 'gridUtil', '$timeout', function ($templateCache, $compile, uiGridConstants, gridUtil, $timeout) {
  953. return {
  954. restrict: 'EA',
  955. replace: true,
  956. // priority: 1000,
  957. require: '^uiGrid',
  958. scope: true,
  959. compile: function ($elm, $attrs) {
  960. return {
  961. pre: function ($scope, $elm, $attrs, uiGridCtrl) {
  962. $scope.grid = uiGridCtrl.grid;
  963. var footerTemplate = $scope.grid.options.gridFooterTemplate;
  964. gridUtil.getTemplate(footerTemplate)
  965. .then(function (contents) {
  966. var template = angular.element(contents);
  967. var newElm = $compile(template)($scope);
  968. $elm.append(newElm);
  969. }).catch(angular.noop);
  970. },
  971. post: function ($scope, $elm, $attrs, controllers) {
  972. }
  973. };
  974. }
  975. };
  976. }]);
  977. })();
  978. (function(){
  979. 'use strict';
  980. angular.module('ui.grid').directive('uiGridHeaderCell', ['$compile', '$timeout', '$window', '$document', 'gridUtil', 'uiGridConstants', 'ScrollEvent', 'i18nService',
  981. function ($compile, $timeout, $window, $document, gridUtil, uiGridConstants, ScrollEvent, i18nService) {
  982. // Do stuff after mouse has been down this many ms on the header cell
  983. var mousedownTimeout = 500;
  984. var changeModeTimeout = 500; // length of time between a touch event and a mouse event being recognised again, and vice versa
  985. var uiGridHeaderCell = {
  986. priority: 0,
  987. scope: {
  988. col: '=',
  989. row: '=',
  990. renderIndex: '='
  991. },
  992. require: ['^uiGrid', '^uiGridRenderContainer'],
  993. replace: true,
  994. compile: function() {
  995. return {
  996. pre: function ($scope, $elm, $attrs) {
  997. var template = $scope.col.headerCellTemplate;
  998. if (template === undefined && $scope.col.providedHeaderCellTemplate !== '') {
  999. if ($scope.col.headerCellTemplatePromise) {
  1000. $scope.col.headerCellTemplatePromise.then(function () {
  1001. template = $scope.col.headerCellTemplate;
  1002. $elm.append($compile(template)($scope));
  1003. });
  1004. }
  1005. }
  1006. else {
  1007. $elm.append($compile(template)($scope));
  1008. }
  1009. },
  1010. post: function ($scope, $elm, $attrs, controllers) {
  1011. var uiGridCtrl = controllers[0];
  1012. var renderContainerCtrl = controllers[1];
  1013. $scope.i18n = {
  1014. headerCell: i18nService.getSafeText('headerCell'),
  1015. sort: i18nService.getSafeText('sort')
  1016. };
  1017. $scope.isSortPriorityVisible = function() {
  1018. //show sort priority if column is sorted and there is at least one other sorted column
  1019. return angular.isNumber($scope.col.sort.priority) && $scope.grid.columns.some(function(element, index){
  1020. return angular.isNumber(element.sort.priority) && element !== $scope.col;
  1021. });
  1022. };
  1023. $scope.getSortDirectionAriaLabel = function(){
  1024. var col = $scope.col;
  1025. //Trying to recreate this sort of thing but it was getting messy having it in the template.
  1026. //Sort direction {{col.sort.direction == asc ? 'ascending' : ( col.sort.direction == desc ? 'descending':'none')}}. {{col.sort.priority ? {{columnPriorityText}} {{col.sort.priority}} : ''}
  1027. var sortDirectionText = col.sort.direction === uiGridConstants.ASC ? $scope.i18n.sort.ascending : ( col.sort.direction === uiGridConstants.DESC ? $scope.i18n.sort.descending : $scope.i18n.sort.none);
  1028. var label = sortDirectionText;
  1029. if ($scope.isSortPriorityVisible()) {
  1030. label = label + '. ' + $scope.i18n.headerCell.priority + ' ' + (col.sort.priority + 1);
  1031. }
  1032. return label;
  1033. };
  1034. $scope.grid = uiGridCtrl.grid;
  1035. $scope.renderContainer = uiGridCtrl.grid.renderContainers[renderContainerCtrl.containerId];
  1036. var initColClass = $scope.col.getColClass(false);
  1037. $elm.addClass(initColClass);
  1038. // Hide the menu by default
  1039. $scope.menuShown = false;
  1040. // Put asc and desc sort directions in scope
  1041. $scope.asc = uiGridConstants.ASC;
  1042. $scope.desc = uiGridConstants.DESC;
  1043. // Store a reference to menu element
  1044. var $colMenu = angular.element( $elm[0].querySelectorAll('.ui-grid-header-cell-menu') );
  1045. var $contentsElm = angular.element( $elm[0].querySelectorAll('.ui-grid-cell-contents') );
  1046. // apply any headerCellClass
  1047. var classAdded;
  1048. var previousMouseX;
  1049. // filter watchers
  1050. var filterDeregisters = [];
  1051. /*
  1052. * Our basic approach here for event handlers is that we listen for a down event (mousedown or touchstart).
  1053. * Once we have a down event, we need to work out whether we have a click, a drag, or a
  1054. * hold. A click would sort the grid (if sortable). A drag would be used by moveable, so
  1055. * we ignore it. A hold would open the menu.
  1056. *
  1057. * So, on down event, we put in place handlers for move and up events, and a timer. If the
  1058. * timer expires before we see a move or up, then we have a long press and hence a column menu open.
  1059. * If the up happens before the timer, then we have a click, and we sort if the column is sortable.
  1060. * If a move happens before the timer, then we are doing column move, so we do nothing, the moveable feature
  1061. * will handle it.
  1062. *
  1063. * To deal with touch enabled devices that also have mice, we only create our handlers when
  1064. * we get the down event, and we create the corresponding handlers - if we're touchstart then
  1065. * we get touchmove and touchend, if we're mousedown then we get mousemove and mouseup.
  1066. *
  1067. * We also suppress the click action whilst this is happening - otherwise after the mouseup there
  1068. * will be a click event and that can cause the column menu to close
  1069. *
  1070. */
  1071. $scope.downFn = function( event ){
  1072. event.stopPropagation();
  1073. if (typeof(event.originalEvent) !== 'undefined' && event.originalEvent !== undefined) {
  1074. event = event.originalEvent;
  1075. }
  1076. // Don't show the menu if it's not the left button
  1077. if (event.button && event.button !== 0) {
  1078. return;
  1079. }
  1080. previousMouseX = event.pageX;
  1081. $scope.mousedownStartTime = (new Date()).getTime();
  1082. $scope.mousedownTimeout = $timeout(function() { }, mousedownTimeout);
  1083. $scope.mousedownTimeout.then(function () {
  1084. if ( $scope.colMenu ) {
  1085. uiGridCtrl.columnMenuScope.showMenu($scope.col, $elm, event);
  1086. }
  1087. }).catch(angular.noop);
  1088. uiGridCtrl.fireEvent(uiGridConstants.events.COLUMN_HEADER_CLICK, {event: event, columnName: $scope.col.colDef.name});
  1089. $scope.offAllEvents();
  1090. if ( event.type === 'touchstart'){
  1091. $document.on('touchend', $scope.upFn);
  1092. $document.on('touchmove', $scope.moveFn);
  1093. } else if ( event.type === 'mousedown' ){
  1094. $document.on('mouseup', $scope.upFn);
  1095. $document.on('mousemove', $scope.moveFn);
  1096. }
  1097. };
  1098. $scope.upFn = function( event ){
  1099. event.stopPropagation();
  1100. $timeout.cancel($scope.mousedownTimeout);
  1101. $scope.offAllEvents();
  1102. $scope.onDownEvents(event.type);
  1103. var mousedownEndTime = (new Date()).getTime();
  1104. var mousedownTime = mousedownEndTime - $scope.mousedownStartTime;
  1105. if (mousedownTime > mousedownTimeout) {
  1106. // long click, handled above with mousedown
  1107. }
  1108. else {
  1109. // short click
  1110. if ( $scope.sortable ){
  1111. $scope.handleClick(event);
  1112. }
  1113. }
  1114. };
  1115. $scope.handleKeyDown = function(event) {
  1116. if (event.keyCode === 32) {
  1117. event.preventDefault();
  1118. }
  1119. };
  1120. $scope.moveFn = function( event ){
  1121. // Chrome is known to fire some bogus move events.
  1122. var changeValue = event.pageX - previousMouseX;
  1123. if ( changeValue === 0 ){ return; }
  1124. // we're a move, so do nothing and leave for column move (if enabled) to take over
  1125. $timeout.cancel($scope.mousedownTimeout);
  1126. $scope.offAllEvents();
  1127. $scope.onDownEvents(event.type);
  1128. };
  1129. $scope.clickFn = function ( event ){
  1130. event.stopPropagation();
  1131. $contentsElm.off('click', $scope.clickFn);
  1132. };
  1133. $scope.offAllEvents = function(){
  1134. $contentsElm.off('touchstart', $scope.downFn);
  1135. $contentsElm.off('mousedown', $scope.downFn);
  1136. $document.off('touchend', $scope.upFn);
  1137. $document.off('mouseup', $scope.upFn);
  1138. $document.off('touchmove', $scope.moveFn);
  1139. $document.off('mousemove', $scope.moveFn);
  1140. $contentsElm.off('click', $scope.clickFn);
  1141. };
  1142. $scope.onDownEvents = function( type ){
  1143. // If there is a previous event, then wait a while before
  1144. // activating the other mode - i.e. if the last event was a touch event then
  1145. // don't enable mouse events for a wee while (500ms or so)
  1146. // Avoids problems with devices that emulate mouse events when you have touch events
  1147. switch (type){
  1148. case 'touchmove':
  1149. case 'touchend':
  1150. $contentsElm.on('click', $scope.clickFn);
  1151. $contentsElm.on('touchstart', $scope.downFn);
  1152. $timeout(function(){
  1153. $contentsElm.on('mousedown', $scope.downFn);
  1154. }, changeModeTimeout);
  1155. break;
  1156. case 'mousemove':
  1157. case 'mouseup':
  1158. $contentsElm.on('click', $scope.clickFn);
  1159. $contentsElm.on('mousedown', $scope.downFn);
  1160. $timeout(function(){
  1161. $contentsElm.on('touchstart', $scope.downFn);
  1162. }, changeModeTimeout);
  1163. break;
  1164. default:
  1165. $contentsElm.on('click', $scope.clickFn);
  1166. $contentsElm.on('touchstart', $scope.downFn);
  1167. $contentsElm.on('mousedown', $scope.downFn);
  1168. }
  1169. };
  1170. var updateHeaderOptions = function( grid ){
  1171. var contents = $elm;
  1172. if ( classAdded ){
  1173. contents.removeClass( classAdded );
  1174. classAdded = null;
  1175. }
  1176. if (angular.isFunction($scope.col.headerCellClass)) {
  1177. classAdded = $scope.col.headerCellClass($scope.grid, $scope.row, $scope.col, $scope.rowRenderIndex, $scope.colRenderIndex);
  1178. }
  1179. else {
  1180. classAdded = $scope.col.headerCellClass;
  1181. }
  1182. contents.addClass(classAdded);
  1183. $scope.$applyAsync(function() {
  1184. var rightMostContainer = $scope.grid.renderContainers['right'] && $scope.grid.renderContainers['right'].visibleColumnCache.length ?
  1185. $scope.grid.renderContainers['right'] : $scope.grid.renderContainers['body'];
  1186. $scope.isLastCol = uiGridCtrl.grid.options && uiGridCtrl.grid.options.enableGridMenu &&
  1187. $scope.col === rightMostContainer.visibleColumnCache[ rightMostContainer.visibleColumnCache.length - 1 ];
  1188. });
  1189. // Figure out whether this column is sortable or not
  1190. $scope.sortable = Boolean($scope.col.enableSorting);
  1191. // Figure out whether this column is filterable or not
  1192. var oldFilterable = $scope.filterable;
  1193. $scope.filterable = Boolean(uiGridCtrl.grid.options.enableFiltering && $scope.col.enableFiltering);
  1194. if ( oldFilterable !== $scope.filterable){
  1195. if ( typeof($scope.col.updateFilters) !== 'undefined' ){
  1196. $scope.col.updateFilters($scope.filterable);
  1197. }
  1198. // if column is filterable add a filter watcher
  1199. if ($scope.filterable) {
  1200. $scope.col.filters.forEach( function(filter, i) {
  1201. filterDeregisters.push($scope.$watch('col.filters[' + i + '].term', function(n, o) {
  1202. if (n !== o) {
  1203. uiGridCtrl.grid.api.core.raise.filterChanged();
  1204. uiGridCtrl.grid.api.core.notifyDataChange( uiGridConstants.dataChange.COLUMN );
  1205. uiGridCtrl.grid.queueGridRefresh();
  1206. }
  1207. }));
  1208. });
  1209. $scope.$on('$destroy', function() {
  1210. filterDeregisters.forEach( function(filterDeregister) {
  1211. filterDeregister();
  1212. });
  1213. });
  1214. } else {
  1215. filterDeregisters.forEach( function(filterDeregister) {
  1216. filterDeregister();
  1217. });
  1218. }
  1219. }
  1220. // figure out whether we support column menus
  1221. if ($scope.col.grid.options && $scope.col.grid.options.enableColumnMenus !== false &&
  1222. $scope.col.colDef && $scope.col.colDef.enableColumnMenu !== false){
  1223. $scope.colMenu = true;
  1224. } else {
  1225. $scope.colMenu = false;
  1226. }
  1227. /**
  1228. * @ngdoc property
  1229. * @name enableColumnMenu
  1230. * @propertyOf ui.grid.class:GridOptions.columnDef
  1231. * @description if column menus are enabled, controls the column menus for this specific
  1232. * column (i.e. if gridOptions.enableColumnMenus, then you can control column menus
  1233. * using this option. If gridOptions.enableColumnMenus === false then you get no column
  1234. * menus irrespective of the value of this option ). Defaults to true.
  1235. *
  1236. * By default column menu's trigger is hidden before mouse over, but you can always force it to be visible with CSS:
  1237. *
  1238. * <pre>
  1239. * .ui-grid-column-menu-button {
  1240. * display: block;
  1241. * }
  1242. * </pre>
  1243. */
  1244. /**
  1245. * @ngdoc property
  1246. * @name enableColumnMenus
  1247. * @propertyOf ui.grid.class:GridOptions.columnDef
  1248. * @description Override for column menus everywhere - if set to false then you get no
  1249. * column menus. Defaults to true.
  1250. *
  1251. */
  1252. $scope.offAllEvents();
  1253. if ($scope.sortable || $scope.colMenu) {
  1254. $scope.onDownEvents();
  1255. $scope.$on('$destroy', function () {
  1256. $scope.offAllEvents();
  1257. });
  1258. }
  1259. };
  1260. /*
  1261. $scope.$watch('col', function (n, o) {
  1262. if (n !== o) {
  1263. // See if the column's internal class has changed
  1264. var newColClass = $scope.col.getColClass(false);
  1265. if (newColClass !== initColClass) {
  1266. $elm.removeClass(initColClass);
  1267. $elm.addClass(newColClass);
  1268. initColClass = newColClass;
  1269. }
  1270. }
  1271. });
  1272. */
  1273. updateHeaderOptions();
  1274. // Register a data change watch that would get triggered whenever someone edits a cell or modifies column defs
  1275. var dataChangeDereg = $scope.grid.registerDataChangeCallback( updateHeaderOptions, [uiGridConstants.dataChange.COLUMN]);
  1276. $scope.$on( '$destroy', dataChangeDereg );
  1277. $scope.handleClick = function(event) {
  1278. // If the shift key is being held down, add this column to the sort
  1279. var add = false;
  1280. if (event.shiftKey) {
  1281. add = true;
  1282. }
  1283. // Sort this column then rebuild the grid's rows
  1284. uiGridCtrl.grid.sortColumn($scope.col, add)
  1285. .then(function () {
  1286. if (uiGridCtrl.columnMenuScope) { uiGridCtrl.columnMenuScope.hideMenu(); }
  1287. uiGridCtrl.grid.refresh();
  1288. }).catch(angular.noop);
  1289. };
  1290. $scope.headerCellArrowKeyDown = function(event) {
  1291. if (event.keyCode === 32 || event.keyCode === 13) {
  1292. event.preventDefault();
  1293. $scope.toggleMenu(event);
  1294. }
  1295. };
  1296. $scope.toggleMenu = function(event) {
  1297. event.stopPropagation();
  1298. // If the menu is already showing...
  1299. if (uiGridCtrl.columnMenuScope.menuShown) {
  1300. // ... and we're the column the menu is on...
  1301. if (uiGridCtrl.columnMenuScope.col === $scope.col) {
  1302. // ... hide it
  1303. uiGridCtrl.columnMenuScope.hideMenu();
  1304. }
  1305. // ... and we're NOT the column the menu is on
  1306. else {
  1307. // ... move the menu to our column
  1308. uiGridCtrl.columnMenuScope.showMenu($scope.col, $elm);
  1309. }
  1310. }
  1311. // If the menu is NOT showing
  1312. else {
  1313. // ... show it on our column
  1314. uiGridCtrl.columnMenuScope.showMenu($scope.col, $elm);
  1315. }
  1316. };
  1317. }
  1318. };
  1319. }
  1320. };
  1321. return uiGridHeaderCell;
  1322. }]);
  1323. })();
  1324. (function(){
  1325. 'use strict';
  1326. angular.module('ui.grid').directive('uiGridHeader', ['$templateCache', '$compile', 'uiGridConstants', 'gridUtil', '$timeout', 'ScrollEvent',
  1327. function($templateCache, $compile, uiGridConstants, gridUtil, $timeout, ScrollEvent) {
  1328. var defaultTemplate = 'ui-grid/ui-grid-header';
  1329. var emptyTemplate = 'ui-grid/ui-grid-no-header';
  1330. return {
  1331. restrict: 'EA',
  1332. // templateUrl: 'ui-grid/ui-grid-header',
  1333. replace: true,
  1334. // priority: 1000,
  1335. require: ['^uiGrid', '^uiGridRenderContainer'],
  1336. scope: true,
  1337. compile: function($elm, $attrs) {
  1338. return {
  1339. pre: function ($scope, $elm, $attrs, controllers) {
  1340. var uiGridCtrl = controllers[0];
  1341. var containerCtrl = controllers[1];
  1342. $scope.grid = uiGridCtrl.grid;
  1343. $scope.colContainer = containerCtrl.colContainer;
  1344. updateHeaderReferences();
  1345. var headerTemplate;
  1346. if (!$scope.grid.options.showHeader) {
  1347. headerTemplate = emptyTemplate;
  1348. }
  1349. else {
  1350. headerTemplate = ($scope.grid.options.headerTemplate) ? $scope.grid.options.headerTemplate : defaultTemplate;
  1351. }
  1352. gridUtil.getTemplate(headerTemplate)
  1353. .then(function (contents) {
  1354. var template = angular.element(contents);
  1355. var newElm = $compile(template)($scope);
  1356. $elm.replaceWith(newElm);
  1357. // And update $elm to be the new element
  1358. $elm = newElm;
  1359. updateHeaderReferences();
  1360. if (containerCtrl) {
  1361. // Inject a reference to the header viewport (if it exists) into the grid controller for use in the horizontal scroll handler below
  1362. var headerViewport = $elm[0].getElementsByClassName('ui-grid-header-viewport')[0];
  1363. if (headerViewport) {
  1364. containerCtrl.headerViewport = headerViewport;
  1365. angular.element(headerViewport).on('scroll', scrollHandler);
  1366. $scope.$on('$destroy', function () {
  1367. angular.element(headerViewport).off('scroll', scrollHandler);
  1368. });
  1369. }
  1370. }
  1371. $scope.grid.queueRefresh();
  1372. }).catch(angular.noop);
  1373. function updateHeaderReferences() {
  1374. containerCtrl.header = containerCtrl.colContainer.header = $elm;
  1375. var headerCanvases = $elm[0].getElementsByClassName('ui-grid-header-canvas');
  1376. if (headerCanvases.length > 0) {
  1377. containerCtrl.headerCanvas = containerCtrl.colContainer.headerCanvas = headerCanvases[0];
  1378. }
  1379. else {
  1380. containerCtrl.headerCanvas = null;
  1381. }
  1382. }
  1383. function scrollHandler(evt) {
  1384. if (uiGridCtrl.grid.isScrollingHorizontally) {
  1385. return;
  1386. }
  1387. var newScrollLeft = gridUtil.normalizeScrollLeft(containerCtrl.headerViewport, uiGridCtrl.grid);
  1388. var horizScrollPercentage = containerCtrl.colContainer.scrollHorizontal(newScrollLeft);
  1389. var scrollEvent = new ScrollEvent(uiGridCtrl.grid, null, containerCtrl.colContainer, ScrollEvent.Sources.ViewPortScroll);
  1390. scrollEvent.newScrollLeft = newScrollLeft;
  1391. if ( horizScrollPercentage > -1 ){
  1392. scrollEvent.x = { percentage: horizScrollPercentage };
  1393. }
  1394. uiGridCtrl.grid.scrollContainers(null, scrollEvent);
  1395. }
  1396. },
  1397. post: function ($scope, $elm, $attrs, controllers) {
  1398. var uiGridCtrl = controllers[0];
  1399. var containerCtrl = controllers[1];
  1400. // gridUtil.logDebug('ui-grid-header link');
  1401. var grid = uiGridCtrl.grid;
  1402. // Don't animate header cells
  1403. gridUtil.disableAnimations($elm);
  1404. function updateColumnWidths() {
  1405. // this styleBuilder always runs after the renderContainer, so we can rely on the column widths
  1406. // already being populated correctly
  1407. var columnCache = containerCtrl.colContainer.visibleColumnCache;
  1408. // Build the CSS
  1409. // uiGridCtrl.grid.columns.forEach(function (column) {
  1410. var ret = '';
  1411. var canvasWidth = 0;
  1412. columnCache.forEach(function (column) {
  1413. ret = ret + column.getColClassDefinition();
  1414. canvasWidth += column.drawnWidth;
  1415. });
  1416. containerCtrl.colContainer.canvasWidth = canvasWidth;
  1417. // Return the styles back to buildStyles which pops them into the `customStyles` scope variable
  1418. return ret;
  1419. }
  1420. containerCtrl.header = $elm;
  1421. var headerViewport = $elm[0].getElementsByClassName('ui-grid-header-viewport')[0];
  1422. if (headerViewport) {
  1423. containerCtrl.headerViewport = headerViewport;
  1424. }
  1425. //todo: remove this if by injecting gridCtrl into unit tests
  1426. if (uiGridCtrl) {
  1427. uiGridCtrl.grid.registerStyleComputation({
  1428. priority: 15,
  1429. func: updateColumnWidths
  1430. });
  1431. }
  1432. }
  1433. };
  1434. }
  1435. };
  1436. }]);
  1437. })();
  1438. (function(){
  1439. angular.module('ui.grid')
  1440. .service('uiGridGridMenuService', [ 'gridUtil', 'i18nService', 'uiGridConstants', function( gridUtil, i18nService, uiGridConstants ) {
  1441. /**
  1442. * @ngdoc service
  1443. * @name ui.grid.gridMenuService
  1444. *
  1445. * @description Methods for working with the grid menu
  1446. */
  1447. var service = {
  1448. /**
  1449. * @ngdoc method
  1450. * @methodOf ui.grid.gridMenuService
  1451. * @name initialize
  1452. * @description Sets up the gridMenu. Most importantly, sets our
  1453. * scope onto the grid object as grid.gridMenuScope, allowing us
  1454. * to operate when passed only the grid. Second most importantly,
  1455. * we register the 'addToGridMenu' and 'removeFromGridMenu' methods
  1456. * on the core api.
  1457. * @param {$scope} $scope the scope of this gridMenu
  1458. * @param {Grid} grid the grid to which this gridMenu is associated
  1459. */
  1460. initialize: function( $scope, grid ){
  1461. grid.gridMenuScope = $scope;
  1462. $scope.grid = grid;
  1463. $scope.registeredMenuItems = [];
  1464. // not certain this is needed, but would be bad to create a memory leak
  1465. $scope.$on('$destroy', function() {
  1466. if ( $scope.grid && $scope.grid.gridMenuScope ){
  1467. $scope.grid.gridMenuScope = null;
  1468. }
  1469. if ( $scope.grid ){
  1470. $scope.grid = null;
  1471. }
  1472. if ( $scope.registeredMenuItems ){
  1473. $scope.registeredMenuItems = null;
  1474. }
  1475. });
  1476. $scope.registeredMenuItems = [];
  1477. /**
  1478. * @ngdoc function
  1479. * @name addToGridMenu
  1480. * @methodOf ui.grid.core.api:PublicApi
  1481. * @description add items to the grid menu. Used by features
  1482. * to add their menu items if they are enabled, can also be used by
  1483. * end users to add menu items. This method has the advantage of allowing
  1484. * remove again, which can simplify management of which items are included
  1485. * in the menu when. (Noting that in most cases the shown and active functions
  1486. * provide a better way to handle visibility of menu items)
  1487. * @param {Grid} grid the grid on which we are acting
  1488. * @param {array} items menu items in the format as described in the tutorial, with
  1489. * the added note that if you want to use remove you must also specify an `id` field,
  1490. * which is provided when you want to remove an item. The id should be unique.
  1491. *
  1492. */
  1493. grid.api.registerMethod( 'core', 'addToGridMenu', service.addToGridMenu );
  1494. /**
  1495. * @ngdoc function
  1496. * @name removeFromGridMenu
  1497. * @methodOf ui.grid.core.api:PublicApi
  1498. * @description Remove an item from the grid menu based on a provided id. Assumes
  1499. * that the id is unique, removes only the last instance of that id. Does nothing if
  1500. * the specified id is not found
  1501. * @param {Grid} grid the grid on which we are acting
  1502. * @param {string} id the id we'd like to remove from the menu
  1503. *
  1504. */
  1505. grid.api.registerMethod( 'core', 'removeFromGridMenu', service.removeFromGridMenu );
  1506. },
  1507. /**
  1508. * @ngdoc function
  1509. * @name addToGridMenu
  1510. * @propertyOf ui.grid.gridMenuService
  1511. * @description add items to the grid menu. Used by features
  1512. * to add their menu items if they are enabled, can also be used by
  1513. * end users to add menu items. This method has the advantage of allowing
  1514. * remove again, which can simplify management of which items are included
  1515. * in the menu when. (Noting that in most cases the shown and active functions
  1516. * provide a better way to handle visibility of menu items)
  1517. * @param {Grid} grid the grid on which we are acting
  1518. * @param {array} items menu items in the format as described in the tutorial, with
  1519. * the added note that if you want to use remove you must also specify an `id` field,
  1520. * which is provided when you want to remove an item. The id should be unique.
  1521. *
  1522. */
  1523. addToGridMenu: function( grid, menuItems ) {
  1524. if ( !angular.isArray( menuItems ) ) {
  1525. gridUtil.logError( 'addToGridMenu: menuItems must be an array, and is not, not adding any items');
  1526. } else {
  1527. if ( grid.gridMenuScope ){
  1528. grid.gridMenuScope.registeredMenuItems = grid.gridMenuScope.registeredMenuItems ? grid.gridMenuScope.registeredMenuItems : [];
  1529. grid.gridMenuScope.registeredMenuItems = grid.gridMenuScope.registeredMenuItems.concat( menuItems );
  1530. } else {
  1531. gridUtil.logError( 'Asked to addToGridMenu, but gridMenuScope not present. Timing issue? Please log issue with ui-grid');
  1532. }
  1533. }
  1534. },
  1535. /**
  1536. * @ngdoc function
  1537. * @name removeFromGridMenu
  1538. * @methodOf ui.grid.gridMenuService
  1539. * @description Remove an item from the grid menu based on a provided id. Assumes
  1540. * that the id is unique, removes only the last instance of that id. Does nothing if
  1541. * the specified id is not found. If there is no gridMenuScope or registeredMenuItems
  1542. * then do nothing silently - the desired result is those menu items not be present and they
  1543. * aren't.
  1544. * @param {Grid} grid the grid on which we are acting
  1545. * @param {string} id the id we'd like to remove from the menu
  1546. *
  1547. */
  1548. removeFromGridMenu: function( grid, id ){
  1549. var foundIndex = -1;
  1550. if ( grid && grid.gridMenuScope ){
  1551. grid.gridMenuScope.registeredMenuItems.forEach( function( value, index ) {
  1552. if ( value.id === id ){
  1553. if (foundIndex > -1) {
  1554. gridUtil.logError( 'removeFromGridMenu: found multiple items with the same id, removing only the last' );
  1555. } else {
  1556. foundIndex = index;
  1557. }
  1558. }
  1559. });
  1560. }
  1561. if ( foundIndex > -1 ){
  1562. grid.gridMenuScope.registeredMenuItems.splice( foundIndex, 1 );
  1563. }
  1564. },
  1565. /**
  1566. * @ngdoc array
  1567. * @name gridMenuCustomItems
  1568. * @propertyOf ui.grid.class:GridOptions
  1569. * @description (optional) An array of menu items that should be added to
  1570. * the gridMenu. Follow the format documented in the tutorial for column
  1571. * menu customisation. The context provided to the action function will
  1572. * include context.grid. An alternative if working with dynamic menus is to use the
  1573. * provided api - core.addToGridMenu and core.removeFromGridMenu, which handles
  1574. * some of the management of items for you.
  1575. *
  1576. */
  1577. /**
  1578. * @ngdoc boolean
  1579. * @name gridMenuShowHideColumns
  1580. * @propertyOf ui.grid.class:GridOptions
  1581. * @description true by default, whether the grid menu should allow hide/show
  1582. * of columns
  1583. *
  1584. */
  1585. /**
  1586. * @ngdoc method
  1587. * @methodOf ui.grid.gridMenuService
  1588. * @name getMenuItems
  1589. * @description Decides the menu items to show in the menu. This is a
  1590. * combination of:
  1591. *
  1592. * - the default menu items that are always included,
  1593. * - any menu items that have been provided through the addMenuItem api. These
  1594. * are typically added by features within the grid
  1595. * - any menu items included in grid.options.gridMenuCustomItems. These can be
  1596. * changed dynamically, as they're always recalculated whenever we show the
  1597. * menu
  1598. * @param {$scope} $scope the scope of this gridMenu, from which we can find all
  1599. * the information that we need
  1600. * @returns {Array} an array of menu items that can be shown
  1601. */
  1602. getMenuItems: function( $scope ) {
  1603. var menuItems = [
  1604. // this is where we add any menu items we want to always include
  1605. ];
  1606. if ( $scope.grid.options.gridMenuCustomItems ){
  1607. if ( !angular.isArray( $scope.grid.options.gridMenuCustomItems ) ){
  1608. gridUtil.logError( 'gridOptions.gridMenuCustomItems must be an array, and is not');
  1609. } else {
  1610. menuItems = menuItems.concat( $scope.grid.options.gridMenuCustomItems );
  1611. }
  1612. }
  1613. var clearFilters = [{
  1614. title: i18nService.getSafeText('gridMenu.clearAllFilters'),
  1615. action: function ($event) {
  1616. $scope.grid.clearAllFilters();
  1617. },
  1618. shown: function() {
  1619. return $scope.grid.options.enableFiltering;
  1620. },
  1621. order: 100
  1622. }];
  1623. menuItems = menuItems.concat( clearFilters );
  1624. menuItems = menuItems.concat( $scope.registeredMenuItems );
  1625. if ( $scope.grid.options.gridMenuShowHideColumns !== false ){
  1626. menuItems = menuItems.concat( service.showHideColumns( $scope ) );
  1627. }
  1628. menuItems.sort(function(a, b){
  1629. return a.order - b.order;
  1630. });
  1631. return menuItems;
  1632. },
  1633. /**
  1634. * @ngdoc array
  1635. * @name gridMenuTitleFilter
  1636. * @propertyOf ui.grid.class:GridOptions
  1637. * @description (optional) A function that takes a title string
  1638. * (usually the col.displayName), and converts it into a display value. The function
  1639. * must return either a string or a promise.
  1640. *
  1641. * Used for internationalization of the grid menu column names - for angular-translate
  1642. * you can pass $translate as the function, for i18nService you can pass getSafeText as the
  1643. * function
  1644. * @example
  1645. * <pre>
  1646. * gridOptions = {
  1647. * gridMenuTitleFilter: $translate
  1648. * }
  1649. * </pre>
  1650. */
  1651. /**
  1652. * @ngdoc method
  1653. * @methodOf ui.grid.gridMenuService
  1654. * @name showHideColumns
  1655. * @description Adds two menu items for each of the columns in columnDefs. One
  1656. * menu item for hide, one menu item for show. Each is visible when appropriate
  1657. * (show when column is not visible, hide when column is visible). Each toggles
  1658. * the visible property on the columnDef using toggleColumnVisibility
  1659. * @param {$scope} $scope of a gridMenu, which contains a reference to the grid
  1660. */
  1661. showHideColumns: function( $scope ){
  1662. var showHideColumns = [];
  1663. if ( !$scope.grid.options.columnDefs || $scope.grid.options.columnDefs.length === 0 || $scope.grid.columns.length === 0 ) {
  1664. return showHideColumns;
  1665. }
  1666. // add header for columns
  1667. showHideColumns.push({
  1668. title: i18nService.getSafeText('gridMenu.columns'),
  1669. order: 300
  1670. });
  1671. $scope.grid.options.gridMenuTitleFilter = $scope.grid.options.gridMenuTitleFilter ? $scope.grid.options.gridMenuTitleFilter : function( title ) { return title; };
  1672. $scope.grid.options.columnDefs.forEach( function( colDef, index ){
  1673. if ( colDef.enableHiding !== false ){
  1674. // add hide menu item - shows an OK icon as we only show when column is already visible
  1675. var menuItem = {
  1676. icon: 'ui-grid-icon-ok',
  1677. action: function($event) {
  1678. $event.stopPropagation();
  1679. service.toggleColumnVisibility( this.context.gridCol );
  1680. },
  1681. shown: function() {
  1682. return this.context.gridCol.colDef.visible === true || this.context.gridCol.colDef.visible === undefined;
  1683. },
  1684. context: { gridCol: $scope.grid.getColumn(colDef.name || colDef.field) },
  1685. leaveOpen: true,
  1686. order: 301 + index * 2
  1687. };
  1688. service.setMenuItemTitle( menuItem, colDef, $scope.grid );
  1689. showHideColumns.push( menuItem );
  1690. // add show menu item - shows no icon as we only show when column is invisible
  1691. menuItem = {
  1692. icon: 'ui-grid-icon-cancel',
  1693. action: function($event) {
  1694. $event.stopPropagation();
  1695. service.toggleColumnVisibility( this.context.gridCol );
  1696. },
  1697. shown: function() {
  1698. return !(this.context.gridCol.colDef.visible === true || this.context.gridCol.colDef.visible === undefined);
  1699. },
  1700. context: { gridCol: $scope.grid.getColumn(colDef.name || colDef.field) },
  1701. leaveOpen: true,
  1702. order: 301 + index * 2 + 1
  1703. };
  1704. service.setMenuItemTitle( menuItem, colDef, $scope.grid );
  1705. showHideColumns.push( menuItem );
  1706. }
  1707. });
  1708. return showHideColumns;
  1709. },
  1710. /**
  1711. * @ngdoc method
  1712. * @methodOf ui.grid.gridMenuService
  1713. * @name setMenuItemTitle
  1714. * @description Handles the response from gridMenuTitleFilter, adding it directly to the menu
  1715. * item if it returns a string, otherwise waiting for the promise to resolve or reject then
  1716. * putting the result into the title
  1717. * @param {object} menuItem the menuItem we want to put the title on
  1718. * @param {object} colDef the colDef from which we can get displayName, name or field
  1719. * @param {Grid} grid the grid, from which we can get the options.gridMenuTitleFilter
  1720. *
  1721. */
  1722. setMenuItemTitle: function( menuItem, colDef, grid ){
  1723. var title = grid.options.gridMenuTitleFilter( colDef.displayName || gridUtil.readableColumnName(colDef.name) || colDef.field );
  1724. if ( typeof(title) === 'string' ){
  1725. menuItem.title = title;
  1726. } else if ( title.then ){
  1727. // must be a promise
  1728. menuItem.title = "";
  1729. title.then( function( successValue ) {
  1730. menuItem.title = successValue;
  1731. }, function( errorValue ) {
  1732. menuItem.title = errorValue;
  1733. }).catch(angular.noop);
  1734. } else {
  1735. gridUtil.logError('Expected gridMenuTitleFilter to return a string or a promise, it has returned neither, bad config');
  1736. menuItem.title = 'badconfig';
  1737. }
  1738. },
  1739. /**
  1740. * @ngdoc method
  1741. * @methodOf ui.grid.gridMenuService
  1742. * @name toggleColumnVisibility
  1743. * @description Toggles the visibility of an individual column. Expects to be
  1744. * provided a context that has on it a gridColumn, which is the column that
  1745. * we'll operate upon. We change the visibility, and refresh the grid as appropriate
  1746. * @param {GridColumn} gridCol the column that we want to toggle
  1747. *
  1748. */
  1749. toggleColumnVisibility: function( gridCol ) {
  1750. gridCol.colDef.visible = !( gridCol.colDef.visible === true || gridCol.colDef.visible === undefined );
  1751. gridCol.grid.refresh();
  1752. gridCol.grid.api.core.notifyDataChange( uiGridConstants.dataChange.COLUMN );
  1753. gridCol.grid.api.core.raise.columnVisibilityChanged( gridCol );
  1754. }
  1755. };
  1756. return service;
  1757. }])
  1758. .directive('uiGridMenuButton', ['gridUtil', 'uiGridConstants', 'uiGridGridMenuService', 'i18nService',
  1759. function (gridUtil, uiGridConstants, uiGridGridMenuService, i18nService) {
  1760. return {
  1761. priority: 0,
  1762. scope: true,
  1763. require: ['^uiGrid'],
  1764. templateUrl: 'ui-grid/ui-grid-menu-button',
  1765. replace: true,
  1766. link: function ($scope, $elm, $attrs, controllers) {
  1767. var uiGridCtrl = controllers[0];
  1768. // For the aria label
  1769. $scope.i18n = {
  1770. aria: i18nService.getSafeText('gridMenu.aria')
  1771. };
  1772. uiGridGridMenuService.initialize($scope, uiGridCtrl.grid);
  1773. $scope.shown = false;
  1774. $scope.toggleMenu = function () {
  1775. if ( $scope.shown ){
  1776. $scope.$broadcast('hide-menu');
  1777. $scope.shown = false;
  1778. } else {
  1779. $scope.menuItems = uiGridGridMenuService.getMenuItems( $scope );
  1780. $scope.$broadcast('show-menu');
  1781. $scope.shown = true;
  1782. }
  1783. };
  1784. $scope.$on('menu-hidden', function() {
  1785. $scope.shown = false;
  1786. gridUtil.focus.bySelector($elm, '.ui-grid-icon-container');
  1787. });
  1788. }
  1789. };
  1790. }]);
  1791. })();
  1792. (function(){
  1793. /**
  1794. * @ngdoc directive
  1795. * @name ui.grid.directive:uiGridMenu
  1796. * @element style
  1797. * @restrict A
  1798. *
  1799. * @description
  1800. * Allows us to interpolate expressions in `<style>` elements. Angular doesn't do this by default as it can/will/might? break in IE8.
  1801. *
  1802. * @example
  1803. <doc:example module="app">
  1804. <doc:source>
  1805. <script>
  1806. var app = angular.module('app', ['ui.grid']);
  1807. app.controller('MainCtrl', ['$scope', function ($scope) {
  1808. }]);
  1809. </script>
  1810. <div ng-controller="MainCtrl">
  1811. <div ui-grid-menu shown="true" ></div>
  1812. </div>
  1813. </doc:source>
  1814. <doc:scenario>
  1815. </doc:scenario>
  1816. </doc:example>
  1817. */
  1818. angular.module('ui.grid')
  1819. .directive('uiGridMenu', ['$compile', '$timeout', '$window', '$document', 'gridUtil', 'uiGridConstants', 'i18nService',
  1820. function ($compile, $timeout, $window, $document, gridUtil, uiGridConstants, i18nService) {
  1821. var uiGridMenu = {
  1822. priority: 0,
  1823. scope: {
  1824. // shown: '&',
  1825. menuItems: '=',
  1826. autoHide: '=?'
  1827. },
  1828. require: '?^uiGrid',
  1829. templateUrl: 'ui-grid/uiGridMenu',
  1830. replace: false,
  1831. link: function ($scope, $elm, $attrs, uiGridCtrl) {
  1832. $scope.dynamicStyles = '';
  1833. if (uiGridCtrl && uiGridCtrl.grid && uiGridCtrl.grid.options && uiGridCtrl.grid.options.gridMenuTemplate) {
  1834. var gridMenuTemplate = uiGridCtrl.grid.options.gridMenuTemplate;
  1835. gridUtil.getTemplate(gridMenuTemplate).then(function (contents) {
  1836. var template = angular.element(contents);
  1837. var newElm = $compile(template)($scope);
  1838. $elm.replaceWith(newElm);
  1839. }).catch(angular.noop);
  1840. }
  1841. var setupHeightStyle = function(gridHeight) {
  1842. //menu appears under header row, so substract that height from it's total
  1843. // additional 20px for general padding
  1844. var gridMenuMaxHeight = gridHeight - uiGridCtrl.grid.headerHeight - 20;
  1845. $scope.dynamicStyles = [
  1846. '.grid' + uiGridCtrl.grid.id + ' .ui-grid-menu-mid {',
  1847. 'max-height: ' + gridMenuMaxHeight + 'px;',
  1848. '}'
  1849. ].join(' ');
  1850. };
  1851. if (uiGridCtrl) {
  1852. setupHeightStyle(uiGridCtrl.grid.gridHeight);
  1853. uiGridCtrl.grid.api.core.on.gridDimensionChanged($scope, function(oldGridHeight, oldGridWidth, newGridHeight, newGridWidth) {
  1854. setupHeightStyle(newGridHeight);
  1855. });
  1856. }
  1857. $scope.i18n = {
  1858. close: i18nService.getSafeText('columnMenu.close')
  1859. };
  1860. // *** Show/Hide functions ******
  1861. $scope.showMenu = function(event, args) {
  1862. if ( !$scope.shown ){
  1863. /*
  1864. * In order to animate cleanly we remove the ng-if, wait a digest cycle, then
  1865. * animate the removal of the ng-hide. We can't successfully (so far as I can tell)
  1866. * animate removal of the ng-if, as the menu items aren't there yet. And we don't want
  1867. * to rely on ng-show only, as that leaves elements in the DOM that are needlessly evaluated
  1868. * on scroll events.
  1869. *
  1870. * Note when testing animation that animations don't run on the tutorials. When debugging it looks
  1871. * like they do, but angular has a default $animate provider that is just a stub, and that's what's
  1872. * being called. ALso don't be fooled by the fact that your browser has actually loaded the
  1873. * angular-translate.js, it's not using it. You need to test animations in an external application.
  1874. */
  1875. $scope.shown = true;
  1876. // Must be a timeout in order to work properly in Firefox. Issue #6533
  1877. $timeout(function() {
  1878. $scope.shownMid = true;
  1879. $scope.$emit('menu-shown');
  1880. });
  1881. } else if ( !$scope.shownMid ) {
  1882. // we're probably doing a hide then show, so we don't need to wait for ng-if
  1883. $scope.shownMid = true;
  1884. $scope.$emit('menu-shown');
  1885. }
  1886. var docEventType = 'click';
  1887. if (args && args.originalEvent && args.originalEvent.type && args.originalEvent.type === 'touchstart') {
  1888. docEventType = args.originalEvent.type;
  1889. }
  1890. // Turn off an existing document click handler
  1891. angular.element(document).off('click touchstart', applyHideMenu);
  1892. $elm.off('keyup', checkKeyUp);
  1893. $elm.off('keydown', checkKeyDown);
  1894. // Turn on the document click handler, but in a timeout so it doesn't apply to THIS click if there is one
  1895. $timeout(function() {
  1896. angular.element(document).on(docEventType, applyHideMenu);
  1897. $elm.on('keyup', checkKeyUp);
  1898. $elm.on('keydown', checkKeyDown);
  1899. });
  1900. };
  1901. $scope.hideMenu = function(event) {
  1902. if ( $scope.shown ){
  1903. /*
  1904. * In order to animate cleanly we animate the addition of ng-hide, then use a $timeout to
  1905. * set the ng-if (shown = false) after the animation runs. In theory we can cascade off the
  1906. * callback on the addClass method, but it is very unreliable with unit tests for no discernable reason.
  1907. *
  1908. * The user may have clicked on the menu again whilst
  1909. * we're waiting, so we check that the mid isn't shown before applying the ng-if.
  1910. */
  1911. $scope.shownMid = false;
  1912. $timeout( function() {
  1913. if ( !$scope.shownMid ){
  1914. $scope.shown = false;
  1915. $scope.$emit('menu-hidden');
  1916. }
  1917. }, 40);
  1918. }
  1919. angular.element(document).off('click touchstart', applyHideMenu);
  1920. $elm.off('keyup', checkKeyUp);
  1921. $elm.off('keydown', checkKeyDown);
  1922. };
  1923. $scope.$on('hide-menu', function (event, args) {
  1924. $scope.hideMenu(event, args);
  1925. });
  1926. $scope.$on('show-menu', function (event, args) {
  1927. $scope.showMenu(event, args);
  1928. });
  1929. // *** Auto hide when click elsewhere ******
  1930. var applyHideMenu = function(){
  1931. if ($scope.shown) {
  1932. $scope.$apply(function () {
  1933. $scope.hideMenu();
  1934. });
  1935. }
  1936. };
  1937. // close menu on ESC and keep tab cyclical
  1938. var checkKeyUp = function(event) {
  1939. if (event.keyCode === 27) {
  1940. $scope.hideMenu();
  1941. }
  1942. };
  1943. var checkKeyDown = function(event) {
  1944. var setFocus = function(elm) {
  1945. elm.focus();
  1946. event.preventDefault();
  1947. return false;
  1948. };
  1949. if (event.keyCode === 9) {
  1950. var firstMenuItem, lastMenuItem;
  1951. var menuItemButtons = $elm[0].querySelectorAll('button:not(.ng-hide)');
  1952. if (menuItemButtons.length > 0) {
  1953. firstMenuItem = menuItemButtons[0];
  1954. lastMenuItem = menuItemButtons[menuItemButtons.length - 1];
  1955. if (event.target === lastMenuItem && !event.shiftKey) {
  1956. setFocus(firstMenuItem);
  1957. } else if (event.target === firstMenuItem && event.shiftKey) {
  1958. setFocus(lastMenuItem);
  1959. }
  1960. }
  1961. }
  1962. };
  1963. if (typeof($scope.autoHide) === 'undefined' || $scope.autoHide === undefined) {
  1964. $scope.autoHide = true;
  1965. }
  1966. if ($scope.autoHide) {
  1967. angular.element($window).on('resize', applyHideMenu);
  1968. }
  1969. $scope.$on('$destroy', function unbindEvents() {
  1970. angular.element($window).off('resize', applyHideMenu);
  1971. angular.element(document).off('click touchstart', applyHideMenu);
  1972. $elm.off('keyup', checkKeyUp);
  1973. $elm.off('keydown', checkKeyDown);
  1974. });
  1975. if (uiGridCtrl) {
  1976. $scope.$on('$destroy', uiGridCtrl.grid.api.core.on.scrollBegin($scope, applyHideMenu ));
  1977. }
  1978. $scope.$on('$destroy', $scope.$on(uiGridConstants.events.ITEM_DRAGGING, applyHideMenu ));
  1979. }
  1980. };
  1981. return uiGridMenu;
  1982. }])
  1983. .directive('uiGridMenuItem', ['gridUtil', '$compile', 'i18nService', function (gridUtil, $compile, i18nService) {
  1984. var uiGridMenuItem = {
  1985. priority: 0,
  1986. scope: {
  1987. name: '=',
  1988. active: '=',
  1989. action: '=',
  1990. icon: '=',
  1991. shown: '=',
  1992. context: '=',
  1993. templateUrl: '=',
  1994. leaveOpen: '=',
  1995. screenReaderOnly: '='
  1996. },
  1997. require: ['?^uiGrid'],
  1998. templateUrl: 'ui-grid/uiGridMenuItem',
  1999. replace: false,
  2000. compile: function() {
  2001. return {
  2002. pre: function ($scope, $elm) {
  2003. if ($scope.templateUrl) {
  2004. gridUtil.getTemplate($scope.templateUrl)
  2005. .then(function (contents) {
  2006. var template = angular.element(contents);
  2007. var newElm = $compile(template)($scope);
  2008. $elm.replaceWith(newElm);
  2009. }).catch(angular.noop);
  2010. }
  2011. },
  2012. post: function ($scope, $elm, $attrs, controllers) {
  2013. var uiGridCtrl = controllers[0];
  2014. // TODO(c0bra): validate that shown and active are functions if they're defined. An exception is already thrown above this though
  2015. // if (typeof($scope.shown) !== 'undefined' && $scope.shown && typeof($scope.shown) !== 'function') {
  2016. // throw new TypeError("$scope.shown is defined but not a function");
  2017. // }
  2018. if (typeof($scope.shown) === 'undefined' || $scope.shown === null) {
  2019. $scope.shown = function() { return true; };
  2020. }
  2021. $scope.itemShown = function () {
  2022. var context = {};
  2023. if ($scope.context) {
  2024. context.context = $scope.context;
  2025. }
  2026. if (typeof(uiGridCtrl) !== 'undefined' && uiGridCtrl) {
  2027. context.grid = uiGridCtrl.grid;
  2028. }
  2029. return $scope.shown.call(context);
  2030. };
  2031. $scope.itemAction = function($event,title) {
  2032. $event.stopPropagation();
  2033. if (typeof($scope.action) === 'function') {
  2034. var context = {};
  2035. if ($scope.context) {
  2036. context.context = $scope.context;
  2037. }
  2038. // Add the grid to the function call context if the uiGrid controller is present
  2039. if (typeof(uiGridCtrl) !== 'undefined' && uiGridCtrl) {
  2040. context.grid = uiGridCtrl.grid;
  2041. }
  2042. $scope.action.call(context, $event, title);
  2043. if ( !$scope.leaveOpen ){
  2044. $scope.$emit('hide-menu');
  2045. } else {
  2046. // Maintain focus on the selected item
  2047. gridUtil.focus.bySelector(angular.element($event.target.parentElement), 'button[type=button]', true);
  2048. }
  2049. }
  2050. };
  2051. $scope.label = function(){
  2052. var toBeDisplayed = $scope.name;
  2053. if (typeof($scope.name) === 'function'){
  2054. toBeDisplayed = $scope.name.call();
  2055. }
  2056. return toBeDisplayed;
  2057. };
  2058. $scope.i18n = i18nService.get();
  2059. }
  2060. };
  2061. }
  2062. };
  2063. return uiGridMenuItem;
  2064. }]);
  2065. })();
  2066. (function(){
  2067. 'use strict';
  2068. /**
  2069. * @ngdoc overview
  2070. * @name ui.grid.directive:uiGridOneBind
  2071. * @summary A group of directives that provide a one time bind to a dom element.
  2072. * @description A group of directives that provide a one time bind to a dom element.
  2073. * As one time bindings are not supported in Angular 1.2.* this directive provdes this capability.
  2074. * This is done to reduce the number of watchers on the dom.
  2075. * <br/>
  2076. * <h2>Short Example ({@link ui.grid.directive:uiGridOneBindSrc ui-grid-one-bind-src})</h2>
  2077. * <pre>
  2078. <div ng-init="imageName = 'myImageDir.jpg'">
  2079. <img ui-grid-one-bind-src="imageName"></img>
  2080. </div>
  2081. </pre>
  2082. * Will become:
  2083. * <pre>
  2084. <div ng-init="imageName = 'myImageDir.jpg'">
  2085. <img ui-grid-one-bind-src="imageName" src="myImageDir.jpg"></img>
  2086. </div>
  2087. </pre>
  2088. </br>
  2089. <h2>Short Example ({@link ui.grid.directive:uiGridOneBindText ui-grid-one-bind-text})</h2>
  2090. * <pre>
  2091. <div ng-init="text='Add this text'" ui-grid-one-bind-text="text"></div>
  2092. </pre>
  2093. * Will become:
  2094. * <pre>
  2095. <div ng-init="text='Add this text'" ui-grid-one-bind-text="text">Add this text</div>
  2096. </pre>
  2097. </br>
  2098. * <b>Note:</b> This behavior is slightly different for the {@link ui.grid.directive:uiGridOneBindIdGrid uiGridOneBindIdGrid}
  2099. * and {@link ui.grid.directive:uiGridOneBindAriaLabelledbyGrid uiGridOneBindAriaLabelledbyGrid} directives.
  2100. *
  2101. */
  2102. //https://github.com/joshkurz/Black-Belt-AngularJS-Directives/blob/master/directives/Optimization/oneBind.js
  2103. var oneBinders = angular.module('ui.grid');
  2104. angular.forEach([
  2105. /**
  2106. * @ngdoc directive
  2107. * @name ui.grid.directive:uiGridOneBindSrc
  2108. * @memberof ui.grid.directive:uiGridOneBind
  2109. * @element img
  2110. * @restrict A
  2111. * @param {String} uiGridOneBindSrc The angular string you want to bind. Does not support interpolation. Don't use <code>{{scopeElt}}</code> instead use <code>scopeElt</code>.
  2112. * @description One time binding for the src dom tag.
  2113. *
  2114. */
  2115. {tag: 'Src', method: 'attr'},
  2116. /**
  2117. * @ngdoc directive
  2118. * @name ui.grid.directive:uiGridOneBindText
  2119. * @element div
  2120. * @restrict A
  2121. * @param {String} uiGridOneBindText The angular string you want to bind. Does not support interpolation. Don't use <code>{{scopeElt}}</code> instead use <code>scopeElt</code>.
  2122. * @description One time binding for the text dom tag.
  2123. */
  2124. {tag: 'Text', method: 'text'},
  2125. /**
  2126. * @ngdoc directive
  2127. * @name ui.grid.directive:uiGridOneBindHref
  2128. * @element div
  2129. * @restrict A
  2130. * @param {String} uiGridOneBindHref The angular string you want to bind. Does not support interpolation. Don't use <code>{{scopeElt}}</code> instead use <code>scopeElt</code>.
  2131. * @description One time binding for the href dom tag. For more information see {@link ui.grid.directive:uiGridOneBind}.
  2132. */
  2133. {tag: 'Href', method: 'attr'},
  2134. /**
  2135. * @ngdoc directive
  2136. * @name ui.grid.directive:uiGridOneBindClass
  2137. * @element div
  2138. * @restrict A
  2139. * @param {String} uiGridOneBindClass The angular string you want to bind. Does not support interpolation. Don't use <code>{{scopeElt}}</code> instead use <code>scopeElt</code>.
  2140. * @param {Object} uiGridOneBindClass The object that you want to bind. At least one of the values in the object must be something other than null or undefined for the watcher to be removed.
  2141. * this is to prevent the watcher from being removed before the scope is initialized.
  2142. * @param {Array} uiGridOneBindClass An array of classes to bind to this element.
  2143. * @description One time binding for the class dom tag. For more information see {@link ui.grid.directive:uiGridOneBind}.
  2144. */
  2145. {tag: 'Class', method: 'addClass'},
  2146. /**
  2147. * @ngdoc directive
  2148. * @name ui.grid.directive:uiGridOneBindHtml
  2149. * @element div
  2150. * @restrict A
  2151. * @param {String} uiGridOneBindHtml The angular string you want to bind. Does not support interpolation. Don't use <code>{{scopeElt}}</code> instead use <code>scopeElt</code>.
  2152. * @description One time binding for the html method on a dom element. For more information see {@link ui.grid.directive:uiGridOneBind}.
  2153. */
  2154. {tag: 'Html', method: 'html'},
  2155. /**
  2156. * @ngdoc directive
  2157. * @name ui.grid.directive:uiGridOneBindAlt
  2158. * @element div
  2159. * @restrict A
  2160. * @param {String} uiGridOneBindAlt The angular string you want to bind. Does not support interpolation. Don't use <code>{{scopeElt}}</code> instead use <code>scopeElt</code>.
  2161. * @description One time binding for the alt dom tag. For more information see {@link ui.grid.directive:uiGridOneBind}.
  2162. */
  2163. {tag: 'Alt', method: 'attr'},
  2164. /**
  2165. * @ngdoc directive
  2166. * @name ui.grid.directive:uiGridOneBindStyle
  2167. * @element div
  2168. * @restrict A
  2169. * @param {String} uiGridOneBindStyle The angular string you want to bind. Does not support interpolation. Don't use <code>{{scopeElt}}</code> instead use <code>scopeElt</code>.
  2170. * @description One time binding for the style dom tag. For more information see {@link ui.grid.directive:uiGridOneBind}.
  2171. */
  2172. {tag: 'Style', method: 'css'},
  2173. /**
  2174. * @ngdoc directive
  2175. * @name ui.grid.directive:uiGridOneBindValue
  2176. * @element div
  2177. * @restrict A
  2178. * @param {String} uiGridOneBindValue The angular string you want to bind. Does not support interpolation. Don't use <code>{{scopeElt}}</code> instead use <code>scopeElt</code>.
  2179. * @description One time binding for the value dom tag. For more information see {@link ui.grid.directive:uiGridOneBind}.
  2180. */
  2181. {tag: 'Value', method: 'attr'},
  2182. /**
  2183. * @ngdoc directive
  2184. * @name ui.grid.directive:uiGridOneBindId
  2185. * @element div
  2186. * @restrict A
  2187. * @param {String} uiGridOneBindId The angular string you want to bind. Does not support interpolation. Don't use <code>{{scopeElt}}</code> instead use <code>scopeElt</code>.
  2188. * @description One time binding for the value dom tag. For more information see {@link ui.grid.directive:uiGridOneBind}.
  2189. */
  2190. {tag: 'Id', method: 'attr'},
  2191. /**
  2192. * @ngdoc directive
  2193. * @name ui.grid.directive:uiGridOneBindIdGrid
  2194. * @element div
  2195. * @restrict A
  2196. * @param {String} uiGridOneBindIdGrid The angular string you want to bind. Does not support interpolation. Don't use <code>{{scopeElt}}</code> instead use <code>scopeElt</code>.
  2197. * @description One time binding for the id dom tag.
  2198. * <h1>Important Note!</h1>
  2199. * If the id tag passed as a parameter does <b>not</b> contain the grid id as a substring
  2200. * then the directive will search the scope and the parent controller (if it is a uiGridController) for the grid.id value.
  2201. * If this value is found then it is appended to the begining of the id tag. If the grid is not found then the directive throws an error.
  2202. * This is done in order to ensure uniqueness of id tags across the grid.
  2203. * This is to prevent two grids in the same document having duplicate id tags.
  2204. */
  2205. {tag: 'Id', directiveName:'IdGrid', method: 'attr', appendGridId: true},
  2206. /**
  2207. * @ngdoc directive
  2208. * @name ui.grid.directive:uiGridOneBindTitle
  2209. * @element div
  2210. * @restrict A
  2211. * @param {String} uiGridOneBindTitle The angular string you want to bind. Does not support interpolation. Don't use <code>{{scopeElt}}</code> instead use <code>scopeElt</code>.
  2212. * @description One time binding for the title dom tag. For more information see {@link ui.grid.directive:uiGridOneBind}.
  2213. */
  2214. {tag: 'Title', method: 'attr'},
  2215. /**
  2216. * @ngdoc directive
  2217. * @name ui.grid.directive:uiGridOneBindAriaLabel
  2218. * @element div
  2219. * @restrict A
  2220. * @param {String} uiGridOneBindAriaLabel The angular string you want to bind. Does not support interpolation. Don't use <code>{{scopeElt}}</code> instead use <code>scopeElt</code>.
  2221. * @description One time binding for the aria-label dom tag. For more information see {@link ui.grid.directive:uiGridOneBind}.
  2222. *<br/>
  2223. * <pre>
  2224. <div ng-init="text='Add this text'" ui-grid-one-bind-aria-label="text"></div>
  2225. </pre>
  2226. * Will become:
  2227. * <pre>
  2228. <div ng-init="text='Add this text'" ui-grid-one-bind-aria-label="text" aria-label="Add this text"></div>
  2229. </pre>
  2230. */
  2231. {tag: 'Label', method: 'attr', aria:true},
  2232. /**
  2233. * @ngdoc directive
  2234. * @name ui.grid.directive:uiGridOneBindAriaLabelledby
  2235. * @element div
  2236. * @restrict A
  2237. * @param {String} uiGridOneBindAriaLabelledby The angular string you want to bind. Does not support interpolation. Don't use <code>{{scopeElt}}</code> instead use <code>scopeElt</code>.
  2238. * @description One time binding for the aria-labelledby dom tag. For more information see {@link ui.grid.directive:uiGridOneBind}.
  2239. *<br/>
  2240. * <pre>
  2241. <div ng-init="anId = 'gridID32'" ui-grid-one-bind-aria-labelledby="anId"></div>
  2242. </pre>
  2243. * Will become:
  2244. * <pre>
  2245. <div ng-init="anId = 'gridID32'" ui-grid-one-bind-aria-labelledby="anId" aria-labelledby="gridID32"></div>
  2246. </pre>
  2247. */
  2248. {tag: 'Labelledby', method: 'attr', aria:true},
  2249. /**
  2250. * @ngdoc directive
  2251. * @name ui.grid.directive:uiGridOneBindAriaLabelledbyGrid
  2252. * @element div
  2253. * @restrict A
  2254. * @param {String} uiGridOneBindAriaLabelledbyGrid The angular string you want to bind. Does not support interpolation. Don't use <code>{{scopeElt}}</code> instead use <code>scopeElt</code>.
  2255. * @description One time binding for the aria-labelledby dom tag. For more information see {@link ui.grid.directive:uiGridOneBind}.
  2256. * Works somewhat like {@link ui.grid.directive:uiGridOneBindIdGrid} however this one supports a list of ids (seperated by a space) and will dynamically add the
  2257. * grid id to each one.
  2258. *<br/>
  2259. * <pre>
  2260. <div ng-init="anId = 'gridID32'" ui-grid-one-bind-aria-labelledby-grid="anId"></div>
  2261. </pre>
  2262. * Will become ([grid.id] will be replaced by the actual grid id):
  2263. * <pre>
  2264. <div ng-init="anId = 'gridID32'" ui-grid-one-bind-aria-labelledby-grid="anId" aria-labelledby-Grid="[grid.id]-gridID32"></div>
  2265. </pre>
  2266. */
  2267. {tag: 'Labelledby', directiveName:'LabelledbyGrid', appendGridId:true, method: 'attr', aria:true},
  2268. /**
  2269. * @ngdoc directive
  2270. * @name ui.grid.directive:uiGridOneBindAriaDescribedby
  2271. * @element ANY
  2272. * @restrict A
  2273. * @param {String} uiGridOneBindAriaDescribedby The angular string you want to bind. Does not support interpolation. Don't use <code>{{scopeElt}}</code> instead use <code>scopeElt</code>.
  2274. * @description One time binding for the aria-describedby dom tag. For more information see {@link ui.grid.directive:uiGridOneBind}.
  2275. *<br/>
  2276. * <pre>
  2277. <div ng-init="anId = 'gridID32'" ui-grid-one-bind-aria-describedby="anId"></div>
  2278. </pre>
  2279. * Will become:
  2280. * <pre>
  2281. <div ng-init="anId = 'gridID32'" ui-grid-one-bind-aria-describedby="anId" aria-describedby="gridID32"></div>
  2282. </pre>
  2283. */
  2284. {tag: 'Describedby', method: 'attr', aria:true},
  2285. /**
  2286. * @ngdoc directive
  2287. * @name ui.grid.directive:uiGridOneBindAriaDescribedbyGrid
  2288. * @element ANY
  2289. * @restrict A
  2290. * @param {String} uiGridOneBindAriaDescribedbyGrid The angular string you want to bind. Does not support interpolation. Don't use <code>{{scopeElt}}</code> instead use <code>scopeElt</code>.
  2291. * @description One time binding for the aria-labelledby dom tag. For more information see {@link ui.grid.directive:uiGridOneBind}.
  2292. * Works somewhat like {@link ui.grid.directive:uiGridOneBindIdGrid} however this one supports a list of ids (seperated by a space) and will dynamically add the
  2293. * grid id to each one.
  2294. *<br/>
  2295. * <pre>
  2296. <div ng-init="anId = 'gridID32'" ui-grid-one-bind-aria-describedby-grid="anId"></div>
  2297. </pre>
  2298. * Will become ([grid.id] will be replaced by the actual grid id):
  2299. * <pre>
  2300. <div ng-init="anId = 'gridID32'" ui-grid-one-bind-aria-describedby-grid="anId" aria-describedby="[grid.id]-gridID32"></div>
  2301. </pre>
  2302. */
  2303. {tag: 'Describedby', directiveName:'DescribedbyGrid', appendGridId:true, method: 'attr', aria:true}],
  2304. function(v){
  2305. var baseDirectiveName = 'uiGridOneBind';
  2306. //If it is an aria tag then append the aria label seperately
  2307. //This is done because the aria tags are formatted aria-* and the directive name can't have a '-' character in it.
  2308. //If the diretiveName has to be overridden then it does so here. This is because the tag being modified and the directive sometimes don't match up.
  2309. var directiveName = (v.aria ? baseDirectiveName + 'Aria' : baseDirectiveName) + (v.directiveName ? v.directiveName : v.tag);
  2310. oneBinders.directive(directiveName, ['gridUtil', function(gridUtil){
  2311. return {
  2312. restrict: 'A',
  2313. require: ['?uiGrid','?^uiGrid'],
  2314. link: function(scope, iElement, iAttrs, controllers){
  2315. /* Appends the grid id to the beginnig of the value. */
  2316. var appendGridId = function(val){
  2317. var grid; //Get an instance of the grid if its available
  2318. //If its available in the scope then we don't need to try to find it elsewhere
  2319. if (scope.grid) {
  2320. grid = scope.grid;
  2321. }
  2322. //Another possible location to try to find the grid
  2323. else if (scope.col && scope.col.grid){
  2324. grid = scope.col.grid;
  2325. }
  2326. //Last ditch effort: Search through the provided controllers.
  2327. else if (!controllers.some( //Go through the controllers till one has the element we need
  2328. function(controller){
  2329. if (controller && controller.grid) {
  2330. grid = controller.grid;
  2331. return true; //We've found the grid
  2332. }
  2333. })){
  2334. //We tried our best to find it for you
  2335. gridUtil.logError("["+directiveName+"] A valid grid could not be found to bind id. Are you using this directive " +
  2336. "within the correct scope? Trying to generate id: [gridID]-" + val);
  2337. throw new Error("No valid grid could be found");
  2338. }
  2339. if (grid){
  2340. var idRegex = new RegExp(grid.id.toString());
  2341. //If the grid id hasn't been appended already in the template declaration
  2342. if (!idRegex.test(val)){
  2343. val = grid.id.toString() + '-' + val;
  2344. }
  2345. }
  2346. return val;
  2347. };
  2348. // The watch returns a function to remove itself.
  2349. var rmWatcher = scope.$watch(iAttrs[directiveName], function(newV){
  2350. if (newV){
  2351. //If we are trying to add an id element then we also apply the grid id if it isn't already there
  2352. if (v.appendGridId) {
  2353. var newIdString = null;
  2354. //Append the id to all of the new ids.
  2355. angular.forEach( newV.split(' '), function(s){
  2356. newIdString = (newIdString ? (newIdString + ' ') : '') + appendGridId(s);
  2357. });
  2358. newV = newIdString;
  2359. }
  2360. // Append this newValue to the dom element.
  2361. switch (v.method) {
  2362. case 'attr': //The attr method takes two paraams the tag and the value
  2363. if (v.aria) {
  2364. //If it is an aria element then append the aria prefix
  2365. iElement[v.method]('aria-' + v.tag.toLowerCase(),newV);
  2366. } else {
  2367. iElement[v.method](v.tag.toLowerCase(),newV);
  2368. }
  2369. break;
  2370. case 'addClass':
  2371. //Pulled from https://github.com/Pasvaz/bindonce/blob/master/bindonce.js
  2372. if (angular.isObject(newV) && !angular.isArray(newV)) {
  2373. var results = [];
  2374. var nonNullFound = false; //We don't want to remove the binding unless the key is actually defined
  2375. angular.forEach(newV, function (value, index) {
  2376. if (value !== null && typeof(value) !== "undefined"){
  2377. nonNullFound = true; //A non null value for a key was found so the object must have been initialized
  2378. if (value) {results.push(index);}
  2379. }
  2380. });
  2381. //A non null value for a key wasn't found so assume that the scope values haven't been fully initialized
  2382. if (!nonNullFound){
  2383. return; // If not initialized then the watcher should not be removed yet.
  2384. }
  2385. newV = results;
  2386. }
  2387. if (newV) {
  2388. iElement.addClass(angular.isArray(newV) ? newV.join(' ') : newV);
  2389. } else {
  2390. return;
  2391. }
  2392. break;
  2393. default:
  2394. iElement[v.method](newV);
  2395. break;
  2396. }
  2397. //Removes the watcher on itself after the bind
  2398. rmWatcher();
  2399. }
  2400. // True ensures that equality is determined using angular.equals instead of ===
  2401. }, true); //End rm watchers
  2402. } //End compile function
  2403. }; //End directive return
  2404. } // End directive function
  2405. ]); //End directive
  2406. }); // End angular foreach
  2407. })();
  2408. (function () {
  2409. 'use strict';
  2410. var module = angular.module('ui.grid');
  2411. module.directive('uiGridRenderContainer', ['$timeout', '$document', 'uiGridConstants', 'gridUtil', 'ScrollEvent',
  2412. function($timeout, $document, uiGridConstants, gridUtil, ScrollEvent) {
  2413. return {
  2414. replace: true,
  2415. transclude: true,
  2416. templateUrl: 'ui-grid/uiGridRenderContainer',
  2417. require: ['^uiGrid', 'uiGridRenderContainer'],
  2418. scope: {
  2419. containerId: '=',
  2420. rowContainerName: '=',
  2421. colContainerName: '=',
  2422. bindScrollHorizontal: '=',
  2423. bindScrollVertical: '=',
  2424. enableVerticalScrollbar: '=',
  2425. enableHorizontalScrollbar: '='
  2426. },
  2427. controller: 'uiGridRenderContainer as RenderContainer',
  2428. compile: function () {
  2429. return {
  2430. pre: function prelink($scope, $elm, $attrs, controllers) {
  2431. var uiGridCtrl = controllers[0];
  2432. var containerCtrl = controllers[1];
  2433. var grid = $scope.grid = uiGridCtrl.grid;
  2434. // Verify that the render container for this element exists
  2435. if (!$scope.rowContainerName) {
  2436. throw new Error("No row render container name specified");
  2437. }
  2438. if (!$scope.colContainerName) {
  2439. throw new Error("No column render container name specified");
  2440. }
  2441. if (!grid.renderContainers[$scope.rowContainerName]) {
  2442. throw new Error("Row render container '" + $scope.rowContainerName + "' is not registered.");
  2443. }
  2444. if (!grid.renderContainers[$scope.colContainerName]) {
  2445. throw new Error("Column render container '" + $scope.colContainerName + "' is not registered.");
  2446. }
  2447. var rowContainer = $scope.rowContainer = grid.renderContainers[$scope.rowContainerName];
  2448. var colContainer = $scope.colContainer = grid.renderContainers[$scope.colContainerName];
  2449. containerCtrl.containerId = $scope.containerId;
  2450. containerCtrl.rowContainer = rowContainer;
  2451. containerCtrl.colContainer = colContainer;
  2452. },
  2453. post: function postlink($scope, $elm, $attrs, controllers) {
  2454. var uiGridCtrl = controllers[0];
  2455. var containerCtrl = controllers[1];
  2456. var grid = uiGridCtrl.grid;
  2457. var rowContainer = containerCtrl.rowContainer;
  2458. var colContainer = containerCtrl.colContainer;
  2459. var scrollTop = null;
  2460. var scrollLeft = null;
  2461. var renderContainer = grid.renderContainers[$scope.containerId];
  2462. // Put the container name on this element as a class
  2463. $elm.addClass('ui-grid-render-container-' + $scope.containerId);
  2464. // Scroll the render container viewport when the mousewheel is used
  2465. gridUtil.on.mousewheel($elm, function (event) {
  2466. var scrollEvent = new ScrollEvent(grid, rowContainer, colContainer, ScrollEvent.Sources.RenderContainerMouseWheel);
  2467. if (event.deltaY !== 0) {
  2468. var scrollYAmount = event.deltaY * -1 * event.deltaFactor;
  2469. scrollTop = containerCtrl.viewport[0].scrollTop;
  2470. // Get the scroll percentage
  2471. scrollEvent.verticalScrollLength = rowContainer.getVerticalScrollLength();
  2472. var scrollYPercentage = (scrollTop + scrollYAmount) / scrollEvent.verticalScrollLength;
  2473. // If we should be scrolled 100%, make sure the scrollTop matches the maximum scroll length
  2474. // Viewports that have "overflow: hidden" don't let the mousewheel scroll all the way to the bottom without this check
  2475. if (scrollYPercentage >= 1 && scrollTop < scrollEvent.verticalScrollLength) {
  2476. containerCtrl.viewport[0].scrollTop = scrollEvent.verticalScrollLength;
  2477. }
  2478. // Keep scrollPercentage within the range 0-1.
  2479. if (scrollYPercentage < 0) { scrollYPercentage = 0; }
  2480. else if (scrollYPercentage > 1) { scrollYPercentage = 1; }
  2481. scrollEvent.y = { percentage: scrollYPercentage, pixels: scrollYAmount };
  2482. }
  2483. if (event.deltaX !== 0) {
  2484. var scrollXAmount = event.deltaX * event.deltaFactor;
  2485. // Get the scroll percentage
  2486. scrollLeft = gridUtil.normalizeScrollLeft(containerCtrl.viewport, grid);
  2487. scrollEvent.horizontalScrollLength = (colContainer.getCanvasWidth() - colContainer.getViewportWidth());
  2488. var scrollXPercentage = (scrollLeft + scrollXAmount) / scrollEvent.horizontalScrollLength;
  2489. // Keep scrollPercentage within the range 0-1.
  2490. if (scrollXPercentage < 0) { scrollXPercentage = 0; }
  2491. else if (scrollXPercentage > 1) { scrollXPercentage = 1; }
  2492. scrollEvent.x = { percentage: scrollXPercentage, pixels: scrollXAmount };
  2493. }
  2494. // Let the parent container scroll if the grid is already at the top/bottom
  2495. if ((event.deltaY !== 0 && (scrollEvent.atTop(scrollTop) || scrollEvent.atBottom(scrollTop))) ||
  2496. (event.deltaX !== 0 && (scrollEvent.atLeft(scrollLeft) || scrollEvent.atRight(scrollLeft)))) {
  2497. //parent controller scrolls
  2498. }
  2499. else {
  2500. event.preventDefault();
  2501. event.stopPropagation();
  2502. scrollEvent.fireThrottledScrollingEvent('', scrollEvent);
  2503. }
  2504. });
  2505. $elm.bind('$destroy', function() {
  2506. $elm.unbind('keydown');
  2507. ['touchstart', 'touchmove', 'touchend','keydown', 'wheel', 'mousewheel', 'DomMouseScroll', 'MozMousePixelScroll'].forEach(function (eventName) {
  2508. $elm.unbind(eventName);
  2509. });
  2510. });
  2511. // TODO(c0bra): Handle resizing the inner canvas based on the number of elements
  2512. function update() {
  2513. var ret = '';
  2514. var canvasWidth = colContainer.canvasWidth;
  2515. var viewportWidth = colContainer.getViewportWidth();
  2516. var canvasHeight = rowContainer.getCanvasHeight();
  2517. //add additional height for scrollbar on left and right container
  2518. //if ($scope.containerId !== 'body') {
  2519. // canvasHeight -= grid.scrollbarHeight;
  2520. //}
  2521. var viewportHeight = rowContainer.getViewportHeight();
  2522. //shorten the height to make room for a scrollbar placeholder
  2523. if (colContainer.needsHScrollbarPlaceholder()) {
  2524. viewportHeight -= grid.scrollbarHeight;
  2525. }
  2526. var headerViewportWidth,
  2527. footerViewportWidth;
  2528. headerViewportWidth = footerViewportWidth = colContainer.getHeaderViewportWidth();
  2529. // Set canvas dimensions
  2530. ret += '\n .grid' + uiGridCtrl.grid.id + ' .ui-grid-render-container-' + $scope.containerId + ' .ui-grid-canvas { width: ' + canvasWidth + 'px; height: ' + canvasHeight + 'px; }';
  2531. ret += '\n .grid' + uiGridCtrl.grid.id + ' .ui-grid-render-container-' + $scope.containerId + ' .ui-grid-header-canvas { width: ' + (canvasWidth + grid.scrollbarWidth) + 'px; }';
  2532. if (renderContainer.explicitHeaderCanvasHeight) {
  2533. ret += '\n .grid' + uiGridCtrl.grid.id + ' .ui-grid-render-container-' + $scope.containerId + ' .ui-grid-header-canvas { height: ' + renderContainer.explicitHeaderCanvasHeight + 'px; }';
  2534. }
  2535. else {
  2536. ret += '\n .grid' + uiGridCtrl.grid.id + ' .ui-grid-render-container-' + $scope.containerId + ' .ui-grid-header-canvas { height: inherit; }';
  2537. }
  2538. ret += '\n .grid' + uiGridCtrl.grid.id + ' .ui-grid-render-container-' + $scope.containerId + ' .ui-grid-viewport { width: ' + viewportWidth + 'px; height: ' + viewportHeight + 'px; }';
  2539. ret += '\n .grid' + uiGridCtrl.grid.id + ' .ui-grid-render-container-' + $scope.containerId + ' .ui-grid-header-viewport { width: ' + headerViewportWidth + 'px; }';
  2540. ret += '\n .grid' + uiGridCtrl.grid.id + ' .ui-grid-render-container-' + $scope.containerId + ' .ui-grid-footer-canvas { width: ' + (canvasWidth + grid.scrollbarWidth) + 'px; }';
  2541. ret += '\n .grid' + uiGridCtrl.grid.id + ' .ui-grid-render-container-' + $scope.containerId + ' .ui-grid-footer-viewport { width: ' + footerViewportWidth + 'px; }';
  2542. return ret;
  2543. }
  2544. uiGridCtrl.grid.registerStyleComputation({
  2545. priority: 6,
  2546. func: update
  2547. });
  2548. }
  2549. };
  2550. }
  2551. };
  2552. }]);
  2553. module.controller('uiGridRenderContainer', ['$scope', 'gridUtil', function ($scope, gridUtil) {
  2554. }]);
  2555. })();
  2556. (function(){
  2557. 'use strict';
  2558. angular.module('ui.grid').directive('uiGridRow', ['gridUtil', function(gridUtil) {
  2559. return {
  2560. replace: true,
  2561. // priority: 2001,
  2562. // templateUrl: 'ui-grid/ui-grid-row',
  2563. require: ['^uiGrid', '^uiGridRenderContainer'],
  2564. scope: {
  2565. row: '=uiGridRow',
  2566. //rowRenderIndex is added to scope to give the true visual index of the row to any directives that need it
  2567. rowRenderIndex: '='
  2568. },
  2569. compile: function() {
  2570. return {
  2571. pre: function($scope, $elm, $attrs, controllers) {
  2572. var uiGridCtrl = controllers[0];
  2573. var containerCtrl = controllers[1];
  2574. var grid = uiGridCtrl.grid;
  2575. $scope.grid = uiGridCtrl.grid;
  2576. $scope.colContainer = containerCtrl.colContainer;
  2577. // Function for attaching the template to this scope
  2578. var clonedElement, cloneScope;
  2579. function compileTemplate() {
  2580. $scope.row.getRowTemplateFn.then(function (compiledElementFn) {
  2581. // var compiledElementFn = $scope.row.compiledElementFn;
  2582. // Create a new scope for the contents of this row, so we can destroy it later if need be
  2583. var newScope = $scope.$new();
  2584. compiledElementFn(newScope, function (newElm, scope) {
  2585. // If we already have a cloned element, we need to remove it and destroy its scope
  2586. if (clonedElement) {
  2587. clonedElement.remove();
  2588. cloneScope.$destroy();
  2589. }
  2590. // Empty the row and append the new element
  2591. $elm.empty().append(newElm);
  2592. // Save the new cloned element and scope
  2593. clonedElement = newElm;
  2594. cloneScope = newScope;
  2595. });
  2596. }).catch(angular.noop);
  2597. }
  2598. // Initially attach the compiled template to this scope
  2599. compileTemplate();
  2600. // If the row's compiled element function changes, we need to replace this element's contents with the new compiled template
  2601. $scope.$watch('row.getRowTemplateFn', function (newFunc, oldFunc) {
  2602. if (newFunc !== oldFunc) {
  2603. compileTemplate();
  2604. }
  2605. });
  2606. },
  2607. post: function($scope, $elm, $attrs, controllers) {
  2608. }
  2609. };
  2610. }
  2611. };
  2612. }]);
  2613. })();
  2614. (function(){
  2615. // 'use strict';
  2616. /**
  2617. * @ngdoc directive
  2618. * @name ui.grid.directive:uiGridStyle
  2619. * @element style
  2620. * @restrict A
  2621. *
  2622. * @description
  2623. * Allows us to interpolate expressions in `<style>` elements. Angular doesn't do this by default as it can/will/might? break in IE8.
  2624. *
  2625. * @example
  2626. <doc:example module="app">
  2627. <doc:source>
  2628. <script>
  2629. var app = angular.module('app', ['ui.grid']);
  2630. app.controller('MainCtrl', ['$scope', function ($scope) {
  2631. $scope.myStyle = '.blah { border: 1px solid }';
  2632. }]);
  2633. </script>
  2634. <div ng-controller="MainCtrl">
  2635. <style ui-grid-style>{{ myStyle }}</style>
  2636. <span class="blah">I am in a box.</span>
  2637. </div>
  2638. </doc:source>
  2639. <doc:scenario>
  2640. it('should apply the right class to the element', function () {
  2641. element(by.css('.blah')).getCssValue('border-top-width')
  2642. .then(function(c) {
  2643. expect(c).toContain('1px');
  2644. });
  2645. });
  2646. </doc:scenario>
  2647. </doc:example>
  2648. */
  2649. angular.module('ui.grid').directive('uiGridStyle', ['gridUtil', '$interpolate', function(gridUtil, $interpolate) {
  2650. return {
  2651. // restrict: 'A',
  2652. // priority: 1000,
  2653. // require: '?^uiGrid',
  2654. link: function($scope, $elm, $attrs, uiGridCtrl) {
  2655. // gridUtil.logDebug('ui-grid-style link');
  2656. // if (uiGridCtrl === undefined) {
  2657. // gridUtil.logWarn('[ui-grid-style link] uiGridCtrl is undefined!');
  2658. // }
  2659. var interpolateFn = $interpolate($elm.text(), true);
  2660. if (interpolateFn) {
  2661. $scope.$watch(interpolateFn, function(value) {
  2662. $elm.text(value);
  2663. });
  2664. }
  2665. // uiGridCtrl.recalcRowStyles = function() {
  2666. // var offset = (scope.options.offsetTop || 0) - (scope.options.excessRows * scope.options.rowHeight);
  2667. // var rowHeight = scope.options.rowHeight;
  2668. // var ret = '';
  2669. // var rowStyleCount = uiGridCtrl.minRowsToRender() + (scope.options.excessRows * 2);
  2670. // for (var i = 1; i <= rowStyleCount; i++) {
  2671. // ret = ret + ' .grid' + scope.gridId + ' .ui-grid-row:nth-child(' + i + ') { top: ' + offset + 'px; }';
  2672. // offset = offset + rowHeight;
  2673. // }
  2674. // scope.rowStyles = ret;
  2675. // };
  2676. // uiGridCtrl.styleComputions.push(uiGridCtrl.recalcRowStyles);
  2677. }
  2678. };
  2679. }]);
  2680. })();
  2681. (function(){
  2682. 'use strict';
  2683. angular.module('ui.grid').directive('uiGridViewport', ['gridUtil','ScrollEvent','uiGridConstants', '$log',
  2684. function(gridUtil, ScrollEvent, uiGridConstants, $log) {
  2685. return {
  2686. replace: true,
  2687. scope: {},
  2688. controllerAs: 'Viewport',
  2689. templateUrl: 'ui-grid/uiGridViewport',
  2690. require: ['^uiGrid', '^uiGridRenderContainer'],
  2691. link: function($scope, $elm, $attrs, controllers) {
  2692. // gridUtil.logDebug('viewport post-link');
  2693. var uiGridCtrl = controllers[0];
  2694. var containerCtrl = controllers[1];
  2695. $scope.containerCtrl = containerCtrl;
  2696. var rowContainer = containerCtrl.rowContainer;
  2697. var colContainer = containerCtrl.colContainer;
  2698. var grid = uiGridCtrl.grid;
  2699. $scope.grid = uiGridCtrl.grid;
  2700. // Put the containers in scope so we can get rows and columns from them
  2701. $scope.rowContainer = containerCtrl.rowContainer;
  2702. $scope.colContainer = containerCtrl.colContainer;
  2703. // Register this viewport with its container
  2704. containerCtrl.viewport = $elm;
  2705. /**
  2706. * @ngdoc function
  2707. * @name customScroller
  2708. * @methodOf ui.grid.class:GridOptions
  2709. * @description (optional) uiGridViewport.on('scroll', scrollHandler) by default.
  2710. * A function that allows you to provide your own scroller function. It is particularly helpful if you want to use third party scrollers
  2711. * as this allows you to do that.
  2712. *
  2713. * <div class="alert alert-info" role="alert"> <strong>NOTE:</strong> It is important to remember to always pass in an event object to
  2714. * the scrollHandler as the grid scrolling behavior will break without it.</div>
  2715. * <h5>Example</h5>
  2716. * <pre>
  2717. * $scope.gridOptions = {
  2718. * customScroller: function myScrolling(uiGridViewport, scrollHandler) {
  2719. * uiGridViewport.on('scroll', function myScrollingOverride(event) {
  2720. * // Do something here
  2721. *
  2722. * scrollHandler(event);
  2723. * });
  2724. * }
  2725. * };
  2726. * </pre>
  2727. * @param {object} uiGridViewport Element being scrolled. (this gets passed in by the grid).
  2728. * @param {function} scrollHandler Function that needs to be called when scrolling happens. (this gets passed in by the grid).
  2729. */
  2730. if (grid && grid.options && grid.options.customScroller) {
  2731. grid.options.customScroller($elm, scrollHandler);
  2732. } else {
  2733. $elm.on('scroll', scrollHandler);
  2734. }
  2735. var ignoreScroll = false;
  2736. function scrollHandler(evt) {
  2737. //Leaving in this commented code in case it can someday be used
  2738. //It does improve performance, but because the horizontal scroll is normalized,
  2739. // using this code will lead to the column header getting slightly out of line with columns
  2740. //
  2741. //if (ignoreScroll && (grid.isScrollingHorizontally || grid.isScrollingHorizontally)) {
  2742. // //don't ask for scrollTop if we just set it
  2743. // ignoreScroll = false;
  2744. // return;
  2745. //}
  2746. //ignoreScroll = true;
  2747. var newScrollTop = $elm[0].scrollTop;
  2748. var newScrollLeft = gridUtil.normalizeScrollLeft($elm, grid);
  2749. var vertScrollPercentage = rowContainer.scrollVertical(newScrollTop);
  2750. var horizScrollPercentage = colContainer.scrollHorizontal(newScrollLeft);
  2751. var scrollEvent = new ScrollEvent(grid, rowContainer, colContainer, ScrollEvent.Sources.ViewPortScroll);
  2752. scrollEvent.newScrollLeft = newScrollLeft;
  2753. scrollEvent.newScrollTop = newScrollTop;
  2754. if ( horizScrollPercentage > -1 ){
  2755. scrollEvent.x = { percentage: horizScrollPercentage };
  2756. }
  2757. if ( vertScrollPercentage > -1 ){
  2758. scrollEvent.y = { percentage: vertScrollPercentage };
  2759. }
  2760. grid.scrollContainers($scope.$parent.containerId, scrollEvent);
  2761. }
  2762. if ($scope.$parent.bindScrollVertical) {
  2763. grid.addVerticalScrollSync($scope.$parent.containerId, syncVerticalScroll);
  2764. }
  2765. if ($scope.$parent.bindScrollHorizontal) {
  2766. grid.addHorizontalScrollSync($scope.$parent.containerId, syncHorizontalScroll);
  2767. grid.addHorizontalScrollSync($scope.$parent.containerId + 'header', syncHorizontalHeader);
  2768. grid.addHorizontalScrollSync($scope.$parent.containerId + 'footer', syncHorizontalFooter);
  2769. }
  2770. function syncVerticalScroll(scrollEvent){
  2771. containerCtrl.prevScrollArgs = scrollEvent;
  2772. var newScrollTop = scrollEvent.getNewScrollTop(rowContainer,containerCtrl.viewport);
  2773. $elm[0].scrollTop = newScrollTop;
  2774. }
  2775. function syncHorizontalScroll(scrollEvent){
  2776. containerCtrl.prevScrollArgs = scrollEvent;
  2777. var newScrollLeft = scrollEvent.getNewScrollLeft(colContainer, containerCtrl.viewport);
  2778. $elm[0].scrollLeft = gridUtil.denormalizeScrollLeft(containerCtrl.viewport,newScrollLeft, grid);
  2779. }
  2780. function syncHorizontalHeader(scrollEvent){
  2781. var newScrollLeft = scrollEvent.getNewScrollLeft(colContainer, containerCtrl.viewport);
  2782. if (containerCtrl.headerViewport) {
  2783. containerCtrl.headerViewport.scrollLeft = gridUtil.denormalizeScrollLeft(containerCtrl.viewport,newScrollLeft, grid);
  2784. }
  2785. }
  2786. function syncHorizontalFooter(scrollEvent){
  2787. var newScrollLeft = scrollEvent.getNewScrollLeft(colContainer, containerCtrl.viewport);
  2788. if (containerCtrl.footerViewport) {
  2789. containerCtrl.footerViewport.scrollLeft = gridUtil.denormalizeScrollLeft(containerCtrl.viewport,newScrollLeft, grid);
  2790. }
  2791. }
  2792. $scope.$on('$destroy', function unbindEvents() {
  2793. $elm.off();
  2794. });
  2795. },
  2796. controller: ['$scope', function ($scope) {
  2797. this.rowStyle = function (index) {
  2798. var rowContainer = $scope.rowContainer;
  2799. var colContainer = $scope.colContainer;
  2800. var styles = {};
  2801. if (rowContainer.currentTopRow !== 0){
  2802. //top offset based on hidden rows count
  2803. var translateY = "translateY("+ (rowContainer.currentTopRow * rowContainer.grid.options.rowHeight) +"px)";
  2804. styles['transform'] = translateY;
  2805. styles['-webkit-transform'] = translateY;
  2806. styles['-ms-transform'] = translateY;
  2807. }
  2808. if (colContainer.currentFirstColumn !== 0) {
  2809. if (colContainer.grid.isRTL()) {
  2810. styles['margin-right'] = colContainer.columnOffset + 'px';
  2811. }
  2812. else {
  2813. styles['margin-left'] = colContainer.columnOffset + 'px';
  2814. }
  2815. }
  2816. return styles;
  2817. };
  2818. }]
  2819. };
  2820. }
  2821. ]);
  2822. })();
  2823. (function() {
  2824. angular.module('ui.grid')
  2825. .directive('uiGridVisible', function uiGridVisibleAction() {
  2826. return function ($scope, $elm, $attr) {
  2827. $scope.$watch($attr.uiGridVisible, function (visible) {
  2828. // $elm.css('visibility', visible ? 'visible' : 'hidden');
  2829. $elm[visible ? 'removeClass' : 'addClass']('ui-grid-invisible');
  2830. });
  2831. };
  2832. });
  2833. })();
  2834. (function () {
  2835. 'use strict';
  2836. angular.module('ui.grid').controller('uiGridController', ['$scope', '$element', '$attrs', 'gridUtil', '$q', 'uiGridConstants',
  2837. 'gridClassFactory', '$parse', '$compile',
  2838. function ($scope, $elm, $attrs, gridUtil, $q, uiGridConstants,
  2839. gridClassFactory, $parse, $compile) {
  2840. // gridUtil.logDebug('ui-grid controller');
  2841. var self = this;
  2842. var deregFunctions = [];
  2843. self.grid = gridClassFactory.createGrid($scope.uiGrid);
  2844. //assign $scope.$parent if appScope not already assigned
  2845. self.grid.appScope = self.grid.appScope || $scope.$parent;
  2846. $elm.addClass('grid' + self.grid.id);
  2847. self.grid.rtl = gridUtil.getStyles($elm[0])['direction'] === 'rtl';
  2848. // angular.extend(self.grid.options, );
  2849. //all properties of grid are available on scope
  2850. $scope.grid = self.grid;
  2851. if ($attrs.uiGridColumns) {
  2852. deregFunctions.push( $attrs.$observe('uiGridColumns', function(value) {
  2853. self.grid.options.columnDefs = angular.isString(value) ? angular.fromJson(value) : value;
  2854. self.grid.buildColumns()
  2855. .then(function(){
  2856. self.grid.preCompileCellTemplates();
  2857. self.grid.refreshCanvas(true);
  2858. }).catch(angular.noop);
  2859. }) );
  2860. }
  2861. // prevents an error from being thrown when the array is not defined yet and fastWatch is on
  2862. function getSize(array) {
  2863. return array ? array.length : 0;
  2864. }
  2865. // if fastWatch is set we watch only the length and the reference, not every individual object
  2866. if (self.grid.options.fastWatch) {
  2867. self.uiGrid = $scope.uiGrid;
  2868. if (angular.isString($scope.uiGrid.data)) {
  2869. deregFunctions.push( $scope.$parent.$watch($scope.uiGrid.data, dataWatchFunction) );
  2870. deregFunctions.push( $scope.$parent.$watch(function() {
  2871. if ( self.grid.appScope[$scope.uiGrid.data] ){
  2872. return self.grid.appScope[$scope.uiGrid.data].length;
  2873. } else {
  2874. return undefined;
  2875. }
  2876. }, dataWatchFunction) );
  2877. } else {
  2878. deregFunctions.push( $scope.$parent.$watch(function() { return $scope.uiGrid.data; }, dataWatchFunction) );
  2879. deregFunctions.push( $scope.$parent.$watch(function() { return getSize($scope.uiGrid.data); }, function(){ dataWatchFunction($scope.uiGrid.data); }) );
  2880. }
  2881. deregFunctions.push( $scope.$parent.$watch(function() { return $scope.uiGrid.columnDefs; }, columnDefsWatchFunction) );
  2882. deregFunctions.push( $scope.$parent.$watch(function() { return getSize($scope.uiGrid.columnDefs); }, function(){ columnDefsWatchFunction($scope.uiGrid.columnDefs); }) );
  2883. } else {
  2884. if (angular.isString($scope.uiGrid.data)) {
  2885. deregFunctions.push( $scope.$parent.$watchCollection($scope.uiGrid.data, dataWatchFunction) );
  2886. } else {
  2887. deregFunctions.push( $scope.$parent.$watchCollection(function() { return $scope.uiGrid.data; }, dataWatchFunction) );
  2888. }
  2889. deregFunctions.push( $scope.$parent.$watchCollection(function() { return $scope.uiGrid.columnDefs; }, columnDefsWatchFunction) );
  2890. }
  2891. function columnDefsWatchFunction(n, o) {
  2892. if (n && n !== o) {
  2893. self.grid.options.columnDefs = $scope.uiGrid.columnDefs;
  2894. self.grid.callDataChangeCallbacks(uiGridConstants.dataChange.COLUMN, {
  2895. orderByColumnDefs: true,
  2896. preCompileCellTemplates: true
  2897. });
  2898. }
  2899. }
  2900. var mostRecentData;
  2901. function dataWatchFunction(newData) {
  2902. // gridUtil.logDebug('dataWatch fired');
  2903. var promises = [];
  2904. if (angular.isString($scope.uiGrid.data)) {
  2905. newData = self.grid.appScope[$scope.uiGrid.data];
  2906. } else {
  2907. newData = $scope.uiGrid.data;
  2908. }
  2909. mostRecentData = newData;
  2910. if (newData) {
  2911. // columns length is greater than the number of row header columns, which don't count because they're created automatically
  2912. var hasColumns = self.grid.columns.length > (self.grid.rowHeaderColumns ? self.grid.rowHeaderColumns.length : 0);
  2913. if (
  2914. // If we have no columns
  2915. !hasColumns &&
  2916. // ... and we don't have a ui-grid-columns attribute, which would define columns for us
  2917. !$attrs.uiGridColumns &&
  2918. // ... and we have no pre-defined columns
  2919. self.grid.options.columnDefs.length === 0 &&
  2920. // ... but we DO have data
  2921. newData.length > 0
  2922. ) {
  2923. // ... then build the column definitions from the data that we have
  2924. self.grid.buildColumnDefsFromData(newData);
  2925. }
  2926. // If we haven't built columns before and either have some columns defined or some data defined
  2927. if (!hasColumns && (self.grid.options.columnDefs.length > 0 || newData.length > 0)) {
  2928. // Build the column set, then pre-compile the column cell templates
  2929. promises.push(self.grid.buildColumns()
  2930. .then(function() {
  2931. self.grid.preCompileCellTemplates();
  2932. }).catch(angular.noop));
  2933. }
  2934. $q.all(promises).then(function() {
  2935. // use most recent data, rather than the potentially outdated data passed into watcher handler
  2936. self.grid.modifyRows(mostRecentData)
  2937. .then(function () {
  2938. // if (self.viewport) {
  2939. self.grid.redrawInPlace(true);
  2940. // }
  2941. $scope.$evalAsync(function() {
  2942. self.grid.refreshCanvas(true);
  2943. self.grid.callDataChangeCallbacks(uiGridConstants.dataChange.ROW);
  2944. });
  2945. }).catch(angular.noop);
  2946. }).catch(angular.noop);
  2947. }
  2948. }
  2949. var styleWatchDereg = $scope.$watch(function () { return self.grid.styleComputations; }, function() {
  2950. self.grid.refreshCanvas(true);
  2951. });
  2952. $scope.$on('$destroy', function() {
  2953. deregFunctions.forEach( function( deregFn ){ deregFn(); });
  2954. styleWatchDereg();
  2955. });
  2956. self.fireEvent = function(eventName, args) {
  2957. args = args || {};
  2958. // Add the grid to the event arguments if it's not there
  2959. if (angular.isUndefined(args.grid)) {
  2960. args.grid = self.grid;
  2961. }
  2962. $scope.$broadcast(eventName, args);
  2963. };
  2964. self.innerCompile = function innerCompile(elm) {
  2965. $compile(elm)($scope);
  2966. };
  2967. }]);
  2968. /**
  2969. * @ngdoc directive
  2970. * @name ui.grid.directive:uiGrid
  2971. * @element div
  2972. * @restrict EA
  2973. * @param {Object} uiGrid Options for the grid to use
  2974. *
  2975. * @description Create a very basic grid.
  2976. *
  2977. * @example
  2978. <example module="app">
  2979. <file name="app.js">
  2980. var app = angular.module('app', ['ui.grid']);
  2981. app.controller('MainCtrl', ['$scope', function ($scope) {
  2982. $scope.data = [
  2983. { name: 'Bob', title: 'CEO' },
  2984. { name: 'Frank', title: 'Lowly Developer' }
  2985. ];
  2986. }]);
  2987. </file>
  2988. <file name="index.html">
  2989. <div ng-controller="MainCtrl">
  2990. <div ui-grid="{ data: data }"></div>
  2991. </div>
  2992. </file>
  2993. </example>
  2994. */
  2995. angular.module('ui.grid').directive('uiGrid', uiGridDirective);
  2996. uiGridDirective.$inject = ['$window', 'gridUtil', 'uiGridConstants'];
  2997. function uiGridDirective($window, gridUtil, uiGridConstants) {
  2998. return {
  2999. templateUrl: 'ui-grid/ui-grid',
  3000. scope: {
  3001. uiGrid: '='
  3002. },
  3003. replace: true,
  3004. transclude: true,
  3005. controller: 'uiGridController',
  3006. compile: function () {
  3007. return {
  3008. post: function ($scope, $elm, $attrs, uiGridCtrl) {
  3009. var grid = uiGridCtrl.grid;
  3010. // Initialize scrollbars (TODO: move to controller??)
  3011. uiGridCtrl.scrollbars = [];
  3012. grid.element = $elm;
  3013. // See if the grid has a rendered width, if not, wait a bit and try again
  3014. var sizeCheckInterval = 100; // ms
  3015. var maxSizeChecks = 20; // 2 seconds total
  3016. var sizeChecks = 0;
  3017. // Setup (event listeners) the grid
  3018. setup();
  3019. // And initialize it
  3020. init();
  3021. // Mark rendering complete so API events can happen
  3022. grid.renderingComplete();
  3023. // If the grid doesn't have size currently, wait for a bit to see if it gets size
  3024. checkSize();
  3025. /*-- Methods --*/
  3026. function checkSize() {
  3027. // If the grid has no width and we haven't checked more than <maxSizeChecks> times, check again in <sizeCheckInterval> milliseconds
  3028. if ($elm[0].offsetWidth <= 0 && sizeChecks < maxSizeChecks) {
  3029. setTimeout(checkSize, sizeCheckInterval);
  3030. sizeChecks++;
  3031. } else {
  3032. $scope.$applyAsync(init);
  3033. }
  3034. }
  3035. // Setup event listeners and watchers
  3036. function setup() {
  3037. var deregisterLeftWatcher, deregisterRightWatcher;
  3038. // Bind to window resize events
  3039. angular.element($window).on('resize', gridResize);
  3040. // Unbind from window resize events when the grid is destroyed
  3041. $elm.on('$destroy', function () {
  3042. angular.element($window).off('resize', gridResize);
  3043. deregisterLeftWatcher();
  3044. deregisterRightWatcher();
  3045. });
  3046. // If we add a left container after render, we need to watch and react
  3047. deregisterLeftWatcher = $scope.$watch(function () { return grid.hasLeftContainer();}, function (newValue, oldValue) {
  3048. if (newValue === oldValue) {
  3049. return;
  3050. }
  3051. grid.refreshCanvas(true);
  3052. });
  3053. // If we add a right container after render, we need to watch and react
  3054. deregisterRightWatcher = $scope.$watch(function () { return grid.hasRightContainer();}, function (newValue, oldValue) {
  3055. if (newValue === oldValue) {
  3056. return;
  3057. }
  3058. grid.refreshCanvas(true);
  3059. });
  3060. }
  3061. // Initialize the directive
  3062. function init() {
  3063. grid.gridWidth = $scope.gridWidth = gridUtil.elementWidth($elm);
  3064. // Default canvasWidth to the grid width, in case we don't get any column definitions to calculate it from
  3065. grid.canvasWidth = uiGridCtrl.grid.gridWidth;
  3066. grid.gridHeight = $scope.gridHeight = gridUtil.elementHeight($elm);
  3067. // If the grid isn't tall enough to fit a single row, it's kind of useless. Resize it to fit a minimum number of rows
  3068. if (grid.gridHeight <= grid.options.rowHeight && grid.options.enableMinHeightCheck) {
  3069. autoAdjustHeight();
  3070. }
  3071. // Run initial canvas refresh
  3072. grid.refreshCanvas(true);
  3073. }
  3074. // Set the grid's height ourselves in the case that its height would be unusably small
  3075. function autoAdjustHeight() {
  3076. // Figure out the new height
  3077. var contentHeight = grid.options.minRowsToShow * grid.options.rowHeight;
  3078. var headerHeight = grid.options.showHeader ? grid.options.headerRowHeight : 0;
  3079. var footerHeight = grid.calcFooterHeight();
  3080. var scrollbarHeight = 0;
  3081. if (grid.options.enableHorizontalScrollbar === uiGridConstants.scrollbars.ALWAYS) {
  3082. scrollbarHeight = gridUtil.getScrollbarWidth();
  3083. }
  3084. var maxNumberOfFilters = 0;
  3085. // Calculates the maximum number of filters in the columns
  3086. angular.forEach(grid.options.columnDefs, function(col) {
  3087. if (col.hasOwnProperty('filter')) {
  3088. if (maxNumberOfFilters < 1) {
  3089. maxNumberOfFilters = 1;
  3090. }
  3091. }
  3092. else if (col.hasOwnProperty('filters')) {
  3093. if (maxNumberOfFilters < col.filters.length) {
  3094. maxNumberOfFilters = col.filters.length;
  3095. }
  3096. }
  3097. });
  3098. if (grid.options.enableFiltering && !maxNumberOfFilters) {
  3099. var allColumnsHaveFilteringTurnedOff = grid.options.columnDefs.length && grid.options.columnDefs.every(function(col) {
  3100. return col.enableFiltering === false;
  3101. });
  3102. if (!allColumnsHaveFilteringTurnedOff) {
  3103. maxNumberOfFilters = 1;
  3104. }
  3105. }
  3106. var filterHeight = maxNumberOfFilters * headerHeight;
  3107. var newHeight = headerHeight + contentHeight + footerHeight + scrollbarHeight + filterHeight;
  3108. $elm.css('height', newHeight + 'px');
  3109. grid.gridHeight = $scope.gridHeight = gridUtil.elementHeight($elm);
  3110. }
  3111. // Resize the grid on window resize events
  3112. function gridResize() {
  3113. grid.gridWidth = $scope.gridWidth = gridUtil.elementWidth($elm);
  3114. grid.gridHeight = $scope.gridHeight = gridUtil.elementHeight($elm);
  3115. grid.refreshCanvas(true);
  3116. }
  3117. }
  3118. };
  3119. }
  3120. };
  3121. }
  3122. })();
  3123. (function(){
  3124. 'use strict';
  3125. // TODO: rename this file to ui-grid-pinned-container.js
  3126. angular.module('ui.grid').directive('uiGridPinnedContainer', ['gridUtil', function (gridUtil) {
  3127. return {
  3128. restrict: 'EA',
  3129. replace: true,
  3130. template: '<div class="ui-grid-pinned-container"><div ui-grid-render-container container-id="side" row-container-name="\'body\'" col-container-name="side" bind-scroll-vertical="true" class="{{ side }} ui-grid-render-container-{{ side }}"></div></div>',
  3131. scope: {
  3132. side: '=uiGridPinnedContainer'
  3133. },
  3134. require: '^uiGrid',
  3135. compile: function compile() {
  3136. return {
  3137. post: function ($scope, $elm, $attrs, uiGridCtrl) {
  3138. // gridUtil.logDebug('ui-grid-pinned-container ' + $scope.side + ' link');
  3139. var grid = uiGridCtrl.grid;
  3140. var myWidth = 0;
  3141. $elm.addClass('ui-grid-pinned-container-' + $scope.side);
  3142. // Monkey-patch the viewport width function
  3143. if ($scope.side === 'left' || $scope.side === 'right') {
  3144. grid.renderContainers[$scope.side].getViewportWidth = monkeyPatchedGetViewportWidth;
  3145. }
  3146. function monkeyPatchedGetViewportWidth() {
  3147. /*jshint validthis: true */
  3148. var self = this;
  3149. var viewportWidth = 0;
  3150. self.visibleColumnCache.forEach(function (column) {
  3151. viewportWidth += column.drawnWidth;
  3152. });
  3153. var adjustment = self.getViewportAdjustment();
  3154. viewportWidth = viewportWidth + adjustment.width;
  3155. return viewportWidth;
  3156. }
  3157. function updateContainerWidth() {
  3158. if ($scope.side === 'left' || $scope.side === 'right') {
  3159. var cols = grid.renderContainers[$scope.side].visibleColumnCache;
  3160. var width = 0;
  3161. for (var i = 0; i < cols.length; i++) {
  3162. var col = cols[i];
  3163. width += col.drawnWidth || col.width || 0;
  3164. }
  3165. return width;
  3166. }
  3167. }
  3168. function updateContainerDimensions() {
  3169. var ret = '';
  3170. // Column containers
  3171. if ($scope.side === 'left' || $scope.side === 'right') {
  3172. myWidth = updateContainerWidth();
  3173. // gridUtil.logDebug('myWidth', myWidth);
  3174. // TODO(c0bra): Subtract sum of col widths from grid viewport width and update it
  3175. $elm.attr('style', null);
  3176. // var myHeight = grid.renderContainers.body.getViewportHeight(); // + grid.horizontalScrollbarHeight;
  3177. ret += '.grid' + grid.id + ' .ui-grid-pinned-container-' + $scope.side + ', .grid' + grid.id + ' .ui-grid-pinned-container-' + $scope.side + ' .ui-grid-render-container-' + $scope.side + ' .ui-grid-viewport { width: ' + myWidth + 'px; } ';
  3178. }
  3179. return ret;
  3180. }
  3181. grid.renderContainers.body.registerViewportAdjuster(function (adjustment) {
  3182. myWidth = updateContainerWidth();
  3183. // Subtract our own width
  3184. adjustment.width -= myWidth;
  3185. adjustment.side = $scope.side;
  3186. return adjustment;
  3187. });
  3188. // Register style computation to adjust for columns in `side`'s render container
  3189. grid.registerStyleComputation({
  3190. priority: 15,
  3191. func: updateContainerDimensions
  3192. });
  3193. }
  3194. };
  3195. }
  3196. };
  3197. }]);
  3198. })();
  3199. (function(){
  3200. angular.module('ui.grid')
  3201. .factory('Grid', ['$q', '$compile', '$parse', 'gridUtil', 'uiGridConstants', 'GridOptions', 'GridColumn', 'GridRow', 'GridApi', 'rowSorter', 'rowSearcher', 'GridRenderContainer', '$timeout','ScrollEvent',
  3202. function($q, $compile, $parse, gridUtil, uiGridConstants, GridOptions, GridColumn, GridRow, GridApi, rowSorter, rowSearcher, GridRenderContainer, $timeout, ScrollEvent) {
  3203. /**
  3204. * @ngdoc object
  3205. * @name ui.grid.core.api:PublicApi
  3206. * @description Public Api for the core grid features
  3207. *
  3208. */
  3209. /**
  3210. * @ngdoc function
  3211. * @name ui.grid.class:Grid
  3212. * @description Grid is the main viewModel. Any properties or methods needed to maintain state are defined in
  3213. * this prototype. One instance of Grid is created per Grid directive instance.
  3214. * @param {object} options Object map of options to pass into the grid. An 'id' property is expected.
  3215. */
  3216. var Grid = function Grid(options) {
  3217. var self = this;
  3218. // Get the id out of the options, then remove it
  3219. if (options !== undefined && typeof(options.id) !== 'undefined' && options.id) {
  3220. if (!/^[_a-zA-Z0-9-]+$/.test(options.id)) {
  3221. throw new Error("Grid id '" + options.id + '" is invalid. It must follow CSS selector syntax rules.');
  3222. }
  3223. }
  3224. else {
  3225. throw new Error('No ID provided. An ID must be given when creating a grid.');
  3226. }
  3227. self.id = options.id;
  3228. delete options.id;
  3229. // Get default options
  3230. self.options = GridOptions.initialize( options );
  3231. /**
  3232. * @ngdoc object
  3233. * @name appScope
  3234. * @propertyOf ui.grid.class:Grid
  3235. * @description reference to the application scope (the parent scope of the ui-grid element). Assigned in ui-grid controller
  3236. * <br/>
  3237. * use gridOptions.appScopeProvider to override the default assignment of $scope.$parent with any reference
  3238. */
  3239. self.appScope = self.options.appScopeProvider;
  3240. self.headerHeight = self.options.headerRowHeight;
  3241. /**
  3242. * @ngdoc object
  3243. * @name footerHeight
  3244. * @propertyOf ui.grid.class:Grid
  3245. * @description returns the total footer height gridFooter + columnFooter
  3246. */
  3247. self.footerHeight = self.calcFooterHeight();
  3248. /**
  3249. * @ngdoc object
  3250. * @name columnFooterHeight
  3251. * @propertyOf ui.grid.class:Grid
  3252. * @description returns the total column footer height
  3253. */
  3254. self.columnFooterHeight = self.calcColumnFooterHeight();
  3255. self.rtl = false;
  3256. self.gridHeight = 0;
  3257. self.gridWidth = 0;
  3258. self.columnBuilders = [];
  3259. self.rowBuilders = [];
  3260. self.rowsProcessors = [];
  3261. self.columnsProcessors = [];
  3262. self.styleComputations = [];
  3263. self.viewportAdjusters = [];
  3264. self.rowHeaderColumns = [];
  3265. self.dataChangeCallbacks = {};
  3266. self.verticalScrollSyncCallBackFns = {};
  3267. self.horizontalScrollSyncCallBackFns = {};
  3268. // self.visibleRowCache = [];
  3269. // Set of 'render' containers for self grid, which can render sets of rows
  3270. self.renderContainers = {};
  3271. // Create a
  3272. self.renderContainers.body = new GridRenderContainer('body', self);
  3273. self.cellValueGetterCache = {};
  3274. // Cached function to use with custom row templates
  3275. self.getRowTemplateFn = null;
  3276. //representation of the rows on the grid.
  3277. //these are wrapped references to the actual data rows (options.data)
  3278. self.rows = [];
  3279. //represents the columns on the grid
  3280. self.columns = [];
  3281. /**
  3282. * @ngdoc boolean
  3283. * @name isScrollingVertically
  3284. * @propertyOf ui.grid.class:Grid
  3285. * @description set to true when Grid is scrolling vertically. Set to false via debounced method
  3286. */
  3287. self.isScrollingVertically = false;
  3288. /**
  3289. * @ngdoc boolean
  3290. * @name isScrollingHorizontally
  3291. * @propertyOf ui.grid.class:Grid
  3292. * @description set to true when Grid is scrolling horizontally. Set to false via debounced method
  3293. */
  3294. self.isScrollingHorizontally = false;
  3295. /**
  3296. * @ngdoc property
  3297. * @name scrollDirection
  3298. * @propertyOf ui.grid.class:Grid
  3299. * @description set one of the {@link ui.grid.service:uiGridConstants#properties_scrollDirection uiGridConstants.scrollDirection}
  3300. * values (UP, DOWN, LEFT, RIGHT, NONE), which tells us which direction we are scrolling.
  3301. * Set to NONE via debounced method
  3302. */
  3303. self.scrollDirection = uiGridConstants.scrollDirection.NONE;
  3304. //if true, grid will not respond to any scroll events
  3305. self.disableScrolling = false;
  3306. function vertical (scrollEvent) {
  3307. self.isScrollingVertically = false;
  3308. self.api.core.raise.scrollEnd(scrollEvent);
  3309. self.scrollDirection = uiGridConstants.scrollDirection.NONE;
  3310. }
  3311. var debouncedVertical = gridUtil.debounce(vertical, self.options.scrollDebounce);
  3312. var debouncedVerticalMinDelay = gridUtil.debounce(vertical, 0);
  3313. function horizontal (scrollEvent) {
  3314. self.isScrollingHorizontally = false;
  3315. self.api.core.raise.scrollEnd(scrollEvent);
  3316. self.scrollDirection = uiGridConstants.scrollDirection.NONE;
  3317. }
  3318. var debouncedHorizontal = gridUtil.debounce(horizontal, self.options.scrollDebounce);
  3319. var debouncedHorizontalMinDelay = gridUtil.debounce(horizontal, 0);
  3320. /**
  3321. * @ngdoc function
  3322. * @name flagScrollingVertically
  3323. * @methodOf ui.grid.class:Grid
  3324. * @description sets isScrollingVertically to true and sets it to false in a debounced function
  3325. */
  3326. self.flagScrollingVertically = function(scrollEvent) {
  3327. if (!self.isScrollingVertically && !self.isScrollingHorizontally) {
  3328. self.api.core.raise.scrollBegin(scrollEvent);
  3329. }
  3330. self.isScrollingVertically = true;
  3331. if (self.options.scrollDebounce === 0 || !scrollEvent.withDelay) {
  3332. debouncedVerticalMinDelay(scrollEvent);
  3333. }
  3334. else {
  3335. debouncedVertical(scrollEvent);
  3336. }
  3337. };
  3338. /**
  3339. * @ngdoc function
  3340. * @name flagScrollingHorizontally
  3341. * @methodOf ui.grid.class:Grid
  3342. * @description sets isScrollingHorizontally to true and sets it to false in a debounced function
  3343. */
  3344. self.flagScrollingHorizontally = function(scrollEvent) {
  3345. if (!self.isScrollingVertically && !self.isScrollingHorizontally) {
  3346. self.api.core.raise.scrollBegin(scrollEvent);
  3347. }
  3348. self.isScrollingHorizontally = true;
  3349. if (self.options.scrollDebounce === 0 || !scrollEvent.withDelay) {
  3350. debouncedHorizontalMinDelay(scrollEvent);
  3351. }
  3352. else {
  3353. debouncedHorizontal(scrollEvent);
  3354. }
  3355. };
  3356. self.scrollbarHeight = 0;
  3357. self.scrollbarWidth = 0;
  3358. if (self.options.enableHorizontalScrollbar === uiGridConstants.scrollbars.ALWAYS) {
  3359. self.scrollbarHeight = gridUtil.getScrollbarWidth();
  3360. }
  3361. if (self.options.enableVerticalScrollbar === uiGridConstants.scrollbars.ALWAYS) {
  3362. self.scrollbarWidth = gridUtil.getScrollbarWidth();
  3363. }
  3364. self.api = new GridApi(self);
  3365. /**
  3366. * @ngdoc function
  3367. * @name refresh
  3368. * @methodOf ui.grid.core.api:PublicApi
  3369. * @description Refresh the rendered grid on screen.
  3370. * The refresh method re-runs both the columnProcessors and the
  3371. * rowProcessors, as well as calling refreshCanvas to update all
  3372. * the grid sizing. In general you should prefer to use queueGridRefresh
  3373. * instead, which is basically a debounced version of refresh.
  3374. *
  3375. * If you only want to resize the grid, not regenerate all the rows
  3376. * and columns, you should consider directly calling refreshCanvas instead.
  3377. *
  3378. * @param {boolean} [rowsAltered] Optional flag for refreshing when the number of rows has changed
  3379. */
  3380. self.api.registerMethod( 'core', 'refresh', this.refresh );
  3381. /**
  3382. * @ngdoc function
  3383. * @name queueGridRefresh
  3384. * @methodOf ui.grid.core.api:PublicApi
  3385. * @description Request a refresh of the rendered grid on screen, if multiple
  3386. * calls to queueGridRefresh are made within a digest cycle only one will execute.
  3387. * The refresh method re-runs both the columnProcessors and the
  3388. * rowProcessors, as well as calling refreshCanvas to update all
  3389. * the grid sizing. In general you should prefer to use queueGridRefresh
  3390. * instead, which is basically a debounced version of refresh.
  3391. *
  3392. */
  3393. self.api.registerMethod( 'core', 'queueGridRefresh', this.queueGridRefresh );
  3394. /**
  3395. * @ngdoc function
  3396. * @name refreshRows
  3397. * @methodOf ui.grid.core.api:PublicApi
  3398. * @description Runs only the rowProcessors, columns remain as they were.
  3399. * It then calls redrawInPlace and refreshCanvas, which adjust the grid sizing.
  3400. * @returns {promise} promise that is resolved when render completes?
  3401. *
  3402. */
  3403. self.api.registerMethod( 'core', 'refreshRows', this.refreshRows );
  3404. /**
  3405. * @ngdoc function
  3406. * @name queueRefresh
  3407. * @methodOf ui.grid.core.api:PublicApi
  3408. * @description Requests execution of refreshCanvas, if multiple requests are made
  3409. * during a digest cycle only one will run. RefreshCanvas updates the grid sizing.
  3410. * @returns {promise} promise that is resolved when render completes?
  3411. *
  3412. */
  3413. self.api.registerMethod( 'core', 'queueRefresh', this.queueRefresh );
  3414. /**
  3415. * @ngdoc function
  3416. * @name handleWindowResize
  3417. * @methodOf ui.grid.core.api:PublicApi
  3418. * @description Trigger a grid resize, normally this would be picked
  3419. * up by a watch on window size, but in some circumstances it is necessary
  3420. * to call this manually
  3421. * @returns {promise} promise that is resolved when render completes?
  3422. *
  3423. */
  3424. self.api.registerMethod( 'core', 'handleWindowResize', this.handleWindowResize );
  3425. /**
  3426. * @ngdoc function
  3427. * @name addRowHeaderColumn
  3428. * @methodOf ui.grid.core.api:PublicApi
  3429. * @description adds a row header column to the grid
  3430. * @param {object} column def
  3431. * @param {number} order Determines order of header column on grid. Lower order means header
  3432. * is positioned to the left of higher order headers
  3433. *
  3434. */
  3435. self.api.registerMethod( 'core', 'addRowHeaderColumn', this.addRowHeaderColumn );
  3436. /**
  3437. * @ngdoc function
  3438. * @name scrollToIfNecessary
  3439. * @methodOf ui.grid.core.api:PublicApi
  3440. * @description Scrolls the grid to make a certain row and column combo visible,
  3441. * in the case that it is not completely visible on the screen already.
  3442. * @param {GridRow} gridRow row to make visible
  3443. * @param {GridColumn} gridCol column to make visible
  3444. * @returns {promise} a promise that is resolved when scrolling is complete
  3445. *
  3446. */
  3447. self.api.registerMethod( 'core', 'scrollToIfNecessary', function(gridRow, gridCol) { return self.scrollToIfNecessary(gridRow, gridCol);} );
  3448. /**
  3449. * @ngdoc function
  3450. * @name scrollTo
  3451. * @methodOf ui.grid.core.api:PublicApi
  3452. * @description Scroll the grid such that the specified
  3453. * row and column is in view
  3454. * @param {object} rowEntity gridOptions.data[] array instance to make visible
  3455. * @param {object} colDef to make visible
  3456. * @returns {promise} a promise that is resolved after any scrolling is finished
  3457. */
  3458. self.api.registerMethod( 'core', 'scrollTo', function (rowEntity, colDef) { return self.scrollTo(rowEntity, colDef);} );
  3459. /**
  3460. * @ngdoc function
  3461. * @name registerRowsProcessor
  3462. * @methodOf ui.grid.core.api:PublicApi
  3463. * @description
  3464. * Register a "rows processor" function. When the rows are updated,
  3465. * the grid calls each registered "rows processor", which has a chance
  3466. * to alter the set of rows (sorting, etc) as long as the count is not
  3467. * modified.
  3468. *
  3469. * @param {function(renderedRowsToProcess, columns )} processorFunction rows processor function, which
  3470. * is run in the context of the grid (i.e. this for the function will be the grid), and must
  3471. * return the updated rows list, which is passed to the next processor in the chain
  3472. * @param {number} priority the priority of this processor. In general we try to do them in 100s to leave room
  3473. * for other people to inject rows processors at intermediate priorities. Lower priority rowsProcessors run earlier.
  3474. *
  3475. * At present allRowsVisible is running at 50, sort manipulations running at 60-65, filter is running at 100,
  3476. * sort is at 200, grouping and treeview at 400-410, selectable rows at 500, pagination at 900 (pagination will generally want to be last)
  3477. */
  3478. self.api.registerMethod( 'core', 'registerRowsProcessor', this.registerRowsProcessor );
  3479. /**
  3480. * @ngdoc function
  3481. * @name registerColumnsProcessor
  3482. * @methodOf ui.grid.core.api:PublicApi
  3483. * @description
  3484. * Register a "columns processor" function. When the columns are updated,
  3485. * the grid calls each registered "columns processor", which has a chance
  3486. * to alter the set of columns as long as the count is not
  3487. * modified.
  3488. *
  3489. * @param {function(renderedColumnsToProcess, rows )} processorFunction columns processor function, which
  3490. * is run in the context of the grid (i.e. this for the function will be the grid), and must
  3491. * return the updated columns list, which is passed to the next processor in the chain
  3492. * @param {number} priority the priority of this processor. In general we try to do them in 100s to leave room
  3493. * for other people to inject columns processors at intermediate priorities. Lower priority columnsProcessors run earlier.
  3494. *
  3495. * At present allRowsVisible is running at 50, filter is running at 100, sort is at 200, grouping at 400, selectable rows at 500, pagination at 900 (pagination will generally want to be last)
  3496. */
  3497. self.api.registerMethod( 'core', 'registerColumnsProcessor', this.registerColumnsProcessor );
  3498. /**
  3499. * @ngdoc function
  3500. * @name sortHandleNulls
  3501. * @methodOf ui.grid.core.api:PublicApi
  3502. * @description A null handling method that can be used when building custom sort
  3503. * functions
  3504. * @example
  3505. * <pre>
  3506. * mySortFn = function(a, b) {
  3507. * var nulls = $scope.gridApi.core.sortHandleNulls(a, b);
  3508. * if ( nulls !== null ){
  3509. * return nulls;
  3510. * } else {
  3511. * // your code for sorting here
  3512. * };
  3513. * </pre>
  3514. * @param {object} a sort value a
  3515. * @param {object} b sort value b
  3516. * @returns {number} null if there were no nulls/undefineds, otherwise returns
  3517. * a sort value that should be passed back from the sort function
  3518. *
  3519. */
  3520. self.api.registerMethod( 'core', 'sortHandleNulls', rowSorter.handleNulls );
  3521. /**
  3522. * @ngdoc function
  3523. * @name sortChanged
  3524. * @methodOf ui.grid.core.api:PublicApi
  3525. * @description The sort criteria on one or more columns has
  3526. * changed. Provides as parameters the grid and the output of
  3527. * getColumnSorting, which is an array of gridColumns
  3528. * that have sorting on them, sorted in priority order.
  3529. *
  3530. * @param {$scope} scope The scope of the controller. This is used to deregister this event when the scope is destroyed.
  3531. * @param {Function} callBack Will be called when the event is emited. The function passes back the grid and an array of
  3532. * columns with sorts on them, in priority order.
  3533. *
  3534. * @example
  3535. * <pre>
  3536. * gridApi.core.on.sortChanged( $scope, function(grid, sortColumns){
  3537. * // do something
  3538. * });
  3539. * </pre>
  3540. */
  3541. self.api.registerEvent( 'core', 'sortChanged' );
  3542. /**
  3543. * @ngdoc function
  3544. * @name columnVisibilityChanged
  3545. * @methodOf ui.grid.core.api:PublicApi
  3546. * @description The visibility of a column has changed,
  3547. * the column itself is passed out as a parameter of the event.
  3548. *
  3549. * @param {$scope} scope The scope of the controller. This is used to deregister this event when the scope is destroyed.
  3550. * @param {Function} callBack Will be called when the event is emited. The function passes back the GridCol that has changed.
  3551. *
  3552. * @example
  3553. * <pre>
  3554. * gridApi.core.on.columnVisibilityChanged( $scope, function (column) {
  3555. * // do something
  3556. * } );
  3557. * </pre>
  3558. */
  3559. self.api.registerEvent( 'core', 'columnVisibilityChanged' );
  3560. /**
  3561. * @ngdoc method
  3562. * @name notifyDataChange
  3563. * @methodOf ui.grid.core.api:PublicApi
  3564. * @description Notify the grid that a data or config change has occurred,
  3565. * where that change isn't something the grid was otherwise noticing. This
  3566. * might be particularly relevant where you've changed values within the data
  3567. * and you'd like cell classes to be re-evaluated, or changed config within
  3568. * the columnDef and you'd like headerCellClasses to be re-evaluated.
  3569. * @param {string} type one of the
  3570. * {@link ui.grid.service:uiGridConstants#properties_dataChange uiGridConstants.dataChange}
  3571. * values (ALL, ROW, EDIT, COLUMN, OPTIONS), which tells us which refreshes to fire.
  3572. *
  3573. * - ALL: listeners fired on any of these events, fires listeners on all events.
  3574. * - ROW: fired when a row is added or removed.
  3575. * - EDIT: fired when the data in a cell is edited.
  3576. * - COLUMN: fired when the column definitions are modified.
  3577. * - OPTIONS: fired when the grid options are modified.
  3578. */
  3579. self.api.registerMethod( 'core', 'notifyDataChange', this.notifyDataChange );
  3580. /**
  3581. * @ngdoc method
  3582. * @name clearAllFilters
  3583. * @methodOf ui.grid.core.api:PublicApi
  3584. * @description Clears all filters and optionally refreshes the visible rows.
  3585. * @param {object} refreshRows Defaults to true.
  3586. * @param {object} clearConditions Defaults to false.
  3587. * @param {object} clearFlags Defaults to false.
  3588. * @returns {promise} If `refreshRows` is true, returns a promise of the rows refreshing.
  3589. */
  3590. self.api.registerMethod('core', 'clearAllFilters', this.clearAllFilters);
  3591. self.registerDataChangeCallback( self.columnRefreshCallback, [uiGridConstants.dataChange.COLUMN]);
  3592. self.registerDataChangeCallback( self.processRowsCallback, [uiGridConstants.dataChange.EDIT]);
  3593. self.registerDataChangeCallback( self.updateFooterHeightCallback, [uiGridConstants.dataChange.OPTIONS]);
  3594. self.registerStyleComputation({
  3595. priority: 10,
  3596. func: self.getFooterStyles
  3597. });
  3598. };
  3599. Grid.prototype.calcFooterHeight = function () {
  3600. if (!this.hasFooter()) {
  3601. return 0;
  3602. }
  3603. var height = 0;
  3604. if (this.options.showGridFooter) {
  3605. height += this.options.gridFooterHeight;
  3606. }
  3607. height += this.calcColumnFooterHeight();
  3608. return height;
  3609. };
  3610. Grid.prototype.calcColumnFooterHeight = function () {
  3611. var height = 0;
  3612. if (this.options.showColumnFooter) {
  3613. height += this.options.columnFooterHeight;
  3614. }
  3615. return height;
  3616. };
  3617. Grid.prototype.getFooterStyles = function () {
  3618. var style = '.grid' + this.id + ' .ui-grid-footer-aggregates-row { height: ' + this.options.columnFooterHeight + 'px; }';
  3619. style += ' .grid' + this.id + ' .ui-grid-footer-info { height: ' + this.options.gridFooterHeight + 'px; }';
  3620. return style;
  3621. };
  3622. Grid.prototype.hasFooter = function () {
  3623. return this.options.showGridFooter || this.options.showColumnFooter;
  3624. };
  3625. /**
  3626. * @ngdoc function
  3627. * @name isRTL
  3628. * @methodOf ui.grid.class:Grid
  3629. * @description Returns true if grid is RightToLeft
  3630. */
  3631. Grid.prototype.isRTL = function () {
  3632. return this.rtl;
  3633. };
  3634. /**
  3635. * @ngdoc function
  3636. * @name registerColumnBuilder
  3637. * @methodOf ui.grid.class:Grid
  3638. * @description When the build creates columns from column definitions, the columnbuilders will be called to add
  3639. * additional properties to the column.
  3640. * @param {function(colDef, col, gridOptions)} columnBuilder function to be called
  3641. */
  3642. Grid.prototype.registerColumnBuilder = function registerColumnBuilder(columnBuilder) {
  3643. this.columnBuilders.push(columnBuilder);
  3644. };
  3645. /**
  3646. * @ngdoc function
  3647. * @name buildColumnDefsFromData
  3648. * @methodOf ui.grid.class:Grid
  3649. * @description Populates columnDefs from the provided data
  3650. * @param {function(colDef, col, gridOptions)} rowBuilder function to be called
  3651. */
  3652. Grid.prototype.buildColumnDefsFromData = function (dataRows){
  3653. this.options.columnDefs = gridUtil.getColumnsFromData(dataRows, this.options.excludeProperties);
  3654. };
  3655. /**
  3656. * @ngdoc function
  3657. * @name registerRowBuilder
  3658. * @methodOf ui.grid.class:Grid
  3659. * @description When the build creates rows from gridOptions.data, the rowBuilders will be called to add
  3660. * additional properties to the row.
  3661. * @param {function(row, gridOptions)} rowBuilder function to be called
  3662. */
  3663. Grid.prototype.registerRowBuilder = function registerRowBuilder(rowBuilder) {
  3664. this.rowBuilders.push(rowBuilder);
  3665. };
  3666. /**
  3667. * @ngdoc function
  3668. * @name registerDataChangeCallback
  3669. * @methodOf ui.grid.class:Grid
  3670. * @description When a data change occurs, the data change callbacks of the specified type
  3671. * will be called. The rules are:
  3672. *
  3673. * - when the data watch fires, that is considered a ROW change (the data watch only notices
  3674. * added or removed rows)
  3675. * - when the api is called to inform us of a change, the declared type of that change is used
  3676. * - when a cell edit completes, the EDIT callbacks are triggered
  3677. * - when the columnDef watch fires, the COLUMN callbacks are triggered
  3678. * - when the options watch fires, the OPTIONS callbacks are triggered
  3679. *
  3680. * For a given event:
  3681. * - ALL calls ROW, EDIT, COLUMN, OPTIONS and ALL callbacks
  3682. * - ROW calls ROW and ALL callbacks
  3683. * - EDIT calls EDIT and ALL callbacks
  3684. * - COLUMN calls COLUMN and ALL callbacks
  3685. * - OPTIONS calls OPTIONS and ALL callbacks
  3686. *
  3687. * @param {function(grid)} callback function to be called
  3688. * @param {array} types the types of data change you want to be informed of. Values from
  3689. * the {@link ui.grid.service:uiGridConstants#properties_dataChange uiGridConstants.dataChange}
  3690. * values ( ALL, EDIT, ROW, COLUMN, OPTIONS ). Optional and defaults to ALL
  3691. * @returns {function} deregister function - a function that can be called to deregister this callback
  3692. */
  3693. Grid.prototype.registerDataChangeCallback = function registerDataChangeCallback(callback, types, _this) {
  3694. var uid = gridUtil.nextUid();
  3695. if ( !types ){
  3696. types = [uiGridConstants.dataChange.ALL];
  3697. }
  3698. if ( !Array.isArray(types)){
  3699. gridUtil.logError("Expected types to be an array or null in registerDataChangeCallback, value passed was: " + types );
  3700. }
  3701. this.dataChangeCallbacks[uid] = { callback: callback, types: types, _this:_this };
  3702. var self = this;
  3703. var deregisterFunction = function() {
  3704. delete self.dataChangeCallbacks[uid];
  3705. };
  3706. return deregisterFunction;
  3707. };
  3708. /**
  3709. * @ngdoc function
  3710. * @name callDataChangeCallbacks
  3711. * @methodOf ui.grid.class:Grid
  3712. * @description Calls the callbacks based on the type of data change that
  3713. * has occurred. Always calls the ALL callbacks, calls the ROW, EDIT, COLUMN and OPTIONS callbacks if the
  3714. * event type is matching, or if the type is ALL.
  3715. * @param {string} type the type of event that occurred - one of the
  3716. * {@link ui.grid.service:uiGridConstants#properties_dataChange uiGridConstants.dataChange}
  3717. * values (ALL, ROW, EDIT, COLUMN, OPTIONS)
  3718. */
  3719. Grid.prototype.callDataChangeCallbacks = function callDataChangeCallbacks(type, options) {
  3720. angular.forEach( this.dataChangeCallbacks, function( callback, uid ){
  3721. if ( callback.types.indexOf( uiGridConstants.dataChange.ALL ) !== -1 ||
  3722. callback.types.indexOf( type ) !== -1 ||
  3723. type === uiGridConstants.dataChange.ALL ) {
  3724. if (callback._this) {
  3725. callback.callback.apply(callback._this, this, options);
  3726. }
  3727. else {
  3728. callback.callback(this, options);
  3729. }
  3730. }
  3731. }, this);
  3732. };
  3733. /**
  3734. * @ngdoc function
  3735. * @name notifyDataChange
  3736. * @methodOf ui.grid.class:Grid
  3737. * @description Notifies us that a data change has occurred, used in the public
  3738. * api for users to tell us when they've changed data or some other event that
  3739. * our watches cannot pick up
  3740. * @param {string} type the type of event that occurred - one of the
  3741. * uiGridConstants.dataChange values (ALL, ROW, EDIT, COLUMN, OPTIONS)
  3742. *
  3743. * - ALL: listeners fired on any of these events, fires listeners on all events.
  3744. * - ROW: fired when a row is added or removed.
  3745. * - EDIT: fired when the data in a cell is edited.
  3746. * - COLUMN: fired when the column definitions are modified.
  3747. * - OPTIONS: fired when the grid options are modified.
  3748. */
  3749. Grid.prototype.notifyDataChange = function notifyDataChange(type) {
  3750. var constants = uiGridConstants.dataChange;
  3751. if ( type === constants.ALL ||
  3752. type === constants.COLUMN ||
  3753. type === constants.EDIT ||
  3754. type === constants.ROW ||
  3755. type === constants.OPTIONS ){
  3756. this.callDataChangeCallbacks( type );
  3757. } else {
  3758. gridUtil.logError("Notified of a data change, but the type was not recognised, so no action taken, type was: " + type);
  3759. }
  3760. };
  3761. /**
  3762. * @ngdoc function
  3763. * @name columnRefreshCallback
  3764. * @methodOf ui.grid.class:Grid
  3765. * @description refreshes the grid when a column refresh
  3766. * is notified, which triggers handling of the visible flag.
  3767. * This is called on uiGridConstants.dataChange.COLUMN, and is
  3768. * registered as a dataChangeCallback in grid.js
  3769. * @param {object} grid The grid object.
  3770. * @param {object} options Any options passed into the callback.
  3771. */
  3772. Grid.prototype.columnRefreshCallback = function columnRefreshCallback(grid, options){
  3773. grid.buildColumns(options);
  3774. grid.queueGridRefresh();
  3775. };
  3776. /**
  3777. * @ngdoc function
  3778. * @name processRowsCallback
  3779. * @methodOf ui.grid.class:Grid
  3780. * @description calls the row processors, specifically
  3781. * intended to reset the sorting when an edit is called,
  3782. * registered as a dataChangeCallback on uiGridConstants.dataChange.EDIT
  3783. * @param {string} name column name
  3784. */
  3785. Grid.prototype.processRowsCallback = function processRowsCallback( grid ){
  3786. grid.queueGridRefresh();
  3787. };
  3788. /**
  3789. * @ngdoc function
  3790. * @name updateFooterHeightCallback
  3791. * @methodOf ui.grid.class:Grid
  3792. * @description recalculates the footer height,
  3793. * registered as a dataChangeCallback on uiGridConstants.dataChange.OPTIONS
  3794. * @param {string} name column name
  3795. */
  3796. Grid.prototype.updateFooterHeightCallback = function updateFooterHeightCallback( grid ){
  3797. grid.footerHeight = grid.calcFooterHeight();
  3798. grid.columnFooterHeight = grid.calcColumnFooterHeight();
  3799. };
  3800. /**
  3801. * @ngdoc function
  3802. * @name getColumn
  3803. * @methodOf ui.grid.class:Grid
  3804. * @description returns a grid column for the column name
  3805. * @param {string} name column name
  3806. */
  3807. Grid.prototype.getColumn = function getColumn(name) {
  3808. var columns = this.columns.filter(function (column) {
  3809. return column.colDef.name === name;
  3810. });
  3811. return columns.length > 0 ? columns[0] : null;
  3812. };
  3813. /**
  3814. * @ngdoc function
  3815. * @name getColDef
  3816. * @methodOf ui.grid.class:Grid
  3817. * @description returns a grid colDef for the column name
  3818. * @param {string} name column.field
  3819. */
  3820. Grid.prototype.getColDef = function getColDef(name) {
  3821. var colDefs = this.options.columnDefs.filter(function (colDef) {
  3822. return colDef.name === name;
  3823. });
  3824. return colDefs.length > 0 ? colDefs[0] : null;
  3825. };
  3826. /**
  3827. * @ngdoc function
  3828. * @name assignTypes
  3829. * @methodOf ui.grid.class:Grid
  3830. * @description uses the first row of data to assign colDef.type for any types not defined.
  3831. */
  3832. /**
  3833. * @ngdoc property
  3834. * @name type
  3835. * @propertyOf ui.grid.class:GridOptions.columnDef
  3836. * @description the type of the column, used in sorting. If not provided then the
  3837. * grid will guess the type. Add this only if the grid guessing is not to your
  3838. * satisfaction. One of:
  3839. * - 'string'
  3840. * - 'boolean'
  3841. * - 'number'
  3842. * - 'date'
  3843. * - 'object'
  3844. * - 'numberStr'
  3845. * Note that if you choose date, your dates should be in a javascript date type
  3846. *
  3847. */
  3848. Grid.prototype.assignTypes = function(){
  3849. var self = this;
  3850. self.options.columnDefs.forEach(function (colDef, index) {
  3851. //Assign colDef type if not specified
  3852. if (!colDef.type) {
  3853. var col = new GridColumn(colDef, index, self);
  3854. var firstRow = self.rows.length > 0 ? self.rows[0] : null;
  3855. if (firstRow) {
  3856. colDef.type = gridUtil.guessType(self.getCellValue(firstRow, col));
  3857. }
  3858. else {
  3859. colDef.type = 'string';
  3860. }
  3861. }
  3862. });
  3863. };
  3864. /**
  3865. * @ngdoc function
  3866. * @name isRowHeaderColumn
  3867. * @methodOf ui.grid.class:Grid
  3868. * @description returns true if the column is a row Header
  3869. * @param {object} column column
  3870. */
  3871. Grid.prototype.isRowHeaderColumn = function isRowHeaderColumn(column) {
  3872. return this.rowHeaderColumns.indexOf(column) !== -1;
  3873. };
  3874. /**
  3875. * @ngdoc function
  3876. * @name addRowHeaderColumn
  3877. * @methodOf ui.grid.class:Grid
  3878. * @description adds a row header column to the grid
  3879. * @param {object} colDef Column definition object.
  3880. * @param {float} order Number that indicates where the column should be placed in the grid.
  3881. * @param {boolean} stopColumnBuild Prevents the buildColumn callback from being triggered. This is useful to improve
  3882. * performance of the grid during initial load.
  3883. */
  3884. Grid.prototype.addRowHeaderColumn = function addRowHeaderColumn(colDef, order, stopColumnBuild) {
  3885. var self = this;
  3886. //default order
  3887. if (order === undefined) {
  3888. order = 0;
  3889. }
  3890. var rowHeaderCol = new GridColumn(colDef, gridUtil.nextUid(), self);
  3891. rowHeaderCol.isRowHeader = true;
  3892. if (self.isRTL()) {
  3893. self.createRightContainer();
  3894. rowHeaderCol.renderContainer = 'right';
  3895. }
  3896. else {
  3897. self.createLeftContainer();
  3898. rowHeaderCol.renderContainer = 'left';
  3899. }
  3900. // relies on the default column builder being first in array, as it is instantiated
  3901. // as part of grid creation
  3902. self.columnBuilders[0](colDef,rowHeaderCol,self.options)
  3903. .then(function(){
  3904. rowHeaderCol.enableFiltering = false;
  3905. rowHeaderCol.enableSorting = false;
  3906. rowHeaderCol.enableHiding = false;
  3907. rowHeaderCol.headerPriority = order;
  3908. self.rowHeaderColumns.push(rowHeaderCol);
  3909. self.rowHeaderColumns = self.rowHeaderColumns.sort(function (a, b) {
  3910. return a.headerPriority - b.headerPriority;
  3911. });
  3912. if (!stopColumnBuild) {
  3913. self.buildColumns()
  3914. .then(function() {
  3915. self.preCompileCellTemplates();
  3916. self.queueGridRefresh();
  3917. }).catch(angular.noop);
  3918. }
  3919. }).catch(angular.noop);
  3920. };
  3921. /**
  3922. * @ngdoc function
  3923. * @name getOnlyDataColumns
  3924. * @methodOf ui.grid.class:Grid
  3925. * @description returns all columns except for rowHeader columns
  3926. */
  3927. Grid.prototype.getOnlyDataColumns = function getOnlyDataColumns() {
  3928. var self = this;
  3929. var cols = [];
  3930. self.columns.forEach(function (col) {
  3931. if (self.rowHeaderColumns.indexOf(col) === -1) {
  3932. cols.push(col);
  3933. }
  3934. });
  3935. return cols;
  3936. };
  3937. /**
  3938. * @ngdoc function
  3939. * @name buildColumns
  3940. * @methodOf ui.grid.class:Grid
  3941. * @description creates GridColumn objects from the columnDefinition. Calls each registered
  3942. * columnBuilder to further process the column
  3943. * @param {object} options An object contains options to use when building columns
  3944. *
  3945. * * **orderByColumnDefs**: defaults to **false**. When true, `buildColumns` will reorder existing columns according to the order within the column definitions.
  3946. *
  3947. * @returns {Promise} a promise to load any needed column resources
  3948. */
  3949. Grid.prototype.buildColumns = function buildColumns(opts) {
  3950. var options = {
  3951. orderByColumnDefs: false
  3952. };
  3953. angular.extend(options, opts);
  3954. // gridUtil.logDebug('buildColumns');
  3955. var self = this;
  3956. var builderPromises = [];
  3957. var headerOffset = self.rowHeaderColumns.length;
  3958. var i;
  3959. // Remove any columns for which a columnDef cannot be found
  3960. // Deliberately don't use forEach, as it doesn't like splice being called in the middle
  3961. // Also don't cache columns.length, as it will change during this operation
  3962. for (i = 0; i < self.columns.length; i++){
  3963. if (!self.getColDef(self.columns[i].name)) {
  3964. self.columns.splice(i, 1);
  3965. i--;
  3966. }
  3967. }
  3968. //add row header columns to the grid columns array _after_ columns without columnDefs have been removed
  3969. //rowHeaderColumns is ordered by priority so insert in reverse
  3970. for (var j = self.rowHeaderColumns.length - 1; j >= 0; j--) {
  3971. self.columns.unshift(self.rowHeaderColumns[j]);
  3972. }
  3973. // look at each column def, and update column properties to match. If the column def
  3974. // doesn't have a column, then splice in a new gridCol
  3975. self.options.columnDefs.forEach(function (colDef, index) {
  3976. self.preprocessColDef(colDef);
  3977. var col = self.getColumn(colDef.name);
  3978. if (!col) {
  3979. col = new GridColumn(colDef, gridUtil.nextUid(), self);
  3980. self.columns.splice(index + headerOffset, 0, col);
  3981. }
  3982. else {
  3983. // tell updateColumnDef that the column was pre-existing
  3984. col.updateColumnDef(colDef, false);
  3985. }
  3986. self.columnBuilders.forEach(function (builder) {
  3987. builderPromises.push(builder.call(self, colDef, col, self.options));
  3988. });
  3989. });
  3990. /*** Reorder columns if necessary ***/
  3991. if (!!options.orderByColumnDefs) {
  3992. // Create a shallow copy of the columns as a cache
  3993. var columnCache = self.columns.slice(0);
  3994. // We need to allow for the "row headers" when mapping from the column defs array to the columns array
  3995. // If we have a row header in columns[0] and don't account for it we'll overwrite it with the column in columnDefs[0]
  3996. // Go through all the column defs, use the shorter of columns length and colDefs.length because if a user has given two columns the same name then
  3997. // columns will be shorter than columnDefs. In this situation we'll avoid an error, but the user will still get an unexpected result
  3998. var len = Math.min(self.options.columnDefs.length, self.columns.length);
  3999. for (i = 0; i < len; i++) {
  4000. // If the column at this index has a different name than the column at the same index in the column defs...
  4001. if (self.columns[i + headerOffset].name !== self.options.columnDefs[i].name) {
  4002. // Replace the one in the cache with the appropriate column
  4003. columnCache[i + headerOffset] = self.getColumn(self.options.columnDefs[i].name);
  4004. }
  4005. else {
  4006. // Otherwise just copy over the one from the initial columns
  4007. columnCache[i + headerOffset] = self.columns[i + headerOffset];
  4008. }
  4009. }
  4010. // Empty out the columns array, non-destructively
  4011. self.columns.length = 0;
  4012. // And splice in the updated, ordered columns from the cache
  4013. Array.prototype.splice.apply(self.columns, [0, 0].concat(columnCache));
  4014. }
  4015. return $q.all(builderPromises).then(function(){
  4016. if (self.rows.length > 0){
  4017. self.assignTypes();
  4018. }
  4019. if (options.preCompileCellTemplates) {
  4020. self.preCompileCellTemplates();
  4021. }
  4022. }).catch(angular.noop);
  4023. };
  4024. Grid.prototype.preCompileCellTemplate = function(col) {
  4025. var self = this;
  4026. var html = col.cellTemplate.replace(uiGridConstants.MODEL_COL_FIELD, self.getQualifiedColField(col));
  4027. html = html.replace(uiGridConstants.COL_FIELD, 'grid.getCellValue(row, col)');
  4028. var compiledElementFn = $compile(html);
  4029. col.compiledElementFn = compiledElementFn;
  4030. if (col.compiledElementFnDefer) {
  4031. col.compiledElementFnDefer.resolve(col.compiledElementFn);
  4032. }
  4033. };
  4034. /**
  4035. * @ngdoc function
  4036. * @name preCompileCellTemplates
  4037. * @methodOf ui.grid.class:Grid
  4038. * @description precompiles all cell templates
  4039. */
  4040. Grid.prototype.preCompileCellTemplates = function() {
  4041. var self = this;
  4042. self.columns.forEach(function (col) {
  4043. if ( col.cellTemplate ){
  4044. self.preCompileCellTemplate( col );
  4045. } else if ( col.cellTemplatePromise ){
  4046. col.cellTemplatePromise.then( function() {
  4047. self.preCompileCellTemplate( col );
  4048. }).catch(angular.noop);
  4049. }
  4050. });
  4051. };
  4052. /**
  4053. * @ngdoc function
  4054. * @name getGridQualifiedColField
  4055. * @methodOf ui.grid.class:Grid
  4056. * @description Returns the $parse-able accessor for a column within its $scope
  4057. * @param {GridColumn} col col object
  4058. */
  4059. Grid.prototype.getQualifiedColField = function (col) {
  4060. var base = 'row.entity';
  4061. if ( col.field === uiGridConstants.ENTITY_BINDING ) {
  4062. return base;
  4063. }
  4064. return gridUtil.preEval(base + '.' + col.field);
  4065. };
  4066. /**
  4067. * @ngdoc function
  4068. * @name createLeftContainer
  4069. * @methodOf ui.grid.class:Grid
  4070. * @description creates the left render container if it doesn't already exist
  4071. */
  4072. Grid.prototype.createLeftContainer = function() {
  4073. if (!this.hasLeftContainer()) {
  4074. this.renderContainers.left = new GridRenderContainer('left', this, { disableColumnOffset: true });
  4075. }
  4076. };
  4077. /**
  4078. * @ngdoc function
  4079. * @name createRightContainer
  4080. * @methodOf ui.grid.class:Grid
  4081. * @description creates the right render container if it doesn't already exist
  4082. */
  4083. Grid.prototype.createRightContainer = function() {
  4084. if (!this.hasRightContainer()) {
  4085. this.renderContainers.right = new GridRenderContainer('right', this, { disableColumnOffset: true });
  4086. }
  4087. };
  4088. /**
  4089. * @ngdoc function
  4090. * @name hasLeftContainer
  4091. * @methodOf ui.grid.class:Grid
  4092. * @description returns true if leftContainer exists
  4093. */
  4094. Grid.prototype.hasLeftContainer = function() {
  4095. return this.renderContainers.left !== undefined;
  4096. };
  4097. /**
  4098. * @ngdoc function
  4099. * @name hasRightContainer
  4100. * @methodOf ui.grid.class:Grid
  4101. * @description returns true if rightContainer exists
  4102. */
  4103. Grid.prototype.hasRightContainer = function() {
  4104. return this.renderContainers.right !== undefined;
  4105. };
  4106. /**
  4107. * undocumented function
  4108. * @name preprocessColDef
  4109. * @methodOf ui.grid.class:Grid
  4110. * @description defaults the name property from field to maintain backwards compatibility with 2.x
  4111. * validates that name or field is present
  4112. */
  4113. Grid.prototype.preprocessColDef = function preprocessColDef(colDef) {
  4114. var self = this;
  4115. if (!colDef.field && !colDef.name) {
  4116. throw new Error('colDef.name or colDef.field property is required');
  4117. }
  4118. //maintain backwards compatibility with 2.x
  4119. //field was required in 2.x. now name is required
  4120. if (colDef.name === undefined && colDef.field !== undefined) {
  4121. // See if the column name already exists:
  4122. var newName = colDef.field,
  4123. counter = 2;
  4124. while (self.getColumn(newName)) {
  4125. newName = colDef.field + counter.toString();
  4126. counter++;
  4127. }
  4128. colDef.name = newName;
  4129. }
  4130. };
  4131. // Return a list of items that exist in the `n` array but not the `o` array. Uses optional property accessors passed as third & fourth parameters
  4132. Grid.prototype.newInN = function newInN(o, n, oAccessor, nAccessor) {
  4133. var self = this;
  4134. var t = [];
  4135. for (var i = 0; i < n.length; i++) {
  4136. var nV = nAccessor ? n[i][nAccessor] : n[i];
  4137. var found = false;
  4138. for (var j = 0; j < o.length; j++) {
  4139. var oV = oAccessor ? o[j][oAccessor] : o[j];
  4140. if (self.options.rowEquality(nV, oV)) {
  4141. found = true;
  4142. break;
  4143. }
  4144. }
  4145. if (!found) {
  4146. t.push(nV);
  4147. }
  4148. }
  4149. return t;
  4150. };
  4151. /**
  4152. * @ngdoc function
  4153. * @name getRow
  4154. * @methodOf ui.grid.class:Grid
  4155. * @description returns the GridRow that contains the rowEntity
  4156. * @param {object} rowEntity the gridOptions.data array element instance
  4157. * @param {array} lookInRows [optional] the rows to look in - if not provided then
  4158. * looks in grid.rows
  4159. */
  4160. Grid.prototype.getRow = function getRow(rowEntity, lookInRows) {
  4161. var self = this;
  4162. lookInRows = typeof(lookInRows) === 'undefined' ? self.rows : lookInRows;
  4163. var rows = lookInRows.filter(function (row) {
  4164. return self.options.rowEquality(row.entity, rowEntity);
  4165. });
  4166. return rows.length > 0 ? rows[0] : null;
  4167. };
  4168. /**
  4169. * @ngdoc function
  4170. * @name modifyRows
  4171. * @methodOf ui.grid.class:Grid
  4172. * @description creates or removes GridRow objects from the newRawData array. Calls each registered
  4173. * rowBuilder to further process the row
  4174. * @param {array} newRawData Modified set of data
  4175. *
  4176. * This method aims to achieve three things:
  4177. * 1. the resulting rows array is in the same order as the newRawData, we'll call
  4178. * rowsProcessors immediately after to sort the data anyway
  4179. * 2. if we have row hashing available, we try to use the rowHash to find the row
  4180. * 3. no memory leaks - rows that are no longer in newRawData need to be garbage collected
  4181. *
  4182. * The basic logic flow makes use of the newRawData, oldRows and oldHash, and creates
  4183. * the newRows and newHash
  4184. *
  4185. * ```
  4186. * newRawData.forEach newEntity
  4187. * if (hashing enabled)
  4188. * check oldHash for newEntity
  4189. * else
  4190. * look for old row directly in oldRows
  4191. * if !oldRowFound // must be a new row
  4192. * create newRow
  4193. * append to the newRows and add to newHash
  4194. * run the processors
  4195. * ```
  4196. *
  4197. * Rows are identified using the hashKey if configured. If not configured, then rows
  4198. * are identified using the gridOptions.rowEquality function
  4199. *
  4200. * This method is useful when trying to select rows immediately after loading data without
  4201. * using a $timeout/$interval, e.g.:
  4202. *
  4203. * $scope.gridOptions.data = someData;
  4204. * $scope.gridApi.grid.modifyRows($scope.gridOptions.data);
  4205. * $scope.gridApi.selection.selectRow($scope.gridOptions.data[0]);
  4206. *
  4207. * OR to persist row selection after data update (e.g. rows selected, new data loaded, want
  4208. * originally selected rows to be re-selected))
  4209. */
  4210. Grid.prototype.modifyRows = function modifyRows(newRawData) {
  4211. var self = this;
  4212. var oldRows = self.rows.slice(0);
  4213. var oldRowHash = self.rowHashMap || self.createRowHashMap();
  4214. var allRowsSelected = true;
  4215. self.rowHashMap = self.createRowHashMap();
  4216. self.rows.length = 0;
  4217. newRawData.forEach( function( newEntity, i ) {
  4218. var newRow, oldRow;
  4219. if ( self.options.enableRowHashing ){
  4220. // if hashing is enabled, then this row will be in the hash if we already know about it
  4221. oldRow = oldRowHash.get( newEntity );
  4222. } else {
  4223. // otherwise, manually search the oldRows to see if we can find this row
  4224. oldRow = self.getRow(newEntity, oldRows);
  4225. }
  4226. // update newRow to have an entity
  4227. if ( oldRow ) {
  4228. newRow = oldRow;
  4229. newRow.entity = newEntity;
  4230. }
  4231. // if we didn't find the row, it must be new, so create it
  4232. if ( !newRow ){
  4233. newRow = self.processRowBuilders(new GridRow(newEntity, i, self));
  4234. }
  4235. self.rows.push( newRow );
  4236. self.rowHashMap.put( newEntity, newRow );
  4237. if (!newRow.isSelected) {
  4238. allRowsSelected = false;
  4239. }
  4240. });
  4241. if (self.selection) {
  4242. self.selection.selectAll = allRowsSelected;
  4243. }
  4244. self.assignTypes();
  4245. var p1 = $q.when(self.processRowsProcessors(self.rows))
  4246. .then(function (renderableRows) {
  4247. return self.setVisibleRows(renderableRows);
  4248. }).catch(angular.noop);
  4249. var p2 = $q.when(self.processColumnsProcessors(self.columns))
  4250. .then(function (renderableColumns) {
  4251. return self.setVisibleColumns(renderableColumns);
  4252. }).catch(angular.noop);
  4253. return $q.all([p1, p2]);
  4254. };
  4255. /**
  4256. * Private Undocumented Method
  4257. * @name addRows
  4258. * @methodOf ui.grid.class:Grid
  4259. * @description adds the newRawData array of rows to the grid and calls all registered
  4260. * rowBuilders. this keyword will reference the grid
  4261. */
  4262. Grid.prototype.addRows = function addRows(newRawData) {
  4263. var self = this;
  4264. var existingRowCount = self.rows.length;
  4265. for (var i = 0; i < newRawData.length; i++) {
  4266. var newRow = self.processRowBuilders(new GridRow(newRawData[i], i + existingRowCount, self));
  4267. if (self.options.enableRowHashing) {
  4268. var found = self.rowHashMap.get(newRow.entity);
  4269. if (found) {
  4270. found.row = newRow;
  4271. }
  4272. }
  4273. self.rows.push(newRow);
  4274. }
  4275. };
  4276. /**
  4277. * @ngdoc function
  4278. * @name processRowBuilders
  4279. * @methodOf ui.grid.class:Grid
  4280. * @description processes all RowBuilders for the gridRow
  4281. * @param {GridRow} gridRow reference to gridRow
  4282. * @returns {GridRow} the gridRow with all additional behavior added
  4283. */
  4284. Grid.prototype.processRowBuilders = function processRowBuilders(gridRow) {
  4285. var self = this;
  4286. self.rowBuilders.forEach(function (builder) {
  4287. builder.call(self, gridRow, self.options);
  4288. });
  4289. return gridRow;
  4290. };
  4291. /**
  4292. * @ngdoc function
  4293. * @name registerStyleComputation
  4294. * @methodOf ui.grid.class:Grid
  4295. * @description registered a styleComputation function
  4296. *
  4297. * If the function returns a value it will be appended into the grid's `<style>` block
  4298. * @param {function($scope)} styleComputation function
  4299. */
  4300. Grid.prototype.registerStyleComputation = function registerStyleComputation(styleComputationInfo) {
  4301. this.styleComputations.push(styleComputationInfo);
  4302. };
  4303. // NOTE (c0bra): We already have rowBuilders. I think these do exactly the same thing...
  4304. // Grid.prototype.registerRowFilter = function(filter) {
  4305. // // TODO(c0bra): validate filter?
  4306. // this.rowFilters.push(filter);
  4307. // };
  4308. // Grid.prototype.removeRowFilter = function(filter) {
  4309. // var idx = this.rowFilters.indexOf(filter);
  4310. // if (typeof(idx) !== 'undefined' && idx !== undefined) {
  4311. // this.rowFilters.slice(idx, 1);
  4312. // }
  4313. // };
  4314. // Grid.prototype.processRowFilters = function(rows) {
  4315. // var self = this;
  4316. // self.rowFilters.forEach(function (filter) {
  4317. // filter.call(self, rows);
  4318. // });
  4319. // };
  4320. /**
  4321. * @ngdoc function
  4322. * @name registerRowsProcessor
  4323. * @methodOf ui.grid.class:Grid
  4324. * @description
  4325. *
  4326. * Register a "rows processor" function. When the rows are updated,
  4327. * the grid calls each registered "rows processor", which has a chance
  4328. * to alter the set of rows (sorting, etc) as long as the count is not
  4329. * modified.
  4330. *
  4331. * @param {function(renderedRowsToProcess, columns )} processorFunction rows processor function, which
  4332. * is run in the context of the grid (i.e. this for the function will be the grid), and must
  4333. * return the updated rows list, which is passed to the next processor in the chain
  4334. * @param {number} priority the priority of this processor. In general we try to do them in 100s to leave room
  4335. * for other people to inject rows processors at intermediate priorities. Lower priority rowsProcessors run earlier.
  4336. *
  4337. * At present all rows visible is running at 50, filter is running at 100, sort is at 200, grouping at 400, selectable rows at 500, pagination at 900 (pagination will generally want to be last)
  4338. *
  4339. */
  4340. Grid.prototype.registerRowsProcessor = function registerRowsProcessor(processor, priority) {
  4341. if (!angular.isFunction(processor)) {
  4342. throw 'Attempt to register non-function rows processor: ' + processor;
  4343. }
  4344. this.rowsProcessors.push({processor: processor, priority: priority});
  4345. this.rowsProcessors.sort(function sortByPriority( a, b ){
  4346. return a.priority - b.priority;
  4347. });
  4348. };
  4349. /**
  4350. * @ngdoc function
  4351. * @name removeRowsProcessor
  4352. * @methodOf ui.grid.class:Grid
  4353. * @param {function(renderableRows)} rows processor function
  4354. * @description Remove a registered rows processor
  4355. */
  4356. Grid.prototype.removeRowsProcessor = function removeRowsProcessor(processor) {
  4357. var idx = -1;
  4358. this.rowsProcessors.forEach(function(rowsProcessor, index){
  4359. if ( rowsProcessor.processor === processor ){
  4360. idx = index;
  4361. }
  4362. });
  4363. if ( idx !== -1 ) {
  4364. this.rowsProcessors.splice(idx, 1);
  4365. }
  4366. };
  4367. /**
  4368. * Private Undocumented Method
  4369. * @name processRowsProcessors
  4370. * @methodOf ui.grid.class:Grid
  4371. * @param {Array[GridRow]} The array of "renderable" rows
  4372. * @param {Array[GridColumn]} The array of columns
  4373. * @description Run all the registered rows processors on the array of renderable rows
  4374. */
  4375. Grid.prototype.processRowsProcessors = function processRowsProcessors(renderableRows) {
  4376. var self = this;
  4377. // Create a shallow copy of the rows so that we can safely sort them without altering the original grid.rows sort order
  4378. var myRenderableRows = renderableRows.slice(0);
  4379. // Return myRenderableRows with no processing if we have no rows processors
  4380. if (self.rowsProcessors.length === 0) {
  4381. return $q.when(myRenderableRows);
  4382. }
  4383. // Counter for iterating through rows processors
  4384. var i = 0;
  4385. // Promise for when we're done with all the processors
  4386. var finished = $q.defer();
  4387. // This function will call the processor in self.rowsProcessors at index 'i', and then
  4388. // when done will call the next processor in the list, using the output from the processor
  4389. // at i as the argument for 'renderedRowsToProcess' on the next iteration.
  4390. //
  4391. // If we're at the end of the list of processors, we resolve our 'finished' callback with
  4392. // the result.
  4393. function startProcessor(i, renderedRowsToProcess) {
  4394. // Get the processor at 'i'
  4395. var processor = self.rowsProcessors[i].processor;
  4396. // Call the processor, passing in the rows to process and the current columns
  4397. // (note: it's wrapped in $q.when() in case the processor does not return a promise)
  4398. return $q.when( processor.call(self, renderedRowsToProcess, self.columns) )
  4399. .then(function handleProcessedRows(processedRows) {
  4400. // Check for errors
  4401. if (!processedRows) {
  4402. throw "Processor at index " + i + " did not return a set of renderable rows";
  4403. }
  4404. if (!angular.isArray(processedRows)) {
  4405. throw "Processor at index " + i + " did not return an array";
  4406. }
  4407. // Processor is done, increment the counter
  4408. i++;
  4409. // If we're not done with the processors, call the next one
  4410. if (i <= self.rowsProcessors.length - 1) {
  4411. return startProcessor(i, processedRows);
  4412. }
  4413. // We're done! Resolve the 'finished' promise
  4414. else {
  4415. finished.resolve(processedRows);
  4416. }
  4417. }).catch(function(error) {
  4418. throw error;
  4419. });
  4420. }
  4421. // Start on the first processor
  4422. startProcessor(0, myRenderableRows);
  4423. return finished.promise;
  4424. };
  4425. Grid.prototype.setVisibleRows = function setVisibleRows(rows) {
  4426. var self = this;
  4427. // Reset all the render container row caches
  4428. for (var i in self.renderContainers) {
  4429. var container = self.renderContainers[i];
  4430. container.canvasHeightShouldUpdate = true;
  4431. if ( typeof(container.visibleRowCache) === 'undefined' ){
  4432. container.visibleRowCache = [];
  4433. } else {
  4434. container.visibleRowCache.length = 0;
  4435. }
  4436. }
  4437. // rows.forEach(function (row) {
  4438. for (var ri = 0; ri < rows.length; ri++) {
  4439. var row = rows[ri];
  4440. var targetContainer = (typeof(row.renderContainer) !== 'undefined' && row.renderContainer) ? row.renderContainer : 'body';
  4441. // If the row is visible
  4442. if (row.visible) {
  4443. self.renderContainers[targetContainer].visibleRowCache.push(row);
  4444. }
  4445. }
  4446. self.api.core.raise.rowsVisibleChanged(this.api);
  4447. self.api.core.raise.rowsRendered(this.api);
  4448. };
  4449. /**
  4450. * @ngdoc function
  4451. * @name registerColumnsProcessor
  4452. * @methodOf ui.grid.class:Grid
  4453. * @param {function(renderedColumnsToProcess, rows)} columnProcessor column processor function, which
  4454. * is run in the context of the grid (i.e. this for the function will be the grid), and
  4455. * which must return an updated renderedColumnsToProcess which can be passed to the next processor
  4456. * in the chain
  4457. * @param {number} priority the priority of this processor. In general we try to do them in 100s to leave room
  4458. * for other people to inject columns processors at intermediate priorities. Lower priority columnsProcessors run earlier.
  4459. *
  4460. * At present all rows visible is running at 50, filter is running at 100, sort is at 200, grouping at 400, selectable rows at 500, pagination at 900 (pagination will generally want to be last)
  4461. * @description
  4462. Register a "columns processor" function. When the columns are updated,
  4463. the grid calls each registered "columns processor", which has a chance
  4464. to alter the set of columns, as long as the count is not modified.
  4465. */
  4466. Grid.prototype.registerColumnsProcessor = function registerColumnsProcessor(processor, priority) {
  4467. if (!angular.isFunction(processor)) {
  4468. throw 'Attempt to register non-function rows processor: ' + processor;
  4469. }
  4470. this.columnsProcessors.push({processor: processor, priority: priority});
  4471. this.columnsProcessors.sort(function sortByPriority( a, b ){
  4472. return a.priority - b.priority;
  4473. });
  4474. };
  4475. Grid.prototype.removeColumnsProcessor = function removeColumnsProcessor(processor) {
  4476. var idx = this.columnsProcessors.indexOf(processor);
  4477. if (typeof(idx) !== 'undefined' && idx !== undefined) {
  4478. this.columnsProcessors.splice(idx, 1);
  4479. }
  4480. };
  4481. Grid.prototype.processColumnsProcessors = function processColumnsProcessors(renderableColumns) {
  4482. var self = this;
  4483. // Create a shallow copy of the rows so that we can safely sort them without altering the original grid.rows sort order
  4484. var myRenderableColumns = renderableColumns.slice(0);
  4485. // Return myRenderableRows with no processing if we have no rows processors
  4486. if (self.columnsProcessors.length === 0) {
  4487. return $q.when(myRenderableColumns);
  4488. }
  4489. // Counter for iterating through rows processors
  4490. var i = 0;
  4491. // Promise for when we're done with all the processors
  4492. var finished = $q.defer();
  4493. // This function will call the processor in self.rowsProcessors at index 'i', and then
  4494. // when done will call the next processor in the list, using the output from the processor
  4495. // at i as the argument for 'renderedRowsToProcess' on the next iteration.
  4496. //
  4497. // If we're at the end of the list of processors, we resolve our 'finished' callback with
  4498. // the result.
  4499. function startProcessor(i, renderedColumnsToProcess) {
  4500. // Get the processor at 'i'
  4501. var processor = self.columnsProcessors[i].processor;
  4502. // Call the processor, passing in the rows to process and the current columns
  4503. // (note: it's wrapped in $q.when() in case the processor does not return a promise)
  4504. return $q.when( processor.call(self, renderedColumnsToProcess, self.rows) )
  4505. .then(function handleProcessedRows(processedColumns) {
  4506. // Check for errors
  4507. if (!processedColumns) {
  4508. throw "Processor at index " + i + " did not return a set of renderable rows";
  4509. }
  4510. if (!angular.isArray(processedColumns)) {
  4511. throw "Processor at index " + i + " did not return an array";
  4512. }
  4513. // Processor is done, increment the counter
  4514. i++;
  4515. // If we're not done with the processors, call the next one
  4516. if (i <= self.columnsProcessors.length - 1) {
  4517. return startProcessor(i, myRenderableColumns);
  4518. }
  4519. // We're done! Resolve the 'finished' promise
  4520. else {
  4521. finished.resolve(myRenderableColumns);
  4522. }
  4523. }).catch(angular.noop);
  4524. }
  4525. // Start on the first processor
  4526. startProcessor(0, myRenderableColumns);
  4527. return finished.promise;
  4528. };
  4529. Grid.prototype.setVisibleColumns = function setVisibleColumns(columns) {
  4530. // gridUtil.logDebug('setVisibleColumns');
  4531. var self = this;
  4532. // Reset all the render container row caches
  4533. for (var i in self.renderContainers) {
  4534. var container = self.renderContainers[i];
  4535. container.visibleColumnCache.length = 0;
  4536. }
  4537. for (var ci = 0; ci < columns.length; ci++) {
  4538. var column = columns[ci];
  4539. // If the column is visible
  4540. if (column.visible) {
  4541. // If the column has a container specified
  4542. if (typeof(column.renderContainer) !== 'undefined' && column.renderContainer) {
  4543. self.renderContainers[column.renderContainer].visibleColumnCache.push(column);
  4544. }
  4545. // If not, put it into the body container
  4546. else {
  4547. self.renderContainers.body.visibleColumnCache.push(column);
  4548. }
  4549. }
  4550. }
  4551. };
  4552. /**
  4553. * @ngdoc function
  4554. * @name handleWindowResize
  4555. * @methodOf ui.grid.class:Grid
  4556. * @description Triggered when the browser window resizes; automatically resizes the grid
  4557. * @returns {Promise} A resolved promise once the window resize has completed.
  4558. */
  4559. Grid.prototype.handleWindowResize = function handleWindowResize($event) {
  4560. var self = this;
  4561. self.gridWidth = gridUtil.elementWidth(self.element);
  4562. self.gridHeight = gridUtil.elementHeight(self.element);
  4563. return self.queueRefresh();
  4564. };
  4565. /**
  4566. * @ngdoc function
  4567. * @name queueRefresh
  4568. * @methodOf ui.grid.class:Grid
  4569. * @description queues a grid refreshCanvas, a way of debouncing all the refreshes we might otherwise issue
  4570. */
  4571. Grid.prototype.queueRefresh = function queueRefresh() {
  4572. var self = this;
  4573. if (self.refreshCanceller) {
  4574. $timeout.cancel(self.refreshCanceller);
  4575. }
  4576. self.refreshCanceller = $timeout(function () {
  4577. self.refreshCanvas(true);
  4578. });
  4579. self.refreshCanceller.then(function () {
  4580. self.refreshCanceller = null;
  4581. }).catch(angular.noop);
  4582. return self.refreshCanceller;
  4583. };
  4584. /**
  4585. * @ngdoc function
  4586. * @name queueGridRefresh
  4587. * @methodOf ui.grid.class:Grid
  4588. * @description queues a grid refresh, a way of debouncing all the refreshes we might otherwise issue
  4589. */
  4590. Grid.prototype.queueGridRefresh = function queueGridRefresh() {
  4591. var self = this;
  4592. if (self.gridRefreshCanceller) {
  4593. $timeout.cancel(self.gridRefreshCanceller);
  4594. }
  4595. self.gridRefreshCanceller = $timeout(function () {
  4596. self.refresh(true);
  4597. });
  4598. self.gridRefreshCanceller.then(function () {
  4599. self.gridRefreshCanceller = null;
  4600. }).catch(angular.noop);
  4601. return self.gridRefreshCanceller;
  4602. };
  4603. /**
  4604. * @ngdoc function
  4605. * @name updateCanvasHeight
  4606. * @methodOf ui.grid.class:Grid
  4607. * @description flags all render containers to update their canvas height
  4608. */
  4609. Grid.prototype.updateCanvasHeight = function updateCanvasHeight() {
  4610. var self = this;
  4611. for (var containerId in self.renderContainers) {
  4612. if (self.renderContainers.hasOwnProperty(containerId)) {
  4613. var container = self.renderContainers[containerId];
  4614. container.canvasHeightShouldUpdate = true;
  4615. }
  4616. }
  4617. };
  4618. /**
  4619. * @ngdoc function
  4620. * @name buildStyles
  4621. * @methodOf ui.grid.class:Grid
  4622. * @description calls each styleComputation function
  4623. */
  4624. Grid.prototype.buildStyles = function buildStyles() {
  4625. var self = this;
  4626. // gridUtil.logDebug('buildStyles');
  4627. self.customStyles = '';
  4628. self.styleComputations
  4629. .sort(function(a, b) {
  4630. if (a.priority === null) { return 1; }
  4631. if (b.priority === null) { return -1; }
  4632. if (a.priority === null && b.priority === null) { return 0; }
  4633. return a.priority - b.priority;
  4634. })
  4635. .forEach(function (compInfo) {
  4636. // this used to provide $scope as a second parameter, but I couldn't find any
  4637. // style builders that used it, so removed it as part of moving to grid from controller
  4638. var ret = compInfo.func.call(self);
  4639. if (angular.isString(ret)) {
  4640. self.customStyles += '\n' + ret;
  4641. }
  4642. });
  4643. };
  4644. Grid.prototype.minColumnsToRender = function minColumnsToRender() {
  4645. var self = this;
  4646. var viewport = this.getViewportWidth();
  4647. var min = 0;
  4648. var totalWidth = 0;
  4649. self.columns.forEach(function(col, i) {
  4650. if (totalWidth < viewport) {
  4651. totalWidth += col.drawnWidth;
  4652. min++;
  4653. }
  4654. else {
  4655. var currWidth = 0;
  4656. for (var j = i; j >= i - min; j--) {
  4657. currWidth += self.columns[j].drawnWidth;
  4658. }
  4659. if (currWidth < viewport) {
  4660. min++;
  4661. }
  4662. }
  4663. });
  4664. return min;
  4665. };
  4666. Grid.prototype.getBodyHeight = function getBodyHeight() {
  4667. // Start with the viewportHeight
  4668. var bodyHeight = this.getViewportHeight();
  4669. // Add the horizontal scrollbar height if there is one
  4670. //if (typeof(this.horizontalScrollbarHeight) !== 'undefined' && this.horizontalScrollbarHeight !== undefined && this.horizontalScrollbarHeight > 0) {
  4671. // bodyHeight = bodyHeight + this.horizontalScrollbarHeight;
  4672. //}
  4673. return bodyHeight;
  4674. };
  4675. // NOTE: viewport drawable height is the height of the grid minus the header row height (including any border)
  4676. // TODO(c0bra): account for footer height
  4677. Grid.prototype.getViewportHeight = function getViewportHeight() {
  4678. var self = this;
  4679. var viewPortHeight = this.gridHeight - this.headerHeight - this.footerHeight;
  4680. // Account for native horizontal scrollbar, if present
  4681. //if (typeof(this.horizontalScrollbarHeight) !== 'undefined' && this.horizontalScrollbarHeight !== undefined && this.horizontalScrollbarHeight > 0) {
  4682. // viewPortHeight = viewPortHeight - this.horizontalScrollbarHeight;
  4683. //}
  4684. var adjustment = self.getViewportAdjustment();
  4685. viewPortHeight = viewPortHeight + adjustment.height;
  4686. //gridUtil.logDebug('viewPortHeight', viewPortHeight);
  4687. return viewPortHeight;
  4688. };
  4689. Grid.prototype.getViewportWidth = function getViewportWidth() {
  4690. var self = this;
  4691. var viewPortWidth = this.gridWidth;
  4692. //if (typeof(this.verticalScrollbarWidth) !== 'undefined' && this.verticalScrollbarWidth !== undefined && this.verticalScrollbarWidth > 0) {
  4693. // viewPortWidth = viewPortWidth - this.verticalScrollbarWidth;
  4694. //}
  4695. var adjustment = self.getViewportAdjustment();
  4696. viewPortWidth = viewPortWidth + adjustment.width;
  4697. //gridUtil.logDebug('getviewPortWidth', viewPortWidth);
  4698. return viewPortWidth;
  4699. };
  4700. Grid.prototype.getHeaderViewportWidth = function getHeaderViewportWidth() {
  4701. var viewPortWidth = this.getViewportWidth();
  4702. //if (typeof(this.verticalScrollbarWidth) !== 'undefined' && this.verticalScrollbarWidth !== undefined && this.verticalScrollbarWidth > 0) {
  4703. // viewPortWidth = viewPortWidth + this.verticalScrollbarWidth;
  4704. //}
  4705. return viewPortWidth;
  4706. };
  4707. Grid.prototype.addVerticalScrollSync = function (containerId, callBackFn) {
  4708. this.verticalScrollSyncCallBackFns[containerId] = callBackFn;
  4709. };
  4710. Grid.prototype.addHorizontalScrollSync = function (containerId, callBackFn) {
  4711. this.horizontalScrollSyncCallBackFns[containerId] = callBackFn;
  4712. };
  4713. /**
  4714. * Scroll needed containers by calling their ScrollSyncs
  4715. * @param sourceContainerId the containerId that has already set it's top/left.
  4716. * can be empty string which means all containers need to set top/left
  4717. * @param scrollEvent
  4718. */
  4719. Grid.prototype.scrollContainers = function (sourceContainerId, scrollEvent) {
  4720. if (scrollEvent.y) {
  4721. //default for no container Id (ex. mousewheel means that all containers must set scrollTop/Left)
  4722. var verts = ['body','left', 'right'];
  4723. this.flagScrollingVertically(scrollEvent);
  4724. if (sourceContainerId === 'body') {
  4725. verts = ['left', 'right'];
  4726. }
  4727. else if (sourceContainerId === 'left') {
  4728. verts = ['body', 'right'];
  4729. }
  4730. else if (sourceContainerId === 'right') {
  4731. verts = ['body', 'left'];
  4732. }
  4733. for (var i = 0; i < verts.length; i++) {
  4734. var id = verts[i];
  4735. if (this.verticalScrollSyncCallBackFns[id]) {
  4736. this.verticalScrollSyncCallBackFns[id](scrollEvent);
  4737. }
  4738. }
  4739. }
  4740. if (scrollEvent.x) {
  4741. //default for no container Id (ex. mousewheel means that all containers must set scrollTop/Left)
  4742. var horizs = ['body','bodyheader', 'bodyfooter'];
  4743. this.flagScrollingHorizontally(scrollEvent);
  4744. if (sourceContainerId === 'body') {
  4745. horizs = ['bodyheader', 'bodyfooter'];
  4746. }
  4747. for (var j = 0; j < horizs.length; j++) {
  4748. var idh = horizs[j];
  4749. if (this.horizontalScrollSyncCallBackFns[idh]) {
  4750. this.horizontalScrollSyncCallBackFns[idh](scrollEvent);
  4751. }
  4752. }
  4753. }
  4754. };
  4755. Grid.prototype.registerViewportAdjuster = function registerViewportAdjuster(func) {
  4756. this.viewportAdjusters.push(func);
  4757. };
  4758. Grid.prototype.removeViewportAdjuster = function registerViewportAdjuster(func) {
  4759. var idx = this.viewportAdjusters.indexOf(func);
  4760. if (typeof(idx) !== 'undefined' && idx !== undefined) {
  4761. this.viewportAdjusters.splice(idx, 1);
  4762. }
  4763. };
  4764. Grid.prototype.getViewportAdjustment = function getViewportAdjustment() {
  4765. var self = this;
  4766. var adjustment = { height: 0, width: 0 };
  4767. self.viewportAdjusters.forEach(function (func) {
  4768. adjustment = func.call(this, adjustment);
  4769. });
  4770. return adjustment;
  4771. };
  4772. Grid.prototype.getVisibleRowCount = function getVisibleRowCount() {
  4773. // var count = 0;
  4774. // this.rows.forEach(function (row) {
  4775. // if (row.visible) {
  4776. // count++;
  4777. // }
  4778. // });
  4779. // return this.visibleRowCache.length;
  4780. return this.renderContainers.body.visibleRowCache.length;
  4781. };
  4782. Grid.prototype.getVisibleRows = function getVisibleRows() {
  4783. return this.renderContainers.body.visibleRowCache;
  4784. };
  4785. Grid.prototype.getVisibleColumnCount = function getVisibleColumnCount() {
  4786. // var count = 0;
  4787. // this.rows.forEach(function (row) {
  4788. // if (row.visible) {
  4789. // count++;
  4790. // }
  4791. // });
  4792. // return this.visibleRowCache.length;
  4793. return this.renderContainers.body.visibleColumnCache.length;
  4794. };
  4795. Grid.prototype.searchRows = function searchRows(renderableRows) {
  4796. return rowSearcher.search(this, renderableRows, this.columns);
  4797. };
  4798. Grid.prototype.sortByColumn = function sortByColumn(renderableRows) {
  4799. return rowSorter.sort(this, renderableRows, this.columns);
  4800. };
  4801. /**
  4802. * @ngdoc function
  4803. * @name getCellValue
  4804. * @methodOf ui.grid.class:Grid
  4805. * @description Gets the value of a cell for a particular row and column
  4806. * @param {GridRow} row Row to access
  4807. * @param {GridColumn} col Column to access
  4808. */
  4809. Grid.prototype.getCellValue = function getCellValue(row, col){
  4810. if ( typeof(row.entity[ '$$' + col.uid ]) !== 'undefined' ) {
  4811. return row.entity[ '$$' + col.uid].rendered;
  4812. } else if (this.options.flatEntityAccess && typeof(col.field) !== 'undefined' ){
  4813. return row.entity[col.field];
  4814. } else {
  4815. if (!col.cellValueGetterCache) {
  4816. col.cellValueGetterCache = $parse(row.getEntityQualifiedColField(col));
  4817. }
  4818. return col.cellValueGetterCache(row);
  4819. }
  4820. };
  4821. /**
  4822. * @ngdoc function
  4823. * @name getCellDisplayValue
  4824. * @methodOf ui.grid.class:Grid
  4825. * @description Gets the displayed value of a cell after applying any the `cellFilter`
  4826. * @param {GridRow} row Row to access
  4827. * @param {GridColumn} col Column to access
  4828. */
  4829. Grid.prototype.getCellDisplayValue = function getCellDisplayValue(row, col) {
  4830. if ( !col.cellDisplayGetterCache ) {
  4831. var custom_filter = col.cellFilter ? " | " + col.cellFilter : "";
  4832. if (typeof(row.entity['$$' + col.uid]) !== 'undefined') {
  4833. col.cellDisplayGetterCache = $parse(row.entity['$$' + col.uid].rendered + custom_filter);
  4834. } else if (this.options.flatEntityAccess && typeof(col.field) !== 'undefined') {
  4835. var colField = col.field.replace(/(')|(\\)/g, "\\$&");
  4836. col.cellDisplayGetterCache = $parse('entity[\'' + colField + '\']' + custom_filter);
  4837. } else {
  4838. col.cellDisplayGetterCache = $parse(row.getEntityQualifiedColField(col) + custom_filter);
  4839. }
  4840. }
  4841. var rowWithCol = angular.extend({}, row, {col: col});
  4842. return col.cellDisplayGetterCache(rowWithCol);
  4843. };
  4844. Grid.prototype.getNextColumnSortPriority = function getNextColumnSortPriority() {
  4845. var self = this,
  4846. p = 0;
  4847. self.columns.forEach(function (col) {
  4848. if (col.sort && col.sort.priority !== undefined && col.sort.priority >= p) {
  4849. p = col.sort.priority + 1;
  4850. }
  4851. });
  4852. return p;
  4853. };
  4854. /**
  4855. * @ngdoc function
  4856. * @name resetColumnSorting
  4857. * @methodOf ui.grid.class:Grid
  4858. * @description Return the columns that the grid is currently being sorted by
  4859. * @param {GridColumn} [excludedColumn] Optional GridColumn to exclude from having its sorting reset
  4860. */
  4861. Grid.prototype.resetColumnSorting = function resetColumnSorting(excludeCol) {
  4862. var self = this;
  4863. self.columns.forEach(function (col) {
  4864. if (col !== excludeCol && !col.suppressRemoveSort) {
  4865. col.sort = {};
  4866. }
  4867. });
  4868. };
  4869. /**
  4870. * @ngdoc function
  4871. * @name getColumnSorting
  4872. * @methodOf ui.grid.class:Grid
  4873. * @description Return the columns that the grid is currently being sorted by
  4874. * @returns {Array[GridColumn]} An array of GridColumn objects
  4875. */
  4876. Grid.prototype.getColumnSorting = function getColumnSorting() {
  4877. var self = this;
  4878. var sortedCols = [], myCols;
  4879. // Iterate through all the columns, sorted by priority
  4880. // Make local copy of column list, because sorting is in-place and we do not want to
  4881. // change the original sequence of columns
  4882. myCols = self.columns.slice(0);
  4883. myCols.sort(rowSorter.prioritySort).forEach(function (col) {
  4884. if (col.sort && typeof(col.sort.direction) !== 'undefined' && col.sort.direction && (col.sort.direction === uiGridConstants.ASC || col.sort.direction === uiGridConstants.DESC)) {
  4885. sortedCols.push(col);
  4886. }
  4887. });
  4888. return sortedCols;
  4889. };
  4890. /**
  4891. * @ngdoc function
  4892. * @name sortColumn
  4893. * @methodOf ui.grid.class:Grid
  4894. * @description Set the sorting on a given column, optionally resetting any existing sorting on the Grid.
  4895. * Emits the sortChanged event whenever the sort criteria are changed.
  4896. * @param {GridColumn} column Column to set the sorting on
  4897. * @param {uiGridConstants.ASC|uiGridConstants.DESC} [direction] Direction to sort by, either descending or ascending.
  4898. * If not provided, the column will iterate through the sort directions
  4899. * specified in the {@link ui.grid.class:GridOptions.columnDef#sortDirectionCycle sortDirectionCycle} attribute.
  4900. * @param {boolean} [add] Add this column to the sorting. If not provided or set to `false`, the Grid will reset any existing sorting and sort
  4901. * by this column only
  4902. * @returns {Promise} A resolved promise that supplies the column.
  4903. */
  4904. Grid.prototype.sortColumn = function sortColumn(column, directionOrAdd, add) {
  4905. var self = this,
  4906. direction = null;
  4907. if (typeof(column) === 'undefined' || !column) {
  4908. throw new Error('No column parameter provided');
  4909. }
  4910. // Second argument can either be a direction or whether to add this column to the existing sort.
  4911. // If it's a boolean, it's an add, otherwise, it's a direction
  4912. if (typeof(directionOrAdd) === 'boolean') {
  4913. add = directionOrAdd;
  4914. }
  4915. else {
  4916. direction = directionOrAdd;
  4917. }
  4918. if (!add) {
  4919. self.resetColumnSorting(column);
  4920. column.sort.priority = undefined;
  4921. // Get the actual priority since there may be columns which have suppressRemoveSort set
  4922. column.sort.priority = self.getNextColumnSortPriority();
  4923. }
  4924. else if (column.sort.priority === undefined){
  4925. column.sort.priority = self.getNextColumnSortPriority();
  4926. }
  4927. if (!direction) {
  4928. // Find the current position in the cycle (or -1).
  4929. var i = column.sortDirectionCycle.indexOf(column.sort.direction ? column.sort.direction : null);
  4930. // Proceed to the next position in the cycle (or start at the beginning).
  4931. i = (i+1) % column.sortDirectionCycle.length;
  4932. // If suppressRemoveSort is set, and the next position in the cycle would
  4933. // remove the sort, skip it.
  4934. if (column.colDef && column.suppressRemoveSort && !column.sortDirectionCycle[i]) {
  4935. i = (i+1) % column.sortDirectionCycle.length;
  4936. }
  4937. if (column.sortDirectionCycle[i]) {
  4938. column.sort.direction = column.sortDirectionCycle[i];
  4939. } else {
  4940. removeSortOfColumn(column, self);
  4941. }
  4942. }
  4943. else {
  4944. column.sort.direction = direction;
  4945. }
  4946. self.api.core.raise.sortChanged( self, self.getColumnSorting() );
  4947. return $q.when(column);
  4948. };
  4949. var removeSortOfColumn = function removeSortOfColumn(column, grid) {
  4950. //Decrease priority for every col where priority is higher than the removed sort's priority.
  4951. grid.columns.forEach(function (col) {
  4952. if (col.sort && col.sort.priority !== undefined && col.sort.priority > column.sort.priority) {
  4953. col.sort.priority -= 1;
  4954. }
  4955. });
  4956. //Remove sort
  4957. column.sort = {};
  4958. };
  4959. /**
  4960. * communicate to outside world that we are done with initial rendering
  4961. */
  4962. Grid.prototype.renderingComplete = function(){
  4963. if (angular.isFunction(this.options.onRegisterApi)) {
  4964. this.options.onRegisterApi(this.api);
  4965. }
  4966. this.api.core.raise.renderingComplete( this.api );
  4967. };
  4968. Grid.prototype.createRowHashMap = function createRowHashMap() {
  4969. var self = this;
  4970. var hashMap = new RowHashMap();
  4971. hashMap.grid = self;
  4972. return hashMap;
  4973. };
  4974. /**
  4975. * @ngdoc function
  4976. * @name refresh
  4977. * @methodOf ui.grid.class:Grid
  4978. * @description Refresh the rendered grid on screen.
  4979. * @param {boolean} [rowsAltered] Optional flag for refreshing when the number of rows has changed.
  4980. */
  4981. Grid.prototype.refresh = function refresh(rowsAltered) {
  4982. var self = this;
  4983. var p1 = self.processRowsProcessors(self.rows).then(function (renderableRows) {
  4984. self.setVisibleRows(renderableRows);
  4985. }).catch(angular.noop);
  4986. var p2 = self.processColumnsProcessors(self.columns).then(function (renderableColumns) {
  4987. self.setVisibleColumns(renderableColumns);
  4988. }).catch(angular.noop);
  4989. return $q.all([p1, p2]).then(function () {
  4990. self.refreshCanvas(true);
  4991. self.redrawInPlace(rowsAltered);
  4992. }).catch(angular.noop);
  4993. };
  4994. /**
  4995. * @ngdoc function
  4996. * @name refreshRows
  4997. * @methodOf ui.grid.class:Grid
  4998. * @description Refresh the rendered rows on screen? Note: not functional at present
  4999. * @returns {promise} promise that is resolved when render completes?
  5000. *
  5001. */
  5002. Grid.prototype.refreshRows = function refreshRows() {
  5003. var self = this;
  5004. return self.processRowsProcessors(self.rows)
  5005. .then(function (renderableRows) {
  5006. self.setVisibleRows(renderableRows);
  5007. self.redrawInPlace();
  5008. self.refreshCanvas( true );
  5009. }).catch(angular.noop);
  5010. };
  5011. /**
  5012. * @ngdoc function
  5013. * @name refreshCanvas
  5014. * @methodOf ui.grid.class:Grid
  5015. * @description Builds all styles and recalculates much of the grid sizing
  5016. * @param {object} buildStyles optional parameter. Use TBD
  5017. * @returns {promise} promise that is resolved when the canvas
  5018. * has been refreshed
  5019. *
  5020. */
  5021. Grid.prototype.refreshCanvas = function(buildStyles) {
  5022. var self = this;
  5023. // gridUtil.logDebug('refreshCanvas');
  5024. var p = $q.defer();
  5025. // Get all the header heights
  5026. var containerHeadersToRecalc = [];
  5027. for (var containerId in self.renderContainers) {
  5028. if (self.renderContainers.hasOwnProperty(containerId)) {
  5029. var container = self.renderContainers[containerId];
  5030. // Skip containers that have no canvasWidth set yet
  5031. if (container.canvasWidth === null || isNaN(container.canvasWidth)) {
  5032. continue;
  5033. }
  5034. if (container.header || container.headerCanvas) {
  5035. container.explicitHeaderHeight = null;
  5036. container.explicitHeaderCanvasHeight = null;
  5037. containerHeadersToRecalc.push(container);
  5038. }
  5039. }
  5040. }
  5041. // Build the styles without the explicit header heights
  5042. if (buildStyles) {
  5043. self.buildStyles();
  5044. }
  5045. /*
  5046. *
  5047. * Here we loop through the headers, measuring each element as well as any header "canvas" it has within it.
  5048. *
  5049. * If any header is less than the largest header height, it will be resized to that so that we don't have headers
  5050. * with different heights, which looks like a rendering problem
  5051. *
  5052. * We'll do the same thing with the header canvases, and give the header CELLS an explicit height if their canvas
  5053. * is smaller than the largest canvas height. That was header cells without extra controls like filtering don't
  5054. * appear shorter than other cells.
  5055. *
  5056. */
  5057. if (containerHeadersToRecalc.length > 0) {
  5058. // Putting in a timeout as it's not calculating after the grid element is rendered and filled out
  5059. $timeout(function() {
  5060. // var oldHeaderHeight = self.grid.headerHeight;
  5061. // self.grid.headerHeight = gridUtil.outerElementHeight(self.header);
  5062. var rebuildStyles = false;
  5063. // Get all the header heights
  5064. var maxHeaderHeight = 0;
  5065. var maxHeaderCanvasHeight = 0;
  5066. var i, container;
  5067. var getHeight = function(oldVal, newVal){
  5068. if ( oldVal !== newVal){
  5069. rebuildStyles = true;
  5070. }
  5071. return newVal;
  5072. };
  5073. for (i = 0; i < containerHeadersToRecalc.length; i++) {
  5074. container = containerHeadersToRecalc[i];
  5075. // Skip containers that have no canvasWidth set yet
  5076. if (container.canvasWidth === null || isNaN(container.canvasWidth)) {
  5077. continue;
  5078. }
  5079. if (container.header) {
  5080. var headerHeight = container.headerHeight = getHeight(container.headerHeight, gridUtil.outerElementHeight(container.header));
  5081. // Get the "inner" header height, that is the height minus the top and bottom borders, if present. We'll use it to make sure all the headers have a consistent height
  5082. var topBorder = gridUtil.getBorderSize(container.header, 'top');
  5083. var bottomBorder = gridUtil.getBorderSize(container.header, 'bottom');
  5084. var innerHeaderHeight = parseInt(headerHeight - topBorder - bottomBorder, 10);
  5085. innerHeaderHeight = innerHeaderHeight < 0 ? 0 : innerHeaderHeight;
  5086. container.innerHeaderHeight = innerHeaderHeight;
  5087. // If the header doesn't have an explicit height set, save the largest header height for use later
  5088. // Explicit header heights are based off of the max we are calculating here. We never want to base the max on something we're setting explicitly
  5089. if (!container.explicitHeaderHeight && innerHeaderHeight > maxHeaderHeight) {
  5090. maxHeaderHeight = innerHeaderHeight;
  5091. }
  5092. }
  5093. if (container.headerCanvas) {
  5094. var headerCanvasHeight = container.headerCanvasHeight = getHeight(container.headerCanvasHeight, parseInt(gridUtil.outerElementHeight(container.headerCanvas), 10));
  5095. // If the header doesn't have an explicit canvas height, save the largest header canvas height for use later
  5096. // Explicit header heights are based off of the max we are calculating here. We never want to base the max on something we're setting explicitly
  5097. if (!container.explicitHeaderCanvasHeight && headerCanvasHeight > maxHeaderCanvasHeight) {
  5098. maxHeaderCanvasHeight = headerCanvasHeight;
  5099. }
  5100. }
  5101. }
  5102. // Go through all the headers
  5103. for (i = 0; i < containerHeadersToRecalc.length; i++) {
  5104. container = containerHeadersToRecalc[i];
  5105. /* If:
  5106. 1. We have a max header height
  5107. 2. This container has a header height defined
  5108. 3. And either this container has an explicit header height set, OR its header height is less than the max
  5109. then:
  5110. Give this container's header an explicit height so it will line up with the tallest header
  5111. */
  5112. if (
  5113. maxHeaderHeight > 0 && typeof(container.headerHeight) !== 'undefined' && container.headerHeight !== null &&
  5114. (container.explicitHeaderHeight || container.headerHeight < maxHeaderHeight)
  5115. ) {
  5116. container.explicitHeaderHeight = getHeight(container.explicitHeaderHeight, maxHeaderHeight);
  5117. }
  5118. // Do the same as above except for the header canvas
  5119. if (
  5120. maxHeaderCanvasHeight > 0 && typeof(container.headerCanvasHeight) !== 'undefined' && container.headerCanvasHeight !== null &&
  5121. (container.explicitHeaderCanvasHeight || container.headerCanvasHeight < maxHeaderCanvasHeight)
  5122. ) {
  5123. container.explicitHeaderCanvasHeight = getHeight(container.explicitHeaderCanvasHeight, maxHeaderCanvasHeight);
  5124. }
  5125. }
  5126. // Rebuild styles if the header height has changed
  5127. // The header height is used in body/viewport calculations and those are then used in other styles so we need it to be available
  5128. if (buildStyles && rebuildStyles) {
  5129. self.buildStyles();
  5130. }
  5131. p.resolve();
  5132. });
  5133. }
  5134. else {
  5135. // Timeout still needs to be here to trigger digest after styles have been rebuilt
  5136. $timeout(function() {
  5137. p.resolve();
  5138. });
  5139. }
  5140. return p.promise;
  5141. };
  5142. /**
  5143. * @ngdoc function
  5144. * @name redrawInPlace
  5145. * @methodOf ui.grid.class:Grid
  5146. * @description Redraw the rows and columns based on our current scroll position
  5147. * @param {boolean} [rowsAdded] Optional to indicate rows are added and the scroll percentage must be recalculated
  5148. *
  5149. */
  5150. Grid.prototype.redrawInPlace = function redrawInPlace(rowsAdded) {
  5151. // gridUtil.logDebug('redrawInPlace');
  5152. var self = this;
  5153. for (var i in self.renderContainers) {
  5154. var container = self.renderContainers[i];
  5155. // gridUtil.logDebug('redrawing container', i);
  5156. if (rowsAdded) {
  5157. container.adjustRows(container.prevScrollTop, null);
  5158. container.adjustColumns(container.prevScrollLeft, null);
  5159. }
  5160. else {
  5161. container.adjustRows(null, container.prevScrolltopPercentage);
  5162. container.adjustColumns(null, container.prevScrollleftPercentage);
  5163. }
  5164. }
  5165. };
  5166. /**
  5167. * @ngdoc function
  5168. * @name hasLeftContainerColumns
  5169. * @methodOf ui.grid.class:Grid
  5170. * @description returns true if leftContainer has columns
  5171. */
  5172. Grid.prototype.hasLeftContainerColumns = function () {
  5173. return this.hasLeftContainer() && this.renderContainers.left.renderedColumns.length > 0;
  5174. };
  5175. /**
  5176. * @ngdoc function
  5177. * @name hasRightContainerColumns
  5178. * @methodOf ui.grid.class:Grid
  5179. * @description returns true if rightContainer has columns
  5180. */
  5181. Grid.prototype.hasRightContainerColumns = function () {
  5182. return this.hasRightContainer() && this.renderContainers.right.renderedColumns.length > 0;
  5183. };
  5184. /**
  5185. * @ngdoc method
  5186. * @methodOf ui.grid.class:Grid
  5187. * @name scrollToIfNecessary
  5188. * @description Scrolls the grid to make a certain row and column combo visible,
  5189. * in the case that it is not completely visible on the screen already.
  5190. * @param {GridRow} gridRow row to make visible
  5191. * @param {GridColumn} gridCol column to make visible
  5192. * @returns {promise} a promise that is resolved when scrolling is complete
  5193. */
  5194. Grid.prototype.scrollToIfNecessary = function (gridRow, gridCol) {
  5195. var self = this;
  5196. var scrollEvent = new ScrollEvent(self, 'uiGrid.scrollToIfNecessary');
  5197. // Alias the visible row and column caches
  5198. var visRowCache = self.renderContainers.body.visibleRowCache;
  5199. var visColCache = self.renderContainers.body.visibleColumnCache;
  5200. /*-- Get the top, left, right, and bottom "scrolled" edges of the grid --*/
  5201. // The top boundary is the current Y scroll position PLUS the header height, because the header can obscure rows when the grid is scrolled downwards
  5202. var topBound = self.renderContainers.body.prevScrollTop + self.headerHeight;
  5203. // Don't the let top boundary be less than 0
  5204. topBound = (topBound < 0) ? 0 : topBound;
  5205. // The left boundary is the current X scroll position
  5206. var leftBound = self.renderContainers.body.prevScrollLeft;
  5207. // The bottom boundary is the current Y scroll position, plus the height of the grid, but minus the header height.
  5208. // Basically this is the viewport height added on to the scroll position
  5209. var bottomBound = self.renderContainers.body.prevScrollTop + self.gridHeight - self.renderContainers.body.headerHeight - self.footerHeight - self.scrollbarWidth;
  5210. // If there's a horizontal scrollbar, remove its height from the bottom boundary, otherwise we'll be letting it obscure rows
  5211. //if (self.horizontalScrollbarHeight) {
  5212. // bottomBound = bottomBound - self.horizontalScrollbarHeight;
  5213. //}
  5214. // The right position is the current X scroll position minus the grid width
  5215. var rightBound = self.renderContainers.body.prevScrollLeft + Math.ceil(self.renderContainers.body.getViewportWidth());
  5216. // If there's a vertical scrollbar, subtract it from the right boundary or we'll allow it to obscure cells
  5217. //if (self.verticalScrollbarWidth) {
  5218. // rightBound = rightBound - self.verticalScrollbarWidth;
  5219. //}
  5220. // We were given a row to scroll to
  5221. if (gridRow !== null) {
  5222. // This is the index of the row we want to scroll to, within the list of rows that can be visible
  5223. var seekRowIndex = visRowCache.indexOf(gridRow);
  5224. // Total vertical scroll length of the grid
  5225. var scrollLength = (self.renderContainers.body.getCanvasHeight() - self.renderContainers.body.getViewportHeight());
  5226. // Add the height of the native horizontal scrollbar to the scroll length, if it's there. Otherwise it will mask over the final row
  5227. //if (self.horizontalScrollbarHeight && self.horizontalScrollbarHeight > 0) {
  5228. // scrollLength = scrollLength + self.horizontalScrollbarHeight;
  5229. //}
  5230. // This is the minimum amount of pixels we need to scroll vertical in order to see this row.
  5231. var pixelsToSeeRow = (seekRowIndex * self.options.rowHeight + self.headerHeight);
  5232. // Don't let the pixels required to see the row be less than zero
  5233. pixelsToSeeRow = (pixelsToSeeRow < 0) ? 0 : pixelsToSeeRow;
  5234. var scrollPixels, percentage;
  5235. // If the scroll position we need to see the row is LESS than the top boundary, i.e. obscured above the top of the self...
  5236. if (pixelsToSeeRow < topBound) {
  5237. // Get the different between the top boundary and the required scroll position and subtract it from the current scroll position\
  5238. // to get the full position we need
  5239. scrollPixels = self.renderContainers.body.prevScrollTop - (topBound - pixelsToSeeRow);
  5240. // Turn the scroll position into a percentage and make it an argument for a scroll event
  5241. percentage = scrollPixels / scrollLength;
  5242. if (percentage <= 1) {
  5243. scrollEvent.y = { percentage: percentage };
  5244. }
  5245. }
  5246. // Otherwise if the scroll position we need to see the row is MORE than the bottom boundary, i.e. obscured below the bottom of the self...
  5247. else if (pixelsToSeeRow > bottomBound) {
  5248. // Get the different between the bottom boundary and the required scroll position and add it to the current scroll position
  5249. // to get the full position we need
  5250. scrollPixels = pixelsToSeeRow - bottomBound + self.renderContainers.body.prevScrollTop;
  5251. // Turn the scroll position into a percentage and make it an argument for a scroll event
  5252. percentage = scrollPixels / scrollLength;
  5253. if (percentage <= 1) {
  5254. scrollEvent.y = { percentage: percentage };
  5255. }
  5256. }
  5257. }
  5258. // We were given a column to scroll to
  5259. if (gridCol !== null) {
  5260. // This is the index of the column we want to scroll to, within the list of columns that can be visible
  5261. var seekColumnIndex = visColCache.indexOf(gridCol);
  5262. // Total horizontal scroll length of the grid
  5263. var horizScrollLength = (self.renderContainers.body.getCanvasWidth() - self.renderContainers.body.getViewportWidth());
  5264. // This is the minimum amount of pixels we need to scroll horizontal in order to see this column
  5265. var columnLeftEdge = 0;
  5266. for (var i = 0; i < seekColumnIndex; i++) {
  5267. var col = visColCache[i];
  5268. columnLeftEdge += col.drawnWidth;
  5269. }
  5270. columnLeftEdge = (columnLeftEdge < 0) ? 0 : columnLeftEdge;
  5271. var columnRightEdge = columnLeftEdge + gridCol.drawnWidth;
  5272. // Don't let the pixels required to see the column be less than zero
  5273. columnRightEdge = (columnRightEdge < 0) ? 0 : columnRightEdge;
  5274. var horizScrollPixels, horizPercentage;
  5275. // If the scroll position we need to see the column is LESS than the left boundary, i.e. obscured before the left of the self...
  5276. if (columnLeftEdge < leftBound) {
  5277. // Get the different between the left boundary and the required scroll position and subtract it from the current scroll position\
  5278. // to get the full position we need
  5279. horizScrollPixels = self.renderContainers.body.prevScrollLeft - (leftBound - columnLeftEdge);
  5280. // Turn the scroll position into a percentage and make it an argument for a scroll event
  5281. horizPercentage = horizScrollPixels / horizScrollLength;
  5282. horizPercentage = (horizPercentage > 1) ? 1 : horizPercentage;
  5283. scrollEvent.x = { percentage: horizPercentage };
  5284. }
  5285. // Otherwise if the scroll position we need to see the column is MORE than the right boundary, i.e. obscured after the right of the self...
  5286. else if (columnRightEdge > rightBound) {
  5287. // Get the different between the right boundary and the required scroll position and add it to the current scroll position
  5288. // to get the full position we need
  5289. horizScrollPixels = columnRightEdge - rightBound + self.renderContainers.body.prevScrollLeft;
  5290. // Turn the scroll position into a percentage and make it an argument for a scroll event
  5291. horizPercentage = horizScrollPixels / horizScrollLength;
  5292. horizPercentage = (horizPercentage > 1) ? 1 : horizPercentage;
  5293. scrollEvent.x = { percentage: horizPercentage };
  5294. }
  5295. }
  5296. var deferred = $q.defer();
  5297. // If we need to scroll on either the x or y axes, fire a scroll event
  5298. if (scrollEvent.y || scrollEvent.x) {
  5299. scrollEvent.withDelay = false;
  5300. self.scrollContainers('',scrollEvent);
  5301. var dereg = self.api.core.on.scrollEnd(null,function() {
  5302. deferred.resolve(scrollEvent);
  5303. dereg();
  5304. });
  5305. }
  5306. else {
  5307. deferred.resolve();
  5308. }
  5309. return deferred.promise;
  5310. };
  5311. /**
  5312. * @ngdoc method
  5313. * @methodOf ui.grid.class:Grid
  5314. * @name scrollTo
  5315. * @description Scroll the grid such that the specified
  5316. * row and column is in view
  5317. * @param {object} rowEntity gridOptions.data[] array instance to make visible
  5318. * @param {object} colDef to make visible
  5319. * @returns {promise} a promise that is resolved after any scrolling is finished
  5320. */
  5321. Grid.prototype.scrollTo = function (rowEntity, colDef) {
  5322. var gridRow = null, gridCol = null;
  5323. if (rowEntity !== null && typeof(rowEntity) !== 'undefined' ) {
  5324. gridRow = this.getRow(rowEntity);
  5325. }
  5326. if (colDef !== null && typeof(colDef) !== 'undefined' ) {
  5327. gridCol = this.getColumn(colDef.name ? colDef.name : colDef.field);
  5328. }
  5329. return this.scrollToIfNecessary(gridRow, gridCol);
  5330. };
  5331. /**
  5332. * @ngdoc function
  5333. * @name clearAllFilters
  5334. * @methodOf ui.grid.class:Grid
  5335. * @description Clears all filters and optionally refreshes the visible rows.
  5336. * @param {object} refreshRows Defaults to true.
  5337. * @param {object} clearConditions Defaults to false.
  5338. * @param {object} clearFlags Defaults to false.
  5339. * @returns {promise} If `refreshRows` is true, returns a promise of the rows refreshing.
  5340. */
  5341. Grid.prototype.clearAllFilters = function clearAllFilters(refreshRows, clearConditions, clearFlags) {
  5342. // Default `refreshRows` to true because it will be the most commonly desired behaviour.
  5343. if (refreshRows === undefined) {
  5344. refreshRows = true;
  5345. }
  5346. if (clearConditions === undefined) {
  5347. clearConditions = false;
  5348. }
  5349. if (clearFlags === undefined) {
  5350. clearFlags = false;
  5351. }
  5352. this.columns.forEach(function(column) {
  5353. column.filters.forEach(function(filter) {
  5354. filter.term = undefined;
  5355. if (clearConditions) {
  5356. filter.condition = undefined;
  5357. }
  5358. if (clearFlags) {
  5359. filter.flags = undefined;
  5360. }
  5361. });
  5362. });
  5363. if (refreshRows) {
  5364. return this.refreshRows();
  5365. }
  5366. };
  5367. // Blatantly stolen from Angular as it isn't exposed (yet? 2.0?)
  5368. function RowHashMap() {}
  5369. RowHashMap.prototype = {
  5370. /**
  5371. * Store key value pair
  5372. * @param key key to store can be any type
  5373. * @param value value to store can be any type
  5374. */
  5375. put: function(key, value) {
  5376. this[this.grid.options.rowIdentity(key)] = value;
  5377. },
  5378. /**
  5379. * @param key
  5380. * @returns {Object} the value for the key
  5381. */
  5382. get: function(key) {
  5383. return this[this.grid.options.rowIdentity(key)];
  5384. },
  5385. /**
  5386. * Remove the key/value pair
  5387. * @param key
  5388. */
  5389. remove: function(key) {
  5390. var value = this[key = this.grid.options.rowIdentity(key)];
  5391. delete this[key];
  5392. return value;
  5393. }
  5394. };
  5395. return Grid;
  5396. }]);
  5397. })();
  5398. (function () {
  5399. angular.module('ui.grid')
  5400. .factory('GridApi', ['$q', '$rootScope', 'gridUtil', 'uiGridConstants', 'GridRow', 'uiGridGridMenuService',
  5401. function ($q, $rootScope, gridUtil, uiGridConstants, GridRow, uiGridGridMenuService) {
  5402. /**
  5403. * @ngdoc function
  5404. * @name ui.grid.class:GridApi
  5405. * @description GridApi provides the ability to register public methods events inside the grid and allow
  5406. * for other components to use the api via featureName.raise.methodName and featureName.on.eventName(function(args){}.
  5407. * <br/>
  5408. * To listen to events, you must add a callback to gridOptions.onRegisterApi
  5409. * <pre>
  5410. * $scope.gridOptions.onRegisterApi = function(gridApi){
  5411. * gridApi.cellNav.on.navigate($scope,function(newRowCol, oldRowCol){
  5412. * $log.log('navigation event');
  5413. * });
  5414. * };
  5415. * </pre>
  5416. * @param {object} grid grid that owns api
  5417. */
  5418. var GridApi = function GridApi(grid) {
  5419. this.grid = grid;
  5420. this.listeners = [];
  5421. /**
  5422. * @ngdoc function
  5423. * @name renderingComplete
  5424. * @methodOf ui.grid.core.api:PublicApi
  5425. * @description Rendering is complete, called at the same
  5426. * time as `onRegisterApi`, but provides a way to obtain
  5427. * that same event within features without stopping end
  5428. * users from getting at the onRegisterApi method.
  5429. *
  5430. * Included in gridApi so that it's always there - otherwise
  5431. * there is still a timing problem with when a feature can
  5432. * call this.
  5433. *
  5434. * @param {GridApi} gridApi the grid api, as normally
  5435. * returned in the onRegisterApi method
  5436. *
  5437. * @example
  5438. * <pre>
  5439. * gridApi.core.on.renderingComplete( grid );
  5440. * </pre>
  5441. */
  5442. this.registerEvent( 'core', 'renderingComplete' );
  5443. /**
  5444. * @ngdoc event
  5445. * @name filterChanged
  5446. * @eventOf ui.grid.core.api:PublicApi
  5447. * @description is raised after the filter is changed. The nature
  5448. * of the watch expression doesn't allow notification of what changed,
  5449. * so the receiver of this event will need to re-extract the filter
  5450. * conditions from the columns.
  5451. *
  5452. */
  5453. this.registerEvent( 'core', 'filterChanged' );
  5454. /**
  5455. * @ngdoc function
  5456. * @name setRowInvisible
  5457. * @methodOf ui.grid.core.api:PublicApi
  5458. * @description Sets an override on the row to make it always invisible,
  5459. * which will override any filtering or other visibility calculations.
  5460. * If the row is currently visible then sets it to invisible and calls
  5461. * both grid refresh and emits the rowsVisibleChanged event
  5462. * @param {GridRow} row the row we want to make invisible
  5463. */
  5464. this.registerMethod( 'core', 'setRowInvisible', GridRow.prototype.setRowInvisible );
  5465. /**
  5466. * @ngdoc function
  5467. * @name clearRowInvisible
  5468. * @methodOf ui.grid.core.api:PublicApi
  5469. * @description Clears any override on visibility for the row so that it returns to
  5470. * using normal filtering and other visibility calculations.
  5471. * If the row is currently invisible then sets it to visible and calls
  5472. * both grid refresh and emits the rowsVisibleChanged event
  5473. * TODO: if a filter is active then we can't just set it to visible?
  5474. * @param {GridRow} row the row we want to make visible
  5475. */
  5476. this.registerMethod( 'core', 'clearRowInvisible', GridRow.prototype.clearRowInvisible );
  5477. /**
  5478. * @ngdoc function
  5479. * @name getVisibleRows
  5480. * @methodOf ui.grid.core.api:PublicApi
  5481. * @description Returns all visible rows
  5482. * @param {Grid} grid the grid you want to get visible rows from
  5483. * @returns {array} an array of gridRow
  5484. */
  5485. this.registerMethod( 'core', 'getVisibleRows', this.grid.getVisibleRows );
  5486. /**
  5487. * @ngdoc event
  5488. * @name rowsVisibleChanged
  5489. * @eventOf ui.grid.core.api:PublicApi
  5490. * @description is raised after the rows that are visible
  5491. * change. The filtering is zero-based, so it isn't possible
  5492. * to say which rows changed (unlike in the selection feature).
  5493. * We can plausibly know which row was changed when setRowInvisible
  5494. * is called, but in that situation the user already knows which row
  5495. * they changed. When a filter runs we don't know what changed,
  5496. * and that is the one that would have been useful.
  5497. *
  5498. */
  5499. this.registerEvent( 'core', 'rowsVisibleChanged' );
  5500. /**
  5501. * @ngdoc event
  5502. * @name rowsRendered
  5503. * @eventOf ui.grid.core.api:PublicApi
  5504. * @description is raised after the cache of visible rows is changed.
  5505. */
  5506. this.registerEvent( 'core', 'rowsRendered' );
  5507. /**
  5508. * @ngdoc event
  5509. * @name scrollBegin
  5510. * @eventOf ui.grid.core.api:PublicApi
  5511. * @description is raised when scroll begins. Is throttled, so won't be raised too frequently
  5512. */
  5513. this.registerEvent( 'core', 'scrollBegin' );
  5514. /**
  5515. * @ngdoc event
  5516. * @name scrollEnd
  5517. * @eventOf ui.grid.core.api:PublicApi
  5518. * @description is raised when scroll has finished. Is throttled, so won't be raised too frequently
  5519. */
  5520. this.registerEvent( 'core', 'scrollEnd' );
  5521. /**
  5522. * @ngdoc event
  5523. * @name canvasHeightChanged
  5524. * @eventOf ui.grid.core.api:PublicApi
  5525. * @description is raised when the canvas height has changed
  5526. * <br/>
  5527. * arguments: oldHeight, newHeight
  5528. */
  5529. this.registerEvent( 'core', 'canvasHeightChanged');
  5530. /**
  5531. * @ngdoc event
  5532. * @name gridDimensionChanged
  5533. * @eventOf ui.grid.core.api:PublicApi
  5534. * @description is raised when the grid dimensions have changed (when autoResize is on)
  5535. * <br/>
  5536. * arguments: oldGridHeight, oldGridWidth, newGridHeight, newGridWidth
  5537. */
  5538. this.registerEvent( 'core', 'gridDimensionChanged');
  5539. };
  5540. /**
  5541. * @ngdoc function
  5542. * @name ui.grid.class:suppressEvents
  5543. * @methodOf ui.grid.class:GridApi
  5544. * @description Used to execute a function while disabling the specified event listeners.
  5545. * Disables the listenerFunctions, executes the callbackFn, and then enables
  5546. * the listenerFunctions again
  5547. * @param {object} listenerFuncs listenerFunc or array of listenerFuncs to suppress. These must be the same
  5548. * functions that were used in the .on.eventName method
  5549. * @param {object} callBackFn function to execute
  5550. * @example
  5551. * <pre>
  5552. * var navigate = function (newRowCol, oldRowCol){
  5553. * //do something on navigate
  5554. * }
  5555. *
  5556. * gridApi.cellNav.on.navigate(scope,navigate);
  5557. *
  5558. *
  5559. * //call the scrollTo event and suppress our navigate listener
  5560. * //scrollTo will still raise the event for other listeners
  5561. * gridApi.suppressEvents(navigate, function(){
  5562. * gridApi.cellNav.scrollTo(aRow, aCol);
  5563. * });
  5564. *
  5565. * </pre>
  5566. */
  5567. GridApi.prototype.suppressEvents = function (listenerFuncs, callBackFn) {
  5568. var self = this;
  5569. var listeners = angular.isArray(listenerFuncs) ? listenerFuncs : [listenerFuncs];
  5570. //find all registered listeners
  5571. var foundListeners = self.listeners.filter(function(listener) {
  5572. return listeners.some(function(l) {
  5573. return listener.handler === l;
  5574. });
  5575. });
  5576. //deregister all the listeners
  5577. foundListeners.forEach(function(l){
  5578. l.dereg();
  5579. });
  5580. callBackFn();
  5581. //reregister all the listeners
  5582. foundListeners.forEach(function(l){
  5583. l.dereg = registerEventWithAngular(l.eventId, l.handler, self.grid, l._this);
  5584. });
  5585. };
  5586. /**
  5587. * @ngdoc function
  5588. * @name registerEvent
  5589. * @methodOf ui.grid.class:GridApi
  5590. * @description Registers a new event for the given feature. The event will get a
  5591. * .raise and .on prepended to it
  5592. * <br>
  5593. * .raise.eventName() - takes no arguments
  5594. * <br/>
  5595. * <br/>
  5596. * .on.eventName(scope, callBackFn, _this)
  5597. * <br/>
  5598. * scope - a scope reference to add a deregister call to the scopes .$on('destroy'). Scope is optional and can be a null value,
  5599. * but in this case you must deregister it yourself via the returned deregister function
  5600. * <br/>
  5601. * callBackFn - The function to call
  5602. * <br/>
  5603. * _this - optional this context variable for callbackFn. If omitted, grid.api will be used for the context
  5604. * <br/>
  5605. * .on.eventName returns a dereg funtion that will remove the listener. It's not necessary to use it as the listener
  5606. * will be removed when the scope is destroyed.
  5607. * @param {string} featureName name of the feature that raises the event
  5608. * @param {string} eventName name of the event
  5609. */
  5610. GridApi.prototype.registerEvent = function (featureName, eventName) {
  5611. var self = this;
  5612. if (!self[featureName]) {
  5613. self[featureName] = {};
  5614. }
  5615. var feature = self[featureName];
  5616. if (!feature.on) {
  5617. feature.on = {};
  5618. feature.raise = {};
  5619. }
  5620. var eventId = self.grid.id + featureName + eventName;
  5621. // gridUtil.logDebug('Creating raise event method ' + featureName + '.raise.' + eventName);
  5622. feature.raise[eventName] = function () {
  5623. $rootScope.$emit.apply($rootScope, [eventId].concat(Array.prototype.slice.call(arguments)));
  5624. };
  5625. // gridUtil.logDebug('Creating on event method ' + featureName + '.on.' + eventName);
  5626. feature.on[eventName] = function (scope, handler, _this) {
  5627. if ( scope !== null && typeof(scope.$on) === 'undefined' ){
  5628. gridUtil.logError('asked to listen on ' + featureName + '.on.' + eventName + ' but scope wasn\'t passed in the input parameters. It is legitimate to pass null, but you\'ve passed something else, so you probably forgot to provide scope rather than did it deliberately, not registering');
  5629. return;
  5630. }
  5631. var deregAngularOn = registerEventWithAngular(eventId, handler, self.grid, _this);
  5632. //track our listener so we can turn off and on
  5633. var listener = {handler: handler, dereg: deregAngularOn, eventId: eventId, scope: scope, _this:_this};
  5634. self.listeners.push(listener);
  5635. var removeListener = function(){
  5636. listener.dereg();
  5637. var index = self.listeners.indexOf(listener);
  5638. self.listeners.splice(index,1);
  5639. };
  5640. //destroy tracking when scope is destroyed
  5641. if (scope) {
  5642. scope.$on('$destroy', function() {
  5643. removeListener();
  5644. });
  5645. }
  5646. return removeListener;
  5647. };
  5648. };
  5649. function registerEventWithAngular(eventId, handler, grid, _this) {
  5650. return $rootScope.$on(eventId, function (event) {
  5651. var args = Array.prototype.slice.call(arguments);
  5652. args.splice(0, 1); //remove evt argument
  5653. handler.apply(_this ? _this : grid.api, args);
  5654. });
  5655. }
  5656. /**
  5657. * @ngdoc function
  5658. * @name registerEventsFromObject
  5659. * @methodOf ui.grid.class:GridApi
  5660. * @description Registers features and events from a simple objectMap.
  5661. * eventObjectMap must be in this format (multiple features allowed)
  5662. * <pre>
  5663. * {featureName:
  5664. * {
  5665. * eventNameOne:function(args){},
  5666. * eventNameTwo:function(args){}
  5667. * }
  5668. * }
  5669. * </pre>
  5670. * @param {object} eventObjectMap map of feature/event names
  5671. */
  5672. GridApi.prototype.registerEventsFromObject = function (eventObjectMap) {
  5673. var self = this;
  5674. var features = [];
  5675. angular.forEach(eventObjectMap, function (featProp, featPropName) {
  5676. var feature = {name: featPropName, events: []};
  5677. angular.forEach(featProp, function (prop, propName) {
  5678. feature.events.push(propName);
  5679. });
  5680. features.push(feature);
  5681. });
  5682. features.forEach(function (feature) {
  5683. feature.events.forEach(function (event) {
  5684. self.registerEvent(feature.name, event);
  5685. });
  5686. });
  5687. };
  5688. /**
  5689. * @ngdoc function
  5690. * @name registerMethod
  5691. * @methodOf ui.grid.class:GridApi
  5692. * @description Registers a new event for the given feature
  5693. * @param {string} featureName name of the feature
  5694. * @param {string} methodName name of the method
  5695. * @param {object} callBackFn function to execute
  5696. * @param {object} _this binds callBackFn 'this' to _this. Defaults to gridApi.grid
  5697. */
  5698. GridApi.prototype.registerMethod = function (featureName, methodName, callBackFn, _this) {
  5699. if (!this[featureName]) {
  5700. this[featureName] = {};
  5701. }
  5702. var feature = this[featureName];
  5703. feature[methodName] = gridUtil.createBoundedWrapper(_this || this.grid, callBackFn);
  5704. };
  5705. /**
  5706. * @ngdoc function
  5707. * @name registerMethodsFromObject
  5708. * @methodOf ui.grid.class:GridApi
  5709. * @description Registers features and methods from a simple objectMap.
  5710. * eventObjectMap must be in this format (multiple features allowed)
  5711. * <br>
  5712. * {featureName:
  5713. * {
  5714. * methodNameOne:function(args){},
  5715. * methodNameTwo:function(args){}
  5716. * }
  5717. * @param {object} eventObjectMap map of feature/event names
  5718. * @param {object} _this binds this to _this for all functions. Defaults to gridApi.grid
  5719. */
  5720. GridApi.prototype.registerMethodsFromObject = function (methodMap, _this) {
  5721. var self = this;
  5722. var features = [];
  5723. angular.forEach(methodMap, function (featProp, featPropName) {
  5724. var feature = {name: featPropName, methods: []};
  5725. angular.forEach(featProp, function (prop, propName) {
  5726. feature.methods.push({name: propName, fn: prop});
  5727. });
  5728. features.push(feature);
  5729. });
  5730. features.forEach(function (feature) {
  5731. feature.methods.forEach(function (method) {
  5732. self.registerMethod(feature.name, method.name, method.fn, _this);
  5733. });
  5734. });
  5735. };
  5736. return GridApi;
  5737. }]);
  5738. })();
  5739. (function(){
  5740. angular.module('ui.grid')
  5741. .factory('GridColumn', ['gridUtil', 'uiGridConstants', 'i18nService', function(gridUtil, uiGridConstants, i18nService) {
  5742. /**
  5743. * ******************************************************************************************
  5744. * PaulL1: Ugly hack here in documentation. These properties are clearly properties of GridColumn,
  5745. * and need to be noted as such for those extending and building ui-grid itself.
  5746. * However, from an end-developer perspective, they interact with all these through columnDefs,
  5747. * and they really need to be documented there. I feel like they're relatively static, and
  5748. * I can't find an elegant way for ngDoc to reference to both....so I've duplicated each
  5749. * comment block. Ugh.
  5750. *
  5751. */
  5752. /**
  5753. * @ngdoc property
  5754. * @name name
  5755. * @propertyOf ui.grid.class:GridColumn
  5756. * @description (mandatory) Each column should have a name, although for backward
  5757. * compatibility with 2.x name can be omitted if field is present.
  5758. *
  5759. * Important - This must be unique to each column on a web page since it can
  5760. * be used as a key for retrieving information such as custom sort algorithms.
  5761. *
  5762. */
  5763. /**
  5764. * @ngdoc property
  5765. * @name name
  5766. * @propertyOf ui.grid.class:GridOptions.columnDef
  5767. * @description (mandatory) Each column should have a name, although for backward
  5768. * compatibility with 2.x name can be omitted if field is present.
  5769. *
  5770. * Important - This must be unique to each column on a web page since it can
  5771. * be used as a key for retrieving information such as custom sort algorithms.
  5772. *
  5773. */
  5774. /**
  5775. * @ngdoc property
  5776. * @name displayName
  5777. * @propertyOf ui.grid.class:GridColumn
  5778. * @description Column name that will be shown in the header. If displayName is not
  5779. * provided then one is generated using the name.
  5780. *
  5781. */
  5782. /**
  5783. * @ngdoc property
  5784. * @name displayName
  5785. * @propertyOf ui.grid.class:GridOptions.columnDef
  5786. * @description Column name that will be shown in the header. If displayName is not
  5787. * provided then one is generated using the name.
  5788. *
  5789. */
  5790. /**
  5791. * @ngdoc property
  5792. * @name field
  5793. * @propertyOf ui.grid.class:GridColumn
  5794. * @description field must be provided if you wish to bind to a
  5795. * property in the data source. Should be an angular expression that evaluates against grid.options.data
  5796. * array element. Can be a complex expression: <code>employee.address.city</code>, or can be a function: <code>employee.getFullAddress()</code>.
  5797. * See the angular docs on binding expressions.
  5798. *
  5799. */
  5800. /**
  5801. * @ngdoc property
  5802. * @name field
  5803. * @propertyOf ui.grid.class:GridOptions.columnDef
  5804. * @description field must be provided if you wish to bind to a
  5805. * property in the data source. Should be an angular expression that evaluates against grid.options.data
  5806. * array element. Can be a complex expression: <code>employee.address.city</code>, or can be a function: <code>employee.getFullAddress()</code>. * See the angular docs on binding expressions. *
  5807. */
  5808. /**
  5809. * @ngdoc property
  5810. * @name filter
  5811. * @propertyOf ui.grid.class:GridColumn
  5812. * @description Filter on this column.
  5813. *
  5814. * Available built-in conditions and types are listed under {@link jui.grid.service:uiGridConstants#properties_filter uiGridOptions.filter}
  5815. * @example
  5816. * <pre>{ term: 'text', condition: uiGridConstants.filter.STARTS_WITH, placeholder: 'type to filter...', ariaLabel: 'Filter for text', flags: { caseSensitive: false }, type: uiGridConstants.filter.SELECT, [ { value: 1, label: 'male' }, { value: 2, label: 'female' } ] }</pre>
  5817. *
  5818. */
  5819. /**
  5820. * @ngdoc property
  5821. * @name extraStyle
  5822. * @propertyOf ui.grid.class:GridColumn
  5823. * @description additional on this column.
  5824. * @example
  5825. * <pre>{extraStyle: {display:'table-cell'}}</pre>
  5826. *
  5827. */
  5828. /**
  5829. * @ngdoc object
  5830. * @name ui.grid.class:GridColumn
  5831. * @description Represents the viewModel for each column. Any state or methods needed for a Grid Column
  5832. * are defined on this prototype
  5833. * @param {ColumnDef} colDef the column def to associate with this column
  5834. * @param {number} uid the unique and immutable uid we'd like to allocate to this column
  5835. * @param {Grid} grid the grid we'd like to create this column in
  5836. */
  5837. function GridColumn(colDef, uid, grid) {
  5838. var self = this;
  5839. self.grid = grid;
  5840. self.uid = uid;
  5841. self.updateColumnDef(colDef, true);
  5842. self.aggregationValue = undefined;
  5843. // The footer cell registers to listen for the rowsRendered event, and calls this. Needed to be
  5844. // in something with a scope so that the dereg would get called
  5845. self.updateAggregationValue = function() {
  5846. // gridUtil.logDebug('getAggregationValue for Column ' + self.colDef.name);
  5847. /**
  5848. * @ngdoc property
  5849. * @name aggregationType
  5850. * @propertyOf ui.grid.class:GridOptions.columnDef
  5851. * @description The aggregation that you'd like to show in the columnFooter for this
  5852. * column. Valid values are in
  5853. * {@link ui.grid.service:uiGridConstants#properties_aggregationTypes uiGridConstants.aggregationTypes},
  5854. * and currently include `uiGridConstants.aggregationTypes.count`,
  5855. * `uiGridConstants.aggregationTypes.sum`, `uiGridConstants.aggregationTypes.avg`, `uiGridConstants.aggregationTypes.min`,
  5856. * `uiGridConstants.aggregationTypes.max`.
  5857. *
  5858. * You can also provide a function as the aggregation type, in this case your function needs to accept the full
  5859. * set of visible rows, and return a value that should be shown
  5860. */
  5861. if (!self.aggregationType) {
  5862. self.aggregationValue = undefined;
  5863. return;
  5864. }
  5865. var result = 0;
  5866. var visibleRows = self.grid.getVisibleRows();
  5867. var cellValues = function(){
  5868. var values = [];
  5869. visibleRows.forEach(function (row) {
  5870. var cellValue = self.grid.getCellValue(row, self);
  5871. var cellNumber = Number(cellValue);
  5872. if (!isNaN(cellNumber)) {
  5873. values.push(cellNumber);
  5874. }
  5875. });
  5876. return values;
  5877. };
  5878. if (angular.isFunction(self.aggregationType)) {
  5879. self.aggregationValue = self.aggregationType(visibleRows, self);
  5880. }
  5881. else if (self.aggregationType === uiGridConstants.aggregationTypes.count) {
  5882. self.aggregationValue = self.grid.getVisibleRowCount();
  5883. }
  5884. else if (self.aggregationType === uiGridConstants.aggregationTypes.sum) {
  5885. cellValues().forEach(function (value) {
  5886. result += value;
  5887. });
  5888. self.aggregationValue = result;
  5889. }
  5890. else if (self.aggregationType === uiGridConstants.aggregationTypes.avg) {
  5891. cellValues().forEach(function (value) {
  5892. result += value;
  5893. });
  5894. result = result / cellValues().length;
  5895. self.aggregationValue = result;
  5896. }
  5897. else if (self.aggregationType === uiGridConstants.aggregationTypes.min) {
  5898. self.aggregationValue = Math.min.apply(null, cellValues());
  5899. }
  5900. else if (self.aggregationType === uiGridConstants.aggregationTypes.max) {
  5901. self.aggregationValue = Math.max.apply(null, cellValues());
  5902. }
  5903. else {
  5904. self.aggregationValue = '\u00A0';
  5905. }
  5906. };
  5907. // var throttledUpdateAggregationValue = gridUtil.throttle(updateAggregationValue, self.grid.options.aggregationCalcThrottle, { trailing: true, context: self.name });
  5908. /**
  5909. * @ngdoc function
  5910. * @name getAggregationValue
  5911. * @methodOf ui.grid.class:GridColumn
  5912. * @description gets the aggregation value based on the aggregation type for this column.
  5913. * Debounced using scrollDebounce option setting
  5914. */
  5915. this.getAggregationValue = function() {
  5916. // if (!self.grid.isScrollingVertically && !self.grid.isScrollingHorizontally) {
  5917. // throttledUpdateAggregationValue();
  5918. // }
  5919. return self.aggregationValue;
  5920. };
  5921. }
  5922. /**
  5923. * @ngdoc function
  5924. * @name hideColumn
  5925. * @methodOf ui.grid.class:GridColumn
  5926. * @description Hides the column by setting colDef.visible = false
  5927. */
  5928. GridColumn.prototype.hideColumn = function() {
  5929. this.colDef.visible = false;
  5930. };
  5931. /**
  5932. * @ngdoc method
  5933. * @methodOf ui.grid.class:GridColumn
  5934. * @name setPropertyOrDefault
  5935. * @description Sets a property on the column using the passed in columnDef, and
  5936. * setting the defaultValue if the value cannot be found on the colDef
  5937. * @param {ColumnDef} colDef the column def to look in for the property value
  5938. * @param {string} propName the property name we'd like to set
  5939. * @param {object} defaultValue the value to use if the colDef doesn't provide the setting
  5940. */
  5941. GridColumn.prototype.setPropertyOrDefault = function (colDef, propName, defaultValue) {
  5942. var self = this;
  5943. // Use the column definition filter if we were passed it
  5944. if (typeof(colDef[propName]) !== 'undefined' && colDef[propName]) {
  5945. self[propName] = colDef[propName];
  5946. }
  5947. // Otherwise use our own if it's set
  5948. else if (typeof(self[propName]) !== 'undefined') {
  5949. self[propName] = self[propName];
  5950. }
  5951. // Default to empty object for the filter
  5952. else {
  5953. self[propName] = defaultValue ? defaultValue : {};
  5954. }
  5955. };
  5956. /**
  5957. * @ngdoc property
  5958. * @name width
  5959. * @propertyOf ui.grid.class:GridOptions.columnDef
  5960. * @description sets the column width. Can be either
  5961. * a number or a percentage, or an * for auto.
  5962. * @example
  5963. * <pre> $scope.gridOptions.columnDefs = [ { field: 'field1', width: 100},
  5964. * { field: 'field2', width: '20%'},
  5965. * { field: 'field3', width: '*' }]; </pre>
  5966. *
  5967. */
  5968. /**
  5969. * @ngdoc property
  5970. * @name minWidth
  5971. * @propertyOf ui.grid.class:GridOptions.columnDef
  5972. * @description sets the minimum column width. Should be a number.
  5973. * @example
  5974. * <pre> $scope.gridOptions.columnDefs = [ { field: 'field1', minWidth: 100}]; </pre>
  5975. *
  5976. */
  5977. /**
  5978. * @ngdoc property
  5979. * @name maxWidth
  5980. * @propertyOf ui.grid.class:GridOptions.columnDef
  5981. * @description sets the maximum column width. Should be a number.
  5982. * @example
  5983. * <pre> $scope.gridOptions.columnDefs = [ { field: 'field1', maxWidth: 100}]; </pre>
  5984. *
  5985. */
  5986. /**
  5987. * @ngdoc property
  5988. * @name visible
  5989. * @propertyOf ui.grid.class:GridOptions.columnDef
  5990. * @description sets whether or not the column is visible
  5991. * </br>Default is true
  5992. * @example
  5993. * <pre> $scope.gridOptions.columnDefs = [
  5994. * { field: 'field1', visible: true},
  5995. * { field: 'field2', visible: false }
  5996. * ]; </pre>
  5997. *
  5998. */
  5999. /**
  6000. * @ngdoc property
  6001. * @name sort
  6002. * @propertyOf ui.grid.class:GridOptions.columnDef
  6003. * @description An object of sort information, attributes are:
  6004. *
  6005. * - direction: values are {@link ui.grid.service:uiGridConstants#properties_ASC uiGridConstants.ASC}
  6006. * or {@link ui.grid.service:uiGridConstants#properties_DESC uiGridConstants.DESC}
  6007. * - ignoreSort: if set to true this sort is ignored (used by tree to manipulate the sort functionality)
  6008. * - priority: says what order to sort the columns in (lower priority gets sorted first).
  6009. * @example
  6010. * <pre>
  6011. * $scope.gridOptions.columnDefs = [{
  6012. * field: 'field1',
  6013. * sort: {
  6014. * direction: uiGridConstants.ASC,
  6015. * ignoreSort: true,
  6016. * priority: 0
  6017. * }
  6018. * }];
  6019. * </pre>
  6020. */
  6021. /**
  6022. * @ngdoc property
  6023. * @name sortingAlgorithm
  6024. * @propertyOf ui.grid.class:GridOptions.columnDef
  6025. * @description Algorithm to use for sorting this column. Takes 'a' and 'b' parameters
  6026. * like any normal sorting function with additional 'rowA', 'rowB', and 'direction' parameters
  6027. * that are the row objects and the current direction of the sort respectively.
  6028. *
  6029. */
  6030. /**
  6031. * @ngdoc property
  6032. * @name defaultSort
  6033. * @propertyOf ui.grid.class:GridOptions.columnDef
  6034. * @description An object of sort information, provides a hidden default ordering of the data
  6035. * when no user sorts are applied, or when a user-provided sort deems two rows to be equal.
  6036. *
  6037. * May be combined with a regular {@link ui.grid.class:GridOptions.columnDef#properties_sort columnDef.sort}
  6038. * to explicitly sort by that column by default.
  6039. *
  6040. * Shares the same object format as {@link ui.grid.class:GridOptions.columnDef#properties_sort columnDef.sort}.
  6041. *
  6042. * Note that a defaultSort can never take priority over an explicit sort.
  6043. * @example
  6044. * <pre>
  6045. * $scope.gridOptions.columnDefs = [{
  6046. * field: 'field1',
  6047. * defaultSort: {
  6048. * direction: uiGridConstants.ASC,
  6049. * priority: 0
  6050. * }
  6051. * }];
  6052. * </pre>
  6053. */
  6054. /**
  6055. * @ngdoc array
  6056. * @name filters
  6057. * @propertyOf ui.grid.class:GridOptions.columnDef
  6058. * @description Specify multiple filter fields.
  6059. * @example
  6060. * <pre>$scope.gridOptions.columnDefs = [
  6061. * {
  6062. * field: 'field1', filters: [
  6063. * {
  6064. * term: 'aa',
  6065. * condition: uiGridConstants.filter.STARTS_WITH,
  6066. * placeholder: 'starts with...',
  6067. * ariaLabel: 'Filter for field1',
  6068. * flags: { caseSensitive: false },
  6069. * type: uiGridConstants.filter.SELECT,
  6070. * selectOptions: [ { value: 1, label: 'male' }, { value: 2, label: 'female' } ]
  6071. * },
  6072. * {
  6073. * condition: uiGridConstants.filter.ENDS_WITH,
  6074. * placeholder: 'ends with...'
  6075. * }
  6076. * ]
  6077. * }
  6078. * ]; </pre>
  6079. *
  6080. *
  6081. */
  6082. /**
  6083. * @ngdoc array
  6084. * @name filters
  6085. * @propertyOf ui.grid.class:GridColumn
  6086. * @description Filters for this column. Includes 'term' property bound to filter input elements.
  6087. * @example
  6088. * <pre>[
  6089. * {
  6090. * term: 'foo', // ngModel for <input>
  6091. * condition: uiGridConstants.filter.STARTS_WITH,
  6092. * placeholder: 'starts with...',
  6093. * ariaLabel: 'Filter for foo',
  6094. * flags: { caseSensitive: false },
  6095. * type: uiGridConstants.filter.SELECT,
  6096. * selectOptions: [ { value: 1, label: 'male' }, { value: 2, label: 'female' } ]
  6097. * },
  6098. * {
  6099. * term: 'baz',
  6100. * condition: uiGridConstants.filter.ENDS_WITH,
  6101. * placeholder: 'ends with...'
  6102. * }
  6103. * ] </pre>
  6104. *
  6105. *
  6106. */
  6107. /**
  6108. * @ngdoc array
  6109. * @name menuItems
  6110. * @propertyOf ui.grid.class:GridOptions.columnDef
  6111. * @description used to add menu items to a column. Refer to the tutorial on this
  6112. * functionality. A number of settings are supported:
  6113. *
  6114. * - title: controls the title that is displayed in the menu
  6115. * - icon: the icon shown alongside that title
  6116. * - action: the method to call when the menu is clicked
  6117. * - shown: a function to evaluate to determine whether or not to show the item
  6118. * - active: a function to evaluate to determine whether or not the item is currently selected
  6119. * - context: context to pass to the action function, available in this.context in your handler
  6120. * - leaveOpen: if set to true, the menu should stay open after the action, defaults to false
  6121. * @example
  6122. * <pre> $scope.gridOptions.columnDefs = [
  6123. * { field: 'field1', menuItems: [
  6124. * {
  6125. * title: 'Outer Scope Alert',
  6126. * icon: 'ui-grid-icon-info-circled',
  6127. * action: function($event) {
  6128. * this.context.blargh(); // $scope.blargh() would work too, this is just an example
  6129. * },
  6130. * shown: function() { return true; },
  6131. * active: function() { return true; },
  6132. * context: $scope
  6133. * },
  6134. * {
  6135. * title: 'Grid ID',
  6136. * action: function() {
  6137. * alert('Grid ID: ' + this.grid.id);
  6138. * }
  6139. * }
  6140. * ] }]; </pre>
  6141. *
  6142. */
  6143. /**
  6144. * @ngdoc method
  6145. * @methodOf ui.grid.class:GridColumn
  6146. * @name updateColumnDef
  6147. * @description Moves settings from the columnDef down onto the column,
  6148. * and sets properties as appropriate
  6149. * @param {ColumnDef} colDef the column def to look in for the property value
  6150. * @param {boolean} isNew whether the column is being newly created, if not
  6151. * we're updating an existing column, and some items such as the sort shouldn't
  6152. * be copied down
  6153. */
  6154. GridColumn.prototype.updateColumnDef = function(colDef, isNew) {
  6155. var self = this;
  6156. self.colDef = colDef;
  6157. if (colDef.name === undefined) {
  6158. throw new Error('colDef.name is required for column at index ' + self.grid.options.columnDefs.indexOf(colDef));
  6159. }
  6160. self.displayName = (colDef.displayName === undefined) ? gridUtil.readableColumnName(colDef.name) : colDef.displayName;
  6161. if (!angular.isNumber(self.width) || !self.hasCustomWidth || colDef.allowCustomWidthOverride) {
  6162. var colDefWidth = colDef.width;
  6163. var parseErrorMsg = "Cannot parse column width '" + colDefWidth + "' for column named '" + colDef.name + "'";
  6164. self.hasCustomWidth = false;
  6165. if (!angular.isString(colDefWidth) && !angular.isNumber(colDefWidth)) {
  6166. self.width = '*';
  6167. } else if (angular.isString(colDefWidth)) {
  6168. // See if it ends with a percent
  6169. if (gridUtil.endsWith(colDefWidth, '%')) {
  6170. // If so we should be able to parse the non-percent-sign part to a number
  6171. var percentStr = colDefWidth.replace(/%/g, '');
  6172. var percent = parseInt(percentStr, 10);
  6173. if (isNaN(percent)) {
  6174. throw new Error(parseErrorMsg);
  6175. }
  6176. self.width = colDefWidth;
  6177. }
  6178. // And see if it's a number string
  6179. else if (colDefWidth.match(/^(\d+)$/)) {
  6180. self.width = parseInt(colDefWidth.match(/^(\d+)$/)[1], 10);
  6181. }
  6182. // Otherwise it should be a string of asterisks
  6183. else if (colDefWidth.match(/^\*+$/)) {
  6184. self.width = colDefWidth;
  6185. }
  6186. // No idea, throw an Error
  6187. else {
  6188. throw new Error(parseErrorMsg);
  6189. }
  6190. }
  6191. // Is a number, use it as the width
  6192. else {
  6193. self.width = colDefWidth;
  6194. }
  6195. }
  6196. ['minWidth', 'maxWidth'].forEach(function (name) {
  6197. var minOrMaxWidth = colDef[name];
  6198. var parseErrorMsg = "Cannot parse column " + name + " '" + minOrMaxWidth + "' for column named '" + colDef.name + "'";
  6199. if (!angular.isString(minOrMaxWidth) && !angular.isNumber(minOrMaxWidth)) {
  6200. //Sets default minWidth and maxWidth values
  6201. self[name] = ((name === 'minWidth') ? 30 : 9000);
  6202. } else if (angular.isString(minOrMaxWidth)) {
  6203. if (minOrMaxWidth.match(/^(\d+)$/)) {
  6204. self[name] = parseInt(minOrMaxWidth.match(/^(\d+)$/)[1], 10);
  6205. } else {
  6206. throw new Error(parseErrorMsg);
  6207. }
  6208. } else {
  6209. self[name] = minOrMaxWidth;
  6210. }
  6211. });
  6212. //use field if it is defined; name if it is not
  6213. self.field = (colDef.field === undefined) ? colDef.name : colDef.field;
  6214. if ( typeof( self.field ) !== 'string' ){
  6215. gridUtil.logError( 'Field is not a string, this is likely to break the code, Field is: ' + self.field );
  6216. }
  6217. self.name = colDef.name;
  6218. // Use colDef.displayName as long as it's not undefined, otherwise default to the field name
  6219. self.displayName = (colDef.displayName === undefined) ? gridUtil.readableColumnName(colDef.name) : colDef.displayName;
  6220. //self.originalIndex = index;
  6221. self.aggregationType = angular.isDefined(colDef.aggregationType) ? colDef.aggregationType : null;
  6222. self.footerCellTemplate = angular.isDefined(colDef.footerCellTemplate) ? colDef.footerCellTemplate : null;
  6223. /**
  6224. * @ngdoc property
  6225. * @name cellTooltip
  6226. * @propertyOf ui.grid.class:GridOptions.columnDef
  6227. * @description Whether or not to show a tooltip when a user hovers over the cell.
  6228. * If set to false, no tooltip. If true, the cell value is shown in the tooltip (useful
  6229. * if you have long values in your cells), if a function then that function is called
  6230. * passing in the row and the col `cellTooltip( row, col )`, and the return value is shown in the tooltip,
  6231. * if it is a static string then displays that static string.
  6232. *
  6233. * Defaults to false
  6234. *
  6235. */
  6236. if ( typeof(colDef.cellTooltip) === 'undefined' || colDef.cellTooltip === false ) {
  6237. self.cellTooltip = false;
  6238. } else if ( colDef.cellTooltip === true ){
  6239. self.cellTooltip = function(row, col) {
  6240. return self.grid.getCellValue( row, col );
  6241. };
  6242. } else if (typeof(colDef.cellTooltip) === 'function' ){
  6243. self.cellTooltip = colDef.cellTooltip;
  6244. } else {
  6245. self.cellTooltip = function ( row, col ){
  6246. return col.colDef.cellTooltip;
  6247. };
  6248. }
  6249. /**
  6250. * @ngdoc property
  6251. * @name headerTooltip
  6252. * @propertyOf ui.grid.class:GridOptions.columnDef
  6253. * @description Whether or not to show a tooltip when a user hovers over the header cell.
  6254. * If set to false, no tooltip. If true, the displayName is shown in the tooltip (useful
  6255. * if you have long values in your headers), if a function then that function is called
  6256. * passing in the row and the col `headerTooltip( col )`, and the return value is shown in the tooltip,
  6257. * if a static string then shows that static string.
  6258. *
  6259. * Defaults to false
  6260. *
  6261. */
  6262. if ( typeof(colDef.headerTooltip) === 'undefined' || colDef.headerTooltip === false ) {
  6263. self.headerTooltip = false;
  6264. } else if ( colDef.headerTooltip === true ){
  6265. self.headerTooltip = function(col) {
  6266. return col.displayName;
  6267. };
  6268. } else if (typeof(colDef.headerTooltip) === 'function' ){
  6269. self.headerTooltip = colDef.headerTooltip;
  6270. } else {
  6271. self.headerTooltip = function ( col ) {
  6272. return col.colDef.headerTooltip;
  6273. };
  6274. }
  6275. /**
  6276. * @ngdoc property
  6277. * @name footerCellClass
  6278. * @propertyOf ui.grid.class:GridOptions.columnDef
  6279. * @description footerCellClass can be a string specifying the class to append to a cell
  6280. * or it can be a function(grid, row, col, rowRenderIndex, colRenderIndex) that returns a class name
  6281. *
  6282. */
  6283. self.footerCellClass = colDef.footerCellClass;
  6284. /**
  6285. * @ngdoc property
  6286. * @name cellClass
  6287. * @propertyOf ui.grid.class:GridOptions.columnDef
  6288. * @description cellClass can be a string specifying the class to append to a cell
  6289. * or it can be a function(grid, row, col, rowRenderIndex, colRenderIndex) that returns a class name
  6290. *
  6291. */
  6292. self.cellClass = colDef.cellClass;
  6293. /**
  6294. * @ngdoc property
  6295. * @name headerCellClass
  6296. * @propertyOf ui.grid.class:GridOptions.columnDef
  6297. * @description headerCellClass can be a string specifying the class to append to a cell
  6298. * or it can be a function(grid, row, col, rowRenderIndex, colRenderIndex) that returns a class name
  6299. *
  6300. */
  6301. self.headerCellClass = colDef.headerCellClass;
  6302. /**
  6303. * @ngdoc property
  6304. * @name cellFilter
  6305. * @propertyOf ui.grid.class:GridOptions.columnDef
  6306. * @description cellFilter is a filter to apply to the content of each cell
  6307. * @example
  6308. * <pre>
  6309. * gridOptions.columnDefs[0].cellFilter = 'date'
  6310. *
  6311. */
  6312. self.cellFilter = colDef.cellFilter ? colDef.cellFilter : "";
  6313. /**
  6314. * @ngdoc boolean
  6315. * @name sortCellFiltered
  6316. * @propertyOf ui.grid.class:GridOptions.columnDef
  6317. * @description (optional) False by default. When `true` uiGrid will apply the cellFilter before
  6318. * sorting the data. Note that when using this option uiGrid will assume that the displayed value is
  6319. * a string, and use the {@link ui.grid.class:RowSorter#sortAlpha sortAlpha} `sortFn`. It is possible
  6320. * to return a non-string value from an angularjs filter, in which case you should define a {@link ui.grid.class:GridOptions.columnDef#sortingAlgorithm sortingAlgorithm}
  6321. * for the column which hanldes the returned type. You may specify one of the `sortingAlgorithms`
  6322. * found in the {@link ui.grid.RowSorter rowSorter} service.
  6323. */
  6324. self.sortCellFiltered = colDef.sortCellFiltered ? true : false;
  6325. /**
  6326. * @ngdoc boolean
  6327. * @name filterCellFiltered
  6328. * @propertyOf ui.grid.class:GridOptions.columnDef
  6329. * @description (optional) False by default. When `true` uiGrid will apply the cellFilter before
  6330. * applying "search" `filters`.
  6331. */
  6332. self.filterCellFiltered = colDef.filterCellFiltered ? true : false;
  6333. /**
  6334. * @ngdoc property
  6335. * @name headerCellFilter
  6336. * @propertyOf ui.grid.class:GridOptions.columnDef
  6337. * @description headerCellFilter is a filter to apply to the content of the column header
  6338. * @example
  6339. * <pre>
  6340. * gridOptions.columnDefs[0].headerCellFilter = 'translate'
  6341. *
  6342. */
  6343. self.headerCellFilter = colDef.headerCellFilter ? colDef.headerCellFilter : "";
  6344. /**
  6345. * @ngdoc property
  6346. * @name footerCellFilter
  6347. * @propertyOf ui.grid.class:GridOptions.columnDef
  6348. * @description footerCellFilter is a filter to apply to the content of the column footer
  6349. * @example
  6350. * <pre>
  6351. * gridOptions.columnDefs[0].footerCellFilter = 'date'
  6352. *
  6353. */
  6354. self.footerCellFilter = colDef.footerCellFilter ? colDef.footerCellFilter : "";
  6355. self.visible = gridUtil.isNullOrUndefined(colDef.visible) || colDef.visible;
  6356. self.headerClass = colDef.headerClass;
  6357. //self.cursor = self.sortable ? 'pointer' : 'default';
  6358. // Turn on sorting by default
  6359. self.enableSorting = typeof(colDef.enableSorting) !== 'undefined' ? colDef.enableSorting : self.grid.options.enableSorting;
  6360. self.sortingAlgorithm = colDef.sortingAlgorithm;
  6361. /**
  6362. * @ngdoc property
  6363. * @name sortDirectionCycle
  6364. * @propertyOf ui.grid.class:GridOptions.columnDef
  6365. * @description (optional) An array of {@link ui.grid.service:uiGridConstants#properties_ASC sort directions},
  6366. * specifying the order that they should cycle through as the user repeatedly clicks on the column heading.
  6367. * The default is `[null, uiGridConstants.ASC, uiGridConstants.DESC]`. Null
  6368. * refers to the unsorted state. This does not affect the initial sort
  6369. * direction; use the {@link ui.grid.class:GridOptions.columnDef#sort sort}
  6370. * property for that. If
  6371. * {@link ui.grid.class:GridOptions.columnDef#suppressRemoveSort suppressRemoveSort}
  6372. * is also set, the unsorted state will be skipped even if it is listed here.
  6373. * Each direction may not appear in the list more than once (e.g. `[ASC,
  6374. * DESC, DESC]` is not allowed), and the list may not be empty.
  6375. */
  6376. self.sortDirectionCycle = typeof(colDef.sortDirectionCycle) !== 'undefined' ?
  6377. colDef.sortDirectionCycle :
  6378. [null, uiGridConstants.ASC, uiGridConstants.DESC];
  6379. /**
  6380. * @ngdoc boolean
  6381. * @name suppressRemoveSort
  6382. * @propertyOf ui.grid.class:GridOptions.columnDef
  6383. * @description (optional) False by default. When enabled, this setting hides the removeSort option
  6384. * in the menu, and prevents users from manually removing the sort
  6385. */
  6386. if ( typeof(self.suppressRemoveSort) === 'undefined'){
  6387. self.suppressRemoveSort = typeof(colDef.suppressRemoveSort) !== 'undefined' ? colDef.suppressRemoveSort : false;
  6388. }
  6389. /**
  6390. * @ngdoc property
  6391. * @name enableFiltering
  6392. * @propertyOf ui.grid.class:GridOptions.columnDef
  6393. * @description turn off filtering for an individual column, where
  6394. * you've turned on filtering for the overall grid
  6395. * @example
  6396. * <pre>
  6397. * gridOptions.columnDefs[0].enableFiltering = false;
  6398. *
  6399. */
  6400. // Turn on filtering by default (it's disabled by default at the Grid level)
  6401. self.enableFiltering = typeof(colDef.enableFiltering) !== 'undefined' ? colDef.enableFiltering : true;
  6402. // self.menuItems = colDef.menuItems;
  6403. self.setPropertyOrDefault(colDef, 'menuItems', []);
  6404. // Use the column definition sort if we were passed it, but only if this is a newly added column
  6405. if ( isNew ){
  6406. self.setPropertyOrDefault(colDef, 'sort');
  6407. }
  6408. // Use the column definition defaultSort always, unlike normal sort
  6409. self.setPropertyOrDefault(colDef, 'defaultSort');
  6410. // Set up default filters array for when one is not provided.
  6411. // In other words, this (in column def):
  6412. //
  6413. // filter: { term: 'something', flags: {}, condition: [CONDITION] }
  6414. //
  6415. // is just shorthand for this:
  6416. //
  6417. // filters: [{ term: 'something', flags: {}, condition: [CONDITION] }]
  6418. //
  6419. var defaultFilters = [];
  6420. if (colDef.filter) {
  6421. defaultFilters.push(colDef.filter);
  6422. }
  6423. else if ( colDef.filters ){
  6424. defaultFilters = colDef.filters;
  6425. } else {
  6426. // Add an empty filter definition object, which will
  6427. // translate to a guessed condition and no pre-populated
  6428. // value for the filter <input>.
  6429. defaultFilters.push({});
  6430. }
  6431. /**
  6432. * @ngdoc property
  6433. * @name filter
  6434. * @propertyOf ui.grid.class:GridOptions.columnDef
  6435. * @description Specify a single filter field on this column.
  6436. *
  6437. * A filter consists of a condition, a term, and a placeholder:
  6438. *
  6439. * - condition defines how rows are chosen as matching the filter term. This can be set to
  6440. * one of the constants in {@link ui.grid.service:uiGridConstants#properties_filter uiGridConstants.filter},
  6441. * or you can supply a custom filter function
  6442. * that gets passed the following arguments: [searchTerm, cellValue, row, column].
  6443. * - term: If set, the filter field will be pre-populated
  6444. * with this value.
  6445. * - placeholder: String that will be set to the `<input>.placeholder` attribute.
  6446. * - ariaLabel: String that will be set to the `<input>.ariaLabel` attribute. This is what is read as a label to screen reader users.
  6447. * - noTerm: set this to true if you have defined a custom function in condition, and
  6448. * your custom function doesn't require a term (so it can run even when the term is null)
  6449. * - rawTerm: set this to true if you have defined a custom function in condition, and
  6450. * your custom function requires access to the raw unmodified search term that was entered
  6451. * - flags: only flag currently available is `caseSensitive`, set to false if you don't want
  6452. * case sensitive matching
  6453. * - type: defaults to {@link ui.grid.service:uiGridConstants#properties_filter uiGridConstants.filter.INPUT},
  6454. * which gives a text box. If set to {@link ui.grid.service:uiGridConstants#properties_filter uiGridConstants.filter.SELECT}
  6455. * then a select box will be shown with options selectOptions
  6456. * - selectOptions: options in the format `[ { value: 1, label: 'male' }]`. No i18n filter is provided, you need
  6457. * to perform the i18n on the values before you provide them
  6458. * - disableCancelFilterButton: defaults to false. If set to true then the 'x' button that cancels/clears the filter
  6459. * will not be shown.
  6460. * @example
  6461. * <pre>$scope.gridOptions.columnDefs = [
  6462. * {
  6463. * field: 'field1',
  6464. * filter: {
  6465. * term: 'xx',
  6466. * condition: uiGridConstants.filter.STARTS_WITH,
  6467. * placeholder: 'starts with...',
  6468. * ariaLabel: 'Starts with filter for field1',
  6469. * flags: { caseSensitive: false },
  6470. * type: uiGridConstants.filter.SELECT,
  6471. * selectOptions: [ { value: 1, label: 'male' }, { value: 2, label: 'female' } ],
  6472. * disableCancelFilterButton: true
  6473. * }
  6474. * }
  6475. * ]; </pre>
  6476. *
  6477. */
  6478. /*
  6479. /*
  6480. self.filters = [
  6481. {
  6482. term: 'search term'
  6483. condition: uiGridConstants.filter.CONTAINS,
  6484. placeholder: 'my placeholder',
  6485. ariaLabel: 'Starts with filter for field1',
  6486. flags: {
  6487. caseSensitive: true
  6488. }
  6489. }
  6490. ]
  6491. */
  6492. // Only set filter if this is a newly added column, if we're updating an existing
  6493. // column then we don't want to put the default filter back if the user may have already
  6494. // removed it.
  6495. // However, we do want to keep the settings if they change, just not the term
  6496. if ( isNew ) {
  6497. self.setPropertyOrDefault(colDef, 'filter');
  6498. self.setPropertyOrDefault(colDef, 'extraStyle');
  6499. self.setPropertyOrDefault(colDef, 'filters', defaultFilters);
  6500. } else if ( self.filters.length === defaultFilters.length ) {
  6501. self.filters.forEach( function( filter, index ){
  6502. if (typeof(defaultFilters[index].placeholder) !== 'undefined') {
  6503. filter.placeholder = defaultFilters[index].placeholder;
  6504. }
  6505. if (typeof(defaultFilters[index].ariaLabel) !== 'undefined') {
  6506. filter.ariaLabel = defaultFilters[index].ariaLabel;
  6507. }
  6508. if (typeof(defaultFilters[index].flags) !== 'undefined') {
  6509. filter.flags = defaultFilters[index].flags;
  6510. }
  6511. if (typeof(defaultFilters[index].type) !== 'undefined') {
  6512. filter.type = defaultFilters[index].type;
  6513. }
  6514. if (typeof(defaultFilters[index].selectOptions) !== 'undefined') {
  6515. filter.selectOptions = defaultFilters[index].selectOptions;
  6516. }
  6517. });
  6518. }
  6519. };
  6520. /**
  6521. * @ngdoc function
  6522. * @name unsort
  6523. * @methodOf ui.grid.class:GridColumn
  6524. * @description Removes column from the grid sorting
  6525. */
  6526. GridColumn.prototype.unsort = function () {
  6527. //Decrease priority for every col where priority is higher than the removed sort's priority.
  6528. var thisPriority = this.sort.priority;
  6529. this.grid.columns.forEach(function (col) {
  6530. if (col.sort && col.sort.priority !== undefined && col.sort.priority > thisPriority) {
  6531. col.sort.priority -= 1;
  6532. }
  6533. });
  6534. this.sort = {};
  6535. this.grid.api.core.raise.sortChanged( this.grid, this.grid.getColumnSorting() );
  6536. };
  6537. /**
  6538. * @ngdoc function
  6539. * @name getColClass
  6540. * @methodOf ui.grid.class:GridColumn
  6541. * @description Returns the class name for the column
  6542. * @param {bool} prefixDot if true, will return .className instead of className
  6543. */
  6544. GridColumn.prototype.getColClass = function (prefixDot) {
  6545. var cls = uiGridConstants.COL_CLASS_PREFIX + this.uid;
  6546. return prefixDot ? '.' + cls : cls;
  6547. };
  6548. /**
  6549. * @ngdoc function
  6550. * @name isPinnedLeft
  6551. * @methodOf ui.grid.class:GridColumn
  6552. * @description Returns true if column is in the left render container
  6553. */
  6554. GridColumn.prototype.isPinnedLeft = function () {
  6555. return this.renderContainer === 'left';
  6556. };
  6557. /**
  6558. * @ngdoc function
  6559. * @name isPinnedRight
  6560. * @methodOf ui.grid.class:GridColumn
  6561. * @description Returns true if column is in the right render container
  6562. */
  6563. GridColumn.prototype.isPinnedRight = function () {
  6564. return this.renderContainer === 'right';
  6565. };
  6566. /**
  6567. * @ngdoc function
  6568. * @name getColClassDefinition
  6569. * @methodOf ui.grid.class:GridColumn
  6570. * @description Returns the class definition for th column
  6571. */
  6572. GridColumn.prototype.getColClassDefinition = function () {
  6573. return ' .grid' + this.grid.id + ' ' + this.getColClass(true) + ' { min-width: ' + this.drawnWidth + 'px; max-width: ' + this.drawnWidth + 'px; }';
  6574. };
  6575. /**
  6576. * @ngdoc function
  6577. * @name getRenderContainer
  6578. * @methodOf ui.grid.class:GridColumn
  6579. * @description Returns the render container object that this column belongs to.
  6580. *
  6581. * Columns will be default be in the `body` render container if they aren't allocated to one specifically.
  6582. */
  6583. GridColumn.prototype.getRenderContainer = function getRenderContainer() {
  6584. var self = this;
  6585. var containerId = self.renderContainer;
  6586. if (containerId === null || containerId === '' || containerId === undefined) {
  6587. containerId = 'body';
  6588. }
  6589. return self.grid.renderContainers[containerId];
  6590. };
  6591. /**
  6592. * @ngdoc function
  6593. * @name showColumn
  6594. * @methodOf ui.grid.class:GridColumn
  6595. * @description Makes the column visible by setting colDef.visible = true
  6596. */
  6597. GridColumn.prototype.showColumn = function() {
  6598. this.colDef.visible = true;
  6599. };
  6600. /**
  6601. * @ngdoc property
  6602. * @name aggregationHideLabel
  6603. * @propertyOf ui.grid.class:GridOptions.columnDef
  6604. * @description defaults to false, if set to true hides the label text
  6605. * in the aggregation footer, so only the value is displayed.
  6606. *
  6607. */
  6608. /**
  6609. * @ngdoc function
  6610. * @name getAggregationText
  6611. * @methodOf ui.grid.class:GridColumn
  6612. * @description Gets the aggregation label from colDef.aggregationLabel if
  6613. * specified or by using i18n, including deciding whether or not to display
  6614. * based on colDef.aggregationHideLabel.
  6615. *
  6616. * @param {string} label the i18n lookup value to use for the column label
  6617. *
  6618. */
  6619. GridColumn.prototype.getAggregationText = function () {
  6620. var self = this;
  6621. if ( self.colDef.aggregationHideLabel ){
  6622. return '';
  6623. }
  6624. else if ( self.colDef.aggregationLabel ) {
  6625. return self.colDef.aggregationLabel;
  6626. }
  6627. else {
  6628. switch ( self.colDef.aggregationType ){
  6629. case uiGridConstants.aggregationTypes.count:
  6630. return i18nService.getSafeText('aggregation.count');
  6631. case uiGridConstants.aggregationTypes.sum:
  6632. return i18nService.getSafeText('aggregation.sum');
  6633. case uiGridConstants.aggregationTypes.avg:
  6634. return i18nService.getSafeText('aggregation.avg');
  6635. case uiGridConstants.aggregationTypes.min:
  6636. return i18nService.getSafeText('aggregation.min');
  6637. case uiGridConstants.aggregationTypes.max:
  6638. return i18nService.getSafeText('aggregation.max');
  6639. default:
  6640. return '';
  6641. }
  6642. }
  6643. };
  6644. GridColumn.prototype.getCellTemplate = function () {
  6645. var self = this;
  6646. return self.cellTemplatePromise;
  6647. };
  6648. GridColumn.prototype.getCompiledElementFn = function () {
  6649. var self = this;
  6650. return self.compiledElementFnDefer.promise;
  6651. };
  6652. return GridColumn;
  6653. }]);
  6654. })();
  6655. (function(){
  6656. angular.module('ui.grid')
  6657. .factory('GridOptions', ['gridUtil','uiGridConstants', function(gridUtil,uiGridConstants) {
  6658. /**
  6659. * @ngdoc function
  6660. * @name ui.grid.class:GridOptions
  6661. * @description Default GridOptions class. GridOptions are defined by the application developer and overlaid
  6662. * over this object. Setting gridOptions within your controller is the most common method for an application
  6663. * developer to configure the behaviour of their ui-grid
  6664. *
  6665. * @example To define your gridOptions within your controller:
  6666. * <pre>$scope.gridOptions = {
  6667. * data: $scope.myData,
  6668. * columnDefs: [
  6669. * { name: 'field1', displayName: 'pretty display name' },
  6670. * { name: 'field2', visible: false }
  6671. * ]
  6672. * };</pre>
  6673. *
  6674. * You can then use this within your html template, when you define your grid:
  6675. * <pre>&lt;div ui-grid="gridOptions"&gt;&lt;/div&gt;</pre>
  6676. *
  6677. * To provide default options for all of the grids within your application, use an angular
  6678. * decorator to modify the GridOptions factory.
  6679. * <pre>
  6680. * app.config(function($provide){
  6681. * $provide.decorator('GridOptions',function($delegate){
  6682. * var gridOptions;
  6683. * gridOptions = angular.copy($delegate);
  6684. * gridOptions.initialize = function(options) {
  6685. * var initOptions;
  6686. * initOptions = $delegate.initialize(options);
  6687. * initOptions.enableColumnMenus = false;
  6688. * return initOptions;
  6689. * };
  6690. * return gridOptions;
  6691. * });
  6692. * });
  6693. * </pre>
  6694. */
  6695. return {
  6696. initialize: function( baseOptions ){
  6697. /**
  6698. * @ngdoc function
  6699. * @name onRegisterApi
  6700. * @propertyOf ui.grid.class:GridOptions
  6701. * @description A callback that returns the gridApi once the grid is instantiated, which is
  6702. * then used to interact with the grid programatically.
  6703. *
  6704. * Note that the gridApi.core.renderingComplete event is identical to this
  6705. * callback, but has the advantage that it can be called from multiple places
  6706. * if needed
  6707. *
  6708. * @example
  6709. * <pre>
  6710. * $scope.gridOptions.onRegisterApi = function ( gridApi ) {
  6711. * $scope.gridApi = gridApi;
  6712. * $scope.gridApi.selection.selectAllRows( $scope.gridApi.grid );
  6713. * };
  6714. * </pre>
  6715. *
  6716. */
  6717. baseOptions.onRegisterApi = baseOptions.onRegisterApi || angular.noop();
  6718. /**
  6719. * @ngdoc object
  6720. * @name data
  6721. * @propertyOf ui.grid.class:GridOptions
  6722. * @description (mandatory) Array of data to be rendered into the grid, providing the data source or data binding for
  6723. * the grid.
  6724. *
  6725. * Most commonly the data is an array of objects, where each object has a number of attributes.
  6726. * Each attribute automatically becomes a column in your grid. This array could, for example, be sourced from
  6727. * an angularJS $resource query request. The array can also contain complex objects, refer the binding tutorial
  6728. * for examples of that.
  6729. *
  6730. * The most flexible usage is to set your data on $scope:
  6731. *
  6732. * `$scope.data = data;`
  6733. *
  6734. * And then direct the grid to resolve whatever is in $scope.data:
  6735. *
  6736. * `$scope.gridOptions.data = 'data';`
  6737. *
  6738. * This is the most flexible approach as it allows you to replace $scope.data whenever you feel like it without
  6739. * getting pointer issues.
  6740. *
  6741. * Alternatively you can directly set the data array:
  6742. *
  6743. * `$scope.gridOptions.data = [ ];`
  6744. * or
  6745. *
  6746. * `$http.get('/data/100.json')
  6747. * .success(function(data) {
  6748. * $scope.myData = data;
  6749. * $scope.gridOptions.data = $scope.myData;
  6750. * });`
  6751. *
  6752. * Where you do this, you need to take care in updating the data - you can't just update `$scope.myData` to some other
  6753. * array, you need to update $scope.gridOptions.data to point to that new array as well.
  6754. *
  6755. */
  6756. baseOptions.data = baseOptions.data || [];
  6757. /**
  6758. * @ngdoc array
  6759. * @name columnDefs
  6760. * @propertyOf ui.grid.class:GridOptions
  6761. * @description Array of columnDef objects. Only required property is name.
  6762. * The individual options available in columnDefs are documented in the
  6763. * {@link ui.grid.class:GridOptions.columnDef columnDef} section
  6764. * </br>_field property can be used in place of name for backwards compatibility with 2.x_
  6765. * @example
  6766. *
  6767. * <pre>var columnDefs = [{name:'field1'}, {name:'field2'}];</pre>
  6768. *
  6769. */
  6770. baseOptions.columnDefs = baseOptions.columnDefs || [];
  6771. /**
  6772. * @ngdoc object
  6773. * @name ui.grid.class:GridOptions.columnDef
  6774. * @description Definition / configuration of an individual column, which would typically be
  6775. * one of many column definitions within the gridOptions.columnDefs array
  6776. * @example
  6777. * <pre>{name:'field1', field: 'field1', filter: { term: 'xxx' }}</pre>
  6778. *
  6779. */
  6780. /**
  6781. * @ngdoc object
  6782. * @name enableGridMenu
  6783. * @propertyOf ui.grid.class:GridOptions
  6784. * @description Takes a boolean that adds a settings icon in the top right of the grid, which floats above
  6785. * the column header, when true. The menu by default gives access to show/hide columns, but can be
  6786. * customised to show additional actions.
  6787. *
  6788. * See the {@link #!/tutorial/121_grid_menu Grid Menu tutorial} for more detailed information.
  6789. */
  6790. /**
  6791. * @ngdoc array
  6792. * @name excludeProperties
  6793. * @propertyOf ui.grid.class:GridOptions
  6794. * @description Array of property names in data to ignore when auto-generating column names. Provides the
  6795. * inverse of columnDefs - columnDefs is a list of columns to include, excludeProperties is a list of columns
  6796. * to exclude.
  6797. *
  6798. * If columnDefs is defined, this will be ignored.
  6799. *
  6800. * Defaults to ['$$hashKey']
  6801. */
  6802. baseOptions.excludeProperties = baseOptions.excludeProperties || ['$$hashKey'];
  6803. /**
  6804. * @ngdoc boolean
  6805. * @name enableRowHashing
  6806. * @propertyOf ui.grid.class:GridOptions
  6807. * @description True by default. When enabled, this setting allows uiGrid to add
  6808. * `$$hashKey`-type properties (similar to Angular) to elements in the `data` array. This allows
  6809. * the grid to maintain state while vastly speeding up the process of altering `data` by adding/moving/removing rows.
  6810. *
  6811. * Note that this DOES add properties to your data that you may not want, but they are stripped out when using `angular.toJson()`. IF
  6812. * you do not want this at all you can disable this setting but you will take a performance hit if you are using large numbers of rows
  6813. * and are altering the data set often.
  6814. */
  6815. baseOptions.enableRowHashing = baseOptions.enableRowHashing !== false;
  6816. /**
  6817. * @ngdoc function
  6818. * @name rowIdentity
  6819. * @methodOf ui.grid.class:GridOptions
  6820. * @description This function is used to get and, if necessary, set the value uniquely identifying this row (i.e. if an identity is not present it will set one).
  6821. *
  6822. * By default it returns the `$$hashKey` property if it exists. If it doesn't it uses gridUtil.nextUid() to generate one
  6823. */
  6824. baseOptions.rowIdentity = baseOptions.rowIdentity || function rowIdentity(row) {
  6825. return gridUtil.hashKey(row);
  6826. };
  6827. /**
  6828. * @ngdoc function
  6829. * @name getRowIdentity
  6830. * @methodOf ui.grid.class:GridOptions
  6831. * @description This function returns the identity value uniquely identifying this row, if one is not present it does not set it.
  6832. *
  6833. * By default it returns the `$$hashKey` property but can be overridden to use any property or set of properties you want.
  6834. */
  6835. baseOptions.getRowIdentity = baseOptions.getRowIdentity || function getRowIdentity(row) {
  6836. return row.$$hashKey;
  6837. };
  6838. /**
  6839. * @ngdoc property
  6840. * @name flatEntityAccess
  6841. * @propertyOf ui.grid.class:GridOptions
  6842. * @description Set to true if your columns are all related directly to fields in a flat object structure - i.e.
  6843. * each of your columns associate directly with a property on each of the entities in your data array.
  6844. *
  6845. * In that situation we can avoid all the logic associated with complex binding to functions or to properties of sub-objects,
  6846. * which can provide a significant speed improvement with large data sets when filtering or sorting.
  6847. *
  6848. * By default false
  6849. */
  6850. baseOptions.flatEntityAccess = baseOptions.flatEntityAccess === true;
  6851. /**
  6852. * @ngdoc property
  6853. * @name showHeader
  6854. * @propertyOf ui.grid.class:GridOptions
  6855. * @description True by default. When set to false, this setting will replace the
  6856. * standard header template with '<div></div>', resulting in no header being shown.
  6857. */
  6858. baseOptions.showHeader = typeof(baseOptions.showHeader) !== "undefined" ? baseOptions.showHeader : true;
  6859. /* (NOTE): Don't show this in the docs. We only use it internally
  6860. * @ngdoc property
  6861. * @name headerRowHeight
  6862. * @propertyOf ui.grid.class:GridOptions
  6863. * @description The height of the header in pixels, defaults to 30
  6864. *
  6865. */
  6866. if (!baseOptions.showHeader) {
  6867. baseOptions.headerRowHeight = 0;
  6868. }
  6869. else {
  6870. baseOptions.headerRowHeight = typeof(baseOptions.headerRowHeight) !== "undefined" ? baseOptions.headerRowHeight : 30;
  6871. }
  6872. /**
  6873. * @ngdoc property
  6874. * @name rowHeight
  6875. * @propertyOf ui.grid.class:GridOptions
  6876. * @description The height of the row in pixels, Can be passed as integer or string. defaults to 30.
  6877. *
  6878. */
  6879. if (typeof baseOptions.rowHeight === "string") {
  6880. baseOptions.rowHeight = parseInt(baseOptions.rowHeight) || 30;
  6881. }
  6882. else {
  6883. baseOptions.rowHeight = baseOptions.rowHeight || 30;
  6884. }
  6885. /**
  6886. * @ngdoc integer
  6887. * @name minRowsToShow
  6888. * @propertyOf ui.grid.class:GridOptions
  6889. * @description Minimum number of rows to show when the grid doesn't have a defined height. Defaults to "10".
  6890. */
  6891. baseOptions.minRowsToShow = typeof(baseOptions.minRowsToShow) !== "undefined" ? baseOptions.minRowsToShow : 10;
  6892. /**
  6893. * @ngdoc property
  6894. * @name showGridFooter
  6895. * @propertyOf ui.grid.class:GridOptions
  6896. * @description Whether or not to show the footer, defaults to false
  6897. * The footer display Total Rows and Visible Rows (filtered rows)
  6898. */
  6899. baseOptions.showGridFooter = baseOptions.showGridFooter === true;
  6900. /**
  6901. * @ngdoc property
  6902. * @name showColumnFooter
  6903. * @propertyOf ui.grid.class:GridOptions
  6904. * @description Whether or not to show the column footer, defaults to false
  6905. * The column footer displays column aggregates
  6906. */
  6907. baseOptions.showColumnFooter = baseOptions.showColumnFooter === true;
  6908. /**
  6909. * @ngdoc property
  6910. * @name columnFooterHeight
  6911. * @propertyOf ui.grid.class:GridOptions
  6912. * @description The height of the footer rows (column footer and grid footer) in pixels
  6913. *
  6914. */
  6915. baseOptions.columnFooterHeight = typeof(baseOptions.columnFooterHeight) !== "undefined" ? baseOptions.columnFooterHeight : 30;
  6916. baseOptions.gridFooterHeight = typeof(baseOptions.gridFooterHeight) !== "undefined" ? baseOptions.gridFooterHeight : 30;
  6917. baseOptions.columnWidth = typeof(baseOptions.columnWidth) !== "undefined" ? baseOptions.columnWidth : 50;
  6918. /**
  6919. * @ngdoc property
  6920. * @name maxVisibleColumnCount
  6921. * @propertyOf ui.grid.class:GridOptions
  6922. * @description Defaults to 200
  6923. *
  6924. */
  6925. baseOptions.maxVisibleColumnCount = typeof(baseOptions.maxVisibleColumnCount) !== "undefined" ? baseOptions.maxVisibleColumnCount : 200;
  6926. /**
  6927. * @ngdoc property
  6928. * @name virtualizationThreshold
  6929. * @propertyOf ui.grid.class:GridOptions
  6930. * @description Turn virtualization on when number of data elements goes over this number, defaults to 20
  6931. */
  6932. baseOptions.virtualizationThreshold = typeof(baseOptions.virtualizationThreshold) !== "undefined" ? baseOptions.virtualizationThreshold : 20;
  6933. /**
  6934. * @ngdoc property
  6935. * @name columnVirtualizationThreshold
  6936. * @propertyOf ui.grid.class:GridOptions
  6937. * @description Turn virtualization on when number of columns goes over this number, defaults to 10
  6938. */
  6939. baseOptions.columnVirtualizationThreshold = typeof(baseOptions.columnVirtualizationThreshold) !== "undefined" ? baseOptions.columnVirtualizationThreshold : 10;
  6940. /**
  6941. * @ngdoc property
  6942. * @name excessRows
  6943. * @propertyOf ui.grid.class:GridOptions
  6944. * @description Extra rows to to render outside of the viewport, which helps with smoothness of scrolling.
  6945. * Defaults to 4
  6946. */
  6947. baseOptions.excessRows = typeof(baseOptions.excessRows) !== "undefined" ? baseOptions.excessRows : 4;
  6948. /**
  6949. * @ngdoc property
  6950. * @name scrollThreshold
  6951. * @propertyOf ui.grid.class:GridOptions
  6952. * @description Defaults to 4
  6953. */
  6954. baseOptions.scrollThreshold = typeof(baseOptions.scrollThreshold) !== "undefined" ? baseOptions.scrollThreshold : 4;
  6955. /**
  6956. * @ngdoc property
  6957. * @name excessColumns
  6958. * @propertyOf ui.grid.class:GridOptions
  6959. * @description Extra columns to to render outside of the viewport, which helps with smoothness of scrolling.
  6960. * Defaults to 4
  6961. */
  6962. baseOptions.excessColumns = typeof(baseOptions.excessColumns) !== "undefined" ? baseOptions.excessColumns : 4;
  6963. /**
  6964. * @ngdoc property
  6965. * @name horizontalScrollThreshold
  6966. * @propertyOf ui.grid.class:GridOptions
  6967. * @description Defaults to 4
  6968. */
  6969. baseOptions.horizontalScrollThreshold = typeof(baseOptions.horizontalScrollThreshold) !== "undefined" ? baseOptions.horizontalScrollThreshold : 2;
  6970. /**
  6971. * @ngdoc property
  6972. * @name aggregationCalcThrottle
  6973. * @propertyOf ui.grid.class:GridOptions
  6974. * @description Default time in milliseconds to throttle aggregation calcuations, defaults to 500ms
  6975. */
  6976. baseOptions.aggregationCalcThrottle = typeof(baseOptions.aggregationCalcThrottle) !== "undefined" ? baseOptions.aggregationCalcThrottle : 500;
  6977. /**
  6978. * @ngdoc property
  6979. * @name wheelScrollThrottle
  6980. * @propertyOf ui.grid.class:GridOptions
  6981. * @description Default time in milliseconds to throttle scroll events to, defaults to 70ms
  6982. */
  6983. baseOptions.wheelScrollThrottle = typeof(baseOptions.wheelScrollThrottle) !== "undefined" ? baseOptions.wheelScrollThrottle : 70;
  6984. /**
  6985. * @ngdoc property
  6986. * @name scrollDebounce
  6987. * @propertyOf ui.grid.class:GridOptions
  6988. * @description Default time in milliseconds to debounce scroll events, defaults to 300ms
  6989. */
  6990. baseOptions.scrollDebounce = typeof(baseOptions.scrollDebounce) !== "undefined" ? baseOptions.scrollDebounce : 300;
  6991. /**
  6992. * @ngdoc boolean
  6993. * @name enableSorting
  6994. * @propertyOf ui.grid.class:GridOptions
  6995. * @description True by default. When enabled, this setting adds sort
  6996. * widgets to the column headers, allowing sorting of the data for the entire grid.
  6997. * Sorting can then be disabled / enabled on individual columns using the columnDefs,
  6998. * if it set, it will override GridOptions enableSorting setting.
  6999. */
  7000. baseOptions.enableSorting = baseOptions.enableSorting !== false;
  7001. /**
  7002. * @ngdoc boolean
  7003. * @name enableFiltering
  7004. * @propertyOf ui.grid.class:GridOptions
  7005. * @description False by default. When enabled, this setting adds filter
  7006. * boxes to each column header, allowing filtering within the column for the entire grid.
  7007. * Filtering can then be disabled on individual columns using the columnDefs.
  7008. */
  7009. baseOptions.enableFiltering = baseOptions.enableFiltering === true;
  7010. /**
  7011. * @ngdoc boolean
  7012. * @name enableColumnMenus
  7013. * @propertyOf ui.grid.class:GridOptions
  7014. * @description True by default. When enabled, this setting displays a column
  7015. * menu within each column.
  7016. * By default column menu's trigger is hidden before mouse over, but you can always force it to be visible with CSS:
  7017. *
  7018. * <pre>
  7019. * .ui-grid-column-menu-button {
  7020. * display: block;
  7021. * }
  7022. * </pre>
  7023. */
  7024. baseOptions.enableColumnMenus = baseOptions.enableColumnMenus !== false;
  7025. /**
  7026. * @ngdoc boolean
  7027. * @name enableVerticalScrollbar
  7028. * @propertyOf ui.grid.class:GridOptions
  7029. * @description {@link ui.grid.service:uiGridConstants#properties_scrollbars uiGridConstants.scrollbars.ALWAYS} by default.
  7030. * This settings controls the vertical scrollbar for the grid.
  7031. * Supported values: uiGridConstants.scrollbars.ALWAYS, uiGridConstants.scrollbars.NEVER, uiGridConstants.scrollbars.WHEN_NEEDED
  7032. */
  7033. baseOptions.enableVerticalScrollbar = typeof(baseOptions.enableVerticalScrollbar) !== "undefined" ? baseOptions.enableVerticalScrollbar : uiGridConstants.scrollbars.ALWAYS;
  7034. /**
  7035. * @ngdoc boolean
  7036. * @name enableHorizontalScrollbar
  7037. * @propertyOf ui.grid.class:GridOptions
  7038. * @description {@link ui.grid.service:uiGridConstants#properties_scrollbars uiGridConstants.scrollbars.ALWAYS} by default.
  7039. * This settings controls the horizontal scrollbar for the grid.
  7040. * Supported values: uiGridConstants.scrollbars.ALWAYS, uiGridConstants.scrollbars.NEVER, uiGridConstants.scrollbars.WHEN_NEEDED
  7041. */
  7042. baseOptions.enableHorizontalScrollbar = typeof(baseOptions.enableHorizontalScrollbar) !== "undefined" ? baseOptions.enableHorizontalScrollbar : uiGridConstants.scrollbars.ALWAYS;
  7043. /**
  7044. * @ngdoc boolean
  7045. * @name enableMinHeightCheck
  7046. * @propertyOf ui.grid.class:GridOptions
  7047. * @description True by default. When enabled, a newly initialized grid will check to see if it is tall enough to display
  7048. * at least one row of data. If the grid is not tall enough, it will resize the DOM element to display minRowsToShow number
  7049. * of rows.
  7050. */
  7051. baseOptions.enableMinHeightCheck = baseOptions.enableMinHeightCheck !== false;
  7052. /**
  7053. * @ngdoc boolean
  7054. * @name minimumColumnSize
  7055. * @propertyOf ui.grid.class:GridOptions
  7056. * @description Columns can't be smaller than this, defaults to 10 pixels
  7057. */
  7058. baseOptions.minimumColumnSize = typeof(baseOptions.minimumColumnSize) !== "undefined" ? baseOptions.minimumColumnSize : 10;
  7059. /**
  7060. * @ngdoc function
  7061. * @name rowEquality
  7062. * @methodOf ui.grid.class:GridOptions
  7063. * @description By default, rows are compared using object equality. This option can be overridden
  7064. * to compare on any data item property or function
  7065. * @param {object} entityA First Data Item to compare
  7066. * @param {object} entityB Second Data Item to compare
  7067. */
  7068. baseOptions.rowEquality = baseOptions.rowEquality || function(entityA, entityB) {
  7069. return entityA === entityB;
  7070. };
  7071. /**
  7072. * @ngdoc string
  7073. * @name headerTemplate
  7074. * @propertyOf ui.grid.class:GridOptions
  7075. * @description Null by default. When provided, this setting uses a custom header
  7076. * template, rather than the default template. Can be set to either the name of a template file:
  7077. * <pre> $scope.gridOptions.headerTemplate = 'header_template.html';</pre>
  7078. * inline html
  7079. * <pre> $scope.gridOptions.headerTemplate = '<div class="ui-grid-top-panel" style="text-align: center">I am a Custom Grid Header</div>'</pre>
  7080. * or the id of a precompiled template (TBD how to use this).
  7081. * </br>Refer to the custom header tutorial for more information.
  7082. * If you want no header at all, you can set to an empty div:
  7083. * <pre> $scope.gridOptions.headerTemplate = '<div></div>';</pre>
  7084. *
  7085. * If you want to only have a static header, then you can set to static content. If
  7086. * you want to tailor the existing column headers, then you should look at the
  7087. * current 'ui-grid-header.html' template in github as your starting point.
  7088. *
  7089. */
  7090. baseOptions.headerTemplate = baseOptions.headerTemplate || null;
  7091. /**
  7092. * @ngdoc string
  7093. * @name footerTemplate
  7094. * @propertyOf ui.grid.class:GridOptions
  7095. * @description (optional) ui-grid/ui-grid-footer by default. This footer shows the per-column
  7096. * aggregation totals.
  7097. * When provided, this setting uses a custom footer template. Can be set to either the name of a template file 'footer_template.html', inline html
  7098. * <pre>'<div class="ui-grid-bottom-panel" style="text-align: center">I am a Custom Grid Footer</div>'</pre>, or the id
  7099. * of a precompiled template (TBD how to use this). Refer to the custom footer tutorial for more information.
  7100. */
  7101. baseOptions.footerTemplate = baseOptions.footerTemplate || 'ui-grid/ui-grid-footer';
  7102. /**
  7103. * @ngdoc string
  7104. * @name gridFooterTemplate
  7105. * @propertyOf ui.grid.class:GridOptions
  7106. * @description (optional) ui-grid/ui-grid-grid-footer by default. This template by default shows the
  7107. * total items at the bottom of the grid, and the selected items if selection is enabled.
  7108. */
  7109. baseOptions.gridFooterTemplate = baseOptions.gridFooterTemplate || 'ui-grid/ui-grid-grid-footer';
  7110. /**
  7111. * @ngdoc string
  7112. * @name rowTemplate
  7113. * @propertyOf ui.grid.class:GridOptions
  7114. * @description 'ui-grid/ui-grid-row' by default. When provided, this setting uses a
  7115. * custom row template. Can be set to either the name of a template file:
  7116. * <pre> $scope.gridOptions.rowTemplate = 'row_template.html';</pre>
  7117. * inline html
  7118. * <pre> $scope.gridOptions.rowTemplate = '<div style="background-color: aquamarine" ng-click="grid.appScope.fnOne(row)" ng-repeat="col in colContainer.renderedColumns track by col.colDef.name" class="ui-grid-cell" ui-grid-cell></div>';</pre>
  7119. * or the id of a precompiled template (TBD how to use this) can be provided.
  7120. * </br>Refer to the custom row template tutorial for more information.
  7121. */
  7122. baseOptions.rowTemplate = baseOptions.rowTemplate || 'ui-grid/ui-grid-row';
  7123. /**
  7124. * @ngdoc string
  7125. * @name gridMenuTemplate
  7126. * @propertyOf ui.grid.class:GridOptions
  7127. * @description 'ui-grid/uiGridMenu' by default. When provided, this setting uses a
  7128. * custom grid menu template.
  7129. */
  7130. baseOptions.gridMenuTemplate = baseOptions.gridMenuTemplate || 'ui-grid/uiGridMenu';
  7131. /**
  7132. * @ngdoc object
  7133. * @name appScopeProvider
  7134. * @propertyOf ui.grid.class:GridOptions
  7135. * @description by default, the parent scope of the ui-grid element will be assigned to grid.appScope
  7136. * this property allows you to assign any reference you want to grid.appScope
  7137. */
  7138. baseOptions.appScopeProvider = baseOptions.appScopeProvider || null;
  7139. return baseOptions;
  7140. }
  7141. };
  7142. }]);
  7143. })();
  7144. (function(){
  7145. angular.module('ui.grid')
  7146. /**
  7147. * @ngdoc function
  7148. * @name ui.grid.class:GridRenderContainer
  7149. * @description The grid has render containers, allowing the ability to have pinned columns. If the grid
  7150. * is right-to-left then there may be a right render container, if left-to-right then there may
  7151. * be a left render container. There is always a body render container.
  7152. * @param {string} name The name of the render container ('body', 'left', or 'right')
  7153. * @param {Grid} grid the grid the render container is in
  7154. * @param {object} options the render container options
  7155. */
  7156. .factory('GridRenderContainer', ['gridUtil', 'uiGridConstants', function(gridUtil, uiGridConstants) {
  7157. function GridRenderContainer(name, grid, options) {
  7158. var self = this;
  7159. // if (gridUtil.type(grid) !== 'Grid') {
  7160. // throw new Error('Grid argument is not a Grid object');
  7161. // }
  7162. self.name = name;
  7163. self.grid = grid;
  7164. // self.rowCache = [];
  7165. // self.columnCache = [];
  7166. self.visibleRowCache = [];
  7167. self.visibleColumnCache = [];
  7168. self.renderedRows = [];
  7169. self.renderedColumns = [];
  7170. self.prevScrollTop = 0;
  7171. self.prevScrolltopPercentage = 0;
  7172. self.prevRowScrollIndex = 0;
  7173. self.prevScrollLeft = 0;
  7174. self.prevScrollleftPercentage = 0;
  7175. self.prevColumnScrollIndex = 0;
  7176. self.columnStyles = '';
  7177. self.viewportAdjusters = [];
  7178. /**
  7179. * @ngdoc boolean
  7180. * @name hasHScrollbar
  7181. * @propertyOf ui.grid.class:GridRenderContainer
  7182. * @description flag to signal that container has a horizontal scrollbar
  7183. */
  7184. self.hasHScrollbar = false;
  7185. /**
  7186. * @ngdoc boolean
  7187. * @name hasVScrollbar
  7188. * @propertyOf ui.grid.class:GridRenderContainer
  7189. * @description flag to signal that container has a vertical scrollbar
  7190. */
  7191. self.hasVScrollbar = false;
  7192. /**
  7193. * @ngdoc boolean
  7194. * @name canvasHeightShouldUpdate
  7195. * @propertyOf ui.grid.class:GridRenderContainer
  7196. * @description flag to signal that container should recalculate the canvas size
  7197. */
  7198. self.canvasHeightShouldUpdate = true;
  7199. /**
  7200. * @ngdoc boolean
  7201. * @name canvasHeight
  7202. * @propertyOf ui.grid.class:GridRenderContainer
  7203. * @description last calculated canvas height value
  7204. */
  7205. self.$$canvasHeight = 0;
  7206. if (options && angular.isObject(options)) {
  7207. angular.extend(self, options);
  7208. }
  7209. grid.registerStyleComputation({
  7210. priority: 5,
  7211. func: function () {
  7212. self.updateColumnWidths();
  7213. return self.columnStyles;
  7214. }
  7215. });
  7216. }
  7217. GridRenderContainer.prototype.reset = function reset() {
  7218. // this.rowCache.length = 0;
  7219. // this.columnCache.length = 0;
  7220. this.visibleColumnCache.length = 0;
  7221. this.visibleRowCache.length = 0;
  7222. this.renderedRows.length = 0;
  7223. this.renderedColumns.length = 0;
  7224. };
  7225. // TODO(c0bra): calculate size?? Should this be in a stackable directive?
  7226. GridRenderContainer.prototype.containsColumn = function (col) {
  7227. return this.visibleColumnCache.indexOf(col) !== -1;
  7228. };
  7229. GridRenderContainer.prototype.minRowsToRender = function minRowsToRender() {
  7230. var self = this;
  7231. var minRows = 0;
  7232. var rowAddedHeight = 0;
  7233. var viewPortHeight = self.getViewportHeight();
  7234. for (var i = self.visibleRowCache.length - 1; rowAddedHeight < viewPortHeight && i >= 0; i--) {
  7235. rowAddedHeight += self.visibleRowCache[i].height;
  7236. minRows++;
  7237. }
  7238. return minRows;
  7239. };
  7240. GridRenderContainer.prototype.minColumnsToRender = function minColumnsToRender() {
  7241. var self = this;
  7242. var viewportWidth = this.getViewportWidth();
  7243. var min = 0;
  7244. var totalWidth = 0;
  7245. for (var i = 0; i < self.visibleColumnCache.length; i++) {
  7246. var col = self.visibleColumnCache[i];
  7247. if (totalWidth < viewportWidth) {
  7248. totalWidth += col.drawnWidth ? col.drawnWidth : 0;
  7249. min++;
  7250. }
  7251. else {
  7252. var currWidth = 0;
  7253. for (var j = i; j >= i - min; j--) {
  7254. currWidth += self.visibleColumnCache[j].drawnWidth ? self.visibleColumnCache[j].drawnWidth : 0;
  7255. }
  7256. if (currWidth < viewportWidth) {
  7257. min++;
  7258. }
  7259. }
  7260. }
  7261. return min;
  7262. };
  7263. GridRenderContainer.prototype.getVisibleRowCount = function getVisibleRowCount() {
  7264. return this.visibleRowCache.length;
  7265. };
  7266. /**
  7267. * @ngdoc function
  7268. * @name registerViewportAdjuster
  7269. * @methodOf ui.grid.class:GridRenderContainer
  7270. * @description Registers an adjuster to the render container's available width or height. Adjusters are used
  7271. * to tell the render container that there is something else consuming space, and to adjust it's size
  7272. * appropriately.
  7273. * @param {function} func the adjuster function we want to register
  7274. */
  7275. GridRenderContainer.prototype.registerViewportAdjuster = function registerViewportAdjuster(func) {
  7276. this.viewportAdjusters.push(func);
  7277. };
  7278. /**
  7279. * @ngdoc function
  7280. * @name removeViewportAdjuster
  7281. * @methodOf ui.grid.class:GridRenderContainer
  7282. * @description Removes an adjuster, should be used when your element is destroyed
  7283. * @param {function} func the adjuster function we want to remove
  7284. */
  7285. GridRenderContainer.prototype.removeViewportAdjuster = function removeViewportAdjuster(func) {
  7286. var idx = this.viewportAdjusters.indexOf(func);
  7287. if (idx > -1) {
  7288. this.viewportAdjusters.splice(idx, 1);
  7289. }
  7290. };
  7291. /**
  7292. * @ngdoc function
  7293. * @name getViewportAdjustment
  7294. * @methodOf ui.grid.class:GridRenderContainer
  7295. * @description Gets the adjustment based on the viewportAdjusters.
  7296. * @returns {object} a hash of { height: x, width: y }. Usually the values will be negative
  7297. */
  7298. GridRenderContainer.prototype.getViewportAdjustment = function getViewportAdjustment() {
  7299. var self = this;
  7300. var adjustment = { height: 0, width: 0 };
  7301. self.viewportAdjusters.forEach(function (func) {
  7302. adjustment = func.call(this, adjustment);
  7303. });
  7304. return adjustment;
  7305. };
  7306. GridRenderContainer.prototype.getMargin = function getMargin(side) {
  7307. var self = this;
  7308. var amount = 0;
  7309. self.viewportAdjusters.forEach(function (func) {
  7310. var adjustment = func.call(this, { height: 0, width: 0 });
  7311. if (adjustment.side && adjustment.side === side) {
  7312. amount += adjustment.width * -1;
  7313. }
  7314. });
  7315. return amount;
  7316. };
  7317. GridRenderContainer.prototype.getViewportHeight = function getViewportHeight() {
  7318. var self = this;
  7319. var headerHeight = (self.headerHeight) ? self.headerHeight : self.grid.headerHeight;
  7320. var viewPortHeight = self.grid.gridHeight - headerHeight - self.grid.footerHeight;
  7321. var adjustment = self.getViewportAdjustment();
  7322. viewPortHeight = viewPortHeight + adjustment.height;
  7323. return viewPortHeight;
  7324. };
  7325. GridRenderContainer.prototype.getViewportWidth = function getViewportWidth() {
  7326. var self = this;
  7327. var viewportWidth = self.grid.gridWidth;
  7328. //if (typeof(self.grid.verticalScrollbarWidth) !== 'undefined' && self.grid.verticalScrollbarWidth !== undefined && self.grid.verticalScrollbarWidth > 0) {
  7329. // viewPortWidth = viewPortWidth - self.grid.verticalScrollbarWidth;
  7330. //}
  7331. // var viewportWidth = 0;\
  7332. // self.visibleColumnCache.forEach(function (column) {
  7333. // viewportWidth += column.drawnWidth;
  7334. // });
  7335. var adjustment = self.getViewportAdjustment();
  7336. viewportWidth = viewportWidth + adjustment.width;
  7337. return viewportWidth;
  7338. };
  7339. GridRenderContainer.prototype.getHeaderViewportWidth = function getHeaderViewportWidth() {
  7340. var self = this;
  7341. var viewportWidth = this.getViewportWidth();
  7342. //if (typeof(self.grid.verticalScrollbarWidth) !== 'undefined' && self.grid.verticalScrollbarWidth !== undefined && self.grid.verticalScrollbarWidth > 0) {
  7343. // viewPortWidth = viewPortWidth + self.grid.verticalScrollbarWidth;
  7344. //}
  7345. // var adjustment = self.getViewportAdjustment();
  7346. // viewPortWidth = viewPortWidth + adjustment.width;
  7347. return viewportWidth;
  7348. };
  7349. /**
  7350. * @ngdoc function
  7351. * @name getCanvasHeight
  7352. * @methodOf ui.grid.class:GridRenderContainer
  7353. * @description Returns the total canvas height. Only recalculates if canvasHeightShouldUpdate = false
  7354. * @returns {number} total height of all the visible rows in the container
  7355. */
  7356. GridRenderContainer.prototype.getCanvasHeight = function getCanvasHeight() {
  7357. var self = this;
  7358. if (!self.canvasHeightShouldUpdate) {
  7359. return self.$$canvasHeight;
  7360. }
  7361. var oldCanvasHeight = self.$$canvasHeight;
  7362. self.$$canvasHeight = 0;
  7363. self.visibleRowCache.forEach(function(row){
  7364. self.$$canvasHeight += row.height;
  7365. });
  7366. self.canvasHeightShouldUpdate = false;
  7367. self.grid.api.core.raise.canvasHeightChanged(oldCanvasHeight, self.$$canvasHeight);
  7368. return self.$$canvasHeight;
  7369. };
  7370. GridRenderContainer.prototype.getVerticalScrollLength = function getVerticalScrollLength() {
  7371. return this.getCanvasHeight() - this.getViewportHeight() + this.grid.scrollbarHeight !== 0 ? this.getCanvasHeight() - this.getViewportHeight() + this.grid.scrollbarHeight : -1;
  7372. };
  7373. GridRenderContainer.prototype.getHorizontalScrollLength = function getHorizontalScrollLength() {
  7374. return this.getCanvasWidth() - this.getViewportWidth() + this.grid.scrollbarWidth !== 0 ? this.getCanvasWidth() - this.getViewportWidth() + this.grid.scrollbarWidth : -1;
  7375. };
  7376. GridRenderContainer.prototype.getCanvasWidth = function getCanvasWidth() {
  7377. var self = this;
  7378. return self.canvasWidth;
  7379. };
  7380. GridRenderContainer.prototype.setRenderedRows = function setRenderedRows(newRows) {
  7381. this.renderedRows.length = newRows.length;
  7382. for (var i = 0; i < newRows.length; i++) {
  7383. this.renderedRows[i] = newRows[i];
  7384. }
  7385. };
  7386. GridRenderContainer.prototype.setRenderedColumns = function setRenderedColumns(newColumns) {
  7387. var self = this;
  7388. // OLD:
  7389. this.renderedColumns.length = newColumns.length;
  7390. for (var i = 0; i < newColumns.length; i++) {
  7391. this.renderedColumns[i] = newColumns[i];
  7392. }
  7393. this.updateColumnOffset();
  7394. };
  7395. GridRenderContainer.prototype.updateColumnOffset = function updateColumnOffset() {
  7396. // Calculate the width of the columns on the left side that are no longer rendered.
  7397. // That will be the offset for the columns as we scroll horizontally.
  7398. var hiddenColumnsWidth = 0;
  7399. for (var i = 0; i < this.currentFirstColumn; i++) {
  7400. hiddenColumnsWidth += this.visibleColumnCache[i].drawnWidth;
  7401. }
  7402. this.columnOffset = hiddenColumnsWidth;
  7403. };
  7404. GridRenderContainer.prototype.scrollVertical = function (newScrollTop) {
  7405. var vertScrollPercentage = -1;
  7406. if (newScrollTop !== this.prevScrollTop) {
  7407. var yDiff = newScrollTop - this.prevScrollTop;
  7408. if (yDiff > 0 ) { this.grid.scrollDirection = uiGridConstants.scrollDirection.DOWN; }
  7409. if (yDiff < 0 ) { this.grid.scrollDirection = uiGridConstants.scrollDirection.UP; }
  7410. var vertScrollLength = this.getVerticalScrollLength();
  7411. vertScrollPercentage = newScrollTop / vertScrollLength;
  7412. // console.log('vert', vertScrollPercentage, newScrollTop, vertScrollLength);
  7413. if (vertScrollPercentage > 1) { vertScrollPercentage = 1; }
  7414. if (vertScrollPercentage < 0) { vertScrollPercentage = 0; }
  7415. this.adjustScrollVertical(newScrollTop, vertScrollPercentage);
  7416. return vertScrollPercentage;
  7417. }
  7418. };
  7419. GridRenderContainer.prototype.scrollHorizontal = function(newScrollLeft){
  7420. var horizScrollPercentage = -1;
  7421. // Handle RTL here
  7422. if (newScrollLeft !== this.prevScrollLeft) {
  7423. var xDiff = newScrollLeft - this.prevScrollLeft;
  7424. if (xDiff > 0) { this.grid.scrollDirection = uiGridConstants.scrollDirection.RIGHT; }
  7425. if (xDiff < 0) { this.grid.scrollDirection = uiGridConstants.scrollDirection.LEFT; }
  7426. var horizScrollLength = this.getHorizontalScrollLength();
  7427. if (horizScrollLength !== 0) {
  7428. horizScrollPercentage = newScrollLeft / horizScrollLength;
  7429. }
  7430. else {
  7431. horizScrollPercentage = 0;
  7432. }
  7433. this.adjustScrollHorizontal(newScrollLeft, horizScrollPercentage);
  7434. return horizScrollPercentage;
  7435. }
  7436. };
  7437. GridRenderContainer.prototype.adjustScrollVertical = function adjustScrollVertical(scrollTop, scrollPercentage, force) {
  7438. if (this.prevScrollTop === scrollTop && !force) {
  7439. return;
  7440. }
  7441. if (typeof(scrollTop) === 'undefined' || scrollTop === undefined || scrollTop === null) {
  7442. scrollTop = (this.getCanvasHeight() - this.getViewportHeight()) * scrollPercentage;
  7443. }
  7444. this.adjustRows(scrollTop, scrollPercentage, false);
  7445. this.prevScrollTop = scrollTop;
  7446. this.prevScrolltopPercentage = scrollPercentage;
  7447. this.grid.queueRefresh();
  7448. };
  7449. GridRenderContainer.prototype.adjustScrollHorizontal = function adjustScrollHorizontal(scrollLeft, scrollPercentage, force) {
  7450. if (this.prevScrollLeft === scrollLeft && !force) {
  7451. return;
  7452. }
  7453. if (typeof(scrollLeft) === 'undefined' || scrollLeft === undefined || scrollLeft === null) {
  7454. scrollLeft = (this.getCanvasWidth() - this.getViewportWidth()) * scrollPercentage;
  7455. }
  7456. this.adjustColumns(scrollLeft, scrollPercentage);
  7457. this.prevScrollLeft = scrollLeft;
  7458. this.prevScrollleftPercentage = scrollPercentage;
  7459. this.grid.queueRefresh();
  7460. };
  7461. GridRenderContainer.prototype.adjustRows = function adjustRows(scrollTop, scrollPercentage, postDataLoaded) {
  7462. var self = this;
  7463. var minRows = self.minRowsToRender();
  7464. var rowCache = self.visibleRowCache;
  7465. var maxRowIndex = rowCache.length - minRows;
  7466. // console.log('scroll%1', scrollPercentage);
  7467. // Calculate the scroll percentage according to the scrollTop location, if no percentage was provided
  7468. if ((typeof(scrollPercentage) === 'undefined' || scrollPercentage === null) && scrollTop) {
  7469. scrollPercentage = scrollTop / self.getVerticalScrollLength();
  7470. }
  7471. var rowIndex = Math.ceil(Math.min(maxRowIndex, maxRowIndex * scrollPercentage));
  7472. // console.log('maxRowIndex / scroll%', maxRowIndex, scrollPercentage, rowIndex);
  7473. // Define a max row index that we can't scroll past
  7474. if (rowIndex > maxRowIndex) {
  7475. rowIndex = maxRowIndex;
  7476. }
  7477. var newRange = [];
  7478. if (rowCache.length > self.grid.options.virtualizationThreshold) {
  7479. if (!(typeof(scrollTop) === 'undefined' || scrollTop === null)) {
  7480. // Have we hit the threshold going down?
  7481. if ( !self.grid.suppressParentScrollDown && self.prevScrollTop < scrollTop && rowIndex < self.prevRowScrollIndex + self.grid.options.scrollThreshold && rowIndex < maxRowIndex) {
  7482. return;
  7483. }
  7484. //Have we hit the threshold going up?
  7485. if ( !self.grid.suppressParentScrollUp && self.prevScrollTop > scrollTop && rowIndex > self.prevRowScrollIndex - self.grid.options.scrollThreshold && rowIndex < maxRowIndex) {
  7486. return;
  7487. }
  7488. }
  7489. var rangeStart = Math.max(0, rowIndex - self.grid.options.excessRows);
  7490. var rangeEnd = Math.min(rowCache.length, rowIndex + minRows + self.grid.options.excessRows);
  7491. newRange = [rangeStart, rangeEnd];
  7492. }
  7493. else {
  7494. var maxLen = self.visibleRowCache.length;
  7495. newRange = [0, Math.max(maxLen, minRows + self.grid.options.excessRows)];
  7496. }
  7497. self.updateViewableRowRange(newRange);
  7498. self.prevRowScrollIndex = rowIndex;
  7499. };
  7500. GridRenderContainer.prototype.adjustColumns = function adjustColumns(scrollLeft, scrollPercentage) {
  7501. var self = this;
  7502. var minCols = self.minColumnsToRender();
  7503. var columnCache = self.visibleColumnCache;
  7504. var maxColumnIndex = columnCache.length - minCols;
  7505. // Calculate the scroll percentage according to the scrollLeft location, if no percentage was provided
  7506. if ((typeof(scrollPercentage) === 'undefined' || scrollPercentage === null) && scrollLeft) {
  7507. scrollPercentage = scrollLeft / self.getHorizontalScrollLength();
  7508. }
  7509. var colIndex = Math.ceil(Math.min(maxColumnIndex, maxColumnIndex * scrollPercentage));
  7510. // Define a max row index that we can't scroll past
  7511. if (colIndex > maxColumnIndex) {
  7512. colIndex = maxColumnIndex;
  7513. }
  7514. var newRange = [];
  7515. if (columnCache.length > self.grid.options.columnVirtualizationThreshold && self.getCanvasWidth() > self.getViewportWidth()) {
  7516. /* Commented the following lines because otherwise the moved column wasn't visible immediately on the new position
  7517. * in the case of many columns with horizontal scroll, one had to scroll left or right and then return in order to see it
  7518. // Have we hit the threshold going down?
  7519. if (self.prevScrollLeft < scrollLeft && colIndex < self.prevColumnScrollIndex + self.grid.options.horizontalScrollThreshold && colIndex < maxColumnIndex) {
  7520. return;
  7521. }
  7522. //Have we hit the threshold going up?
  7523. if (self.prevScrollLeft > scrollLeft && colIndex > self.prevColumnScrollIndex - self.grid.options.horizontalScrollThreshold && colIndex < maxColumnIndex) {
  7524. return;
  7525. }*/
  7526. var rangeStart = Math.max(0, colIndex - self.grid.options.excessColumns);
  7527. var rangeEnd = Math.min(columnCache.length, colIndex + minCols + self.grid.options.excessColumns);
  7528. newRange = [rangeStart, rangeEnd];
  7529. }
  7530. else {
  7531. var maxLen = self.visibleColumnCache.length;
  7532. newRange = [0, Math.max(maxLen, minCols + self.grid.options.excessColumns)];
  7533. }
  7534. self.updateViewableColumnRange(newRange);
  7535. self.prevColumnScrollIndex = colIndex;
  7536. };
  7537. // Method for updating the visible rows
  7538. GridRenderContainer.prototype.updateViewableRowRange = function updateViewableRowRange(renderedRange) {
  7539. // Slice out the range of rows from the data
  7540. // var rowArr = uiGridCtrl.grid.rows.slice(renderedRange[0], renderedRange[1]);
  7541. var rowArr = this.visibleRowCache.slice(renderedRange[0], renderedRange[1]);
  7542. // Define the top-most rendered row
  7543. this.currentTopRow = renderedRange[0];
  7544. this.setRenderedRows(rowArr);
  7545. };
  7546. // Method for updating the visible columns
  7547. GridRenderContainer.prototype.updateViewableColumnRange = function updateViewableColumnRange(renderedRange) {
  7548. // Slice out the range of rows from the data
  7549. // var columnArr = uiGridCtrl.grid.columns.slice(renderedRange[0], renderedRange[1]);
  7550. var columnArr = this.visibleColumnCache.slice(renderedRange[0], renderedRange[1]);
  7551. // Define the left-most rendered columns
  7552. this.currentFirstColumn = renderedRange[0];
  7553. this.setRenderedColumns(columnArr);
  7554. };
  7555. GridRenderContainer.prototype.headerCellWrapperStyle = function () {
  7556. var self = this;
  7557. if (self.currentFirstColumn !== 0) {
  7558. var offset = self.columnOffset;
  7559. if (self.grid.isRTL()) {
  7560. return { 'margin-right': offset + 'px' };
  7561. }
  7562. else {
  7563. return { 'margin-left': offset + 'px' };
  7564. }
  7565. }
  7566. return null;
  7567. };
  7568. /**
  7569. * @ngdoc boolean
  7570. * @name updateColumnWidths
  7571. * @propertyOf ui.grid.class:GridRenderContainer
  7572. * @description Determine the appropriate column width of each column across all render containers.
  7573. *
  7574. * Column width is easy when each column has a specified width. When columns are variable width (i.e.
  7575. * have an * or % of the viewport) then we try to calculate so that things fit in. The problem is that
  7576. * we have multiple render containers, and we don't want one render container to just take the whole viewport
  7577. * when it doesn't need to - we want things to balance out across the render containers.
  7578. *
  7579. * To do this, we use this method to calculate all the renderContainers, recognising that in a given render
  7580. * cycle it'll get called once per render container, so it needs to return the same values each time.
  7581. *
  7582. * The constraints on this method are therefore:
  7583. * - must return the same value when called multiple times, to do this it needs to rely on properties of the
  7584. * columns, but not properties that change when this is called (so it shouldn't rely on drawnWidth)
  7585. *
  7586. * The general logic of this method is:
  7587. * - calculate our total available width
  7588. * - look at all the columns across all render containers, and work out which have widths and which have
  7589. * constraints such as % or * or something else
  7590. * - for those with *, count the total number of * we see and add it onto a running total, add this column to an * array
  7591. * - for those with a %, allocate the % as a percentage of the viewport, having consideration of min and max
  7592. * - for those with manual width (in pixels) we set the drawnWidth to the specified width
  7593. * - we end up with an asterisks array still to process
  7594. * - we look at our remaining width. If it's greater than zero, we divide it up among the asterisk columns, then process
  7595. * them for min and max width constraints
  7596. * - if it's zero or less, we set the asterisk columns to their minimum widths
  7597. * - we use parseInt quite a bit, as we try to make all our column widths integers
  7598. */
  7599. GridRenderContainer.prototype.updateColumnWidths = function () {
  7600. var self = this;
  7601. var asterisksArray = [],
  7602. asteriskNum = 0,
  7603. usedWidthSum = 0,
  7604. ret = '',
  7605. pinRightColumn = false,
  7606. fixedNumberArray = [],
  7607. percentageArray = [],
  7608. totalPercentage = 0;
  7609. // Get the width of the viewport
  7610. var availableWidth = self.grid.getViewportWidth() - self.grid.scrollbarWidth;
  7611. // get all the columns across all render containers, we have to calculate them all or one render container
  7612. // could consume the whole viewport
  7613. var columnCache = [];
  7614. angular.forEach(self.grid.renderContainers, function (container) {
  7615. columnCache = columnCache.concat(container.visibleColumnCache);
  7616. });
  7617. // look at each column, process any manual values or %, put the * into an array to look at later
  7618. columnCache.forEach(function (column) {
  7619. var width = 0;
  7620. // Skip hidden columns
  7621. if (!column.visible) { return; }
  7622. if (pinRightColumn) {
  7623. availableWidth += self.grid.scrollbarWidth;
  7624. }
  7625. if (!pinRightColumn && column.colDef.pinnedRight) {
  7626. pinRightColumn = true;
  7627. }
  7628. if (angular.isNumber(column.width)) {
  7629. // pixel width, set to this value
  7630. width = parseInt(column.width, 10);
  7631. usedWidthSum = usedWidthSum + width;
  7632. column.drawnWidth = width;
  7633. fixedNumberArray.push(column);
  7634. } else if (gridUtil.endsWith(column.width, '%')) {
  7635. // percentage width, set to percentage of the viewport
  7636. // round down to int - some browsers don't play nice with float maxWidth
  7637. var percentageIntegerValue = parseInt(column.width.replace(/%/g, ''), 10);
  7638. width = parseInt(percentageIntegerValue / 100 * availableWidth);
  7639. if (width > column.maxWidth) {
  7640. width = column.maxWidth;
  7641. }
  7642. if (width < column.minWidth) {
  7643. width = column.minWidth;
  7644. }
  7645. usedWidthSum = usedWidthSum + width;
  7646. column.drawnWidth = width;
  7647. totalPercentage = totalPercentage + percentageIntegerValue;
  7648. percentageArray.push(column);
  7649. } else if (angular.isString(column.width) && column.width.indexOf('*') !== -1) {
  7650. // is an asterisk column, the gridColumn already checked the string consists only of '****'
  7651. asteriskNum = asteriskNum + column.width.length;
  7652. asterisksArray.push(column);
  7653. }
  7654. });
  7655. // Get the remaining width (available width subtracted by the used widths sum)
  7656. var remainingWidth = availableWidth - usedWidthSum;
  7657. if (asterisksArray.length > 0) {
  7658. // the width that each asterisk value would be assigned (this can be negative)
  7659. var asteriskVal = remainingWidth / asteriskNum;
  7660. asterisksArray.forEach(function (column) {
  7661. var width = parseInt(column.width.length * asteriskVal, 10);
  7662. if (width > column.maxWidth) {
  7663. width = column.maxWidth;
  7664. }
  7665. if (width < column.minWidth) {
  7666. width = column.minWidth;
  7667. }
  7668. usedWidthSum = usedWidthSum + width;
  7669. column.drawnWidth = width;
  7670. });
  7671. }
  7672. // If there are no columns with asterisk widths then check if there are any with % widths and
  7673. // use them as a fallback for adjusting column widths up or down if we have remaining grid width
  7674. // or need to claw some width back
  7675. var variableWidthColumnArray;
  7676. if (asterisksArray.length > 0) {
  7677. variableWidthColumnArray = asterisksArray;
  7678. } else if (percentageArray.length > 0 && fixedNumberArray.length === 0 && totalPercentage === 100) {
  7679. variableWidthColumnArray = percentageArray;
  7680. }
  7681. if (!angular.isUndefined(variableWidthColumnArray)) {
  7682. // If the grid width didn't divide evenly into the column widths and we have pixels left over, or our
  7683. // calculated widths would have the grid narrower than the available space,
  7684. // dole the remainder out one by one to make everything fit
  7685. var processColumnUpwards = function (column) {
  7686. if (column.drawnWidth < column.maxWidth && leftoverWidth > 0) {
  7687. column.drawnWidth++;
  7688. usedWidthSum++;
  7689. leftoverWidth--;
  7690. columnsToChange = true;
  7691. }
  7692. };
  7693. var leftoverWidth = availableWidth - usedWidthSum;
  7694. var columnsToChange = true;
  7695. while (leftoverWidth > 0 && columnsToChange) {
  7696. columnsToChange = false;
  7697. variableWidthColumnArray.forEach(processColumnUpwards);
  7698. }
  7699. // We can end up with too much width even though some columns aren't at their max width, in this situation
  7700. // we can trim the columns a little
  7701. var processColumnDownwards = function (column) {
  7702. if (column.drawnWidth > column.minWidth && excessWidth > 0) {
  7703. column.drawnWidth--;
  7704. usedWidthSum--;
  7705. excessWidth--;
  7706. columnsToChange = true;
  7707. }
  7708. };
  7709. var excessWidth = usedWidthSum - availableWidth;
  7710. columnsToChange = true;
  7711. while (excessWidth > 0 && columnsToChange) {
  7712. columnsToChange = false;
  7713. variableWidthColumnArray.forEach(processColumnDownwards);
  7714. }
  7715. }
  7716. // all that was across all the renderContainers, now we need to work out what that calculation decided for
  7717. // our renderContainer
  7718. var canvasWidth = 0;
  7719. self.visibleColumnCache.forEach(function(column){
  7720. if ( column.visible ){
  7721. canvasWidth = canvasWidth + column.drawnWidth;
  7722. }
  7723. });
  7724. // Build the CSS
  7725. columnCache.forEach(function (column) {
  7726. ret = ret + column.getColClassDefinition();
  7727. });
  7728. self.canvasWidth = canvasWidth;
  7729. // Return the styles back to buildStyles which pops them into the `customStyles` scope variable
  7730. // return ret;
  7731. // Set this render container's column styles so they can be used in style computation
  7732. this.columnStyles = ret;
  7733. };
  7734. GridRenderContainer.prototype.needsHScrollbarPlaceholder = function () {
  7735. return this.grid.options.enableHorizontalScrollbar && !this.hasHScrollbar && !this.grid.disableScrolling;
  7736. };
  7737. GridRenderContainer.prototype.getViewportStyle = function () {
  7738. var self = this;
  7739. var styles = {};
  7740. var scrollbarVisibility = {};
  7741. scrollbarVisibility[uiGridConstants.scrollbars.ALWAYS] = 'scroll';
  7742. scrollbarVisibility[uiGridConstants.scrollbars.WHEN_NEEDED] = 'auto';
  7743. self.hasHScrollbar = false;
  7744. self.hasVScrollbar = false;
  7745. if (self.grid.disableScrolling) {
  7746. styles['overflow-x'] = 'hidden';
  7747. styles['overflow-y'] = 'hidden';
  7748. return styles;
  7749. }
  7750. if (self.name === 'body') {
  7751. self.hasHScrollbar = self.grid.options.enableHorizontalScrollbar !== uiGridConstants.scrollbars.NEVER;
  7752. if (!self.grid.isRTL()) {
  7753. if (!self.grid.hasRightContainerColumns()) {
  7754. self.hasVScrollbar = self.grid.options.enableVerticalScrollbar !== uiGridConstants.scrollbars.NEVER;
  7755. }
  7756. }
  7757. else {
  7758. if (!self.grid.hasLeftContainerColumns()) {
  7759. self.hasVScrollbar = self.grid.options.enableVerticalScrollbar !== uiGridConstants.scrollbars.NEVER;
  7760. }
  7761. }
  7762. }
  7763. else if (self.name === 'left') {
  7764. self.hasVScrollbar = self.grid.isRTL() ? self.grid.options.enableVerticalScrollbar !== uiGridConstants.scrollbars.NEVER : false;
  7765. }
  7766. else {
  7767. self.hasVScrollbar = !self.grid.isRTL() ? self.grid.options.enableVerticalScrollbar !== uiGridConstants.scrollbars.NEVER : false;
  7768. }
  7769. styles['overflow-x'] = self.hasHScrollbar ? scrollbarVisibility[self.grid.options.enableHorizontalScrollbar] : 'hidden';
  7770. styles['overflow-y'] = self.hasVScrollbar ? scrollbarVisibility[self.grid.options.enableVerticalScrollbar] : 'hidden';
  7771. return styles;
  7772. };
  7773. return GridRenderContainer;
  7774. }]);
  7775. })();
  7776. (function(){
  7777. angular.module('ui.grid')
  7778. .factory('GridRow', ['gridUtil', 'uiGridConstants', function(gridUtil, uiGridConstants) {
  7779. /**
  7780. * @ngdoc function
  7781. * @name ui.grid.class:GridRow
  7782. * @description GridRow is the viewModel for one logical row on the grid. A grid Row is not necessarily a one-to-one
  7783. * relation to gridOptions.data.
  7784. * @param {object} entity the array item from GridOptions.data
  7785. * @param {number} index the current position of the row in the array
  7786. * @param {Grid} reference to the parent grid
  7787. */
  7788. function GridRow(entity, index, grid) {
  7789. /**
  7790. * @ngdoc object
  7791. * @name grid
  7792. * @propertyOf ui.grid.class:GridRow
  7793. * @description A reference back to the grid
  7794. */
  7795. this.grid = grid;
  7796. /**
  7797. * @ngdoc object
  7798. * @name entity
  7799. * @propertyOf ui.grid.class:GridRow
  7800. * @description A reference to an item in gridOptions.data[]
  7801. */
  7802. this.entity = entity;
  7803. /**
  7804. * @ngdoc object
  7805. * @name uid
  7806. * @propertyOf ui.grid.class:GridRow
  7807. * @description UniqueId of row
  7808. */
  7809. this.uid = gridUtil.nextUid();
  7810. /**
  7811. * @ngdoc object
  7812. * @name visible
  7813. * @propertyOf ui.grid.class:GridRow
  7814. * @description If true, the row will be rendered
  7815. */
  7816. // Default to true
  7817. this.visible = true;
  7818. /**
  7819. * @ngdoc object
  7820. * @name isSelected
  7821. * @propertyOf ui.grid.class:GridRow
  7822. * @description Marks if the row has been selected
  7823. */
  7824. // Default to false
  7825. this.isSelected = false;
  7826. this.$$height = grid.options.rowHeight;
  7827. }
  7828. /**
  7829. * @ngdoc object
  7830. * @name height
  7831. * @propertyOf ui.grid.class:GridRow
  7832. * @description height of each individual row. changing the height will flag all
  7833. * row renderContainers to recalculate their canvas height
  7834. */
  7835. Object.defineProperty(GridRow.prototype, 'height', {
  7836. get: function() {
  7837. return this.$$height;
  7838. },
  7839. set: function(height) {
  7840. if (height !== this.$$height) {
  7841. this.grid.updateCanvasHeight();
  7842. this.$$height = height;
  7843. }
  7844. }
  7845. });
  7846. /**
  7847. * @ngdoc function
  7848. * @name getQualifiedColField
  7849. * @methodOf ui.grid.class:GridRow
  7850. * @description returns the qualified field name as it exists on scope
  7851. * ie: row.entity.fieldA
  7852. * @param {GridCol} col column instance
  7853. * @returns {string} resulting name that can be evaluated on scope
  7854. */
  7855. GridRow.prototype.getQualifiedColField = function(col) {
  7856. return 'row.' + this.getEntityQualifiedColField(col);
  7857. };
  7858. /**
  7859. * @ngdoc function
  7860. * @name getEntityQualifiedColField
  7861. * @methodOf ui.grid.class:GridRow
  7862. * @description returns the qualified field name minus the row path
  7863. * ie: entity.fieldA
  7864. * @param {GridCol} col column instance
  7865. * @returns {string} resulting name that can be evaluated against a row
  7866. */
  7867. GridRow.prototype.getEntityQualifiedColField = function(col) {
  7868. var base = 'entity';
  7869. if ( col.field === uiGridConstants.ENTITY_BINDING ) {
  7870. return base;
  7871. }
  7872. return gridUtil.preEval(base + '.' + col.field);
  7873. };
  7874. /**
  7875. * @ngdoc function
  7876. * @name setRowInvisible
  7877. * @methodOf ui.grid.class:GridRow
  7878. * @description Sets an override on the row that forces it to always
  7879. * be invisible. Emits the rowsVisibleChanged event if it changed the row visibility.
  7880. *
  7881. * This method can be called from the api, passing in the gridRow we want
  7882. * altered. It should really work by calling gridRow.setRowInvisible, but that's
  7883. * not the way I coded it, and too late to change now. Changed to just call
  7884. * the internal function row.setThisRowInvisible().
  7885. *
  7886. * @param {GridRow} row the row we want to set to invisible
  7887. *
  7888. */
  7889. GridRow.prototype.setRowInvisible = function ( row ) {
  7890. if (row && row.setThisRowInvisible){
  7891. row.setThisRowInvisible( 'user' );
  7892. }
  7893. };
  7894. /**
  7895. * @ngdoc function
  7896. * @name clearRowInvisible
  7897. * @methodOf ui.grid.class:GridRow
  7898. * @description Clears an override on the row that forces it to always
  7899. * be invisible. Emits the rowsVisibleChanged event if it changed the row visibility.
  7900. *
  7901. * This method can be called from the api, passing in the gridRow we want
  7902. * altered. It should really work by calling gridRow.clearRowInvisible, but that's
  7903. * not the way I coded it, and too late to change now. Changed to just call
  7904. * the internal function row.clearThisRowInvisible().
  7905. *
  7906. * @param {GridRow} row the row we want to clear the invisible flag
  7907. *
  7908. */
  7909. GridRow.prototype.clearRowInvisible = function ( row ) {
  7910. if (row && row.clearThisRowInvisible){
  7911. row.clearThisRowInvisible( 'user' );
  7912. }
  7913. };
  7914. /**
  7915. * @ngdoc function
  7916. * @name setThisRowInvisible
  7917. * @methodOf ui.grid.class:GridRow
  7918. * @description Sets an override on the row that forces it to always
  7919. * be invisible. Emits the rowsVisibleChanged event if it changed the row visibility
  7920. *
  7921. * @param {string} reason the reason (usually the module) for the row to be invisible.
  7922. * E.g. grouping, user, filter
  7923. * @param {boolean} fromRowsProcessor whether we were called from a rowsProcessor, passed through to evaluateRowVisibility
  7924. */
  7925. GridRow.prototype.setThisRowInvisible = function ( reason, fromRowsProcessor ) {
  7926. if ( !this.invisibleReason ){
  7927. this.invisibleReason = {};
  7928. }
  7929. this.invisibleReason[reason] = true;
  7930. this.evaluateRowVisibility( fromRowsProcessor);
  7931. };
  7932. /**
  7933. * @ngdoc function
  7934. * @name clearRowInvisible
  7935. * @methodOf ui.grid.class:GridRow
  7936. * @description Clears any override on the row visibility, returning it
  7937. * to normal visibility calculations. Emits the rowsVisibleChanged
  7938. * event
  7939. *
  7940. * @param {string} reason the reason (usually the module) for the row to be invisible.
  7941. * E.g. grouping, user, filter
  7942. * @param {boolean} fromRowsProcessor whether we were called from a rowsProcessor, passed through to evaluateRowVisibility
  7943. */
  7944. GridRow.prototype.clearThisRowInvisible = function ( reason, fromRowsProcessor ) {
  7945. if (typeof(this.invisibleReason) !== 'undefined' ) {
  7946. delete this.invisibleReason[reason];
  7947. }
  7948. this.evaluateRowVisibility( fromRowsProcessor );
  7949. };
  7950. /**
  7951. * @ngdoc function
  7952. * @name evaluateRowVisibility
  7953. * @methodOf ui.grid.class:GridRow
  7954. * @description Determines whether the row should be visible based on invisibleReason,
  7955. * and if it changes the row visibility, then emits the rowsVisibleChanged event.
  7956. *
  7957. * Queues a grid refresh, but doesn't call it directly to avoid hitting lots of grid refreshes.
  7958. * @param {boolean} fromRowProcessor if true, then it won't raise events or queue the refresh, the
  7959. * row processor does that already
  7960. */
  7961. GridRow.prototype.evaluateRowVisibility = function ( fromRowProcessor ) {
  7962. var newVisibility = true;
  7963. if ( typeof(this.invisibleReason) !== 'undefined' ){
  7964. angular.forEach(this.invisibleReason, function( value, key ){
  7965. if ( value ){
  7966. newVisibility = false;
  7967. }
  7968. });
  7969. }
  7970. if ( typeof(this.visible) === 'undefined' || this.visible !== newVisibility ){
  7971. this.visible = newVisibility;
  7972. if ( !fromRowProcessor ){
  7973. this.grid.queueGridRefresh();
  7974. this.grid.api.core.raise.rowsVisibleChanged(this);
  7975. }
  7976. }
  7977. };
  7978. return GridRow;
  7979. }]);
  7980. })();
  7981. (function(){
  7982. 'use strict';
  7983. /**
  7984. * @ngdoc object
  7985. * @name ui.grid.class:GridRowColumn
  7986. * @param {GridRow} row The row for this pair
  7987. * @param {GridColumn} column The column for this pair
  7988. * @description A row and column pair that represents the intersection of these two entities.
  7989. * Must be instantiated as a constructor using the `new` keyword.
  7990. */
  7991. angular.module('ui.grid')
  7992. .factory('GridRowColumn', ['$parse', '$filter',
  7993. function GridRowColumnFactory($parse, $filter){
  7994. var GridRowColumn = function GridRowColumn(row, col) {
  7995. if ( !(this instanceof GridRowColumn)){
  7996. throw "Using GridRowColumn as a function insead of as a constructor. Must be called with `new` keyword";
  7997. }
  7998. /**
  7999. * @ngdoc object
  8000. * @name row
  8001. * @propertyOf ui.grid.class:GridRowColumn
  8002. * @description {@link ui.grid.class:GridRow }
  8003. */
  8004. this.row = row;
  8005. /**
  8006. * @ngdoc object
  8007. * @name col
  8008. * @propertyOf ui.grid.class:GridRowColumn
  8009. * @description {@link ui.grid.class:GridColumn }
  8010. */
  8011. this.col = col;
  8012. };
  8013. /**
  8014. * @ngdoc function
  8015. * @name getIntersectionValueRaw
  8016. * @methodOf ui.grid.class:GridRowColumn
  8017. * @description Gets the intersection of where the row and column meet.
  8018. * @returns {String|Number|Object} The value from the grid data that this GridRowColumn points too.
  8019. * If the column has a cellFilter this will NOT return the filtered value.
  8020. */
  8021. GridRowColumn.prototype.getIntersectionValueRaw = function(){
  8022. var getter = $parse(this.row.getEntityQualifiedColField(this.col));
  8023. var context = this.row;
  8024. return getter(context);
  8025. };
  8026. return GridRowColumn;
  8027. }
  8028. ]);
  8029. })();
  8030. (function () {
  8031. angular.module('ui.grid')
  8032. .factory('ScrollEvent', ['gridUtil', function (gridUtil) {
  8033. /**
  8034. * @ngdoc function
  8035. * @name ui.grid.class:ScrollEvent
  8036. * @description Model for all scrollEvents
  8037. * @param {Grid} grid that owns the scroll event
  8038. * @param {GridRenderContainer} sourceRowContainer that owns the scroll event. Can be null
  8039. * @param {GridRenderContainer} sourceColContainer that owns the scroll event. Can be null
  8040. * @param {string} source the source of the event - from uiGridConstants.scrollEventSources or a string value of directive/service/factory.functionName
  8041. */
  8042. function ScrollEvent(grid, sourceRowContainer, sourceColContainer, source) {
  8043. var self = this;
  8044. if (!grid) {
  8045. throw new Error("grid argument is required");
  8046. }
  8047. /**
  8048. * @ngdoc object
  8049. * @name grid
  8050. * @propertyOf ui.grid.class:ScrollEvent
  8051. * @description A reference back to the grid
  8052. */
  8053. self.grid = grid;
  8054. /**
  8055. * @ngdoc object
  8056. * @name source
  8057. * @propertyOf ui.grid.class:ScrollEvent
  8058. * @description the source of the scroll event. limited to values from uiGridConstants.scrollEventSources
  8059. */
  8060. self.source = source;
  8061. /**
  8062. * @ngdoc object
  8063. * @name noDelay
  8064. * @propertyOf ui.grid.class:ScrollEvent
  8065. * @description most scroll events from the mouse or trackpad require delay to operate properly
  8066. * set to false to eliminate delay. Useful for scroll events that the grid causes, such as scrolling to make a row visible.
  8067. */
  8068. self.withDelay = true;
  8069. self.sourceRowContainer = sourceRowContainer;
  8070. self.sourceColContainer = sourceColContainer;
  8071. self.newScrollLeft = null;
  8072. self.newScrollTop = null;
  8073. self.x = null;
  8074. self.y = null;
  8075. self.verticalScrollLength = -9999999;
  8076. self.horizontalScrollLength = -999999;
  8077. /**
  8078. * @ngdoc function
  8079. * @name fireThrottledScrollingEvent
  8080. * @methodOf ui.grid.class:ScrollEvent
  8081. * @description fires a throttled event using grid.api.core.raise.scrollEvent
  8082. */
  8083. self.fireThrottledScrollingEvent = gridUtil.throttle(function(sourceContainerId) {
  8084. self.grid.scrollContainers(sourceContainerId, self);
  8085. }, self.grid.options.wheelScrollThrottle, {trailing: true});
  8086. }
  8087. /**
  8088. * @ngdoc function
  8089. * @name getNewScrollLeft
  8090. * @methodOf ui.grid.class:ScrollEvent
  8091. * @description returns newScrollLeft property if available; calculates a new value if it isn't
  8092. */
  8093. ScrollEvent.prototype.getNewScrollLeft = function(colContainer, viewport){
  8094. var self = this;
  8095. if (!self.newScrollLeft){
  8096. var scrollWidth = (colContainer.getCanvasWidth() - colContainer.getViewportWidth());
  8097. var oldScrollLeft = gridUtil.normalizeScrollLeft(viewport, self.grid);
  8098. var scrollXPercentage;
  8099. if (typeof(self.x.percentage) !== 'undefined' && self.x.percentage !== undefined) {
  8100. scrollXPercentage = self.x.percentage;
  8101. }
  8102. else if (typeof(self.x.pixels) !== 'undefined' && self.x.pixels !== undefined) {
  8103. scrollXPercentage = self.x.percentage = (oldScrollLeft + self.x.pixels) / scrollWidth;
  8104. }
  8105. else {
  8106. throw new Error("No percentage or pixel value provided for scroll event X axis");
  8107. }
  8108. return Math.max(0, scrollXPercentage * scrollWidth);
  8109. }
  8110. return self.newScrollLeft;
  8111. };
  8112. /**
  8113. * @ngdoc function
  8114. * @name getNewScrollTop
  8115. * @methodOf ui.grid.class:ScrollEvent
  8116. * @description returns newScrollTop property if available; calculates a new value if it isn't
  8117. */
  8118. ScrollEvent.prototype.getNewScrollTop = function(rowContainer, viewport){
  8119. var self = this;
  8120. if (!self.newScrollTop){
  8121. var scrollLength = rowContainer.getVerticalScrollLength();
  8122. var oldScrollTop = viewport[0].scrollTop;
  8123. var scrollYPercentage;
  8124. if (typeof(self.y.percentage) !== 'undefined' && self.y.percentage !== undefined) {
  8125. scrollYPercentage = self.y.percentage;
  8126. }
  8127. else if (typeof(self.y.pixels) !== 'undefined' && self.y.pixels !== undefined) {
  8128. scrollYPercentage = self.y.percentage = (oldScrollTop + self.y.pixels) / scrollLength;
  8129. }
  8130. else {
  8131. throw new Error("No percentage or pixel value provided for scroll event Y axis");
  8132. }
  8133. return Math.max(0, scrollYPercentage * scrollLength);
  8134. }
  8135. return self.newScrollTop;
  8136. };
  8137. ScrollEvent.prototype.atTop = function(scrollTop) {
  8138. return (this.y && (this.y.percentage === 0 || this.verticalScrollLength < 0) && scrollTop === 0);
  8139. };
  8140. ScrollEvent.prototype.atBottom = function(scrollTop) {
  8141. return (this.y && (this.y.percentage === 1 || this.verticalScrollLength === 0) && scrollTop > 0);
  8142. };
  8143. ScrollEvent.prototype.atLeft = function(scrollLeft) {
  8144. return (this.x && (this.x.percentage === 0 || this.horizontalScrollLength < 0) && scrollLeft === 0);
  8145. };
  8146. ScrollEvent.prototype.atRight = function(scrollLeft) {
  8147. return (this.x && (this.x.percentage === 1 || this.horizontalScrollLength ===0) && scrollLeft > 0);
  8148. };
  8149. ScrollEvent.Sources = {
  8150. ViewPortScroll: 'ViewPortScroll',
  8151. RenderContainerMouseWheel: 'RenderContainerMouseWheel',
  8152. RenderContainerTouchMove: 'RenderContainerTouchMove',
  8153. Other: 99
  8154. };
  8155. return ScrollEvent;
  8156. }]);
  8157. })();
  8158. (function () {
  8159. 'use strict';
  8160. /**
  8161. * @ngdoc object
  8162. * @name ui.grid.service:gridClassFactory
  8163. *
  8164. * @description factory to return dom specific instances of a grid
  8165. *
  8166. */
  8167. angular.module('ui.grid').service('gridClassFactory', ['gridUtil', '$q', '$compile', '$templateCache', 'uiGridConstants', 'Grid', 'GridColumn', 'GridRow',
  8168. function (gridUtil, $q, $compile, $templateCache, uiGridConstants, Grid, GridColumn, GridRow) {
  8169. var service = {
  8170. /**
  8171. * @ngdoc method
  8172. * @name createGrid
  8173. * @methodOf ui.grid.service:gridClassFactory
  8174. * @description Creates a new grid instance. Each instance will have a unique id
  8175. * @param {object} options An object map of options to pass into the created grid instance.
  8176. * @returns {Grid} grid
  8177. */
  8178. createGrid : function(options) {
  8179. options = (typeof(options) !== 'undefined') ? options : {};
  8180. options.id = gridUtil.newId();
  8181. var grid = new Grid(options);
  8182. // NOTE/TODO: rowTemplate should always be defined...
  8183. if (grid.options.rowTemplate) {
  8184. var rowTemplateFnPromise = $q.defer();
  8185. grid.getRowTemplateFn = rowTemplateFnPromise.promise;
  8186. gridUtil.getTemplate(grid.options.rowTemplate)
  8187. .then(
  8188. function (template) {
  8189. var rowTemplateFn = $compile(template);
  8190. rowTemplateFnPromise.resolve(rowTemplateFn);
  8191. },
  8192. function (res) {
  8193. // Todo handle response error here?
  8194. throw new Error("Couldn't fetch/use row template '" + grid.options.rowTemplate + "'");
  8195. }).catch(angular.noop);
  8196. }
  8197. grid.registerColumnBuilder(service.defaultColumnBuilder);
  8198. // Row builder for custom row templates
  8199. grid.registerRowBuilder(service.rowTemplateAssigner);
  8200. // Reset all rows to visible initially
  8201. grid.registerRowsProcessor(function allRowsVisible(rows) {
  8202. rows.forEach(function (row) {
  8203. row.evaluateRowVisibility( true );
  8204. }, 50);
  8205. return rows;
  8206. });
  8207. grid.registerColumnsProcessor(function applyColumnVisibility(columns) {
  8208. columns.forEach(function (column) {
  8209. column.visible = angular.isDefined(column.colDef.visible) ? column.colDef.visible : true;
  8210. });
  8211. return columns;
  8212. }, 50);
  8213. grid.registerRowsProcessor(grid.searchRows, 100);
  8214. // Register the default row processor, it sorts rows by selected columns
  8215. if (grid.options.externalSort && angular.isFunction(grid.options.externalSort)) {
  8216. grid.registerRowsProcessor(grid.options.externalSort, 200);
  8217. }
  8218. else {
  8219. grid.registerRowsProcessor(grid.sortByColumn, 200);
  8220. }
  8221. return grid;
  8222. },
  8223. /**
  8224. * @ngdoc function
  8225. * @name defaultColumnBuilder
  8226. * @methodOf ui.grid.service:gridClassFactory
  8227. * @description Processes designTime column definitions and applies them to col for the
  8228. * core grid features
  8229. * @param {object} colDef reference to column definition
  8230. * @param {GridColumn} col reference to gridCol
  8231. * @param {object} gridOptions reference to grid options
  8232. */
  8233. defaultColumnBuilder: function (colDef, col, gridOptions) {
  8234. var templateGetPromises = [];
  8235. // Abstracts the standard template processing we do for every template type.
  8236. var processTemplate = function( templateType, providedType, defaultTemplate, filterType, tooltipType ) {
  8237. if ( !colDef[templateType] ){
  8238. col[providedType] = defaultTemplate;
  8239. } else {
  8240. col[providedType] = colDef[templateType];
  8241. }
  8242. var templatePromise = gridUtil.getTemplate(col[providedType])
  8243. .then(
  8244. function (template) {
  8245. if ( angular.isFunction(template) ) { template = template(); }
  8246. var tooltipCall = ( tooltipType === 'cellTooltip' ) ? 'col.cellTooltip(row,col)' : 'col.headerTooltip(col)';
  8247. if ( tooltipType && col[tooltipType] === false ){
  8248. template = template.replace(uiGridConstants.TOOLTIP, '');
  8249. } else if ( tooltipType && col[tooltipType] ){
  8250. template = template.replace(uiGridConstants.TOOLTIP, 'title="{{' + tooltipCall + ' CUSTOM_FILTERS }}"');
  8251. }
  8252. if ( filterType ){
  8253. col[templateType] = template.replace(uiGridConstants.CUSTOM_FILTERS, function() {
  8254. return col[filterType] ? "|" + col[filterType] : "";
  8255. });
  8256. } else {
  8257. col[templateType] = template;
  8258. }
  8259. },
  8260. function (res) {
  8261. throw new Error("Couldn't fetch/use colDef." + templateType + " '" + colDef[templateType] + "'");
  8262. }).catch(angular.noop);
  8263. templateGetPromises.push(templatePromise);
  8264. return templatePromise;
  8265. };
  8266. /**
  8267. * @ngdoc property
  8268. * @name cellTemplate
  8269. * @propertyOf ui.grid.class:GridOptions.columnDef
  8270. * @description a custom template for each cell in this column. The default
  8271. * is ui-grid/uiGridCell. If you are using the cellNav feature, this template
  8272. * must contain a div that can receive focus.
  8273. *
  8274. */
  8275. col.cellTemplatePromise = processTemplate( 'cellTemplate', 'providedCellTemplate', 'ui-grid/uiGridCell', 'cellFilter', 'cellTooltip' );
  8276. /**
  8277. * @ngdoc property
  8278. * @name headerCellTemplate
  8279. * @propertyOf ui.grid.class:GridOptions.columnDef
  8280. * @description a custom template for the header for this column. The default
  8281. * is ui-grid/uiGridHeaderCell
  8282. *
  8283. */
  8284. col.headerCellTemplatePromise = processTemplate( 'headerCellTemplate', 'providedHeaderCellTemplate', 'ui-grid/uiGridHeaderCell', 'headerCellFilter', 'headerTooltip' );
  8285. /**
  8286. * @ngdoc property
  8287. * @name footerCellTemplate
  8288. * @propertyOf ui.grid.class:GridOptions.columnDef
  8289. * @description a custom template for the footer for this column. The default
  8290. * is ui-grid/uiGridFooterCell
  8291. *
  8292. */
  8293. col.footerCellTemplatePromise = processTemplate( 'footerCellTemplate', 'providedFooterCellTemplate', 'ui-grid/uiGridFooterCell', 'footerCellFilter' );
  8294. /**
  8295. * @ngdoc property
  8296. * @name filterHeaderTemplate
  8297. * @propertyOf ui.grid.class:GridOptions.columnDef
  8298. * @description a custom template for the filter input. The default is ui-grid/ui-grid-filter
  8299. *
  8300. */
  8301. col.filterHeaderTemplatePromise = processTemplate( 'filterHeaderTemplate', 'providedFilterHeaderTemplate', 'ui-grid/ui-grid-filter' );
  8302. // Create a promise for the compiled element function
  8303. col.compiledElementFnDefer = $q.defer();
  8304. return $q.all(templateGetPromises);
  8305. },
  8306. rowTemplateAssigner: function rowTemplateAssigner(row) {
  8307. var grid = this;
  8308. // Row has no template assigned to it
  8309. if (!row.rowTemplate) {
  8310. // Use the default row template from the grid
  8311. row.rowTemplate = grid.options.rowTemplate;
  8312. // Use the grid's function for fetching the compiled row template function
  8313. row.getRowTemplateFn = grid.getRowTemplateFn;
  8314. }
  8315. // Row has its own template assigned
  8316. else {
  8317. // Create a promise for the compiled row template function
  8318. var perRowTemplateFnPromise = $q.defer();
  8319. row.getRowTemplateFn = perRowTemplateFnPromise.promise;
  8320. // Get the row template
  8321. gridUtil.getTemplate(row.rowTemplate)
  8322. .then(function (template) {
  8323. // Compile the template
  8324. var rowTemplateFn = $compile(template);
  8325. // Resolve the compiled template function promise
  8326. perRowTemplateFnPromise.resolve(rowTemplateFn);
  8327. },
  8328. function (res) {
  8329. // Todo handle response error here?
  8330. throw new Error("Couldn't fetch/use row template '" + row.rowTemplate + "'");
  8331. });
  8332. }
  8333. return row.getRowTemplateFn;
  8334. }
  8335. };
  8336. //class definitions (moved to separate factories)
  8337. return service;
  8338. }]);
  8339. })();
  8340. (function() {
  8341. var module = angular.module('ui.grid');
  8342. function escapeRegExp(str) {
  8343. return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
  8344. }
  8345. /**
  8346. * @ngdoc service
  8347. * @name ui.grid.service:rowSearcher
  8348. *
  8349. * @description Service for searching/filtering rows based on column value conditions.
  8350. */
  8351. module.service('rowSearcher', ['gridUtil', 'uiGridConstants', function (gridUtil, uiGridConstants) {
  8352. var defaultCondition = uiGridConstants.filter.CONTAINS;
  8353. var rowSearcher = {};
  8354. /**
  8355. * @ngdoc function
  8356. * @name getTerm
  8357. * @methodOf ui.grid.service:rowSearcher
  8358. * @description Get the term from a filter
  8359. * Trims leading and trailing whitespace
  8360. * @param {object} filter object to use
  8361. * @returns {object} Parsed term
  8362. */
  8363. rowSearcher.getTerm = function getTerm(filter) {
  8364. if (typeof(filter.term) === 'undefined') { return filter.term; }
  8365. var term = filter.term;
  8366. // Strip leading and trailing whitespace if the term is a string
  8367. if (typeof(term) === 'string') {
  8368. term = term.trim();
  8369. }
  8370. return term;
  8371. };
  8372. /**
  8373. * @ngdoc function
  8374. * @name stripTerm
  8375. * @methodOf ui.grid.service:rowSearcher
  8376. * @description Remove leading and trailing asterisk (*) from the filter's term
  8377. * @param {object} filter object to use
  8378. * @returns {uiGridConstants.filter<int>} Value representing the condition constant value
  8379. */
  8380. rowSearcher.stripTerm = function stripTerm(filter) {
  8381. var term = rowSearcher.getTerm(filter);
  8382. if (typeof(term) === 'string') {
  8383. return escapeRegExp(term.replace(/(^\*|\*$)/g, ''));
  8384. }
  8385. else {
  8386. return term;
  8387. }
  8388. };
  8389. /**
  8390. * @ngdoc function
  8391. * @name guessCondition
  8392. * @methodOf ui.grid.service:rowSearcher
  8393. * @description Guess the condition for a filter based on its term
  8394. * <br>
  8395. * Defaults to STARTS_WITH. Uses CONTAINS for strings beginning and ending with *s (*bob*).
  8396. * Uses STARTS_WITH for strings ending with * (bo*). Uses ENDS_WITH for strings starting with * (*ob).
  8397. * @param {object} filter object to use
  8398. * @returns {uiGridConstants.filter<int>} Value representing the condition constant value
  8399. */
  8400. rowSearcher.guessCondition = function guessCondition(filter) {
  8401. if (typeof(filter.term) === 'undefined' || !filter.term) {
  8402. return defaultCondition;
  8403. }
  8404. var term = rowSearcher.getTerm(filter);
  8405. if (/\*/.test(term)) {
  8406. var regexpFlags = '';
  8407. if (!filter.flags || !filter.flags.caseSensitive) {
  8408. regexpFlags += 'i';
  8409. }
  8410. var reText = term.replace(/(\\)?\*/g, function ($0, $1) { return $1 ? $0 : '[\\s\\S]*?'; });
  8411. return new RegExp('^' + reText + '$', regexpFlags);
  8412. }
  8413. // Otherwise default to default condition
  8414. else {
  8415. return defaultCondition;
  8416. }
  8417. };
  8418. /**
  8419. * @ngdoc function
  8420. * @name setupFilters
  8421. * @methodOf ui.grid.service:rowSearcher
  8422. * @description For a given columns filters (either col.filters, or [col.filter] can be passed in),
  8423. * do all the parsing and pre-processing and store that data into a new filters object. The object
  8424. * has the condition, the flags, the stripped term, and a parsed reg exp if there was one.
  8425. *
  8426. * We could use a forEach in here, since it's much less performance sensitive, but since we're using
  8427. * for loops everywhere else in this module...
  8428. *
  8429. * @param {array} filters the filters from the column (col.filters or [col.filter])
  8430. * @returns {array} An array of parsed/preprocessed filters
  8431. */
  8432. rowSearcher.setupFilters = function setupFilters( filters ){
  8433. var newFilters = [];
  8434. var filtersLength = filters.length;
  8435. for ( var i = 0; i < filtersLength; i++ ){
  8436. var filter = filters[i];
  8437. if ( filter.noTerm || !gridUtil.isNullOrUndefined(filter.term) ){
  8438. var newFilter = {};
  8439. var regexpFlags = '';
  8440. if (!filter.flags || !filter.flags.caseSensitive) {
  8441. regexpFlags += 'i';
  8442. }
  8443. if ( !gridUtil.isNullOrUndefined(filter.term) ){
  8444. // it is possible to have noTerm.
  8445. if ( filter.rawTerm ){
  8446. newFilter.term = filter.term;
  8447. } else {
  8448. newFilter.term = rowSearcher.stripTerm(filter);
  8449. }
  8450. }
  8451. newFilter.noTerm = filter.noTerm;
  8452. if ( filter.condition ){
  8453. newFilter.condition = filter.condition;
  8454. } else {
  8455. newFilter.condition = rowSearcher.guessCondition(filter);
  8456. }
  8457. newFilter.flags = angular.extend( { caseSensitive: false, date: false }, filter.flags );
  8458. if (newFilter.condition === uiGridConstants.filter.STARTS_WITH) {
  8459. newFilter.startswithRE = new RegExp('^' + newFilter.term, regexpFlags);
  8460. }
  8461. if (newFilter.condition === uiGridConstants.filter.ENDS_WITH) {
  8462. newFilter.endswithRE = new RegExp(newFilter.term + '$', regexpFlags);
  8463. }
  8464. if (newFilter.condition === uiGridConstants.filter.CONTAINS) {
  8465. newFilter.containsRE = new RegExp(newFilter.term, regexpFlags);
  8466. }
  8467. if (newFilter.condition === uiGridConstants.filter.EXACT) {
  8468. newFilter.exactRE = new RegExp('^' + newFilter.term + '$', regexpFlags);
  8469. }
  8470. newFilters.push(newFilter);
  8471. }
  8472. }
  8473. return newFilters;
  8474. };
  8475. /**
  8476. * @ngdoc function
  8477. * @name runColumnFilter
  8478. * @methodOf ui.grid.service:rowSearcher
  8479. * @description Runs a single pre-parsed filter against a cell, returning true
  8480. * if the cell matches that one filter.
  8481. *
  8482. * @param {Grid} grid the grid we're working against
  8483. * @param {GridRow} row the row we're matching against
  8484. * @param {GridColumn} column the column that we're working against
  8485. * @param {object} filter the specific, preparsed, filter that we want to test
  8486. * @returns {boolean} true if we match (row stays visible)
  8487. */
  8488. rowSearcher.runColumnFilter = function runColumnFilter(grid, row, column, filter) {
  8489. // Cache typeof condition
  8490. var conditionType = typeof(filter.condition);
  8491. // Term to search for.
  8492. var term = filter.term;
  8493. // Get the column value for this row
  8494. var value;
  8495. if ( column.filterCellFiltered ){
  8496. value = grid.getCellDisplayValue(row, column);
  8497. } else {
  8498. value = grid.getCellValue(row, column);
  8499. }
  8500. // If the filter's condition is a RegExp, then use it
  8501. if (filter.condition instanceof RegExp) {
  8502. return filter.condition.test(value);
  8503. }
  8504. // If the filter's condition is a function, run it
  8505. if (conditionType === 'function') {
  8506. return filter.condition(term, value, row, column);
  8507. }
  8508. if (filter.startswithRE) {
  8509. return filter.startswithRE.test(value);
  8510. }
  8511. if (filter.endswithRE) {
  8512. return filter.endswithRE.test(value);
  8513. }
  8514. if (filter.containsRE) {
  8515. return filter.containsRE.test(value);
  8516. }
  8517. if (filter.exactRE) {
  8518. return filter.exactRE.test(value);
  8519. }
  8520. if (filter.condition === uiGridConstants.filter.NOT_EQUAL) {
  8521. var regex = new RegExp('^' + term + '$');
  8522. return !regex.exec(value);
  8523. }
  8524. if (typeof(value) === 'number' && typeof(term) === 'string' ){
  8525. // if the term has a decimal in it, it comes through as '9\.4', we need to take out the \
  8526. // the same for negative numbers
  8527. // TODO: I suspect the right answer is to look at escapeRegExp at the top of this code file, maybe it's not needed?
  8528. var tempFloat = parseFloat(term.replace(/\\\./,'.').replace(/\\\-/,'-'));
  8529. if (!isNaN(tempFloat)) {
  8530. term = tempFloat;
  8531. }
  8532. }
  8533. if (filter.flags.date === true) {
  8534. value = new Date(value);
  8535. // If the term has a dash in it, it comes through as '\-' -- we need to take out the '\'.
  8536. term = new Date(term.replace(/\\/g, ''));
  8537. }
  8538. if (filter.condition === uiGridConstants.filter.GREATER_THAN) {
  8539. return (value > term);
  8540. }
  8541. if (filter.condition === uiGridConstants.filter.GREATER_THAN_OR_EQUAL) {
  8542. return (value >= term);
  8543. }
  8544. if (filter.condition === uiGridConstants.filter.LESS_THAN) {
  8545. return (value < term);
  8546. }
  8547. if (filter.condition === uiGridConstants.filter.LESS_THAN_OR_EQUAL) {
  8548. return (value <= term);
  8549. }
  8550. return true;
  8551. };
  8552. /**
  8553. * @ngdoc boolean
  8554. * @name useExternalFiltering
  8555. * @propertyOf ui.grid.class:GridOptions
  8556. * @description False by default. When enabled, this setting suppresses the internal filtering.
  8557. * All UI logic will still operate, allowing filter conditions to be set and modified.
  8558. *
  8559. * The external filter logic can listen for the `filterChange` event, which fires whenever
  8560. * a filter has been adjusted.
  8561. */
  8562. /**
  8563. * @ngdoc function
  8564. * @name searchColumn
  8565. * @methodOf ui.grid.service:rowSearcher
  8566. * @description Process provided filters on provided column against a given row. If the row meets
  8567. * the conditions on all the filters, return true.
  8568. * @param {Grid} grid Grid to search in
  8569. * @param {GridRow} row Row to search on
  8570. * @param {GridColumn} column Column with the filters to use
  8571. * @param {array} filters array of pre-parsed/preprocessed filters to apply
  8572. * @returns {boolean} Whether the column matches or not.
  8573. */
  8574. rowSearcher.searchColumn = function searchColumn(grid, row, column, filters) {
  8575. if (grid.options.useExternalFiltering) {
  8576. return true;
  8577. }
  8578. var filtersLength = filters.length;
  8579. for (var i = 0; i < filtersLength; i++) {
  8580. var filter = filters[i];
  8581. if ( !gridUtil.isNullOrUndefined(filter.term) && filter.term !== '' || filter.noTerm ){
  8582. var ret = rowSearcher.runColumnFilter(grid, row, column, filter);
  8583. if (!ret) {
  8584. return false;
  8585. }
  8586. }
  8587. }
  8588. return true;
  8589. };
  8590. /**
  8591. * @ngdoc function
  8592. * @name search
  8593. * @methodOf ui.grid.service:rowSearcher
  8594. * @description Run a search across the given rows and columns, marking any rows that don't
  8595. * match the stored col.filters or col.filter as invisible.
  8596. * @param {Grid} grid Grid instance to search inside
  8597. * @param {Array[GridRow]} rows GridRows to filter
  8598. * @param {Array[GridColumn]} columns GridColumns with filters to process
  8599. */
  8600. rowSearcher.search = function search(grid, rows, columns) {
  8601. /*
  8602. * Added performance optimisations into this code base, as this logic creates deeply nested
  8603. * loops and is therefore very performance sensitive. In particular, avoiding forEach as
  8604. * this impacts some browser optimisers (particularly Chrome), using iterators instead
  8605. */
  8606. // Don't do anything if we weren't passed any rows
  8607. if (!rows) {
  8608. return;
  8609. }
  8610. // don't filter if filtering currently disabled
  8611. if (!grid.options.enableFiltering){
  8612. return rows;
  8613. }
  8614. // Build list of filters to apply
  8615. var filterData = [];
  8616. var colsLength = columns.length;
  8617. var hasTerm = function( filters ) {
  8618. var hasTerm = false;
  8619. filters.forEach( function (filter) {
  8620. if ( !gridUtil.isNullOrUndefined(filter.term) && filter.term !== '' || filter.noTerm ){
  8621. hasTerm = true;
  8622. }
  8623. });
  8624. return hasTerm;
  8625. };
  8626. for (var i = 0; i < colsLength; i++) {
  8627. var col = columns[i];
  8628. if (typeof(col.filters) !== 'undefined' && hasTerm(col.filters) ) {
  8629. filterData.push( { col: col, filters: rowSearcher.setupFilters(col.filters) } );
  8630. }
  8631. }
  8632. if (filterData.length > 0) {
  8633. // define functions outside the loop, performance optimisation
  8634. var foreachRow = function(grid, row, col, filters){
  8635. if ( row.visible && !rowSearcher.searchColumn(grid, row, col, filters) ) {
  8636. row.visible = false;
  8637. }
  8638. };
  8639. var foreachFilterCol = function(grid, filterData){
  8640. var rowsLength = rows.length;
  8641. for ( var i = 0; i < rowsLength; i++){
  8642. foreachRow(grid, rows[i], filterData.col, filterData.filters);
  8643. }
  8644. };
  8645. // nested loop itself - foreachFilterCol, which in turn calls foreachRow
  8646. var filterDataLength = filterData.length;
  8647. for ( var j = 0; j < filterDataLength; j++){
  8648. foreachFilterCol( grid, filterData[j] );
  8649. }
  8650. if (grid.api.core.raise.rowsVisibleChanged) {
  8651. grid.api.core.raise.rowsVisibleChanged();
  8652. }
  8653. // drop any invisible rows
  8654. // keeping these, as needed with filtering for trees - we have to come back and make parent nodes visible if child nodes are selected in the filter
  8655. // rows = rows.filter(function(row){ return row.visible; });
  8656. }
  8657. return rows;
  8658. };
  8659. return rowSearcher;
  8660. }]);
  8661. })();
  8662. (function() {
  8663. var module = angular.module('ui.grid');
  8664. /**
  8665. * @ngdoc object
  8666. * @name ui.grid.class:rowSorter
  8667. * @description rowSorter provides the default sorting mechanisms,
  8668. * including guessing column types and applying appropriate sort
  8669. * algorithms
  8670. *
  8671. */
  8672. module.service('rowSorter', ['$parse', 'uiGridConstants', function ($parse, uiGridConstants) {
  8673. var currencyRegexStr =
  8674. '(' +
  8675. uiGridConstants.CURRENCY_SYMBOLS
  8676. .map(function (a) { return '\\' + a; }) // Escape all the currency symbols ($ at least will jack up this regex)
  8677. .join('|') + // Join all the symbols together with |s
  8678. ')?';
  8679. // /^[-+]?[£$¤¥]?[\d,.]+%?$/
  8680. var numberStrRegex = new RegExp('^[-+]?' + currencyRegexStr + '[\\d,.]+' + currencyRegexStr + '%?$');
  8681. var rowSorter = {
  8682. // Cache of sorting functions. Once we create them, we don't want to keep re-doing it
  8683. // this takes a piece of data from the cell and tries to determine its type and what sorting
  8684. // function to use for it
  8685. colSortFnCache: {}
  8686. };
  8687. /**
  8688. * @ngdoc method
  8689. * @methodOf ui.grid.class:rowSorter
  8690. * @name guessSortFn
  8691. * @description Assigns a sort function to use based on the itemType in the column
  8692. * @param {string} itemType one of 'number', 'boolean', 'string', 'date', 'object'. And
  8693. * error will be thrown for any other type.
  8694. * @returns {function} a sort function that will sort that type
  8695. */
  8696. rowSorter.guessSortFn = function guessSortFn(itemType) {
  8697. switch (itemType) {
  8698. case "number":
  8699. return rowSorter.sortNumber;
  8700. case "numberStr":
  8701. return rowSorter.sortNumberStr;
  8702. case "boolean":
  8703. return rowSorter.sortBool;
  8704. case "string":
  8705. return rowSorter.sortAlpha;
  8706. case "date":
  8707. return rowSorter.sortDate;
  8708. case "object":
  8709. return rowSorter.basicSort;
  8710. default:
  8711. throw new Error('No sorting function found for type:' + itemType);
  8712. }
  8713. };
  8714. /**
  8715. * @ngdoc method
  8716. * @methodOf ui.grid.class:rowSorter
  8717. * @name handleNulls
  8718. * @description Sorts nulls and undefined to the bottom (top when
  8719. * descending). Called by each of the internal sorters before
  8720. * attempting to sort. Note that this method is available on the core api
  8721. * via gridApi.core.sortHandleNulls
  8722. * @param {object} a sort value a
  8723. * @param {object} b sort value b
  8724. * @returns {number} null if there were no nulls/undefineds, otherwise returns
  8725. * a sort value that should be passed back from the sort function
  8726. */
  8727. rowSorter.handleNulls = function handleNulls(a, b) {
  8728. // We want to allow zero values and false values to be evaluated in the sort function
  8729. if ((!a && a !== 0 && a !== false) || (!b && b !== 0 && b !== false)) {
  8730. // We want to force nulls and such to the bottom when we sort... which effectively is "greater than"
  8731. if ((!a && a !== 0 && a !== false) && (!b && b !== 0 && b !== false)) {
  8732. return 0;
  8733. }
  8734. else if (!a && a !== 0 && a !== false) {
  8735. return 1;
  8736. }
  8737. else if (!b && b !== 0 && b !== false) {
  8738. return -1;
  8739. }
  8740. }
  8741. return null;
  8742. };
  8743. /**
  8744. * @ngdoc method
  8745. * @methodOf ui.grid.class:rowSorter
  8746. * @name basicSort
  8747. * @description Sorts any values that provide the < method, including strings
  8748. * or numbers. Handles nulls and undefined through calling handleNulls
  8749. * @param {object} a sort value a
  8750. * @param {object} b sort value b
  8751. * @returns {number} normal sort function, returns -ve, 0, +ve
  8752. */
  8753. rowSorter.basicSort = function basicSort(a, b) {
  8754. var nulls = rowSorter.handleNulls(a, b);
  8755. if ( nulls !== null ){
  8756. return nulls;
  8757. } else {
  8758. if (a === b) {
  8759. return 0;
  8760. }
  8761. if (a < b) {
  8762. return -1;
  8763. }
  8764. return 1;
  8765. }
  8766. };
  8767. /**
  8768. * @ngdoc method
  8769. * @methodOf ui.grid.class:rowSorter
  8770. * @name sortNumber
  8771. * @description Sorts numerical values. Handles nulls and undefined through calling handleNulls
  8772. * @param {object} a sort value a
  8773. * @param {object} b sort value b
  8774. * @returns {number} normal sort function, returns -ve, 0, +ve
  8775. */
  8776. rowSorter.sortNumber = function sortNumber(a, b) {
  8777. var nulls = rowSorter.handleNulls(a, b);
  8778. if ( nulls !== null ){
  8779. return nulls;
  8780. } else {
  8781. return a - b;
  8782. }
  8783. };
  8784. /**
  8785. * @ngdoc method
  8786. * @methodOf ui.grid.class:rowSorter
  8787. * @name sortNumberStr
  8788. * @description Sorts numerical values that are stored in a string (i.e. parses them to numbers first).
  8789. * Handles nulls and undefined through calling handleNulls
  8790. * @param {object} a sort value a
  8791. * @param {object} b sort value b
  8792. * @returns {number} normal sort function, returns -ve, 0, +ve
  8793. */
  8794. rowSorter.sortNumberStr = function sortNumberStr(a, b) {
  8795. var nulls = rowSorter.handleNulls(a, b);
  8796. if ( nulls !== null ){
  8797. return nulls;
  8798. } else {
  8799. var numA, // The parsed number form of 'a'
  8800. numB, // The parsed number form of 'b'
  8801. badA = false,
  8802. badB = false;
  8803. // Try to parse 'a' to a float
  8804. numA = parseFloat(a.replace(/[^0-9.-]/g, ''));
  8805. // If 'a' couldn't be parsed to float, flag it as bad
  8806. if (isNaN(numA)) {
  8807. badA = true;
  8808. }
  8809. // Try to parse 'b' to a float
  8810. numB = parseFloat(b.replace(/[^0-9.-]/g, ''));
  8811. // If 'b' couldn't be parsed to float, flag it as bad
  8812. if (isNaN(numB)) {
  8813. badB = true;
  8814. }
  8815. // We want bad ones to get pushed to the bottom... which effectively is "greater than"
  8816. if (badA && badB) {
  8817. return 0;
  8818. }
  8819. if (badA) {
  8820. return 1;
  8821. }
  8822. if (badB) {
  8823. return -1;
  8824. }
  8825. return numA - numB;
  8826. }
  8827. };
  8828. /**
  8829. * @ngdoc method
  8830. * @methodOf ui.grid.class:rowSorter
  8831. * @name sortAlpha
  8832. * @description Sorts string values. Handles nulls and undefined through calling handleNulls
  8833. * @param {object} a sort value a
  8834. * @param {object} b sort value b
  8835. * @returns {number} normal sort function, returns -ve, 0, +ve
  8836. */
  8837. rowSorter.sortAlpha = function sortAlpha(a, b) {
  8838. var nulls = rowSorter.handleNulls(a, b);
  8839. if ( nulls !== null ){
  8840. return nulls;
  8841. } else {
  8842. var strA = a.toString().toLowerCase(),
  8843. strB = b.toString().toLowerCase();
  8844. return strA === strB ? 0 : strA.localeCompare(strB);
  8845. }
  8846. };
  8847. /**
  8848. * @ngdoc method
  8849. * @methodOf ui.grid.class:rowSorter
  8850. * @name sortDate
  8851. * @description Sorts date values. Handles nulls and undefined through calling handleNulls.
  8852. * Handles date strings by converting to Date object if not already an instance of Date
  8853. * @param {object} a sort value a
  8854. * @param {object} b sort value b
  8855. * @returns {number} normal sort function, returns -ve, 0, +ve
  8856. */
  8857. rowSorter.sortDate = function sortDate(a, b) {
  8858. var nulls = rowSorter.handleNulls(a, b);
  8859. if ( nulls !== null ){
  8860. return nulls;
  8861. } else {
  8862. if (!(a instanceof Date)) {
  8863. a = new Date(a);
  8864. }
  8865. if (!(b instanceof Date)){
  8866. b = new Date(b);
  8867. }
  8868. var timeA = a.getTime(),
  8869. timeB = b.getTime();
  8870. return timeA === timeB ? 0 : (timeA < timeB ? -1 : 1);
  8871. }
  8872. };
  8873. /**
  8874. * @ngdoc method
  8875. * @methodOf ui.grid.class:rowSorter
  8876. * @name sortBool
  8877. * @description Sorts boolean values, true is considered larger than false.
  8878. * Handles nulls and undefined through calling handleNulls
  8879. * @param {object} a sort value a
  8880. * @param {object} b sort value b
  8881. * @returns {number} normal sort function, returns -ve, 0, +ve
  8882. */
  8883. rowSorter.sortBool = function sortBool(a, b) {
  8884. var nulls = rowSorter.handleNulls(a, b);
  8885. if ( nulls !== null ){
  8886. return nulls;
  8887. } else {
  8888. if (a && b) {
  8889. return 0;
  8890. }
  8891. if (!a && !b) {
  8892. return 0;
  8893. }
  8894. else {
  8895. return a ? 1 : -1;
  8896. }
  8897. }
  8898. };
  8899. /**
  8900. * @ngdoc method
  8901. * @methodOf ui.grid.class:rowSorter
  8902. * @name getSortFn
  8903. * @description Get the sort function for the column. Looks first in
  8904. * rowSorter.colSortFnCache using the column name, failing that it
  8905. * looks at col.sortingAlgorithm (and puts it in the cache), failing that
  8906. * it guesses the sort algorithm based on the data type.
  8907. *
  8908. * The cache currently seems a bit pointless, as none of the work we do is
  8909. * processor intensive enough to need caching. Presumably in future we might
  8910. * inspect the row data itself to guess the sort function, and in that case
  8911. * it would make sense to have a cache, the infrastructure is in place to allow
  8912. * that.
  8913. *
  8914. * @param {Grid} grid the grid to consider
  8915. * @param {GridColumn} col the column to find a function for
  8916. * @param {array} rows an array of grid rows. Currently unused, but presumably in future
  8917. * we might inspect the rows themselves to decide what sort of data might be there
  8918. * @returns {function} the sort function chosen for the column
  8919. */
  8920. rowSorter.getSortFn = function getSortFn(grid, col, rows) {
  8921. var sortFn, item;
  8922. // See if we already figured out what to use to sort the column and have it in the cache
  8923. if (rowSorter.colSortFnCache[col.colDef.name]) {
  8924. sortFn = rowSorter.colSortFnCache[col.colDef.name];
  8925. }
  8926. // If the column has its OWN sorting algorithm, use that
  8927. else if (col.sortingAlgorithm !== undefined) {
  8928. sortFn = col.sortingAlgorithm;
  8929. rowSorter.colSortFnCache[col.colDef.name] = col.sortingAlgorithm;
  8930. }
  8931. // Always default to sortAlpha when sorting after a cellFilter
  8932. else if ( col.sortCellFiltered && col.cellFilter ){
  8933. sortFn = rowSorter.sortAlpha;
  8934. rowSorter.colSortFnCache[col.colDef.name] = sortFn;
  8935. }
  8936. // Try and guess what sort function to use
  8937. else {
  8938. // Guess the sort function
  8939. sortFn = rowSorter.guessSortFn(col.colDef.type);
  8940. // If we found a sort function, cache it
  8941. if (sortFn) {
  8942. rowSorter.colSortFnCache[col.colDef.name] = sortFn;
  8943. }
  8944. else {
  8945. // We assign the alpha sort because anything that is null/undefined will never get passed to
  8946. // the actual sorting function. It will get caught in our null check and returned to be sorted
  8947. // down to the bottom
  8948. sortFn = rowSorter.sortAlpha;
  8949. }
  8950. }
  8951. return sortFn;
  8952. };
  8953. /**
  8954. * @ngdoc method
  8955. * @methodOf ui.grid.class:rowSorter
  8956. * @name prioritySort
  8957. * @description Used where multiple columns are present in the sort criteria,
  8958. * we determine which column should take precedence in the sort by sorting
  8959. * the columns based on their sort.priority
  8960. *
  8961. * @param {gridColumn} a column a
  8962. * @param {gridColumn} b column b
  8963. * @returns {number} normal sort function, returns -ve, 0, +ve
  8964. */
  8965. rowSorter.prioritySort = function (a, b) {
  8966. // Both columns have a sort priority
  8967. if (a.sort.priority !== undefined && b.sort.priority !== undefined) {
  8968. // A is higher priority
  8969. if (a.sort.priority < b.sort.priority) {
  8970. return -1;
  8971. }
  8972. // Equal
  8973. else if (a.sort.priority === b.sort.priority) {
  8974. return 0;
  8975. }
  8976. // B is higher
  8977. else {
  8978. return 1;
  8979. }
  8980. }
  8981. // Only A has a priority
  8982. else if (a.sort.priority !== undefined) {
  8983. return -1;
  8984. }
  8985. // Only B has a priority
  8986. else if (b.sort.priority !== undefined) {
  8987. return 1;
  8988. }
  8989. // Neither has a priority
  8990. else {
  8991. return 0;
  8992. }
  8993. };
  8994. /**
  8995. * @ngdoc object
  8996. * @name useExternalSorting
  8997. * @propertyOf ui.grid.class:GridOptions
  8998. * @description Prevents the internal sorting from executing. Events will
  8999. * still be fired when the sort changes, and the sort information on
  9000. * the columns will be updated, allowing an external sorter (for example,
  9001. * server sorting) to be implemented. Defaults to false.
  9002. *
  9003. */
  9004. /**
  9005. * @ngdoc method
  9006. * @methodOf ui.grid.class:rowSorter
  9007. * @name sort
  9008. * @description sorts the grid
  9009. * @param {Object} grid the grid itself
  9010. * @param {array} rows the rows to be sorted
  9011. * @param {array} columns the columns in which to look
  9012. * for sort criteria
  9013. * @returns {array} sorted rows
  9014. */
  9015. rowSorter.sort = function rowSorterSort(grid, rows, columns) {
  9016. // first make sure we are even supposed to do work
  9017. if (!rows) {
  9018. return;
  9019. }
  9020. if (grid.options.useExternalSorting){
  9021. return rows;
  9022. }
  9023. // Build the list of columns to sort by
  9024. var sortCols = [];
  9025. var defaultSortCols = [];
  9026. columns.forEach(function (col) {
  9027. if (col.sort && !col.sort.ignoreSort && col.sort.direction && (col.sort.direction === uiGridConstants.ASC || col.sort.direction === uiGridConstants.DESC)) {
  9028. sortCols.push({
  9029. col: col,
  9030. sort: col.sort
  9031. });
  9032. } else if ( col.defaultSort && col.defaultSort.direction && (col.defaultSort.direction === uiGridConstants.ASC || col.defaultSort.direction === uiGridConstants.DESC) ) {
  9033. defaultSortCols.push({
  9034. col: col,
  9035. sort: col.defaultSort
  9036. });
  9037. }
  9038. });
  9039. // Sort the "sort columns" by their sort priority
  9040. sortCols = sortCols.sort(rowSorter.prioritySort);
  9041. defaultSortCols = defaultSortCols.sort(rowSorter.prioritySort);
  9042. sortCols = sortCols.concat(defaultSortCols);
  9043. // Now rows to sort by, maintain original order
  9044. if (sortCols.length === 0) {
  9045. return rows;
  9046. }
  9047. // Re-usable variables
  9048. var col, direction;
  9049. // put a custom index field on each row, used to make a stable sort out of unstable sorts (e.g. Chrome)
  9050. var setIndex = function( row, idx ){
  9051. row.entity.$$uiGridIndex = idx;
  9052. };
  9053. rows.forEach(setIndex);
  9054. // IE9-11 HACK.... the 'rows' variable would be empty where we call rowSorter.getSortFn(...) below. We have to use a separate reference
  9055. // var d = data.slice(0);
  9056. var r = rows.slice(0);
  9057. // Now actually sort the data
  9058. var rowSortFn = function (rowA, rowB) {
  9059. var tem = 0,
  9060. idx = 0,
  9061. sortFn;
  9062. while (tem === 0 && idx < sortCols.length) {
  9063. // grab the metadata for the rest of the logic
  9064. col = sortCols[idx].col;
  9065. direction = sortCols[idx].sort.direction;
  9066. sortFn = rowSorter.getSortFn(grid, col, r);
  9067. var propA, propB;
  9068. if ( col.sortCellFiltered ){
  9069. propA = grid.getCellDisplayValue(rowA, col);
  9070. propB = grid.getCellDisplayValue(rowB, col);
  9071. } else {
  9072. propA = grid.getCellValue(rowA, col);
  9073. propB = grid.getCellValue(rowB, col);
  9074. }
  9075. tem = sortFn(propA, propB, rowA, rowB, direction, col);
  9076. idx++;
  9077. }
  9078. // Chrome doesn't implement a stable sort function. If our sort returns 0
  9079. // (i.e. the items are equal), and we're at the last sort column in the list,
  9080. // then return the previous order using our custom
  9081. // index variable
  9082. if (tem === 0 ) {
  9083. return rowA.entity.$$uiGridIndex - rowB.entity.$$uiGridIndex;
  9084. }
  9085. // Made it this far, we don't have to worry about null & undefined
  9086. if (direction === uiGridConstants.ASC) {
  9087. return tem;
  9088. } else {
  9089. return 0 - tem;
  9090. }
  9091. };
  9092. var newRows = rows.sort(rowSortFn);
  9093. // remove the custom index field on each row, used to make a stable sort out of unstable sorts (e.g. Chrome)
  9094. var clearIndex = function( row, idx ){
  9095. delete row.entity.$$uiGridIndex;
  9096. };
  9097. rows.forEach(clearIndex);
  9098. return newRows;
  9099. };
  9100. return rowSorter;
  9101. }]);
  9102. })();
  9103. (function() {
  9104. var module = angular.module('ui.grid');
  9105. var bindPolyfill;
  9106. if (typeof Function.prototype.bind !== "function") {
  9107. bindPolyfill = function() {
  9108. var slice = Array.prototype.slice;
  9109. return function(context) {
  9110. var fn = this,
  9111. args = slice.call(arguments, 1);
  9112. if (args.length) {
  9113. return function() {
  9114. return arguments.length ? fn.apply(context, args.concat(slice.call(arguments))) : fn.apply(context, args);
  9115. };
  9116. }
  9117. return function() {
  9118. return arguments.length ? fn.apply(context, arguments) : fn.call(context);
  9119. };
  9120. };
  9121. };
  9122. }
  9123. function getStyles (elem) {
  9124. var e = elem;
  9125. if (typeof(e.length) !== 'undefined' && e.length) {
  9126. e = elem[0];
  9127. }
  9128. return e.ownerDocument.defaultView.getComputedStyle(e, null);
  9129. }
  9130. var rnumnonpx = new RegExp( "^(" + (/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/).source + ")(?!px)[a-z%]+$", "i" ),
  9131. // swappable if display is none or starts with table except "table", "table-cell", or "table-caption"
  9132. // see here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
  9133. rdisplayswap = /^(block|none|table(?!-c[ea]).+)/,
  9134. cssShow = { position: "absolute", visibility: "hidden", display: "block" };
  9135. function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) {
  9136. var i = extra === ( isBorderBox ? 'border' : 'content' ) ?
  9137. // If we already have the right measurement, avoid augmentation
  9138. 4 :
  9139. // Otherwise initialize for horizontal or vertical properties
  9140. name === 'width' ? 1 : 0,
  9141. val = 0;
  9142. var sides = ['Top', 'Right', 'Bottom', 'Left'];
  9143. for ( ; i < 4; i += 2 ) {
  9144. var side = sides[i];
  9145. // dump('side', side);
  9146. // both box models exclude margin, so add it if we want it
  9147. if ( extra === 'margin' ) {
  9148. var marg = parseFloat(styles[extra + side]);
  9149. if (!isNaN(marg)) {
  9150. val += marg;
  9151. }
  9152. }
  9153. // dump('val1', val);
  9154. if ( isBorderBox ) {
  9155. // border-box includes padding, so remove it if we want content
  9156. if ( extra === 'content' ) {
  9157. var padd = parseFloat(styles['padding' + side]);
  9158. if (!isNaN(padd)) {
  9159. val -= padd;
  9160. // dump('val2', val);
  9161. }
  9162. }
  9163. // at this point, extra isn't border nor margin, so remove border
  9164. if ( extra !== 'margin' ) {
  9165. var bordermarg = parseFloat(styles['border' + side + 'Width']);
  9166. if (!isNaN(bordermarg)) {
  9167. val -= bordermarg;
  9168. // dump('val3', val);
  9169. }
  9170. }
  9171. }
  9172. else {
  9173. // at this point, extra isn't content, so add padding
  9174. var nocontentPad = parseFloat(styles['padding' + side]);
  9175. if (!isNaN(nocontentPad)) {
  9176. val += nocontentPad;
  9177. // dump('val4', val);
  9178. }
  9179. // at this point, extra isn't content nor padding, so add border
  9180. if ( extra !== 'padding') {
  9181. var nocontentnopad = parseFloat(styles['border' + side + 'Width']);
  9182. if (!isNaN(nocontentnopad)) {
  9183. val += nocontentnopad;
  9184. // dump('val5', val);
  9185. }
  9186. }
  9187. }
  9188. }
  9189. // dump('augVal', val);
  9190. return val;
  9191. }
  9192. function getWidthOrHeight( elem, name, extra ) {
  9193. // Start with offset property, which is equivalent to the border-box value
  9194. var valueIsBorderBox = true,
  9195. val, // = name === 'width' ? elem.offsetWidth : elem.offsetHeight,
  9196. styles = getStyles(elem),
  9197. isBorderBox = styles['boxSizing'] === 'border-box';
  9198. // some non-html elements return undefined for offsetWidth, so check for null/undefined
  9199. // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
  9200. // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
  9201. if ( val <= 0 || val == null ) {
  9202. // Fall back to computed then uncomputed css if necessary
  9203. val = styles[name];
  9204. if ( val < 0 || val == null ) {
  9205. val = elem.style[ name ];
  9206. }
  9207. // Computed unit is not pixels. Stop here and return.
  9208. if ( rnumnonpx.test(val) ) {
  9209. return val;
  9210. }
  9211. // we need the check for style in case a browser which returns unreliable values
  9212. // for getComputedStyle silently falls back to the reliable elem.style
  9213. valueIsBorderBox = isBorderBox &&
  9214. ( true || val === elem.style[ name ] ); // use 'true' instead of 'support.boxSizingReliable()'
  9215. // Normalize "", auto, and prepare for extra
  9216. val = parseFloat( val ) || 0;
  9217. }
  9218. // use the active box-sizing model to add/subtract irrelevant styles
  9219. var ret = ( val +
  9220. augmentWidthOrHeight(
  9221. elem,
  9222. name,
  9223. extra || ( isBorderBox ? "border" : "content" ),
  9224. valueIsBorderBox,
  9225. styles
  9226. )
  9227. );
  9228. // dump('ret', ret, val);
  9229. return ret;
  9230. }
  9231. function getLineHeight(elm) {
  9232. elm = angular.element(elm)[0];
  9233. var parent = elm.parentElement;
  9234. if (!parent) {
  9235. parent = document.getElementsByTagName('body')[0];
  9236. }
  9237. return parseInt( getStyles(parent).fontSize ) || parseInt( getStyles(elm).fontSize ) || 16;
  9238. }
  9239. var uid = ['0', '0', '0', '0'];
  9240. var uidPrefix = 'uiGrid-';
  9241. /**
  9242. * @ngdoc service
  9243. * @name ui.grid.service:GridUtil
  9244. *
  9245. * @description Grid utility functions
  9246. */
  9247. module.service('gridUtil', ['$log', '$window', '$document', '$http', '$templateCache', '$timeout', '$interval', '$injector', '$q', '$interpolate', 'uiGridConstants',
  9248. function ($log, $window, $document, $http, $templateCache, $timeout, $interval, $injector, $q, $interpolate, uiGridConstants) {
  9249. var s = {
  9250. augmentWidthOrHeight: augmentWidthOrHeight,
  9251. getStyles: getStyles,
  9252. /**
  9253. * @ngdoc method
  9254. * @name createBoundedWrapper
  9255. * @methodOf ui.grid.service:GridUtil
  9256. *
  9257. * @param {object} Object to bind 'this' to
  9258. * @param {method} Method to bind
  9259. * @returns {Function} The wrapper that performs the binding
  9260. *
  9261. * @description
  9262. * Binds given method to given object.
  9263. *
  9264. * By means of a wrapper, ensures that ``method`` is always bound to
  9265. * ``object`` regardless of its calling environment.
  9266. * Iow, inside ``method``, ``this`` always points to ``object``.
  9267. *
  9268. * See http://alistapart.com/article/getoutbindingsituations
  9269. *
  9270. */
  9271. createBoundedWrapper: function(object, method) {
  9272. return function() {
  9273. return method.apply(object, arguments);
  9274. };
  9275. },
  9276. /**
  9277. * @ngdoc method
  9278. * @name readableColumnName
  9279. * @methodOf ui.grid.service:GridUtil
  9280. *
  9281. * @param {string} columnName Column name as a string
  9282. * @returns {string} Column name appropriately capitalized and split apart
  9283. *
  9284. @example
  9285. <example module="app">
  9286. <file name="app.js">
  9287. var app = angular.module('app', ['ui.grid']);
  9288. app.controller('MainCtrl', ['$scope', 'gridUtil', function ($scope, gridUtil) {
  9289. $scope.name = 'firstName';
  9290. $scope.columnName = function(name) {
  9291. return gridUtil.readableColumnName(name);
  9292. };
  9293. }]);
  9294. </file>
  9295. <file name="index.html">
  9296. <div ng-controller="MainCtrl">
  9297. <strong>Column name:</strong> <input ng-model="name" />
  9298. <br>
  9299. <strong>Output:</strong> <span ng-bind="columnName(name)"></span>
  9300. </div>
  9301. </file>
  9302. </example>
  9303. */
  9304. readableColumnName: function (columnName) {
  9305. // Convert underscores to spaces
  9306. if (typeof(columnName) === 'undefined' || columnName === undefined || columnName === null) { return columnName; }
  9307. if (typeof(columnName) !== 'string') {
  9308. columnName = String(columnName);
  9309. }
  9310. return columnName.replace(/_+/g, ' ')
  9311. // Replace a completely all-capsed word with a first-letter-capitalized version
  9312. .replace(/^[A-Z]+$/, function (match) {
  9313. return angular.lowercase(angular.uppercase(match.charAt(0)) + match.slice(1));
  9314. })
  9315. // Capitalize the first letter of words
  9316. .replace(/([\w\u00C0-\u017F]+)/g, function (match) {
  9317. return angular.uppercase(match.charAt(0)) + match.slice(1);
  9318. })
  9319. // Put a space in between words that have partial capilizations (i.e. 'firstName' becomes 'First Name')
  9320. // .replace(/([A-Z]|[A-Z]\w+)([A-Z])/g, "$1 $2");
  9321. // .replace(/(\w+?|\w)([A-Z])/g, "$1 $2");
  9322. .replace(/(\w+?(?=[A-Z]))/g, '$1 ');
  9323. },
  9324. /**
  9325. * @ngdoc method
  9326. * @name getColumnsFromData
  9327. * @methodOf ui.grid.service:GridUtil
  9328. * @description Return a list of column names, given a data set
  9329. *
  9330. * @param {string} data Data array for grid
  9331. * @returns {Object} Column definitions with field accessor and column name
  9332. *
  9333. * @example
  9334. <pre>
  9335. var data = [
  9336. { firstName: 'Bob', lastName: 'Jones' },
  9337. { firstName: 'Frank', lastName: 'Smith' }
  9338. ];
  9339. var columnDefs = GridUtil.getColumnsFromData(data, excludeProperties);
  9340. columnDefs == [
  9341. {
  9342. field: 'firstName',
  9343. name: 'First Name'
  9344. },
  9345. {
  9346. field: 'lastName',
  9347. name: 'Last Name'
  9348. }
  9349. ];
  9350. </pre>
  9351. */
  9352. getColumnsFromData: function (data, excludeProperties) {
  9353. var columnDefs = [];
  9354. if (!data || typeof(data[0]) === 'undefined' || data[0] === undefined) { return []; }
  9355. if (angular.isUndefined(excludeProperties)) { excludeProperties = []; }
  9356. var item = data[0];
  9357. angular.forEach(item,function (prop, propName) {
  9358. if ( excludeProperties.indexOf(propName) === -1){
  9359. columnDefs.push({
  9360. name: propName
  9361. });
  9362. }
  9363. });
  9364. return columnDefs;
  9365. },
  9366. /**
  9367. * @ngdoc method
  9368. * @name newId
  9369. * @methodOf ui.grid.service:GridUtil
  9370. * @description Return a unique ID string
  9371. *
  9372. * @returns {string} Unique string
  9373. *
  9374. * @example
  9375. <pre>
  9376. var id = GridUtil.newId();
  9377. # 1387305700482;
  9378. </pre>
  9379. */
  9380. newId: (function() {
  9381. var seedId = new Date().getTime();
  9382. return function() {
  9383. return seedId += 1;
  9384. };
  9385. })(),
  9386. /**
  9387. * @ngdoc method
  9388. * @name getTemplate
  9389. * @methodOf ui.grid.service:GridUtil
  9390. * @description Get's template from cache / element / url
  9391. *
  9392. * @param {string|element|promise} Either a string representing the template id, a string representing the template url,
  9393. * an jQuery/Angualr element, or a promise that returns the template contents to use.
  9394. * @returns {object} a promise resolving to template contents
  9395. *
  9396. * @example
  9397. <pre>
  9398. GridUtil.getTemplate(url).then(function (contents) {
  9399. alert(contents);
  9400. })
  9401. </pre>
  9402. */
  9403. getTemplate: function (template) {
  9404. // Try to fetch the template out of the templateCache
  9405. if ($templateCache.get(template)) {
  9406. return s.postProcessTemplate($templateCache.get(template));
  9407. }
  9408. // See if the template is itself a promise
  9409. if (angular.isFunction(template.then)) {
  9410. return template.then(s.postProcessTemplate).catch(angular.noop);
  9411. }
  9412. // If the template is an element, return the element
  9413. try {
  9414. if (angular.element(template).length > 0) {
  9415. return $q.when(template).then(s.postProcessTemplate).catch(angular.noop);
  9416. }
  9417. }
  9418. catch (err){
  9419. //do nothing; not valid html
  9420. }
  9421. s.logDebug('fetching url', template);
  9422. // Default to trying to fetch the template as a url with $http
  9423. return $http({ method: 'GET', url: template})
  9424. .then(
  9425. function (result) {
  9426. var templateHtml = result.data.trim();
  9427. //put in templateCache for next call
  9428. $templateCache.put(template, templateHtml);
  9429. return templateHtml;
  9430. },
  9431. function (err) {
  9432. throw new Error("Could not get template " + template + ": " + err);
  9433. }
  9434. )
  9435. .then(s.postProcessTemplate).catch(angular.noop);
  9436. },
  9437. //
  9438. postProcessTemplate: function (template) {
  9439. var startSym = $interpolate.startSymbol(),
  9440. endSym = $interpolate.endSymbol();
  9441. // If either of the interpolation symbols have been changed, we need to alter this template
  9442. if (startSym !== '{{' || endSym !== '}}') {
  9443. template = template.replace(/\{\{/g, startSym);
  9444. template = template.replace(/\}\}/g, endSym);
  9445. }
  9446. return $q.when(template);
  9447. },
  9448. /**
  9449. * @ngdoc method
  9450. * @name guessType
  9451. * @methodOf ui.grid.service:GridUtil
  9452. * @description guesses the type of an argument
  9453. *
  9454. * @param {string/number/bool/object} item variable to examine
  9455. * @returns {string} one of the following
  9456. * - 'string'
  9457. * - 'boolean'
  9458. * - 'number'
  9459. * - 'date'
  9460. * - 'object'
  9461. */
  9462. guessType : function (item) {
  9463. var itemType = typeof(item);
  9464. // Check for numbers and booleans
  9465. switch (itemType) {
  9466. case "number":
  9467. case "boolean":
  9468. case "string":
  9469. return itemType;
  9470. default:
  9471. if (angular.isDate(item)) {
  9472. return "date";
  9473. }
  9474. return "object";
  9475. }
  9476. },
  9477. /**
  9478. * @ngdoc method
  9479. * @name elementWidth
  9480. * @methodOf ui.grid.service:GridUtil
  9481. *
  9482. * @param {element} element DOM element
  9483. * @param {string} [extra] Optional modifier for calculation. Use 'margin' to account for margins on element
  9484. *
  9485. * @returns {number} Element width in pixels, accounting for any borders, etc.
  9486. */
  9487. elementWidth: function (elem) {
  9488. },
  9489. /**
  9490. * @ngdoc method
  9491. * @name elementHeight
  9492. * @methodOf ui.grid.service:GridUtil
  9493. *
  9494. * @param {element} element DOM element
  9495. * @param {string} [extra] Optional modifier for calculation. Use 'margin' to account for margins on element
  9496. *
  9497. * @returns {number} Element height in pixels, accounting for any borders, etc.
  9498. */
  9499. elementHeight: function (elem) {
  9500. },
  9501. // Thanks to http://stackoverflow.com/a/13382873/888165
  9502. getScrollbarWidth: function() {
  9503. var outer = document.createElement("div");
  9504. outer.style.visibility = "hidden";
  9505. outer.style.width = "100px";
  9506. outer.style.msOverflowStyle = "scrollbar"; // needed for WinJS apps
  9507. document.body.appendChild(outer);
  9508. var widthNoScroll = outer.offsetWidth;
  9509. // force scrollbars
  9510. outer.style.overflow = "scroll";
  9511. // add innerdiv
  9512. var inner = document.createElement("div");
  9513. inner.style.width = "100%";
  9514. outer.appendChild(inner);
  9515. var widthWithScroll = inner.offsetWidth;
  9516. // remove divs
  9517. outer.parentNode.removeChild(outer);
  9518. return widthNoScroll - widthWithScroll;
  9519. },
  9520. swap: function( elem, options, callback, args ) {
  9521. var ret, name,
  9522. old = {};
  9523. // Remember the old values, and insert the new ones
  9524. for ( name in options ) {
  9525. old[ name ] = elem.style[ name ];
  9526. elem.style[ name ] = options[ name ];
  9527. }
  9528. ret = callback.apply( elem, args || [] );
  9529. // Revert the old values
  9530. for ( name in options ) {
  9531. elem.style[ name ] = old[ name ];
  9532. }
  9533. return ret;
  9534. },
  9535. fakeElement: function( elem, options, callback, args ) {
  9536. var ret, name,
  9537. newElement = angular.element(elem).clone()[0];
  9538. for ( name in options ) {
  9539. newElement.style[ name ] = options[ name ];
  9540. }
  9541. angular.element(document.body).append(newElement);
  9542. ret = callback.call( newElement, newElement );
  9543. angular.element(newElement).remove();
  9544. return ret;
  9545. },
  9546. /**
  9547. * @ngdoc method
  9548. * @name normalizeWheelEvent
  9549. * @methodOf ui.grid.service:GridUtil
  9550. *
  9551. * @param {event} event A mouse wheel event
  9552. *
  9553. * @returns {event} A normalized event
  9554. *
  9555. * @description
  9556. * Given an event from this list:
  9557. *
  9558. * `wheel, mousewheel, DomMouseScroll, MozMousePixelScroll`
  9559. *
  9560. * "normalize" it
  9561. * so that it stays consistent no matter what browser it comes from (i.e. scale it correctly and make sure the direction is right.)
  9562. */
  9563. normalizeWheelEvent: function (event) {
  9564. // var toFix = ['wheel', 'mousewheel', 'DOMMouseScroll', 'MozMousePixelScroll'];
  9565. // var toBind = 'onwheel' in document || document.documentMode >= 9 ? ['wheel'] : ['mousewheel', 'DomMouseScroll', 'MozMousePixelScroll'];
  9566. var lowestDelta, lowestDeltaXY;
  9567. var orgEvent = event || window.event,
  9568. args = [].slice.call(arguments, 1),
  9569. delta = 0,
  9570. deltaX = 0,
  9571. deltaY = 0,
  9572. absDelta = 0,
  9573. absDeltaXY = 0,
  9574. fn;
  9575. // event = $.event.fix(orgEvent);
  9576. // event.type = 'mousewheel';
  9577. // NOTE: jQuery masks the event and stores it in the event as originalEvent
  9578. if (orgEvent.originalEvent) {
  9579. orgEvent = orgEvent.originalEvent;
  9580. }
  9581. // Old school scrollwheel delta
  9582. if ( orgEvent.wheelDelta ) { delta = orgEvent.wheelDelta; }
  9583. if ( orgEvent.detail ) { delta = orgEvent.detail * -1; }
  9584. // At a minimum, setup the deltaY to be delta
  9585. deltaY = delta;
  9586. // Firefox < 17 related to DOMMouseScroll event
  9587. if ( orgEvent.axis !== undefined && orgEvent.axis === orgEvent.HORIZONTAL_AXIS ) {
  9588. deltaY = 0;
  9589. deltaX = delta * -1;
  9590. }
  9591. // New school wheel delta (wheel event)
  9592. if ( orgEvent.deltaY ) {
  9593. deltaY = orgEvent.deltaY * -1;
  9594. delta = deltaY;
  9595. }
  9596. if ( orgEvent.deltaX ) {
  9597. deltaX = orgEvent.deltaX;
  9598. delta = deltaX * -1;
  9599. }
  9600. // Webkit
  9601. if ( orgEvent.wheelDeltaY !== undefined ) { deltaY = orgEvent.wheelDeltaY; }
  9602. if ( orgEvent.wheelDeltaX !== undefined ) { deltaX = orgEvent.wheelDeltaX; }
  9603. // Look for lowest delta to normalize the delta values
  9604. absDelta = Math.abs(delta);
  9605. if ( !lowestDelta || absDelta < lowestDelta ) { lowestDelta = absDelta; }
  9606. absDeltaXY = Math.max(Math.abs(deltaY), Math.abs(deltaX));
  9607. if ( !lowestDeltaXY || absDeltaXY < lowestDeltaXY ) { lowestDeltaXY = absDeltaXY; }
  9608. // Get a whole value for the deltas
  9609. fn = delta > 0 ? 'floor' : 'ceil';
  9610. delta = Math[fn](delta / lowestDelta);
  9611. deltaX = Math[fn](deltaX / lowestDeltaXY);
  9612. deltaY = Math[fn](deltaY / lowestDeltaXY);
  9613. return {
  9614. delta: delta,
  9615. deltaX: deltaX,
  9616. deltaY: deltaY
  9617. };
  9618. },
  9619. // Stolen from Modernizr
  9620. // TODO: make this, and everythign that flows from it, robust
  9621. //http://www.stucox.com/blog/you-cant-detect-a-touchscreen/
  9622. isTouchEnabled: function() {
  9623. var bool;
  9624. if (('ontouchstart' in $window) || $window.DocumentTouch && $document instanceof DocumentTouch) {
  9625. bool = true;
  9626. }
  9627. return bool;
  9628. },
  9629. isNullOrUndefined: function(obj) {
  9630. return (obj === undefined || obj === null);
  9631. },
  9632. endsWith: function(str, suffix) {
  9633. if (!str || !suffix || typeof str !== "string") {
  9634. return false;
  9635. }
  9636. return str.indexOf(suffix, str.length - suffix.length) !== -1;
  9637. },
  9638. arrayContainsObjectWithProperty: function(array, propertyName, propertyValue) {
  9639. var found = false;
  9640. angular.forEach(array, function (object) {
  9641. if (object[propertyName] === propertyValue) {
  9642. found = true;
  9643. }
  9644. });
  9645. return found;
  9646. },
  9647. //// Shim requestAnimationFrame
  9648. //requestAnimationFrame: $window.requestAnimationFrame && $window.requestAnimationFrame.bind($window) ||
  9649. // $window.webkitRequestAnimationFrame && $window.webkitRequestAnimationFrame.bind($window) ||
  9650. // function(fn) {
  9651. // return $timeout(fn, 10, false);
  9652. // },
  9653. numericAndNullSort: function (a, b) {
  9654. if (a === null) { return 1; }
  9655. if (b === null) { return -1; }
  9656. if (a === null && b === null) { return 0; }
  9657. return a - b;
  9658. },
  9659. // Disable ngAnimate animations on an element
  9660. disableAnimations: function (element) {
  9661. var $animate;
  9662. try {
  9663. $animate = $injector.get('$animate');
  9664. // See: http://brianhann.com/angular-1-4-breaking-changes-to-be-aware-of/#animate
  9665. if (angular.version.major > 1 || (angular.version.major === 1 && angular.version.minor >= 4)) {
  9666. $animate.enabled(element, false);
  9667. } else {
  9668. $animate.enabled(false, element);
  9669. }
  9670. }
  9671. catch (e) {}
  9672. },
  9673. enableAnimations: function (element) {
  9674. var $animate;
  9675. try {
  9676. $animate = $injector.get('$animate');
  9677. // See: http://brianhann.com/angular-1-4-breaking-changes-to-be-aware-of/#animate
  9678. if (angular.version.major > 1 || (angular.version.major === 1 && angular.version.minor >= 4)) {
  9679. $animate.enabled(element, true);
  9680. } else {
  9681. $animate.enabled(true, element);
  9682. }
  9683. return $animate;
  9684. }
  9685. catch (e) {}
  9686. },
  9687. // Blatantly stolen from Angular as it isn't exposed (yet)
  9688. nextUid: function nextUid() {
  9689. var index = uid.length;
  9690. var digit;
  9691. while (index) {
  9692. index--;
  9693. digit = uid[index].charCodeAt(0);
  9694. if (digit === 57 /*'9'*/) {
  9695. uid[index] = 'A';
  9696. return uidPrefix + uid.join('');
  9697. }
  9698. if (digit === 90 /*'Z'*/) {
  9699. uid[index] = '0';
  9700. } else {
  9701. uid[index] = String.fromCharCode(digit + 1);
  9702. return uidPrefix + uid.join('');
  9703. }
  9704. }
  9705. uid.unshift('0');
  9706. return uidPrefix + uid.join('');
  9707. },
  9708. // Blatantly stolen from Angular as it isn't exposed (yet)
  9709. hashKey: function hashKey(obj) {
  9710. var objType = typeof obj,
  9711. key;
  9712. if (objType === 'object' && obj !== null) {
  9713. if (typeof (key = obj.$$hashKey) === 'function') {
  9714. // must invoke on object to keep the right this
  9715. key = obj.$$hashKey();
  9716. }
  9717. else if (typeof(obj.$$hashKey) !== 'undefined' && obj.$$hashKey) {
  9718. key = obj.$$hashKey;
  9719. }
  9720. else if (key === undefined) {
  9721. key = obj.$$hashKey = s.nextUid();
  9722. }
  9723. }
  9724. else {
  9725. key = obj;
  9726. }
  9727. return objType + ':' + key;
  9728. },
  9729. resetUids: function () {
  9730. uid = ['0', '0', '0'];
  9731. },
  9732. /**
  9733. * @ngdoc method
  9734. * @methodOf ui.grid.service:GridUtil
  9735. * @name logError
  9736. * @description wraps the $log method, allowing us to choose different
  9737. * treatment within ui-grid if we so desired. At present we only log
  9738. * error messages if uiGridConstants.LOG_ERROR_MESSAGES is set to true
  9739. * @param {string} logMessage message to be logged to the console
  9740. *
  9741. */
  9742. logError: function( logMessage ){
  9743. if ( uiGridConstants.LOG_ERROR_MESSAGES ){
  9744. $log.error( logMessage );
  9745. }
  9746. },
  9747. /**
  9748. * @ngdoc method
  9749. * @methodOf ui.grid.service:GridUtil
  9750. * @name logWarn
  9751. * @description wraps the $log method, allowing us to choose different
  9752. * treatment within ui-grid if we so desired. At present we only log
  9753. * warning messages if uiGridConstants.LOG_WARN_MESSAGES is set to true
  9754. * @param {string} logMessage message to be logged to the console
  9755. *
  9756. */
  9757. logWarn: function( logMessage ){
  9758. if ( uiGridConstants.LOG_WARN_MESSAGES ){
  9759. $log.warn( logMessage );
  9760. }
  9761. },
  9762. /**
  9763. * @ngdoc method
  9764. * @methodOf ui.grid.service:GridUtil
  9765. * @name logDebug
  9766. * @description wraps the $log method, allowing us to choose different
  9767. * treatment within ui-grid if we so desired. At present we only log
  9768. * debug messages if uiGridConstants.LOG_DEBUG_MESSAGES is set to true
  9769. *
  9770. */
  9771. logDebug: function() {
  9772. if ( uiGridConstants.LOG_DEBUG_MESSAGES ){
  9773. $log.debug.apply($log, arguments);
  9774. }
  9775. }
  9776. };
  9777. /**
  9778. * @ngdoc object
  9779. * @name focus
  9780. * @propertyOf ui.grid.service:GridUtil
  9781. * @description Provies a set of methods to set the document focus inside the grid.
  9782. * See {@link ui.grid.service:GridUtil.focus} for more information.
  9783. */
  9784. /**
  9785. * @ngdoc object
  9786. * @name ui.grid.service:GridUtil.focus
  9787. * @description Provies a set of methods to set the document focus inside the grid.
  9788. * Timeouts are utilized to ensure that the focus is invoked after any other event has been triggered.
  9789. * e.g. click events that need to run before the focus or
  9790. * inputs elements that are in a disabled state but are enabled when those events
  9791. * are triggered.
  9792. */
  9793. s.focus = {
  9794. queue: [],
  9795. //http://stackoverflow.com/questions/25596399/set-element-focus-in-angular-way
  9796. /**
  9797. * @ngdoc method
  9798. * @methodOf ui.grid.service:GridUtil.focus
  9799. * @name byId
  9800. * @description Sets the focus of the document to the given id value.
  9801. * If provided with the grid object it will automatically append the grid id.
  9802. * This is done to encourage unique dom id's as it allows for multiple grids on a
  9803. * page.
  9804. * @param {String} id the id of the dom element to set the focus on
  9805. * @param {Object=} Grid the grid object for this grid instance. See: {@link ui.grid.class:Grid}
  9806. * @param {Number} Grid.id the unique id for this grid. Already set on an initialized grid object.
  9807. * @returns {Promise} The `$timeout` promise that will be resolved once focus is set. If another focus is requested before this request is evaluated.
  9808. * then the promise will fail with the `'canceled'` reason.
  9809. */
  9810. byId: function (id, Grid) {
  9811. this._purgeQueue();
  9812. var promise = $timeout(function() {
  9813. var elementID = (Grid && Grid.id ? Grid.id + '-' : '') + id;
  9814. var element = $window.document.getElementById(elementID);
  9815. if (element) {
  9816. element.focus();
  9817. } else {
  9818. s.logWarn('[focus.byId] Element id ' + elementID + ' was not found.');
  9819. }
  9820. }, 0, false);
  9821. this.queue.push(promise);
  9822. return promise;
  9823. },
  9824. /**
  9825. * @ngdoc method
  9826. * @methodOf ui.grid.service:GridUtil.focus
  9827. * @name byElement
  9828. * @description Sets the focus of the document to the given dom element.
  9829. * @param {(element|angular.element)} element the DOM element to set the focus on
  9830. * @returns {Promise} The `$timeout` promise that will be resolved once focus is set. If another focus is requested before this request is evaluated.
  9831. * then the promise will fail with the `'canceled'` reason.
  9832. */
  9833. byElement: function(element){
  9834. if (!angular.isElement(element)){
  9835. s.logWarn("Trying to focus on an element that isn\'t an element.");
  9836. return $q.reject('not-element');
  9837. }
  9838. element = angular.element(element);
  9839. this._purgeQueue();
  9840. var promise = $timeout(function(){
  9841. if (element){
  9842. element[0].focus();
  9843. }
  9844. }, 0, false);
  9845. this.queue.push(promise);
  9846. return promise;
  9847. },
  9848. /**
  9849. * @ngdoc method
  9850. * @methodOf ui.grid.service:GridUtil.focus
  9851. * @name bySelector
  9852. * @description Sets the focus of the document to the given dom element.
  9853. * @param {(element|angular.element)} parentElement the parent/ancestor of the dom element that you are selecting using the query selector
  9854. * @param {String} querySelector finds the dom element using the {@link http://www.w3schools.com/jsref/met_document_queryselector.asp querySelector}
  9855. * @param {boolean} [aSync=false] If true then the selector will be querried inside of a timeout. Otherwise the selector will be querried imidately
  9856. * then the focus will be called.
  9857. * @returns {Promise} The `$timeout` promise that will be resolved once focus is set. If another focus is requested before this request is evaluated.
  9858. * then the promise will fail with the `'canceled'` reason.
  9859. */
  9860. bySelector: function(parentElement, querySelector, aSync){
  9861. var self = this;
  9862. if (!angular.isElement(parentElement)){
  9863. throw new Error("The parent element is not an element.");
  9864. }
  9865. // Ensure that this is an angular element.
  9866. // It is fine if this is already an angular element.
  9867. parentElement = angular.element(parentElement);
  9868. var focusBySelector = function(){
  9869. var element = parentElement[0].querySelector(querySelector);
  9870. return self.byElement(element);
  9871. };
  9872. this._purgeQueue();
  9873. if (aSync){ //Do this asynchronysly
  9874. var promise = $timeout(focusBySelector, 0, false);
  9875. this.queue.push(promise);
  9876. return promise;
  9877. } else {
  9878. return focusBySelector();
  9879. }
  9880. },
  9881. _purgeQueue: function(){
  9882. this.queue.forEach(function(element){
  9883. $timeout.cancel(element);
  9884. });
  9885. this.queue = [];
  9886. }
  9887. };
  9888. ['width', 'height'].forEach(function (name) {
  9889. var capsName = angular.uppercase(name.charAt(0)) + name.substr(1);
  9890. s['element' + capsName] = function (elem, extra) {
  9891. var e = elem;
  9892. if (e && typeof(e.length) !== 'undefined' && e.length) {
  9893. e = elem[0];
  9894. }
  9895. if (e && e !== null) {
  9896. var styles = getStyles(e);
  9897. return e.offsetWidth === 0 && rdisplayswap.test(styles.display) ?
  9898. s.swap(e, cssShow, function() {
  9899. return getWidthOrHeight(e, name, extra );
  9900. }) :
  9901. getWidthOrHeight( e, name, extra );
  9902. }
  9903. else {
  9904. return null;
  9905. }
  9906. };
  9907. s['outerElement' + capsName] = function (elem, margin) {
  9908. return elem ? s['element' + capsName].call(this, elem, margin ? 'margin' : 'border') : null;
  9909. };
  9910. });
  9911. // http://stackoverflow.com/a/24107550/888165
  9912. s.closestElm = function closestElm(el, selector) {
  9913. if (typeof(el.length) !== 'undefined' && el.length) {
  9914. el = el[0];
  9915. }
  9916. var matchesFn;
  9917. // find vendor prefix
  9918. ['matches','webkitMatchesSelector','mozMatchesSelector','msMatchesSelector','oMatchesSelector'].some(function(fn) {
  9919. if (typeof document.body[fn] === 'function') {
  9920. matchesFn = fn;
  9921. return true;
  9922. }
  9923. return false;
  9924. });
  9925. // traverse parents
  9926. var parent;
  9927. while (el !== null) {
  9928. parent = el.parentElement;
  9929. if (parent !== null && parent[matchesFn](selector)) {
  9930. return parent;
  9931. }
  9932. el = parent;
  9933. }
  9934. return null;
  9935. };
  9936. s.type = function (obj) {
  9937. var text = Function.prototype.toString.call(obj.constructor);
  9938. return text.match(/function (.*?)\(/)[1];
  9939. };
  9940. s.getBorderSize = function getBorderSize(elem, borderType) {
  9941. if (typeof(elem.length) !== 'undefined' && elem.length) {
  9942. elem = elem[0];
  9943. }
  9944. var styles = getStyles(elem);
  9945. // If a specific border is supplied, like 'top', read the 'borderTop' style property
  9946. if (borderType) {
  9947. borderType = 'border' + borderType.charAt(0).toUpperCase() + borderType.slice(1);
  9948. }
  9949. else {
  9950. borderType = 'border';
  9951. }
  9952. borderType += 'Width';
  9953. var val = parseInt(styles[borderType], 10);
  9954. if (isNaN(val)) {
  9955. return 0;
  9956. }
  9957. else {
  9958. return val;
  9959. }
  9960. };
  9961. // http://stackoverflow.com/a/22948274/888165
  9962. // TODO: Opera? Mobile?
  9963. s.detectBrowser = function detectBrowser() {
  9964. var userAgent = $window.navigator.userAgent;
  9965. var browsers = {chrome: /chrome/i, safari: /safari/i, firefox: /firefox/i, ie: /internet explorer|trident\//i};
  9966. for (var key in browsers) {
  9967. if (browsers[key].test(userAgent)) {
  9968. return key;
  9969. }
  9970. }
  9971. return 'unknown';
  9972. };
  9973. // Borrowed from https://github.com/othree/jquery.rtl-scroll-type
  9974. // Determine the scroll "type" this browser is using for RTL
  9975. s.rtlScrollType = function rtlScrollType() {
  9976. if (rtlScrollType.type) {
  9977. return rtlScrollType.type;
  9978. }
  9979. var definer = angular.element('<div dir="rtl" style="font-size: 14px; width: 1px; height: 1px; position: absolute; top: -1000px; overflow: scroll">A</div>')[0],
  9980. type = 'reverse';
  9981. document.body.appendChild(definer);
  9982. if (definer.scrollLeft > 0) {
  9983. type = 'default';
  9984. }
  9985. else {
  9986. definer.scrollLeft = 1;
  9987. if (definer.scrollLeft === 0) {
  9988. type = 'negative';
  9989. }
  9990. }
  9991. angular.element(definer).remove();
  9992. rtlScrollType.type = type;
  9993. return type;
  9994. };
  9995. /**
  9996. * @ngdoc method
  9997. * @name normalizeScrollLeft
  9998. * @methodOf ui.grid.service:GridUtil
  9999. *
  10000. * @param {element} element The element to get the `scrollLeft` from.
  10001. * @param {grid} grid - grid used to normalize (uses the rtl property)
  10002. *
  10003. * @returns {number} A normalized scrollLeft value for the current browser.
  10004. *
  10005. * @description
  10006. * Browsers currently handle RTL in different ways, resulting in inconsistent scrollLeft values. This method normalizes them
  10007. */
  10008. s.normalizeScrollLeft = function normalizeScrollLeft(element, grid) {
  10009. if (typeof(element.length) !== 'undefined' && element.length) {
  10010. element = element[0];
  10011. }
  10012. var scrollLeft = element.scrollLeft;
  10013. if (grid.isRTL()) {
  10014. switch (s.rtlScrollType()) {
  10015. case 'default':
  10016. return element.scrollWidth - scrollLeft - element.clientWidth;
  10017. case 'negative':
  10018. return Math.abs(scrollLeft);
  10019. case 'reverse':
  10020. return scrollLeft;
  10021. }
  10022. }
  10023. return scrollLeft;
  10024. };
  10025. /**
  10026. * @ngdoc method
  10027. * @name denormalizeScrollLeft
  10028. * @methodOf ui.grid.service:GridUtil
  10029. *
  10030. * @param {element} element The element to normalize the `scrollLeft` value for
  10031. * @param {number} scrollLeft The `scrollLeft` value to denormalize.
  10032. * @param {grid} grid The grid that owns the scroll event.
  10033. *
  10034. * @returns {number} A normalized scrollLeft value for the current browser.
  10035. *
  10036. * @description
  10037. * Browsers currently handle RTL in different ways, resulting in inconsistent scrollLeft values. This method denormalizes a value for the current browser.
  10038. */
  10039. s.denormalizeScrollLeft = function denormalizeScrollLeft(element, scrollLeft, grid) {
  10040. if (typeof(element.length) !== 'undefined' && element.length) {
  10041. element = element[0];
  10042. }
  10043. if (grid.isRTL()) {
  10044. switch (s.rtlScrollType()) {
  10045. case 'default':
  10046. // Get the max scroll for the element
  10047. var maxScrollLeft = element.scrollWidth - element.clientWidth;
  10048. // Subtract the current scroll amount from the max scroll
  10049. return maxScrollLeft - scrollLeft;
  10050. case 'negative':
  10051. return scrollLeft * -1;
  10052. case 'reverse':
  10053. return scrollLeft;
  10054. }
  10055. }
  10056. return scrollLeft;
  10057. };
  10058. /**
  10059. * @ngdoc method
  10060. * @name preEval
  10061. * @methodOf ui.grid.service:GridUtil
  10062. *
  10063. * @param {string} path Path to evaluate
  10064. *
  10065. * @returns {string} A path that is normalized.
  10066. *
  10067. * @description
  10068. * Takes a field path and converts it to bracket notation to allow for special characters in path
  10069. * @example
  10070. * <pre>
  10071. * gridUtil.preEval('property') == 'property'
  10072. * gridUtil.preEval('nested.deep.prop-erty') = "nested['deep']['prop-erty']"
  10073. * </pre>
  10074. */
  10075. s.preEval = function (path) {
  10076. var m = uiGridConstants.BRACKET_REGEXP.exec(path);
  10077. if (m) {
  10078. return (m[1] ? s.preEval(m[1]) : m[1]) + m[2] + (m[3] ? s.preEval(m[3]) : m[3]);
  10079. } else {
  10080. path = path.replace(uiGridConstants.APOS_REGEXP, '\\\'');
  10081. var parts = path.split(uiGridConstants.DOT_REGEXP);
  10082. var preparsed = [parts.shift()]; // first item must be var notation, thus skip
  10083. angular.forEach(parts, function (part) {
  10084. preparsed.push(part.replace(uiGridConstants.FUNC_REGEXP, '\']$1'));
  10085. });
  10086. return preparsed.join('[\'');
  10087. }
  10088. };
  10089. /**
  10090. * @ngdoc method
  10091. * @name debounce
  10092. * @methodOf ui.grid.service:GridUtil
  10093. *
  10094. * @param {function} func function to debounce
  10095. * @param {number} wait milliseconds to delay
  10096. * @param {boolean} immediate execute before delay
  10097. *
  10098. * @returns {function} A function that can be executed as debounced function
  10099. *
  10100. * @description
  10101. * Copied from https://github.com/shahata/angular-debounce
  10102. * Takes a function, decorates it to execute only 1 time after multiple calls, and returns the decorated function
  10103. * @example
  10104. * <pre>
  10105. * var debouncedFunc = gridUtil.debounce(function(){alert('debounced');}, 500);
  10106. * debouncedFunc();
  10107. * debouncedFunc();
  10108. * debouncedFunc();
  10109. * </pre>
  10110. */
  10111. s.debounce = function (func, wait, immediate) {
  10112. var timeout, args, context, result;
  10113. function debounce() {
  10114. /* jshint validthis:true */
  10115. context = this;
  10116. args = arguments;
  10117. var later = function () {
  10118. timeout = null;
  10119. if (!immediate) {
  10120. result = func.apply(context, args);
  10121. }
  10122. };
  10123. var callNow = immediate && !timeout;
  10124. if (timeout) {
  10125. $timeout.cancel(timeout);
  10126. }
  10127. timeout = $timeout(later, wait, false);
  10128. if (callNow) {
  10129. result = func.apply(context, args);
  10130. }
  10131. return result;
  10132. }
  10133. debounce.cancel = function () {
  10134. $timeout.cancel(timeout);
  10135. timeout = null;
  10136. };
  10137. return debounce;
  10138. };
  10139. /**
  10140. * @ngdoc method
  10141. * @name throttle
  10142. * @methodOf ui.grid.service:GridUtil
  10143. *
  10144. * @param {function} func function to throttle
  10145. * @param {number} wait milliseconds to delay after first trigger
  10146. * @param {Object} params to use in throttle.
  10147. *
  10148. * @returns {function} A function that can be executed as throttled function
  10149. *
  10150. * @description
  10151. * Adapted from debounce function (above)
  10152. * Potential keys for Params Object are:
  10153. * trailing (bool) - whether to trigger after throttle time ends if called multiple times
  10154. * Updated to use $interval rather than $timeout, as protractor (e2e tests) is able to work with $interval,
  10155. * but not with $timeout
  10156. *
  10157. * Note that when using throttle, you need to use throttle to create a new function upfront, then use the function
  10158. * return from that call each time you need to call throttle. If you call throttle itself repeatedly, the lastCall
  10159. * variable will get overwritten and the throttling won't work
  10160. *
  10161. * @example
  10162. * <pre>
  10163. * var throttledFunc = gridUtil.throttle(function(){console.log('throttled');}, 500, {trailing: true});
  10164. * throttledFunc(); //=> logs throttled
  10165. * throttledFunc(); //=> queues attempt to log throttled for ~500ms (since trailing param is truthy)
  10166. * throttledFunc(); //=> updates arguments to keep most-recent request, but does not do anything else.
  10167. * </pre>
  10168. */
  10169. s.throttle = function(func, wait, options){
  10170. options = options || {};
  10171. var lastCall = 0, queued = null, context, args;
  10172. function runFunc(endDate){
  10173. lastCall = +new Date();
  10174. func.apply(context, args);
  10175. $interval(function(){queued = null; }, 0, 1, false);
  10176. }
  10177. return function(){
  10178. /* jshint validthis:true */
  10179. context = this;
  10180. args = arguments;
  10181. if (queued === null){
  10182. var sinceLast = +new Date() - lastCall;
  10183. if (sinceLast > wait){
  10184. runFunc();
  10185. }
  10186. else if (options.trailing){
  10187. queued = $interval(runFunc, wait - sinceLast, 1, false);
  10188. }
  10189. }
  10190. };
  10191. };
  10192. s.on = {};
  10193. s.off = {};
  10194. s._events = {};
  10195. s.addOff = function (eventName) {
  10196. s.off[eventName] = function (elm, fn) {
  10197. var idx = s._events[eventName].indexOf(fn);
  10198. if (idx > 0) {
  10199. s._events[eventName].removeAt(idx);
  10200. }
  10201. };
  10202. };
  10203. var mouseWheeltoBind = ( 'onwheel' in document || document.documentMode >= 9 ) ? ['wheel'] : ['mousewheel', 'DomMouseScroll', 'MozMousePixelScroll'],
  10204. nullLowestDeltaTimeout,
  10205. lowestDelta;
  10206. s.on.mousewheel = function (elm, fn) {
  10207. if (!elm || !fn) { return; }
  10208. var $elm = angular.element(elm);
  10209. // Store the line height and page height for this particular element
  10210. $elm.data('mousewheel-line-height', getLineHeight($elm));
  10211. $elm.data('mousewheel-page-height', s.elementHeight($elm));
  10212. if (!$elm.data('mousewheel-callbacks')) { $elm.data('mousewheel-callbacks', {}); }
  10213. var cbs = $elm.data('mousewheel-callbacks');
  10214. cbs[fn] = (Function.prototype.bind || bindPolyfill).call(mousewheelHandler, $elm[0], fn);
  10215. // Bind all the mousew heel events
  10216. for ( var i = mouseWheeltoBind.length; i; ) {
  10217. $elm.on(mouseWheeltoBind[--i], cbs[fn]);
  10218. }
  10219. $elm.on('$destroy', function unbindEvents() {
  10220. for ( var i = mouseWheeltoBind.length; i; ) {
  10221. $elm.off(mouseWheeltoBind[--i], cbs[fn]);
  10222. }
  10223. });
  10224. };
  10225. s.off.mousewheel = function (elm, fn) {
  10226. var $elm = angular.element(elm);
  10227. var cbs = $elm.data('mousewheel-callbacks');
  10228. var handler = cbs[fn];
  10229. if (handler) {
  10230. for ( var i = mouseWheeltoBind.length; i; ) {
  10231. $elm.off(mouseWheeltoBind[--i], handler);
  10232. }
  10233. }
  10234. delete cbs[fn];
  10235. if (Object.keys(cbs).length === 0) {
  10236. $elm.removeData('mousewheel-line-height');
  10237. $elm.removeData('mousewheel-page-height');
  10238. $elm.removeData('mousewheel-callbacks');
  10239. }
  10240. };
  10241. function mousewheelHandler(fn, event) {
  10242. var $elm = angular.element(this);
  10243. var delta = 0,
  10244. deltaX = 0,
  10245. deltaY = 0,
  10246. absDelta = 0,
  10247. offsetX = 0,
  10248. offsetY = 0;
  10249. // jQuery masks events
  10250. if (event.originalEvent) { event = event.originalEvent; }
  10251. if ( 'detail' in event ) { deltaY = event.detail * -1; }
  10252. if ( 'wheelDelta' in event ) { deltaY = event.wheelDelta; }
  10253. if ( 'wheelDeltaY' in event ) { deltaY = event.wheelDeltaY; }
  10254. if ( 'wheelDeltaX' in event ) { deltaX = event.wheelDeltaX * -1; }
  10255. // Firefox < 17 horizontal scrolling related to DOMMouseScroll event
  10256. if ( 'axis' in event && event.axis === event.HORIZONTAL_AXIS ) {
  10257. deltaX = deltaY * -1;
  10258. deltaY = 0;
  10259. }
  10260. // Set delta to be deltaY or deltaX if deltaY is 0 for backwards compatabilitiy
  10261. delta = deltaY === 0 ? deltaX : deltaY;
  10262. // New school wheel delta (wheel event)
  10263. if ( 'deltaY' in event ) {
  10264. deltaY = event.deltaY * -1;
  10265. delta = deltaY;
  10266. }
  10267. if ( 'deltaX' in event ) {
  10268. deltaX = event.deltaX;
  10269. if ( deltaY === 0 ) { delta = deltaX * -1; }
  10270. }
  10271. // No change actually happened, no reason to go any further
  10272. if ( deltaY === 0 && deltaX === 0 ) { return; }
  10273. // Need to convert lines and pages to pixels if we aren't already in pixels
  10274. // There are three delta modes:
  10275. // * deltaMode 0 is by pixels, nothing to do
  10276. // * deltaMode 1 is by lines
  10277. // * deltaMode 2 is by pages
  10278. if ( event.deltaMode === 1 ) {
  10279. var lineHeight = $elm.data('mousewheel-line-height');
  10280. delta *= lineHeight;
  10281. deltaY *= lineHeight;
  10282. deltaX *= lineHeight;
  10283. }
  10284. else if ( event.deltaMode === 2 ) {
  10285. var pageHeight = $elm.data('mousewheel-page-height');
  10286. delta *= pageHeight;
  10287. deltaY *= pageHeight;
  10288. deltaX *= pageHeight;
  10289. }
  10290. // Store lowest absolute delta to normalize the delta values
  10291. absDelta = Math.max( Math.abs(deltaY), Math.abs(deltaX) );
  10292. if ( !lowestDelta || absDelta < lowestDelta ) {
  10293. lowestDelta = absDelta;
  10294. // Adjust older deltas if necessary
  10295. if ( shouldAdjustOldDeltas(event, absDelta) ) {
  10296. lowestDelta /= 40;
  10297. }
  10298. }
  10299. // Get a whole, normalized value for the deltas
  10300. delta = Math[ delta >= 1 ? 'floor' : 'ceil' ](delta / lowestDelta);
  10301. deltaX = Math[ deltaX >= 1 ? 'floor' : 'ceil' ](deltaX / lowestDelta);
  10302. deltaY = Math[ deltaY >= 1 ? 'floor' : 'ceil' ](deltaY / lowestDelta);
  10303. // Normalise offsetX and offsetY properties
  10304. // if ($elm[0].getBoundingClientRect ) {
  10305. // var boundingRect = $(elm)[0].getBoundingClientRect();
  10306. // offsetX = event.clientX - boundingRect.left;
  10307. // offsetY = event.clientY - boundingRect.top;
  10308. // }
  10309. // event.deltaX = deltaX;
  10310. // event.deltaY = deltaY;
  10311. // event.deltaFactor = lowestDelta;
  10312. var newEvent = {
  10313. originalEvent: event,
  10314. deltaX: deltaX,
  10315. deltaY: deltaY,
  10316. deltaFactor: lowestDelta,
  10317. preventDefault: function () { event.preventDefault(); },
  10318. stopPropagation: function () { event.stopPropagation(); }
  10319. };
  10320. // Clearout lowestDelta after sometime to better
  10321. // handle multiple device types that give
  10322. // a different lowestDelta
  10323. // Ex: trackpad = 3 and mouse wheel = 120
  10324. if (nullLowestDeltaTimeout) { clearTimeout(nullLowestDeltaTimeout); }
  10325. nullLowestDeltaTimeout = setTimeout(nullLowestDelta, 200);
  10326. fn.call($elm[0], newEvent);
  10327. }
  10328. function nullLowestDelta() {
  10329. lowestDelta = null;
  10330. }
  10331. function shouldAdjustOldDeltas(orgEvent, absDelta) {
  10332. // If this is an older event and the delta is divisable by 120,
  10333. // then we are assuming that the browser is treating this as an
  10334. // older mouse wheel event and that we should divide the deltas
  10335. // by 40 to try and get a more usable deltaFactor.
  10336. // Side note, this actually impacts the reported scroll distance
  10337. // in older browsers and can cause scrolling to be slower than native.
  10338. // Turn this off by setting $.event.special.mousewheel.settings.adjustOldDeltas to false.
  10339. return orgEvent.type === 'mousewheel' && absDelta % 120 === 0;
  10340. }
  10341. return s;
  10342. }]);
  10343. // Add 'px' to the end of a number string if it doesn't have it already
  10344. module.filter('px', function() {
  10345. return function(str) {
  10346. if (str.match(/^[\d\.]+$/)) {
  10347. return str + 'px';
  10348. }
  10349. else {
  10350. return str;
  10351. }
  10352. };
  10353. });
  10354. })();
  10355. (function () {
  10356. angular.module('ui.grid').config(['$provide', function($provide) {
  10357. $provide.decorator('i18nService', ['$delegate', function($delegate) {
  10358. $delegate.add('ar', {
  10359. "headerCell": {
  10360. "aria": {
  10361. "defaultFilterLabel": "التصفيه بالعمود",
  10362. "removeFilter": "محو التصفيه",
  10363. "columnMenuButtonLabel": "قاءمه الاعمده"
  10364. },
  10365. "priority": "أولويه : ",
  10366. "filterLabel": "تصفيه بالاعمده :"
  10367. },
  10368. "aggregate": {
  10369. "label": "العناصر"
  10370. },
  10371. "groupPanel": {
  10372. "description": "اسحب رأس العمود هنا وأسقطه لإنشاء مجموعه"
  10373. },
  10374. "search": {
  10375. "placeholder": "بحث ...",
  10376. "showingItems": "العناصر الظاهره :",
  10377. "selectedItems": "العناصر المحدده :",
  10378. "totalItems": "عدد العناصر :",
  10379. "size": "حجم الصفحه :",
  10380. "first": "اول صفحه",
  10381. "next": "الصفحه التاليه",
  10382. "previous": "الصفحه الصابقه",
  10383. "last": "الصفحه الاخيره"
  10384. },
  10385. "menu": {
  10386. "text": "اختيار العمود :"
  10387. },
  10388. "sort": {
  10389. "ascending": "ترتيب تصاعدى",
  10390. "descending": "ترتيب تنازلى",
  10391. "none": "عدم التحديد",
  10392. "remove": "حذف الترتيب"
  10393. },
  10394. "column": {
  10395. "hide": "إخفاء عمود"
  10396. },
  10397. "aggregation": {
  10398. "count": "عدد الصفوف: ",
  10399. "sum": "جمع: ",
  10400. "avg": "المتوسط الحسابى: ",
  10401. "min": "الادنى: ",
  10402. "max": "الاقصى: "
  10403. },
  10404. "pinning": {
  10405. "pinLeft": "تثبيت لليسار",
  10406. "pinRight": "تثبيت لليمين",
  10407. "unpin": "فك التثبيت"
  10408. },
  10409. "columnMenu": {
  10410. "close": "غلق"
  10411. },
  10412. "gridMenu": {
  10413. "aria": {
  10414. "buttonLabel": "قائمه الجدول"
  10415. },
  10416. "columns": "الاعمده:",
  10417. "importerTitle": "إدخال ملف",
  10418. "exporterAllAsCsv": "إخراج كل البيانات ك(csv)",
  10419. "exporterVisibleAsCsv": "إخراج كل البيانات الواضحه ك (csv)",
  10420. "exporterSelectedAsCsv": "إخراج كل البيانات المحدده ك (csv)",
  10421. "exporterAllAsPdf": "إخراج كل البيانات ك(pdf)",
  10422. "exporterVisibleAsPdf": "إخراج كل البيانات الواضحه ك (pdf)",
  10423. "exporterSelectedAsPdf": "إخراج كل البيانات المحدده ك (pdf)",
  10424. "clearAllFilters": "محو كل الترشيح"
  10425. },
  10426. "importer": {
  10427. "noHeaders": "اسماء هؤلاء الاعمده غير واضحه، هل يوجد رأس للملف؟",
  10428. "noObjects": "Objects were not able to be derived, was there data in the file other than headers?",
  10429. "invalidCsv": "الملف غير قادر على الاتمام ، هل ال (CSV) صحيح؟",
  10430. "invalidJson": "الملف غير قادر على الاتمام ، هل ال (JSON) صحيح؟",
  10431. "jsonNotArray": "Imported json file must contain an array, aborting."
  10432. },
  10433. "pagination": {
  10434. "aria": {
  10435. "pageToFirst": "الصفحه الاولى",
  10436. "pageBack": "الصفه السابقه",
  10437. "pageSelected": "الصفحه المحدده",
  10438. "pageForward": "الصفحه التاليه",
  10439. "pageToLast": "الصفحه الاخيره"
  10440. },
  10441. "sizes": "عدد العناصر فى الصفحه",
  10442. "totalItems": "عناصر",
  10443. "through": "إلى",
  10444. "of": "من"
  10445. },
  10446. "grouping": {
  10447. "group": "جمع",
  10448. "ungroup": "فك الجمع",
  10449. "aggregate_count": "جمله : العدد",
  10450. "aggregate_sum": "جمله : الحاصل",
  10451. "aggregate_max": "جمله : الاقصى",
  10452. "aggregate_min": "جمله : الاقل",
  10453. "aggregate_avg": "جمله :المتوسط ",
  10454. "aggregate_remove": "جمله : حذف"
  10455. },
  10456. "validate": {
  10457. "error": "خطأ :",
  10458. "minLength": "القيمه لابد ان لا تقل عن THRESHOLD حرف.",
  10459. "maxLength": "القيمه لابد ان لا تزيد عن THRESHOLD حرف.",
  10460. "required": "مطلوب قيمه"
  10461. }
  10462. });
  10463. return $delegate;
  10464. }]);
  10465. }]);
  10466. })();
  10467. (function () {
  10468. angular.module('ui.grid').config(['$provide', function($provide) {
  10469. $provide.decorator('i18nService', ['$delegate', function($delegate) {
  10470. $delegate.add('bg', {
  10471. headerCell: {
  10472. aria: {
  10473. defaultFilterLabel: 'Филттър за колоната',
  10474. removeFilter: 'Премахни филтър',
  10475. columnMenuButtonLabel: 'Меню на колоната'
  10476. },
  10477. priority: 'Приоритет:',
  10478. filterLabel: "Филтър за колоната: "
  10479. },
  10480. aggregate: {
  10481. label: 'обекти'
  10482. },
  10483. search: {
  10484. placeholder: 'Търсене...',
  10485. showingItems: 'Показани обекти:',
  10486. selectedItems: 'избрани обекти:',
  10487. totalItems: 'Общо:',
  10488. size: 'Размер на страницата:',
  10489. first: 'Първа страница',
  10490. next: 'Следваща страница',
  10491. previous: 'Предишна страница',
  10492. last: 'Последна страница'
  10493. },
  10494. menu: {
  10495. text: 'Избери колони:'
  10496. },
  10497. sort: {
  10498. ascending: 'Сортиране по възходящ ред',
  10499. descending: 'Сортиране по низходящ ред',
  10500. none: 'Без сортиране',
  10501. remove: 'Премахни сортирането'
  10502. },
  10503. column: {
  10504. hide: 'Скрий колоната'
  10505. },
  10506. aggregation: {
  10507. count: 'Общо редове: ',
  10508. sum: 'общо: ',
  10509. avg: 'средно: ',
  10510. min: 'най-малко: ',
  10511. max: 'най-много: '
  10512. },
  10513. pinning: {
  10514. pinLeft: 'Прикрепи вляво',
  10515. pinRight: 'Прикрепи вдясно',
  10516. unpin: 'Премахване'
  10517. },
  10518. columnMenu: {
  10519. close: 'Затвори'
  10520. },
  10521. gridMenu: {
  10522. aria: {
  10523. buttonLabel: 'Меню на таблицата'
  10524. },
  10525. columns: 'Колони:',
  10526. importerTitle: 'Импортиране на файл',
  10527. exporterAllAsCsv: 'Експортиране на данните като csv',
  10528. exporterVisibleAsCsv: 'Експортиране на видимите данни като csv',
  10529. exporterSelectedAsCsv: 'Експортиране на избраните данни като csv',
  10530. exporterAllAsPdf: 'Експортиране на данните като pdf',
  10531. exporterVisibleAsPdf: 'Експортиране на видимите данни като pdf',
  10532. exporterSelectedAsPdf: 'Експортиране на избраните данни като pdf',
  10533. clearAllFilters: 'Премахни всички филтри'
  10534. },
  10535. importer: {
  10536. noHeaders: 'Имената на колоните не успяха да бъдат извлечени, файлът има ли хедър?',
  10537. noObjects: 'Обектите не успяха да бъдат извлечени, файлът съдържа ли данни, различни от хедър?',
  10538. invalidCsv: 'Файлът не може да бъде обработеб, уверете се, че е валиден CSV файл',
  10539. invalidJson: 'Файлът не може да бъде обработеб, уверете се, че е валиден JSON файл',
  10540. jsonNotArray: 'Импортираният JSON файл трябва да съдържа масив, прекратяване.'
  10541. },
  10542. pagination: {
  10543. aria: {
  10544. pageToFirst: 'Към първа страница',
  10545. pageBack: 'Страница назад',
  10546. pageSelected: 'Избрана страница',
  10547. pageForward: 'Страница напред',
  10548. pageToLast: 'Към последна страница'
  10549. },
  10550. sizes: 'обекта на страница',
  10551. totalItems: 'обекта',
  10552. through: 'до',
  10553. of: 'от'
  10554. },
  10555. grouping: {
  10556. group: 'Групиране',
  10557. ungroup: 'Премахване на групирането',
  10558. aggregate_count: 'Сбор: Брой',
  10559. aggregate_sum: 'Сбор: Сума',
  10560. aggregate_max: 'Сбор: Максимум',
  10561. aggregate_min: 'Сбор: Минимум',
  10562. aggregate_avg: 'Сбор: Средно',
  10563. aggregate_remove: 'Сбор: Премахване'
  10564. },
  10565. validate: {
  10566. error: 'Грешка:',
  10567. minLength: 'Стойността трябва да съдържа поне THRESHOLD символа.',
  10568. maxLength: 'Стойността не трябва да съдържа повече от THRESHOLD символа.',
  10569. required: 'Необходима е стойност.'
  10570. }
  10571. });
  10572. return $delegate;
  10573. }]);
  10574. }]);
  10575. })();
  10576. (function () {
  10577. angular.module('ui.grid').config(['$provide', function($provide) {
  10578. $provide.decorator('i18nService', ['$delegate', function($delegate) {
  10579. var lang = {
  10580. aggregate: {
  10581. label: 'položky'
  10582. },
  10583. groupPanel: {
  10584. description: 'Přesuňte záhlaví zde pro vytvoření skupiny dle sloupce.'
  10585. },
  10586. search: {
  10587. placeholder: 'Hledat...',
  10588. showingItems: 'Zobrazuji položky:',
  10589. selectedItems: 'Vybrané položky:',
  10590. totalItems: 'Celkem položek:',
  10591. size: 'Velikost strany:',
  10592. first: 'První strana',
  10593. next: 'Další strana',
  10594. previous: 'Předchozí strana',
  10595. last: 'Poslední strana'
  10596. },
  10597. menu: {
  10598. text: 'Vyberte sloupec:'
  10599. },
  10600. sort: {
  10601. ascending: 'Seřadit od A-Z',
  10602. descending: 'Seřadit od Z-A',
  10603. remove: 'Odebrat seřazení'
  10604. },
  10605. column: {
  10606. hide: 'Schovat sloupec'
  10607. },
  10608. aggregation: {
  10609. count: 'celkem řádků: ',
  10610. sum: 'celkem: ',
  10611. avg: 'avg: ',
  10612. min: 'min.: ',
  10613. max: 'max.: '
  10614. },
  10615. pinning: {
  10616. pinLeft: 'Zamknout vlevo',
  10617. pinRight: 'Zamknout vpravo',
  10618. unpin: 'Odemknout'
  10619. },
  10620. gridMenu: {
  10621. columns: 'Sloupce:',
  10622. importerTitle: 'Importovat soubor',
  10623. exporterAllAsCsv: 'Exportovat všechna data do csv',
  10624. exporterVisibleAsCsv: 'Exportovat viditelná data do csv',
  10625. exporterSelectedAsCsv: 'Exportovat vybraná data do csv',
  10626. exporterAllAsPdf: 'Exportovat všechna data do pdf',
  10627. exporterVisibleAsPdf: 'Exportovat viditelná data do pdf',
  10628. exporterSelectedAsPdf: 'Exportovat vybraná data do pdf',
  10629. exporterAllAsExcel: 'Exportovat všechna data do excel',
  10630. exporterVisibleAsExcel: 'Exportovat viditelná data do excel',
  10631. exporterSelectedAsExcel: 'Exportovat vybraná data do excel',
  10632. clearAllFilters: 'Odstranit všechny filtry'
  10633. },
  10634. importer: {
  10635. noHeaders: 'Názvy sloupců se nepodařilo získat, obsahuje soubor záhlaví?',
  10636. noObjects: 'Data se nepodařilo zpracovat, obsahuje soubor řádky mimo záhlaví?',
  10637. invalidCsv: 'Soubor nelze zpracovat, jedná se o CSV?',
  10638. invalidJson: 'Soubor nelze zpracovat, je to JSON?',
  10639. jsonNotArray: 'Soubor musí obsahovat json. Ukončuji..'
  10640. },
  10641. pagination: {
  10642. sizes: 'položek na stránku',
  10643. totalItems: 'položek'
  10644. },
  10645. grouping: {
  10646. group: 'Seskupit',
  10647. ungroup: 'Odebrat seskupení',
  10648. aggregate_count: 'Agregace: Count',
  10649. aggregate_sum: 'Agregace: Sum',
  10650. aggregate_max: 'Agregace: Max',
  10651. aggregate_min: 'Agregace: Min',
  10652. aggregate_avg: 'Agregace: Avg',
  10653. aggregate_remove: 'Agregace: Odebrat'
  10654. }
  10655. };
  10656. // support varianty of different czech keys.
  10657. $delegate.add('cs', lang);
  10658. $delegate.add('cz', lang);
  10659. $delegate.add('cs-cz', lang);
  10660. $delegate.add('cs-CZ', lang);
  10661. return $delegate;
  10662. }]);
  10663. }]);
  10664. })();
  10665. (function(){
  10666. angular.module('ui.grid').config(['$provide', function($provide) {
  10667. $provide.decorator('i18nService', ['$delegate', function($delegate) {
  10668. $delegate.add('da', {
  10669. aggregate:{
  10670. label: 'artikler'
  10671. },
  10672. groupPanel:{
  10673. description: 'Grupér rækker udfra en kolonne ved at trække dens overskift hertil.'
  10674. },
  10675. search:{
  10676. placeholder: 'Søg...',
  10677. showingItems: 'Viste rækker:',
  10678. selectedItems: 'Valgte rækker:',
  10679. totalItems: 'Rækker totalt:',
  10680. size: 'Side størrelse:',
  10681. first: 'Første side',
  10682. next: 'Næste side',
  10683. previous: 'Forrige side',
  10684. last: 'Sidste side'
  10685. },
  10686. menu:{
  10687. text: 'Vælg kolonner:'
  10688. },
  10689. sort: {
  10690. ascending: 'Sorter stigende',
  10691. descending: 'Sorter faldende',
  10692. none: 'Sorter ingen',
  10693. remove: 'Fjern sortering'
  10694. },
  10695. column: {
  10696. hide: 'Skjul kolonne'
  10697. },
  10698. aggregation: {
  10699. count: 'antal rækker: ',
  10700. sum: 'sum: ',
  10701. avg: 'gns: ',
  10702. min: 'min: ',
  10703. max: 'max: '
  10704. },
  10705. gridMenu: {
  10706. columns: 'Kolonner:',
  10707. importerTitle: 'Importer fil',
  10708. exporterAllAsCsv: 'Eksporter alle data som csv',
  10709. exporterVisibleAsCsv: 'Eksporter synlige data som csv',
  10710. exporterSelectedAsCsv: 'Eksporter markerede data som csv',
  10711. exporterAllAsPdf: 'Eksporter alle data som pdf',
  10712. exporterVisibleAsPdf: 'Eksporter synlige data som pdf',
  10713. exporterSelectedAsPdf: 'Eksporter markerede data som pdf',
  10714. exporterAllAsExcel: 'Eksporter alle data som excel',
  10715. exporterVisibleAsExcel: 'Eksporter synlige data som excel',
  10716. exporterSelectedAsExcel: 'Eksporter markerede data som excel',
  10717. clearAllFilters: 'Clear all filters'
  10718. },
  10719. importer: {
  10720. noHeaders: 'Column names were unable to be derived, does the file have a header?',
  10721. noObjects: 'Objects were not able to be derived, was there data in the file other than headers?',
  10722. invalidCsv: 'File was unable to be processed, is it valid CSV?',
  10723. invalidJson: 'File was unable to be processed, is it valid Json?',
  10724. jsonNotArray: 'Imported json file must contain an array, aborting.'
  10725. },
  10726. pagination: {
  10727. aria: {
  10728. pageToFirst: 'Gå til første',
  10729. pageBack: 'Gå tilbage',
  10730. pageSelected: 'Valgte side',
  10731. pageForward: 'Gå frem',
  10732. pageToLast: 'Gå til sidste'
  10733. },
  10734. sizes: 'genstande per side',
  10735. totalItems: 'genstande',
  10736. through: 'gennem',
  10737. of: 'af'
  10738. }
  10739. });
  10740. return $delegate;
  10741. }]);
  10742. }]);
  10743. })();
  10744. (function () {
  10745. angular.module('ui.grid').config(['$provide', function ($provide) {
  10746. $provide.decorator('i18nService', ['$delegate', function ($delegate) {
  10747. $delegate.add('de', {
  10748. headerCell: {
  10749. aria: {
  10750. defaultFilterLabel: 'Filter für Spalte',
  10751. removeFilter: 'Filter löschen',
  10752. columnMenuButtonLabel: 'Spaltenmenü',
  10753. column: 'Spalte'
  10754. },
  10755. priority: 'Priorität:',
  10756. filterLabel: "Filter für Spalte: "
  10757. },
  10758. aggregate: {
  10759. label: 'Eintrag'
  10760. },
  10761. groupPanel: {
  10762. description: 'Ziehen Sie eine Spaltenüberschrift hierhin, um nach dieser Spalte zu gruppieren.'
  10763. },
  10764. search: {
  10765. aria: {
  10766. selected: 'Zeile markiert',
  10767. notSelected: 'Zeile nicht markiert'
  10768. },
  10769. placeholder: 'Suche...',
  10770. showingItems: 'Zeige Einträge:',
  10771. selectedItems: 'Ausgewählte Einträge:',
  10772. totalItems: 'Einträge gesamt:',
  10773. size: 'Einträge pro Seite:',
  10774. first: 'Erste Seite',
  10775. next: 'Nächste Seite',
  10776. previous: 'Vorherige Seite',
  10777. last: 'Letzte Seite'
  10778. },
  10779. menu: {
  10780. text: 'Spalten auswählen:'
  10781. },
  10782. sort: {
  10783. ascending: 'aufsteigend sortieren',
  10784. descending: 'absteigend sortieren',
  10785. none: 'keine Sortierung',
  10786. remove: 'Sortierung zurücksetzen'
  10787. },
  10788. column: {
  10789. hide: 'Spalte ausblenden'
  10790. },
  10791. aggregation: {
  10792. count: 'Zeilen insgesamt: ',
  10793. sum: 'gesamt: ',
  10794. avg: 'Durchschnitt: ',
  10795. min: 'min: ',
  10796. max: 'max: '
  10797. },
  10798. pinning: {
  10799. pinLeft: 'Links anheften',
  10800. pinRight: 'Rechts anheften',
  10801. unpin: 'Lösen'
  10802. },
  10803. columnMenu: {
  10804. close: 'Schließen'
  10805. },
  10806. gridMenu: {
  10807. aria: {
  10808. buttonLabel: 'Tabellenmenü'
  10809. },
  10810. columns: 'Spalten:',
  10811. importerTitle: 'Datei importieren',
  10812. exporterAllAsCsv: 'Alle Daten als CSV exportieren',
  10813. exporterVisibleAsCsv: 'sichtbare Daten als CSV exportieren',
  10814. exporterSelectedAsCsv: 'markierte Daten als CSV exportieren',
  10815. exporterAllAsPdf: 'Alle Daten als PDF exportieren',
  10816. exporterVisibleAsPdf: 'sichtbare Daten als PDF exportieren',
  10817. exporterSelectedAsPdf: 'markierte Daten als PDF exportieren',
  10818. exporterAllAsExcel: 'Alle Daten als Excel exportieren',
  10819. exporterVisibleAsExcel: 'sichtbare Daten als Excel exportiere',
  10820. exporterSelectedAsExcel: 'markierte Daten als Excel exportieren',
  10821. clearAllFilters: 'Alle Filter zurücksetzen'
  10822. },
  10823. importer: {
  10824. noHeaders: 'Es konnten keine Spaltennamen ermittelt werden. Sind in der Datei Spaltendefinitionen enthalten?',
  10825. noObjects: 'Es konnten keine Zeileninformationen gelesen werden, Sind in der Datei außer den Spaltendefinitionen auch Daten enthalten?',
  10826. invalidCsv: 'Die Datei konnte nicht eingelesen werden, ist es eine gültige CSV-Datei?',
  10827. invalidJson: 'Die Datei konnte nicht eingelesen werden. Enthält sie gültiges JSON?',
  10828. jsonNotArray: 'Die importierte JSON-Datei muß ein Array enthalten. Breche Import ab.'
  10829. },
  10830. pagination: {
  10831. aria: {
  10832. pageToFirst: 'Zum Anfang',
  10833. pageBack: 'Seite zurück',
  10834. pageSelected: 'Ausgwählte Seite',
  10835. pageForward: 'Seite vor',
  10836. pageToLast: 'Zum Ende'
  10837. },
  10838. sizes: 'Einträge pro Seite',
  10839. totalItems: 'Einträgen',
  10840. through: 'bis',
  10841. of: 'von'
  10842. },
  10843. grouping: {
  10844. group: 'Gruppieren',
  10845. ungroup: 'Gruppierung aufheben',
  10846. aggregate_count: 'Agg: Anzahl',
  10847. aggregate_sum: 'Agg: Summe',
  10848. aggregate_max: 'Agg: Maximum',
  10849. aggregate_min: 'Agg: Minimum',
  10850. aggregate_avg: 'Agg: Mittelwert',
  10851. aggregate_remove: 'Aggregation entfernen'
  10852. }
  10853. });
  10854. return $delegate;
  10855. }]);
  10856. }]);
  10857. })();
  10858. (function () {
  10859. angular.module('ui.grid').config(['$provide', function($provide) {
  10860. $provide.decorator('i18nService', ['$delegate', function($delegate) {
  10861. $delegate.add('en', {
  10862. headerCell: {
  10863. aria: {
  10864. defaultFilterLabel: 'Filter for column',
  10865. removeFilter: 'Remove Filter',
  10866. columnMenuButtonLabel: 'Column Menu',
  10867. column: 'Column'
  10868. },
  10869. priority: 'Priority:',
  10870. filterLabel: "Filter for column: "
  10871. },
  10872. aggregate: {
  10873. label: 'items'
  10874. },
  10875. groupPanel: {
  10876. description: 'Drag a column header here and drop it to group by that column.'
  10877. },
  10878. search: {
  10879. aria: {
  10880. selected: 'Row selected',
  10881. notSelected: 'Row not selected'
  10882. },
  10883. placeholder: 'Search...',
  10884. showingItems: 'Showing Items:',
  10885. selectedItems: 'Selected Items:',
  10886. totalItems: 'Total Items:',
  10887. size: 'Page Size:',
  10888. first: 'First Page',
  10889. next: 'Next Page',
  10890. previous: 'Previous Page',
  10891. last: 'Last Page'
  10892. },
  10893. menu: {
  10894. text: 'Choose Columns:'
  10895. },
  10896. sort: {
  10897. ascending: 'Sort Ascending',
  10898. descending: 'Sort Descending',
  10899. none: 'Sort None',
  10900. remove: 'Remove Sort'
  10901. },
  10902. column: {
  10903. hide: 'Hide Column'
  10904. },
  10905. aggregation: {
  10906. count: 'total rows: ',
  10907. sum: 'total: ',
  10908. avg: 'avg: ',
  10909. min: 'min: ',
  10910. max: 'max: '
  10911. },
  10912. pinning: {
  10913. pinLeft: 'Pin Left',
  10914. pinRight: 'Pin Right',
  10915. unpin: 'Unpin'
  10916. },
  10917. columnMenu: {
  10918. close: 'Close'
  10919. },
  10920. gridMenu: {
  10921. aria: {
  10922. buttonLabel: 'Grid Menu'
  10923. },
  10924. columns: 'Columns:',
  10925. importerTitle: 'Import file',
  10926. exporterAllAsCsv: 'Export all data as csv',
  10927. exporterVisibleAsCsv: 'Export visible data as csv',
  10928. exporterSelectedAsCsv: 'Export selected data as csv',
  10929. exporterAllAsPdf: 'Export all data as pdf',
  10930. exporterVisibleAsPdf: 'Export visible data as pdf',
  10931. exporterSelectedAsPdf: 'Export selected data as pdf',
  10932. exporterAllAsExcel: 'Export all data as excel',
  10933. exporterVisibleAsExcel: 'Export visible data as excel',
  10934. exporterSelectedAsExcel: 'Export selected data as excel',
  10935. clearAllFilters: 'Clear all filters'
  10936. },
  10937. importer: {
  10938. noHeaders: 'Column names were unable to be derived, does the file have a header?',
  10939. noObjects: 'Objects were not able to be derived, was there data in the file other than headers?',
  10940. invalidCsv: 'File was unable to be processed, is it valid CSV?',
  10941. invalidJson: 'File was unable to be processed, is it valid Json?',
  10942. jsonNotArray: 'Imported json file must contain an array, aborting.'
  10943. },
  10944. pagination: {
  10945. aria: {
  10946. pageToFirst: 'Page to first',
  10947. pageBack: 'Page back',
  10948. pageSelected: 'Selected page',
  10949. pageForward: 'Page forward',
  10950. pageToLast: 'Page to last'
  10951. },
  10952. sizes: 'items per page',
  10953. totalItems: 'items',
  10954. through: 'through',
  10955. of: 'of'
  10956. },
  10957. grouping: {
  10958. group: 'Group',
  10959. ungroup: 'Ungroup',
  10960. aggregate_count: 'Agg: Count',
  10961. aggregate_sum: 'Agg: Sum',
  10962. aggregate_max: 'Agg: Max',
  10963. aggregate_min: 'Agg: Min',
  10964. aggregate_avg: 'Agg: Avg',
  10965. aggregate_remove: 'Agg: Remove'
  10966. },
  10967. validate: {
  10968. error: 'Error:',
  10969. minLength: 'Value should be at least THRESHOLD characters long.',
  10970. maxLength: 'Value should be at most THRESHOLD characters long.',
  10971. required: 'A value is needed.'
  10972. }
  10973. });
  10974. return $delegate;
  10975. }]);
  10976. }]);
  10977. })();
  10978. (function () {
  10979. angular.module('ui.grid').config(['$provide', function($provide) {
  10980. $provide.decorator('i18nService', ['$delegate', function($delegate) {
  10981. $delegate.add('es', {
  10982. aggregate: {
  10983. label: 'Artículos'
  10984. },
  10985. groupPanel: {
  10986. description: 'Arrastre un encabezado de columna aquí y suéltelo para agrupar por esa columna.'
  10987. },
  10988. search: {
  10989. placeholder: 'Buscar...',
  10990. showingItems: 'Artículos Mostrados:',
  10991. selectedItems: 'Artículos Seleccionados:',
  10992. totalItems: 'Artículos Totales:',
  10993. size: 'Tamaño de Página:',
  10994. first: 'Primera Página',
  10995. next: 'Página Siguiente',
  10996. previous: 'Página Anterior',
  10997. last: 'Última Página'
  10998. },
  10999. menu: {
  11000. text: 'Elegir columnas:'
  11001. },
  11002. sort: {
  11003. ascending: 'Orden Ascendente',
  11004. descending: 'Orden Descendente',
  11005. remove: 'Sin Ordenar'
  11006. },
  11007. column: {
  11008. hide: 'Ocultar la columna'
  11009. },
  11010. aggregation: {
  11011. count: 'filas totales: ',
  11012. sum: 'total: ',
  11013. avg: 'media: ',
  11014. min: 'min: ',
  11015. max: 'max: '
  11016. },
  11017. pinning: {
  11018. pinLeft: 'Fijar a la Izquierda',
  11019. pinRight: 'Fijar a la Derecha',
  11020. unpin: 'Quitar Fijación'
  11021. },
  11022. gridMenu: {
  11023. columns: 'Columnas:',
  11024. importerTitle: 'Importar archivo',
  11025. exporterAllAsCsv: 'Exportar todo como csv',
  11026. exporterVisibleAsCsv: 'Exportar vista como csv',
  11027. exporterSelectedAsCsv: 'Exportar selección como csv',
  11028. exporterAllAsPdf: 'Exportar todo como pdf',
  11029. exporterVisibleAsPdf: 'Exportar vista como pdf',
  11030. exporterSelectedAsPdf: 'Exportar selección como pdf',
  11031. exporterAllAsExcel: 'Exportar todo como excel',
  11032. exporterVisibleAsExcel: 'Exportar vista como excel',
  11033. exporterSelectedAsExcel: 'Exportar selección como excel',
  11034. clearAllFilters: 'Limpiar todos los filtros'
  11035. },
  11036. importer: {
  11037. noHeaders: 'No fue posible derivar los nombres de las columnas, ¿tiene encabezados el archivo?',
  11038. noObjects: 'No fue posible obtener registros, ¿contiene datos el archivo, aparte de los encabezados?',
  11039. invalidCsv: 'No fue posible procesar el archivo, ¿es un CSV válido?',
  11040. invalidJson: 'No fue posible procesar el archivo, ¿es un Json válido?',
  11041. jsonNotArray: 'El archivo json importado debe contener un array, abortando.'
  11042. },
  11043. pagination: {
  11044. sizes: 'registros por página',
  11045. totalItems: 'registros',
  11046. of: 'de'
  11047. },
  11048. grouping: {
  11049. group: 'Agrupar',
  11050. ungroup: 'Desagrupar',
  11051. aggregate_count: 'Agr: Cont',
  11052. aggregate_sum: 'Agr: Sum',
  11053. aggregate_max: 'Agr: Máx',
  11054. aggregate_min: 'Agr: Min',
  11055. aggregate_avg: 'Agr: Prom',
  11056. aggregate_remove: 'Agr: Quitar'
  11057. }
  11058. });
  11059. return $delegate;
  11060. }]);
  11061. }]);
  11062. })();
  11063. /**
  11064. * Translated by: R. Salarmehr
  11065. * M. Hosseynzade
  11066. * Using Vajje.com online dictionary.
  11067. */
  11068. (function () {
  11069. angular.module('ui.grid').config(['$provide', function ($provide) {
  11070. $provide.decorator('i18nService', ['$delegate', function ($delegate) {
  11071. $delegate.add('fa', {
  11072. aggregate: {
  11073. label: 'قلم'
  11074. },
  11075. groupPanel: {
  11076. description: 'عنوان یک ستون را بگیر و به گروهی از آن ستون رها کن.'
  11077. },
  11078. search: {
  11079. placeholder: 'جستجو...',
  11080. showingItems: 'نمایش اقلام:',
  11081. selectedItems: 'قلم\u200cهای انتخاب شده:',
  11082. totalItems: 'مجموع اقلام:',
  11083. size: 'اندازه\u200cی صفحه:',
  11084. first: 'اولین صفحه',
  11085. next: 'صفحه\u200cی\u200cبعدی',
  11086. previous: 'صفحه\u200cی\u200c قبلی',
  11087. last: 'آخرین صفحه'
  11088. },
  11089. menu: {
  11090. text: 'ستون\u200cهای انتخابی:'
  11091. },
  11092. sort: {
  11093. ascending: 'ترتیب صعودی',
  11094. descending: 'ترتیب نزولی',
  11095. remove: 'حذف مرتب کردن'
  11096. },
  11097. column: {
  11098. hide: 'پنهان\u200cکردن ستون'
  11099. },
  11100. aggregation: {
  11101. count: 'تعداد: ',
  11102. sum: 'مجموع: ',
  11103. avg: 'میانگین: ',
  11104. min: 'کمترین: ',
  11105. max: 'بیشترین: '
  11106. },
  11107. pinning: {
  11108. pinLeft: 'پین کردن سمت چپ',
  11109. pinRight: 'پین کردن سمت راست',
  11110. unpin: 'حذف پین'
  11111. },
  11112. gridMenu: {
  11113. columns: 'ستون\u200cها:',
  11114. importerTitle: 'وارد کردن فایل',
  11115. exporterAllAsCsv: 'خروجی تمام داده\u200cها در فایل csv',
  11116. exporterVisibleAsCsv: 'خروجی داده\u200cهای قابل مشاهده در فایل csv',
  11117. exporterSelectedAsCsv: 'خروجی داده\u200cهای انتخاب\u200cشده در فایل csv',
  11118. exporterAllAsPdf: 'خروجی تمام داده\u200cها در فایل pdf',
  11119. exporterVisibleAsPdf: 'خروجی داده\u200cهای قابل مشاهده در فایل pdf',
  11120. exporterSelectedAsPdf: 'خروجی داده\u200cهای انتخاب\u200cشده در فایل pdf',
  11121. clearAllFilters: 'پاک کردن تمام فیلتر'
  11122. },
  11123. importer: {
  11124. noHeaders: 'نام ستون قابل استخراج نیست. آیا فایل عنوان دارد؟',
  11125. noObjects: 'اشیا قابل استخراج نیستند. آیا به جز عنوان\u200cها در فایل داده وجود دارد؟',
  11126. invalidCsv: 'فایل قابل پردازش نیست. آیا فرمت csv معتبر است؟',
  11127. invalidJson: 'فایل قابل پردازش نیست. آیا فرمت json معتبر است؟',
  11128. jsonNotArray: 'فایل json وارد شده باید حاوی آرایه باشد. عملیات ساقط شد.'
  11129. },
  11130. pagination: {
  11131. sizes: 'اقلام در هر صفحه',
  11132. totalItems: 'اقلام',
  11133. of: 'از'
  11134. },
  11135. grouping: {
  11136. group: 'گروه\u200cبندی',
  11137. ungroup: 'حذف گروه\u200cبندی',
  11138. aggregate_count: 'Agg: تعداد',
  11139. aggregate_sum: 'Agg: جمع',
  11140. aggregate_max: 'Agg: بیشینه',
  11141. aggregate_min: 'Agg: کمینه',
  11142. aggregate_avg: 'Agg: میانگین',
  11143. aggregate_remove: 'Agg: حذف'
  11144. }
  11145. });
  11146. return $delegate;
  11147. }]);
  11148. }]);
  11149. })();
  11150. (function () {
  11151. angular.module('ui.grid').config(['$provide', function($provide) {
  11152. $provide.decorator('i18nService', ['$delegate', function($delegate) {
  11153. $delegate.add('fi', {
  11154. aggregate: {
  11155. label: 'rivit'
  11156. },
  11157. groupPanel: {
  11158. description: 'Raahaa ja pudota otsikko tähän ryhmittääksesi sarakkeen mukaan.'
  11159. },
  11160. search: {
  11161. placeholder: 'Hae...',
  11162. showingItems: 'Näytetään rivejä:',
  11163. selectedItems: 'Valitut rivit:',
  11164. totalItems: 'Rivejä yht.:',
  11165. size: 'Näytä:',
  11166. first: 'Ensimmäinen sivu',
  11167. next: 'Seuraava sivu',
  11168. previous: 'Edellinen sivu',
  11169. last: 'Viimeinen sivu'
  11170. },
  11171. menu: {
  11172. text: 'Valitse sarakkeet:'
  11173. },
  11174. sort: {
  11175. ascending: 'Järjestä nouseva',
  11176. descending: 'Järjestä laskeva',
  11177. remove: 'Poista järjestys'
  11178. },
  11179. column: {
  11180. hide: 'Piilota sarake'
  11181. },
  11182. aggregation: {
  11183. count: 'Rivejä yht.: ',
  11184. sum: 'Summa: ',
  11185. avg: 'K.a.: ',
  11186. min: 'Min: ',
  11187. max: 'Max: '
  11188. },
  11189. pinning: {
  11190. pinLeft: 'Lukitse vasemmalle',
  11191. pinRight: 'Lukitse oikealle',
  11192. unpin: 'Poista lukitus'
  11193. },
  11194. gridMenu: {
  11195. columns: 'Sarakkeet:',
  11196. importerTitle: 'Tuo tiedosto',
  11197. exporterAllAsCsv: 'Vie tiedot csv-muodossa',
  11198. exporterVisibleAsCsv: 'Vie näkyvä tieto csv-muodossa',
  11199. exporterSelectedAsCsv: 'Vie valittu tieto csv-muodossa',
  11200. exporterAllAsPdf: 'Vie tiedot pdf-muodossa',
  11201. exporterVisibleAsPdf: 'Vie näkyvä tieto pdf-muodossa',
  11202. exporterSelectedAsPdf: 'Vie valittu tieto pdf-muodossa',
  11203. exporterAllAsExcel: 'Vie tiedot excel-muodossa',
  11204. exporterVisibleAsExcel: 'Vie näkyvä tieto excel-muodossa',
  11205. exporterSelectedAsExcel: 'Vie valittu tieto excel-muodossa',
  11206. clearAllFilters: 'Puhdista kaikki suodattimet'
  11207. },
  11208. importer: {
  11209. noHeaders: 'Sarakkeen nimiä ei voitu päätellä, onko tiedostossa otsikkoriviä?',
  11210. noObjects: 'Tietoja ei voitu lukea, onko tiedostossa muuta kuin otsikkot?',
  11211. invalidCsv: 'Tiedostoa ei voitu käsitellä, oliko se CSV-muodossa?',
  11212. invalidJson: 'Tiedostoa ei voitu käsitellä, oliko se JSON-muodossa?',
  11213. jsonNotArray: 'Tiedosto ei sisältänyt taulukkoa, lopetetaan.'
  11214. }
  11215. });
  11216. return $delegate;
  11217. }]);
  11218. }]);
  11219. })();
  11220. (function () {
  11221. angular.module('ui.grid').config(['$provide', function($provide) {
  11222. $provide.decorator('i18nService', ['$delegate', function($delegate) {
  11223. $delegate.add('fr', {
  11224. headerCell: {
  11225. aria: {
  11226. defaultFilterLabel: 'Filtre de la colonne',
  11227. removeFilter: 'Supprimer le filtre',
  11228. columnMenuButtonLabel: 'Menu de la colonne'
  11229. },
  11230. priority: 'Priorité:',
  11231. filterLabel: "Filtre de la colonne: "
  11232. },
  11233. aggregate: {
  11234. label: 'éléments'
  11235. },
  11236. groupPanel: {
  11237. description: 'Faites glisser une en-tête de colonne ici pour créer un groupe de colonnes.'
  11238. },
  11239. search: {
  11240. placeholder: 'Recherche...',
  11241. showingItems: 'Affichage des éléments :',
  11242. selectedItems: 'Éléments sélectionnés :',
  11243. totalItems: 'Nombre total d\'éléments:',
  11244. size: 'Taille de page:',
  11245. first: 'Première page',
  11246. next: 'Page Suivante',
  11247. previous: 'Page précédente',
  11248. last: 'Dernière page'
  11249. },
  11250. menu: {
  11251. text: 'Choisir des colonnes :'
  11252. },
  11253. sort: {
  11254. ascending: 'Trier par ordre croissant',
  11255. descending: 'Trier par ordre décroissant',
  11256. none: 'Aucun tri',
  11257. remove: 'Enlever le tri'
  11258. },
  11259. column: {
  11260. hide: 'Cacher la colonne'
  11261. },
  11262. aggregation: {
  11263. count: 'lignes totales: ',
  11264. sum: 'total: ',
  11265. avg: 'moy: ',
  11266. min: 'min: ',
  11267. max: 'max: '
  11268. },
  11269. pinning: {
  11270. pinLeft: 'Épingler à gauche',
  11271. pinRight: 'Épingler à droite',
  11272. unpin: 'Détacher'
  11273. },
  11274. columnMenu: {
  11275. close: 'Fermer'
  11276. },
  11277. gridMenu: {
  11278. aria: {
  11279. buttonLabel: 'Menu du tableau'
  11280. },
  11281. columns: 'Colonnes:',
  11282. importerTitle: 'Importer un fichier',
  11283. exporterAllAsCsv: 'Exporter toutes les données en CSV',
  11284. exporterVisibleAsCsv: 'Exporter les données visibles en CSV',
  11285. exporterSelectedAsCsv: 'Exporter les données sélectionnées en CSV',
  11286. exporterAllAsPdf: 'Exporter toutes les données en PDF',
  11287. exporterVisibleAsPdf: 'Exporter les données visibles en PDF',
  11288. exporterSelectedAsPdf: 'Exporter les données sélectionnées en PDF',
  11289. exporterAllAsExcel: 'Exporter toutes les données en Excel',
  11290. exporterVisibleAsExcel: 'Exporter les données visibles en Excel',
  11291. exporterSelectedAsExcel: 'Exporter les données sélectionnées en Excel',
  11292. clearAllFilters: 'Nettoyez tous les filtres'
  11293. },
  11294. importer: {
  11295. noHeaders: 'Impossible de déterminer le nom des colonnes, le fichier possède-t-il une en-tête ?',
  11296. noObjects: 'Aucun objet trouvé, le fichier possède-t-il des données autres que l\'en-tête ?',
  11297. invalidCsv: 'Le fichier n\'a pas pu être traité, le CSV est-il valide ?',
  11298. invalidJson: 'Le fichier n\'a pas pu être traité, le JSON est-il valide ?',
  11299. jsonNotArray: 'Le fichier JSON importé doit contenir un tableau, abandon.'
  11300. },
  11301. pagination: {
  11302. aria: {
  11303. pageToFirst: 'Aller à la première page',
  11304. pageBack: 'Page précédente',
  11305. pageSelected: 'Page sélectionnée',
  11306. pageForward: 'Page suivante',
  11307. pageToLast: 'Aller à la dernière page'
  11308. },
  11309. sizes: 'éléments par page',
  11310. totalItems: 'éléments',
  11311. through: 'à',
  11312. of: 'sur'
  11313. },
  11314. grouping: {
  11315. group: 'Grouper',
  11316. ungroup: 'Dégrouper',
  11317. aggregate_count: 'Agg: Compter',
  11318. aggregate_sum: 'Agg: Somme',
  11319. aggregate_max: 'Agg: Max',
  11320. aggregate_min: 'Agg: Min',
  11321. aggregate_avg: 'Agg: Moy',
  11322. aggregate_remove: 'Agg: Retirer'
  11323. },
  11324. validate: {
  11325. error: 'Erreur:',
  11326. minLength: 'La valeur doit être supérieure ou égale à THRESHOLD caractères.',
  11327. maxLength: 'La valeur doit être inférieure ou égale à THRESHOLD caractères.',
  11328. required: 'Une valeur est nécéssaire.'
  11329. }
  11330. });
  11331. return $delegate;
  11332. }]);
  11333. }]);
  11334. })();
  11335. (function () {
  11336. angular.module('ui.grid').config(['$provide', function ($provide) {
  11337. $provide.decorator('i18nService', ['$delegate', function ($delegate) {
  11338. $delegate.add('he', {
  11339. aggregate: {
  11340. label: 'items'
  11341. },
  11342. groupPanel: {
  11343. description: 'גרור עמודה לכאן ושחרר בכדי לקבץ עמודה זו.'
  11344. },
  11345. search: {
  11346. placeholder: 'חפש...',
  11347. showingItems: 'מציג:',
  11348. selectedItems: 'סה"כ נבחרו:',
  11349. totalItems: 'סה"כ רשומות:',
  11350. size: 'תוצאות בדף:',
  11351. first: 'דף ראשון',
  11352. next: 'דף הבא',
  11353. previous: 'דף קודם',
  11354. last: 'דף אחרון'
  11355. },
  11356. menu: {
  11357. text: 'בחר עמודות:'
  11358. },
  11359. sort: {
  11360. ascending: 'סדר עולה',
  11361. descending: 'סדר יורד',
  11362. remove: 'בטל'
  11363. },
  11364. column: {
  11365. hide: 'טור הסתר'
  11366. },
  11367. aggregation: {
  11368. count: 'total rows: ',
  11369. sum: 'total: ',
  11370. avg: 'avg: ',
  11371. min: 'min: ',
  11372. max: 'max: '
  11373. },
  11374. gridMenu: {
  11375. columns: 'Columns:',
  11376. importerTitle: 'Import file',
  11377. exporterAllAsCsv: 'Export all data as csv',
  11378. exporterVisibleAsCsv: 'Export visible data as csv',
  11379. exporterSelectedAsCsv: 'Export selected data as csv',
  11380. exporterAllAsPdf: 'Export all data as pdf',
  11381. exporterVisibleAsPdf: 'Export visible data as pdf',
  11382. exporterSelectedAsPdf: 'Export selected data as pdf',
  11383. exporterAllAsExcel: 'Export all data as excel',
  11384. exporterVisibleAsExcel: 'Export visible data as excel',
  11385. exporterSelectedAsExcel: 'Export selected data as excel',
  11386. clearAllFilters: 'Clean all filters'
  11387. },
  11388. importer: {
  11389. noHeaders: 'Column names were unable to be derived, does the file have a header?',
  11390. noObjects: 'Objects were not able to be derived, was there data in the file other than headers?',
  11391. invalidCsv: 'File was unable to be processed, is it valid CSV?',
  11392. invalidJson: 'File was unable to be processed, is it valid Json?',
  11393. jsonNotArray: 'Imported json file must contain an array, aborting.'
  11394. }
  11395. });
  11396. return $delegate;
  11397. }]);
  11398. }]);
  11399. })();
  11400. (function () {
  11401. angular.module('ui.grid').config(['$provide', function($provide) {
  11402. $provide.decorator('i18nService', ['$delegate', function($delegate) {
  11403. $delegate.add('hy', {
  11404. aggregate: {
  11405. label: 'տվյալներ'
  11406. },
  11407. groupPanel: {
  11408. description: 'Ըստ սյան խմբավորելու համար քաշեք և գցեք վերնագիրն այստեղ։'
  11409. },
  11410. search: {
  11411. placeholder: 'Փնտրում...',
  11412. showingItems: 'Ցուցադրված տվյալներ՝',
  11413. selectedItems: 'Ընտրված:',
  11414. totalItems: 'Ընդամենը՝',
  11415. size: 'Տողերի քանակը էջում՝',
  11416. first: 'Առաջին էջ',
  11417. next: 'Հաջորդ էջ',
  11418. previous: 'Նախորդ էջ',
  11419. last: 'Վերջին էջ'
  11420. },
  11421. menu: {
  11422. text: 'Ընտրել սյուները:'
  11423. },
  11424. sort: {
  11425. ascending: 'Աճման կարգով',
  11426. descending: 'Նվազման կարգով',
  11427. remove: 'Հանել '
  11428. },
  11429. column: {
  11430. hide: 'Թաքցնել սյունը'
  11431. },
  11432. aggregation: {
  11433. count: 'ընդամենը տող՝ ',
  11434. sum: 'ընդամենը՝ ',
  11435. avg: 'միջին՝ ',
  11436. min: 'մին՝ ',
  11437. max: 'մաքս՝ '
  11438. },
  11439. pinning: {
  11440. pinLeft: 'Կպցնել ձախ կողմում',
  11441. pinRight: 'Կպցնել աջ կողմում',
  11442. unpin: 'Արձակել'
  11443. },
  11444. gridMenu: {
  11445. columns: 'Սյուներ:',
  11446. importerTitle: 'Ներմուծել ֆայլ',
  11447. exporterAllAsCsv: 'Արտահանել ամբողջը CSV',
  11448. exporterVisibleAsCsv: 'Արտահանել երևացող տվյալները CSV',
  11449. exporterSelectedAsCsv: 'Արտահանել ընտրված տվյալները CSV',
  11450. exporterAllAsPdf: 'Արտահանել PDF',
  11451. exporterVisibleAsPdf: 'Արտահանել երևացող տվյալները PDF',
  11452. exporterSelectedAsPdf: 'Արտահանել ընտրված տվյալները PDF',
  11453. exporterAllAsExcel: 'Արտահանել excel',
  11454. exporterVisibleAsExcel: 'Արտահանել երևացող տվյալները excel',
  11455. exporterSelectedAsExcel: 'Արտահանել ընտրված տվյալները excel',
  11456. clearAllFilters: 'Մաքրել բոլոր ֆիլտրերը'
  11457. },
  11458. importer: {
  11459. noHeaders: 'Հնարավոր չեղավ որոշել սյան վերնագրերը։ Արդյո՞ք ֆայլը ունի վերնագրեր։',
  11460. noObjects: 'Հնարավոր չեղավ կարդալ տվյալները։ Արդյո՞ք ֆայլում կան տվյալներ։',
  11461. invalidCsv: 'Հնարավոր չեղավ մշակել ֆայլը։ Արդյո՞ք այն վավեր CSV է։',
  11462. invalidJson: 'Հնարավոր չեղավ մշակել ֆայլը։ Արդյո՞ք այն վավեր Json է։',
  11463. jsonNotArray: 'Ներմուծված json ֆայլը պետք է պարունակի զանգված, կասեցվում է։'
  11464. }
  11465. });
  11466. return $delegate;
  11467. }]);
  11468. }]);
  11469. })();
  11470. (function () {
  11471. angular.module('ui.grid').config(['$provide', function($provide) {
  11472. $provide.decorator('i18nService', ['$delegate', function($delegate) {
  11473. $delegate.add('is', {
  11474. headerCell: {
  11475. aria: {
  11476. defaultFilterLabel: 'Sía fyrir dálk',
  11477. removeFilter: 'Fjarlægja síu',
  11478. columnMenuButtonLabel: 'Dálkavalmynd'
  11479. },
  11480. priority: 'Forgangsröðun:',
  11481. filterLabel: "Sía fyrir dálka: "
  11482. },
  11483. aggregate: {
  11484. label: 'hlutir'
  11485. },
  11486. groupPanel: {
  11487. description: 'Dragðu dálkhaus hingað til að flokka saman eftir þeim dálki.'
  11488. },
  11489. search: {
  11490. placeholder: 'Leita...',
  11491. showingItems: 'Sýni hluti:',
  11492. selectedItems: 'Valdir hlutir:',
  11493. totalItems: 'Hlutir alls:',
  11494. size: 'Stærð síðu:',
  11495. first: 'Fyrsta síða',
  11496. next: 'Næsta síða',
  11497. previous: 'Fyrri síða',
  11498. last: 'Síðasta síða'
  11499. },
  11500. menu: {
  11501. text: 'Veldu dálka:'
  11502. },
  11503. sort: {
  11504. ascending: 'Raða hækkandi',
  11505. descending: 'Raða lækkandi',
  11506. none: 'Engin röðun',
  11507. remove: 'Fjarlægja röðun'
  11508. },
  11509. column: {
  11510. hide: 'Fela dálk'
  11511. },
  11512. aggregation: {
  11513. count: 'fjöldi raða: ',
  11514. sum: 'summa: ',
  11515. avg: 'meðaltal: ',
  11516. min: 'lágmark: ',
  11517. max: 'hámark: '
  11518. },
  11519. pinning: {
  11520. pinLeft: 'Festa til vinstri',
  11521. pinRight: 'Festa til hægri',
  11522. unpin: 'Losa'
  11523. },
  11524. columnMenu: {
  11525. close: 'Loka'
  11526. },
  11527. gridMenu: {
  11528. aria: {
  11529. buttonLabel: 'Töflu valmynd'
  11530. },
  11531. columns: 'Dálkar:',
  11532. importerTitle: 'Flytja inn skjal',
  11533. exporterAllAsCsv: 'Flytja út gögn sem csv',
  11534. exporterVisibleAsCsv: 'Flytja út sýnileg gögn sem csv',
  11535. exporterSelectedAsCsv: 'Flytja út valin gögn sem csv',
  11536. exporterAllAsPdf: 'Flytja út öll gögn sem pdf',
  11537. exporterVisibleAsPdf: 'Flytja út sýnileg gögn sem pdf',
  11538. exporterSelectedAsPdf: 'Flytja út valin gögn sem pdf',
  11539. clearAllFilters: 'Hreinsa allar síur'
  11540. },
  11541. importer: {
  11542. noHeaders: 'Ekki hægt að vinna dálkanöfn úr skjalinu, er skjalið örugglega með haus?',
  11543. noObjects: 'Ekki hægt að vinna hluti úr skjalinu, voru örugglega gögn í skjalinu önnur en hausinn?',
  11544. invalidCsv: 'Tókst ekki að vinna skjal, er það örggulega gilt CSV?',
  11545. invalidJson: 'Tókst ekki að vinna skjal, er það örugglega gilt Json?',
  11546. jsonNotArray: 'Innflutt json skjal verður að innihalda fylki, hætti við.'
  11547. },
  11548. pagination: {
  11549. aria: {
  11550. pageToFirst: 'Fletta að fyrstu',
  11551. pageBack: 'Fletta til baka',
  11552. pageSelected: 'Valin síða',
  11553. pageForward: 'Fletta áfram',
  11554. pageToLast: 'Fletta að síðustu'
  11555. },
  11556. sizes: 'hlutir á síðu',
  11557. totalItems: 'hlutir',
  11558. through: 'gegnum',
  11559. of: 'af'
  11560. },
  11561. grouping: {
  11562. group: 'Flokka',
  11563. ungroup: 'Sundurliða',
  11564. aggregate_count: 'Fjöldi: ',
  11565. aggregate_sum: 'Summa: ',
  11566. aggregate_max: 'Hámark: ',
  11567. aggregate_min: 'Lágmark: ',
  11568. aggregate_avg: 'Meðaltal: ',
  11569. aggregate_remove: 'Fjarlægja: '
  11570. },
  11571. validate: {
  11572. error: 'Villa:',
  11573. minLength: 'Gildi ætti að vera a.m.k. THRESHOLD stafa langt.',
  11574. maxLength: 'Gildi ætti að vera í mesta lagi THRESHOLD stafa langt.',
  11575. required: 'Þarf að hafa gildi.'
  11576. }
  11577. });
  11578. return $delegate;
  11579. }]);
  11580. }]);
  11581. })();
  11582. (function () {
  11583. angular.module('ui.grid').config(['$provide', function($provide) {
  11584. $provide.decorator('i18nService', ['$delegate', function($delegate) {
  11585. $delegate.add('it', {
  11586. aggregate: {
  11587. label: 'elementi'
  11588. },
  11589. groupPanel: {
  11590. description: 'Trascina un\'intestazione all\'interno del gruppo della colonna.'
  11591. },
  11592. search: {
  11593. placeholder: 'Ricerca...',
  11594. showingItems: 'Mostra:',
  11595. selectedItems: 'Selezionati:',
  11596. totalItems: 'Totali:',
  11597. size: 'Tot Pagine:',
  11598. first: 'Prima',
  11599. next: 'Prossima',
  11600. previous: 'Precedente',
  11601. last: 'Ultima'
  11602. },
  11603. menu: {
  11604. text: 'Scegli le colonne:'
  11605. },
  11606. sort: {
  11607. ascending: 'Asc.',
  11608. descending: 'Desc.',
  11609. remove: 'Annulla ordinamento'
  11610. },
  11611. column: {
  11612. hide: 'Nascondi'
  11613. },
  11614. aggregation: {
  11615. count: 'righe totali: ',
  11616. sum: 'tot: ',
  11617. avg: 'media: ',
  11618. min: 'minimo: ',
  11619. max: 'massimo: '
  11620. },
  11621. pinning: {
  11622. pinLeft: 'Blocca a sx',
  11623. pinRight: 'Blocca a dx',
  11624. unpin: 'Blocca in alto'
  11625. },
  11626. gridMenu: {
  11627. columns: 'Colonne:',
  11628. importerTitle: 'Importa',
  11629. exporterAllAsCsv: 'Esporta tutti i dati in CSV',
  11630. exporterVisibleAsCsv: 'Esporta i dati visibili in CSV',
  11631. exporterSelectedAsCsv: 'Esporta i dati selezionati in CSV',
  11632. exporterAllAsPdf: 'Esporta tutti i dati in PDF',
  11633. exporterVisibleAsPdf: 'Esporta i dati visibili in PDF',
  11634. exporterSelectedAsPdf: 'Esporta i dati selezionati in PDF',
  11635. exporterAllAsExcel: 'Esporta tutti i dati in excel',
  11636. exporterVisibleAsExcel: 'Esporta i dati visibili in excel',
  11637. exporterSelectedAsExcel: 'Esporta i dati selezionati in excel',
  11638. clearAllFilters: 'Pulire tutti i filtri'
  11639. },
  11640. importer: {
  11641. noHeaders: 'Impossibile reperire i nomi delle colonne, sicuro che siano indicati all\'interno del file?',
  11642. noObjects: 'Impossibile reperire gli oggetti, sicuro che siano indicati all\'interno del file?',
  11643. invalidCsv: 'Impossibile elaborare il file, sicuro che sia un CSV?',
  11644. invalidJson: 'Impossibile elaborare il file, sicuro che sia un JSON valido?',
  11645. jsonNotArray: 'Errore! Il file JSON da importare deve contenere un array.'
  11646. },
  11647. pagination: {
  11648. aria: {
  11649. pageToFirst: 'Prima',
  11650. pageBack: 'Indietro',
  11651. pageSelected: 'Pagina selezionata',
  11652. pageForward: 'Avanti',
  11653. pageToLast: 'Ultima'
  11654. },
  11655. sizes: 'elementi per pagina',
  11656. totalItems: 'elementi',
  11657. through: 'a',
  11658. of: 'di'
  11659. },
  11660. grouping: {
  11661. group: 'Raggruppa',
  11662. ungroup: 'Separa',
  11663. aggregate_count: 'Agg: N. Elem.',
  11664. aggregate_sum: 'Agg: Somma',
  11665. aggregate_max: 'Agg: Massimo',
  11666. aggregate_min: 'Agg: Minimo',
  11667. aggregate_avg: 'Agg: Media',
  11668. aggregate_remove: 'Agg: Rimuovi'
  11669. },
  11670. validate: {
  11671. error: 'Errore:',
  11672. minLength: 'Lunghezza minima pari a THRESHOLD caratteri.',
  11673. maxLength: 'Lunghezza massima pari a THRESHOLD caratteri.',
  11674. required: 'Necessario inserire un valore.'
  11675. }
  11676. });
  11677. return $delegate;
  11678. }]);
  11679. }]);
  11680. })();
  11681. (function() {
  11682. angular.module('ui.grid').config(['$provide', function($provide) {
  11683. $provide.decorator('i18nService', ['$delegate', function($delegate) {
  11684. $delegate.add('ja', {
  11685. headerCell: {
  11686. aria: {
  11687. defaultFilterLabel: '列のフィルター',
  11688. removeFilter: 'フィルターの解除',
  11689. columnMenuButtonLabel: '列のメニュー'
  11690. },
  11691. priority: '優先度:',
  11692. filterLabel: "列フィルター: "
  11693. },
  11694. aggregate: {
  11695. label: '項目'
  11696. },
  11697. groupPanel: {
  11698. description: 'ここに列ヘッダをドラッグアンドドロップして、その列でグループ化します。'
  11699. },
  11700. search: {
  11701. placeholder: '検索...',
  11702. showingItems: '表示中の項目:',
  11703. selectedItems: '選択した項目:',
  11704. totalItems: '項目の総数:',
  11705. size: 'ページサイズ:',
  11706. first: '最初のページ',
  11707. next: '次のページ',
  11708. previous: '前のページ',
  11709. last: '前のページ'
  11710. },
  11711. menu: {
  11712. text: '列の選択:'
  11713. },
  11714. sort: {
  11715. ascending: '昇順に並べ替え',
  11716. descending: '降順に並べ替え',
  11717. none: '並べ替え無し',
  11718. remove: '並べ替えの解除'
  11719. },
  11720. column: {
  11721. hide: '列の非表示'
  11722. },
  11723. aggregation: {
  11724. count: '行数: ',
  11725. sum: '合計: ',
  11726. avg: '平均: ',
  11727. min: '最小: ',
  11728. max: '最大: '
  11729. },
  11730. pinning: {
  11731. pinLeft: '左に固定',
  11732. pinRight: '右に固定',
  11733. unpin: '固定解除'
  11734. },
  11735. columnMenu: {
  11736. close: '閉じる'
  11737. },
  11738. gridMenu: {
  11739. aria: {
  11740. buttonLabel: 'グリッドメニュー'
  11741. },
  11742. columns: '列の表示/非表示:',
  11743. importerTitle: 'ファイルのインポート',
  11744. exporterAllAsCsv: 'すべてのデータをCSV形式でエクスポート',
  11745. exporterVisibleAsCsv: '表示中のデータをCSV形式でエクスポート',
  11746. exporterSelectedAsCsv: '選択したデータをCSV形式でエクスポート',
  11747. exporterAllAsPdf: 'すべてのデータをPDF形式でエクスポート',
  11748. exporterVisibleAsPdf: '表示中のデータをPDF形式でエクスポート',
  11749. exporterSelectedAsPdf: '選択したデータをPDF形式でエクスポート',
  11750. clearAllFilters: 'すべてのフィルタをクリア'
  11751. },
  11752. importer: {
  11753. noHeaders: '列名を取得できません。ファイルにヘッダが含まれていることを確認してください。',
  11754. noObjects: 'オブジェクトを取得できません。ファイルにヘッダ以外のデータが含まれていることを確認してください。',
  11755. invalidCsv: 'ファイルを処理できません。ファイルが有効なCSV形式であることを確認してください。',
  11756. invalidJson: 'ファイルを処理できません。ファイルが有効なJSON形式であることを確認してください。',
  11757. jsonNotArray: 'インポートしたJSONファイルには配列が含まれている必要があります。処理を中止します。'
  11758. },
  11759. pagination: {
  11760. aria: {
  11761. pageToFirst: '最初のページ',
  11762. pageBack: '前のページ',
  11763. pageSelected: '現在のページ',
  11764. pageForward: '次のページ',
  11765. pageToLast: '最後のページ'
  11766. },
  11767. sizes: '項目/ページ',
  11768. totalItems: '項目',
  11769. through: 'から',
  11770. of: '項目/全'
  11771. },
  11772. grouping: {
  11773. group: 'グループ化',
  11774. ungroup: 'グループ化の解除',
  11775. aggregate_count: '集計表示: 行数',
  11776. aggregate_sum: '集計表示: 合計',
  11777. aggregate_max: '集計表示: 最大',
  11778. aggregate_min: '集計表示: 最小',
  11779. aggregate_avg: '集計表示: 平均',
  11780. aggregate_remove: '集計表示: 解除'
  11781. },
  11782. validate: {
  11783. error: 'Error:',
  11784. minLength: 'THRESHOLD 文字以上で入力してください。',
  11785. maxLength: 'THRESHOLD 文字以下で入力してください。',
  11786. required: '値が必要です。'
  11787. }
  11788. });
  11789. return $delegate;
  11790. }]);
  11791. }]);
  11792. })();
  11793. (function () {
  11794. angular.module('ui.grid').config(['$provide', function($provide) {
  11795. $provide.decorator('i18nService', ['$delegate', function($delegate) {
  11796. $delegate.add('ko', {
  11797. aggregate: {
  11798. label: '아이템'
  11799. },
  11800. groupPanel: {
  11801. description: '컬럼으로 그룹핑하기 위해서는 컬럼 헤더를 끌어 떨어뜨려 주세요.'
  11802. },
  11803. search: {
  11804. placeholder: '검색...',
  11805. showingItems: '항목 보여주기:',
  11806. selectedItems: '선택 항목:',
  11807. totalItems: '전체 항목:',
  11808. size: '페이지 크기:',
  11809. first: '첫번째 페이지',
  11810. next: '다음 페이지',
  11811. previous: '이전 페이지',
  11812. last: '마지막 페이지'
  11813. },
  11814. menu: {
  11815. text: '컬럼을 선택하세요:'
  11816. },
  11817. sort: {
  11818. ascending: '오름차순 정렬',
  11819. descending: '내림차순 정렬',
  11820. remove: '소팅 제거'
  11821. },
  11822. column: {
  11823. hide: '컬럼 제거'
  11824. },
  11825. aggregation: {
  11826. count: '전체 갯수: ',
  11827. sum: '전체: ',
  11828. avg: '평균: ',
  11829. min: '최소: ',
  11830. max: '최대: '
  11831. },
  11832. pinning: {
  11833. pinLeft: '왼쪽 핀',
  11834. pinRight: '오른쪽 핀',
  11835. unpin: '핀 제거'
  11836. },
  11837. gridMenu: {
  11838. columns: '컬럼:',
  11839. importerTitle: '파일 가져오기',
  11840. exporterAllAsCsv: 'csv로 모든 데이터 내보내기',
  11841. exporterVisibleAsCsv: 'csv로 보이는 데이터 내보내기',
  11842. exporterSelectedAsCsv: 'csv로 선택된 데이터 내보내기',
  11843. exporterAllAsPdf: 'pdf로 모든 데이터 내보내기',
  11844. exporterVisibleAsPdf: 'pdf로 보이는 데이터 내보내기',
  11845. exporterSelectedAsPdf: 'pdf로 선택 데이터 내보내기',
  11846. clearAllFilters: '모든 필터를 청소'
  11847. },
  11848. importer: {
  11849. noHeaders: '컬럼명이 지정되어 있지 않습니다. 파일에 헤더가 명시되어 있는지 확인해 주세요.',
  11850. noObjects: '데이터가 지정되어 있지 않습니다. 데이터가 파일에 있는지 확인해 주세요.',
  11851. invalidCsv: '파일을 처리할 수 없습니다. 올바른 csv인지 확인해 주세요.',
  11852. invalidJson: '파일을 처리할 수 없습니다. 올바른 json인지 확인해 주세요.',
  11853. jsonNotArray: 'json 파일은 배열을 포함해야 합니다.'
  11854. },
  11855. pagination: {
  11856. sizes: '페이지당 항목',
  11857. totalItems: '전체 항목'
  11858. }
  11859. });
  11860. return $delegate;
  11861. }]);
  11862. }]);
  11863. })();
  11864. (function () {
  11865. angular.module('ui.grid').config(['$provide', function($provide) {
  11866. $provide.decorator('i18nService', ['$delegate', function($delegate) {
  11867. $delegate.add('nl', {
  11868. aggregate: {
  11869. label: 'items'
  11870. },
  11871. groupPanel: {
  11872. description: 'Sleep hier een kolomnaam heen om op te groeperen.'
  11873. },
  11874. search: {
  11875. placeholder: 'Zoeken...',
  11876. showingItems: 'Getoonde items:',
  11877. selectedItems: 'Geselecteerde items:',
  11878. totalItems: 'Totaal aantal items:',
  11879. size: 'Items per pagina:',
  11880. first: 'Eerste pagina',
  11881. next: 'Volgende pagina',
  11882. previous: 'Vorige pagina',
  11883. last: 'Laatste pagina'
  11884. },
  11885. menu: {
  11886. text: 'Kies kolommen:'
  11887. },
  11888. sort: {
  11889. ascending: 'Sorteer oplopend',
  11890. descending: 'Sorteer aflopend',
  11891. remove: 'Verwijder sortering'
  11892. },
  11893. column: {
  11894. hide: 'Verberg kolom'
  11895. },
  11896. aggregation: {
  11897. count: 'Aantal rijen: ',
  11898. sum: 'Som: ',
  11899. avg: 'Gemiddelde: ',
  11900. min: 'Min: ',
  11901. max: 'Max: '
  11902. },
  11903. pinning: {
  11904. pinLeft: 'Zet links vast',
  11905. pinRight: 'Zet rechts vast',
  11906. unpin: 'Maak los'
  11907. },
  11908. gridMenu: {
  11909. columns: 'Kolommen:',
  11910. importerTitle: 'Importeer bestand',
  11911. exporterAllAsCsv: 'Exporteer alle data als csv',
  11912. exporterVisibleAsCsv: 'Exporteer zichtbare data als csv',
  11913. exporterSelectedAsCsv: 'Exporteer geselecteerde data als csv',
  11914. exporterAllAsPdf: 'Exporteer alle data als pdf',
  11915. exporterVisibleAsPdf: 'Exporteer zichtbare data als pdf',
  11916. exporterSelectedAsPdf: 'Exporteer geselecteerde data als pdf',
  11917. exporterAllAsExcel: 'Exporteer alle data als excel',
  11918. exporterVisibleAsExcel: 'Exporteer zichtbare data als excel',
  11919. exporterSelectedAsExcel: 'Exporteer alle data als excel',
  11920. clearAllFilters: 'Reinig alle filters'
  11921. },
  11922. importer: {
  11923. noHeaders: 'Kolomnamen kunnen niet worden afgeleid. Heeft het bestand een header?',
  11924. noObjects: 'Objecten kunnen niet worden afgeleid. Bevat het bestand data naast de headers?',
  11925. invalidCsv: 'Het bestand kan niet verwerkt worden. Is het een valide csv bestand?',
  11926. invalidJson: 'Het bestand kan niet verwerkt worden. Is het valide json?',
  11927. jsonNotArray: 'Het json bestand moet een array bevatten. De actie wordt geannuleerd.'
  11928. },
  11929. pagination: {
  11930. sizes: 'items per pagina',
  11931. totalItems: 'items',
  11932. of: 'van de'
  11933. },
  11934. grouping: {
  11935. group: 'Groepeer',
  11936. ungroup: 'Groepering opheffen',
  11937. aggregate_count: 'Agg: Aantal',
  11938. aggregate_sum: 'Agg: Som',
  11939. aggregate_max: 'Agg: Max',
  11940. aggregate_min: 'Agg: Min',
  11941. aggregate_avg: 'Agg: Gem',
  11942. aggregate_remove: 'Agg: Verwijder'
  11943. }
  11944. });
  11945. return $delegate;
  11946. }]);
  11947. }]);
  11948. })();
  11949. (function () {
  11950. angular.module('ui.grid').config(['$provide', function($provide) {
  11951. $provide.decorator('i18nService', ['$delegate', function($delegate) {
  11952. $delegate.add('no', {
  11953. headerCell: {
  11954. aria: {
  11955. defaultFilterLabel: 'Filter for kolonne',
  11956. removeFilter: 'Fjern filter',
  11957. columnMenuButtonLabel: 'Kolonnemeny'
  11958. },
  11959. priority: 'Prioritet:',
  11960. filterLabel: "Filter for kolonne: "
  11961. },
  11962. aggregate: {
  11963. label: 'elementer'
  11964. },
  11965. groupPanel: {
  11966. description: 'Trekk en kolonneoverskrift hit og slipp den for å gruppere etter den kolonnen.'
  11967. },
  11968. search: {
  11969. placeholder: 'Søk...',
  11970. showingItems: 'Viste elementer:',
  11971. selectedItems: 'Valgte elementer:',
  11972. totalItems: 'Antall elementer:',
  11973. size: 'Sidestørrelse:',
  11974. first: 'Første side',
  11975. next: 'Neste side',
  11976. previous: 'Forrige side',
  11977. last: 'Siste side'
  11978. },
  11979. menu: {
  11980. text: 'Velg kolonner:'
  11981. },
  11982. sort: {
  11983. ascending: 'Sortere stigende',
  11984. descending: 'Sortere fallende',
  11985. none: 'Ingen sortering',
  11986. remove: 'Fjern sortering'
  11987. },
  11988. column: {
  11989. hide: 'Skjul kolonne'
  11990. },
  11991. aggregation: {
  11992. count: 'antall rader: ',
  11993. sum: 'total: ',
  11994. avg: 'gjennomsnitt: ',
  11995. min: 'minimum: ',
  11996. max: 'maksimum: '
  11997. },
  11998. pinning: {
  11999. pinLeft: 'Fest til venstre',
  12000. pinRight: 'Fest til høyre',
  12001. unpin: 'Løsne'
  12002. },
  12003. columnMenu: {
  12004. close: 'Lukk'
  12005. },
  12006. gridMenu: {
  12007. aria: {
  12008. buttonLabel: 'Grid Menu'
  12009. },
  12010. columns: 'Kolonner:',
  12011. importerTitle: 'Importer fil',
  12012. exporterAllAsCsv: 'Eksporter alle data som csv',
  12013. exporterVisibleAsCsv: 'Eksporter synlige data som csv',
  12014. exporterSelectedAsCsv: 'Eksporter utvalgte data som csv',
  12015. exporterAllAsPdf: 'Eksporter alle data som pdf',
  12016. exporterVisibleAsPdf: 'Eksporter synlige data som pdf',
  12017. exporterSelectedAsPdf: 'Eksporter utvalgte data som pdf',
  12018. exporterAllAsExcel: 'Eksporter alle data som excel',
  12019. exporterVisibleAsExcel: 'Eksporter synlige data som excel',
  12020. exporterSelectedAsExcel: 'Eksporter utvalgte data som excel',
  12021. clearAllFilters: 'Clear all filters'
  12022. },
  12023. importer: {
  12024. noHeaders: 'Kolonnenavn kunne ikke avledes. Har filen en overskrift?',
  12025. noObjects: 'Objekter kunne ikke avledes. Er der andre data i filen enn overskriften?',
  12026. invalidCsv: 'Filen kunne ikke behandles. Er den gyldig CSV?',
  12027. invalidJson: 'Filen kunne ikke behandles. Er den gyldig JSON?',
  12028. jsonNotArray: 'Importert JSON-fil må inneholde en liste. Avbryter.'
  12029. },
  12030. pagination: {
  12031. aria: {
  12032. pageToFirst: 'Gå til første side',
  12033. pageBack: 'Gå til forrige side',
  12034. pageSelected: 'Valgte side',
  12035. pageForward: 'Gå til neste side',
  12036. pageToLast: 'Gå til siste side'
  12037. },
  12038. sizes: 'elementer per side',
  12039. totalItems: 'elementer',
  12040. through: 'til',
  12041. of: 'av'
  12042. },
  12043. grouping: {
  12044. group: 'Gruppere',
  12045. ungroup: 'Fjerne gruppering',
  12046. aggregate_count: 'Agr: Antall',
  12047. aggregate_sum: 'Agr: Sum',
  12048. aggregate_max: 'Agr: Maksimum',
  12049. aggregate_min: 'Agr: Minimum',
  12050. aggregate_avg: 'Agr: Gjennomsnitt',
  12051. aggregate_remove: 'Agr: Fjern'
  12052. }
  12053. });
  12054. return $delegate;
  12055. }]);
  12056. }]);
  12057. })();
  12058. (function () {
  12059. angular.module('ui.grid').config(['$provide', function($provide) {
  12060. $provide.decorator('i18nService', ['$delegate', function($delegate) {
  12061. $delegate.add('pl', {
  12062. headerCell: {
  12063. aria: {
  12064. defaultFilterLabel: 'Filtr dla kolumny',
  12065. removeFilter: 'Usuń filtr',
  12066. columnMenuButtonLabel: 'Opcje kolumny',
  12067. column: 'Kolumna'
  12068. },
  12069. priority: 'Priorytet:',
  12070. filterLabel: "Filtr dla kolumny: "
  12071. },
  12072. aggregate: {
  12073. label: 'pozycji'
  12074. },
  12075. groupPanel: {
  12076. description: 'Przeciągnij nagłówek kolumny tutaj, aby pogrupować według niej.'
  12077. },
  12078. search: {
  12079. aria: {
  12080. selected: 'Wiersz zaznaczony',
  12081. notSelected: 'Wiersz niezaznaczony'
  12082. },
  12083. placeholder: 'Szukaj...',
  12084. showingItems: 'Widoczne pozycje:',
  12085. selectedItems: 'Zaznaczone pozycje:',
  12086. totalItems: 'Wszystkich pozycji:',
  12087. size: 'Rozmiar strony:',
  12088. first: 'Pierwsza strona',
  12089. next: 'Następna strona',
  12090. previous: 'Poprzednia strona',
  12091. last: 'Ostatnia strona'
  12092. },
  12093. menu: {
  12094. text: 'Wybierz kolumny:'
  12095. },
  12096. sort: {
  12097. ascending: 'Sortuj rosnąco',
  12098. descending: 'Sortuj malejąco',
  12099. none: 'Brak sortowania',
  12100. remove: 'Wyłącz sortowanie'
  12101. },
  12102. column: {
  12103. hide: 'Ukryj kolumnę'
  12104. },
  12105. aggregation: {
  12106. count: 'Razem pozycji: ',
  12107. sum: 'Razem: ',
  12108. avg: 'Średnia: ',
  12109. min: 'Min: ',
  12110. max: 'Max: '
  12111. },
  12112. pinning: {
  12113. pinLeft: 'Przypnij do lewej',
  12114. pinRight: 'Przypnij do prawej',
  12115. unpin: 'Odepnij'
  12116. },
  12117. columnMenu: {
  12118. close: 'Zamknij'
  12119. },
  12120. gridMenu: {
  12121. aria: {
  12122. buttonLabel: 'Opcje tabeli'
  12123. },
  12124. columns: 'Kolumny:',
  12125. importerTitle: 'Importuj plik',
  12126. exporterAllAsCsv: 'Eksportuj wszystkie dane do csv',
  12127. exporterVisibleAsCsv: 'Eksportuj widoczne dane do csv',
  12128. exporterSelectedAsCsv: 'Eksportuj zaznaczone dane do csv',
  12129. exporterAllAsPdf: 'Eksportuj wszystkie dane do pdf',
  12130. exporterVisibleAsPdf: 'Eksportuj widoczne dane do pdf',
  12131. exporterSelectedAsPdf: 'Eksportuj zaznaczone dane do pdf',
  12132. exporterAllAsExcel: 'Eksportuj wszystkie dane do excel',
  12133. exporterVisibleAsExcel: 'Eksportuj widoczne dane do excel',
  12134. exporterSelectedAsExcel: 'Eksportuj zaznaczone dane do excel',
  12135. clearAllFilters: 'Wyczyść filtry'
  12136. },
  12137. importer: {
  12138. noHeaders: 'Nie udało się wczytać nazw kolumn. Czy plik posiada nagłówek?',
  12139. noObjects: 'Nie udalo się wczytać pozycji. Czy plik zawiera dane?',
  12140. invalidCsv: 'Nie udało się przetworzyć pliku. Czy to prawidłowy plik CSV?',
  12141. invalidJson: 'Nie udało się przetworzyć pliku. Czy to prawidłowy plik JSON?',
  12142. jsonNotArray: 'Importowany plik JSON musi zawierać tablicę. Importowanie przerwane.'
  12143. },
  12144. pagination: {
  12145. aria: {
  12146. pageToFirst: 'Pierwsza strona',
  12147. pageBack: 'Poprzednia strona',
  12148. pageSelected: 'Wybrana strona',
  12149. pageForward: 'Następna strona',
  12150. pageToLast: 'Ostatnia strona'
  12151. },
  12152. sizes: 'pozycji na stronę',
  12153. totalItems: 'pozycji',
  12154. through: 'do',
  12155. of: 'z'
  12156. },
  12157. grouping: {
  12158. group: 'Grupuj',
  12159. ungroup: 'Rozgrupuj',
  12160. aggregate_count: 'Zbiorczo: Razem',
  12161. aggregate_sum: 'Zbiorczo: Suma',
  12162. aggregate_max: 'Zbiorczo: Max',
  12163. aggregate_min: 'Zbiorczo: Min',
  12164. aggregate_avg: 'Zbiorczo: Średnia',
  12165. aggregate_remove: 'Zbiorczo: Usuń'
  12166. },
  12167. validate: {
  12168. error: 'Błąd:',
  12169. minLength: 'Wartość powinna składać się z co najmniej THRESHOLD znaków.',
  12170. maxLength: 'Wartość powinna składać się z przynajmniej THRESHOLD znaków.',
  12171. required: 'Wartość jest wymagana.'
  12172. }
  12173. });
  12174. return $delegate;
  12175. }]);
  12176. }]);
  12177. })();
  12178. (function () {
  12179. angular.module('ui.grid').config(['$provide', function($provide) {
  12180. $provide.decorator('i18nService', ['$delegate', function($delegate) {
  12181. $delegate.add('pt-br', {
  12182. headerCell: {
  12183. aria: {
  12184. defaultFilterLabel: 'Filtro por coluna',
  12185. removeFilter: 'Remover filtro',
  12186. columnMenuButtonLabel: 'Menu coluna'
  12187. },
  12188. priority: 'Prioridade:',
  12189. filterLabel: "Filtro por coluna: "
  12190. },
  12191. aggregate: {
  12192. label: 'itens'
  12193. },
  12194. groupPanel: {
  12195. description: 'Arraste e solte uma coluna aqui para agrupar por essa coluna'
  12196. },
  12197. search: {
  12198. placeholder: 'Procurar...',
  12199. showingItems: 'Mostrando os Itens:',
  12200. selectedItems: 'Items Selecionados:',
  12201. totalItems: 'Total de Itens:',
  12202. size: 'Tamanho da Página:',
  12203. first: 'Primeira Página',
  12204. next: 'Próxima Página',
  12205. previous: 'Página Anterior',
  12206. last: 'Última Página'
  12207. },
  12208. menu: {
  12209. text: 'Selecione as colunas:'
  12210. },
  12211. sort: {
  12212. ascending: 'Ordenar Ascendente',
  12213. descending: 'Ordenar Descendente',
  12214. none: 'Nenhuma Ordem',
  12215. remove: 'Remover Ordenação'
  12216. },
  12217. column: {
  12218. hide: 'Esconder coluna'
  12219. },
  12220. aggregation: {
  12221. count: 'total de linhas: ',
  12222. sum: 'total: ',
  12223. avg: 'med: ',
  12224. min: 'min: ',
  12225. max: 'max: '
  12226. },
  12227. pinning: {
  12228. pinLeft: 'Fixar Esquerda',
  12229. pinRight: 'Fixar Direita',
  12230. unpin: 'Desprender'
  12231. },
  12232. columnMenu: {
  12233. close: 'Fechar'
  12234. },
  12235. gridMenu: {
  12236. aria: {
  12237. buttonLabel: 'Menu Grid'
  12238. },
  12239. columns: 'Colunas:',
  12240. importerTitle: 'Importar arquivo',
  12241. exporterAllAsCsv: 'Exportar todos os dados como csv',
  12242. exporterVisibleAsCsv: 'Exportar dados visíveis como csv',
  12243. exporterSelectedAsCsv: 'Exportar dados selecionados como csv',
  12244. exporterAllAsPdf: 'Exportar todos os dados como pdf',
  12245. exporterVisibleAsPdf: 'Exportar dados visíveis como pdf',
  12246. exporterSelectedAsPdf: 'Exportar dados selecionados como pdf',
  12247. exporterAllAsExcel: 'Exportar todos os dados como excel',
  12248. exporterVisibleAsExcel: 'Exportar dados visíveis como excel',
  12249. clearAllFilters: 'Limpar todos os filtros'
  12250. },
  12251. importer: {
  12252. noHeaders: 'Nomes de colunas não puderam ser derivados. O arquivo tem um cabeçalho?',
  12253. noObjects: 'Objetos não puderam ser derivados. Havia dados no arquivo, além dos cabeçalhos?',
  12254. invalidCsv: 'Arquivo não pode ser processado. É um CSV válido?',
  12255. invalidJson: 'Arquivo não pode ser processado. É um Json válido?',
  12256. jsonNotArray: 'Arquivo json importado tem que conter um array. Abortando.'
  12257. },
  12258. pagination: {
  12259. aria: {
  12260. pageToFirst: 'Primeira página',
  12261. pageBack: 'Página anterior',
  12262. pageSelected: 'Página Selecionada',
  12263. pageForward: 'Proxima',
  12264. pageToLast: 'Anterior'
  12265. },
  12266. sizes: 'itens por página',
  12267. totalItems: 'itens',
  12268. through: 'através dos',
  12269. of: 'de'
  12270. },
  12271. grouping: {
  12272. group: 'Agrupar',
  12273. ungroup: 'Desagrupar',
  12274. aggregate_count: 'Agr: Contar',
  12275. aggregate_sum: 'Agr: Soma',
  12276. aggregate_max: 'Agr: Max',
  12277. aggregate_min: 'Agr: Min',
  12278. aggregate_avg: 'Agr: Med',
  12279. aggregate_remove: 'Agr: Remover'
  12280. }
  12281. });
  12282. return $delegate;
  12283. }]);
  12284. }]);
  12285. })();
  12286. (function () {
  12287. angular.module('ui.grid').config(['$provide', function($provide) {
  12288. $provide.decorator('i18nService', ['$delegate', function($delegate) {
  12289. $delegate.add('pt', {
  12290. headerCell: {
  12291. aria: {
  12292. defaultFilterLabel: 'Filtro por coluna',
  12293. removeFilter: 'Remover filtro',
  12294. columnMenuButtonLabel: 'Menu coluna'
  12295. },
  12296. priority: 'Prioridade:',
  12297. filterLabel: "Filtro por coluna: "
  12298. },
  12299. aggregate: {
  12300. label: 'itens'
  12301. },
  12302. groupPanel: {
  12303. description: 'Arraste e solte uma coluna aqui para agrupar por essa coluna'
  12304. },
  12305. search: {
  12306. placeholder: 'Procurar...',
  12307. showingItems: 'Mostrando os Itens:',
  12308. selectedItems: 'Itens Selecionados:',
  12309. totalItems: 'Total de Itens:',
  12310. size: 'Tamanho da Página:',
  12311. first: 'Primeira Página',
  12312. next: 'Próxima Página',
  12313. previous: 'Página Anterior',
  12314. last: 'Última Página'
  12315. },
  12316. menu: {
  12317. text: 'Selecione as colunas:'
  12318. },
  12319. sort: {
  12320. ascending: 'Ordenar Ascendente',
  12321. descending: 'Ordenar Descendente',
  12322. none: 'Nenhuma Ordem',
  12323. remove: 'Remover Ordenação'
  12324. },
  12325. column: {
  12326. hide: 'Esconder coluna'
  12327. },
  12328. aggregation: {
  12329. count: 'total de linhas: ',
  12330. sum: 'total: ',
  12331. avg: 'med: ',
  12332. min: 'min: ',
  12333. max: 'max: '
  12334. },
  12335. pinning: {
  12336. pinLeft: 'Fixar Esquerda',
  12337. pinRight: 'Fixar Direita',
  12338. unpin: 'Desprender'
  12339. },
  12340. columnMenu: {
  12341. close: 'Fechar'
  12342. },
  12343. gridMenu: {
  12344. aria: {
  12345. buttonLabel: 'Menu Grid'
  12346. },
  12347. columns: 'Colunas:',
  12348. importerTitle: 'Importar ficheiro',
  12349. exporterAllAsCsv: 'Exportar todos os dados como csv',
  12350. exporterVisibleAsCsv: 'Exportar dados visíveis como csv',
  12351. exporterSelectedAsCsv: 'Exportar dados selecionados como csv',
  12352. exporterAllAsPdf: 'Exportar todos os dados como pdf',
  12353. exporterVisibleAsPdf: 'Exportar dados visíveis como pdf',
  12354. exporterSelectedAsPdf: 'Exportar dados selecionados como pdf',
  12355. clearAllFilters: 'Limpar todos os filtros'
  12356. },
  12357. importer: {
  12358. noHeaders: 'Nomes de colunas não puderam ser derivados. O ficheiro tem um cabeçalho?',
  12359. noObjects: 'Objetos não puderam ser derivados. Havia dados no ficheiro, além dos cabeçalhos?',
  12360. invalidCsv: 'Ficheiro não pode ser processado. É um CSV válido?',
  12361. invalidJson: 'Ficheiro não pode ser processado. É um Json válido?',
  12362. jsonNotArray: 'Ficheiro json importado tem que conter um array. Interrompendo.'
  12363. },
  12364. pagination: {
  12365. aria: {
  12366. pageToFirst: 'Primeira página',
  12367. pageBack: 'Página anterior',
  12368. pageSelected: 'Página Selecionada',
  12369. pageForward: 'Próxima',
  12370. pageToLast: 'Anterior'
  12371. },
  12372. sizes: 'itens por página',
  12373. totalItems: 'itens',
  12374. through: 'a',
  12375. of: 'de'
  12376. },
  12377. grouping: {
  12378. group: 'Agrupar',
  12379. ungroup: 'Desagrupar',
  12380. aggregate_count: 'Agr: Contar',
  12381. aggregate_sum: 'Agr: Soma',
  12382. aggregate_max: 'Agr: Max',
  12383. aggregate_min: 'Agr: Min',
  12384. aggregate_avg: 'Agr: Med',
  12385. aggregate_remove: 'Agr: Remover'
  12386. }
  12387. });
  12388. return $delegate;
  12389. }]);
  12390. }]);
  12391. })();
  12392. (function () {
  12393. angular.module('ui.grid').config(['$provide', function($provide) {
  12394. $provide.decorator('i18nService', ['$delegate', function($delegate) {
  12395. $delegate.add('ro', {
  12396. headerCell: {
  12397. aria: {
  12398. defaultFilterLabel: 'Filtru pentru coloana',
  12399. removeFilter: 'Sterge filtru',
  12400. columnMenuButtonLabel: 'Column Menu'
  12401. },
  12402. priority: 'Prioritate:',
  12403. filterLabel: "Filtru pentru coloana:"
  12404. },
  12405. aggregate: {
  12406. label: 'Elemente'
  12407. },
  12408. groupPanel: {
  12409. description: 'Trage un cap de coloana aici pentru a grupa elementele dupa coloana respectiva'
  12410. },
  12411. search: {
  12412. placeholder: 'Cauta...',
  12413. showingItems: 'Arata elementele:',
  12414. selectedItems: 'Elementele selectate:',
  12415. totalItems: 'Total elemente:',
  12416. size: 'Marime pagina:',
  12417. first: 'Prima pagina',
  12418. next: 'Pagina urmatoare',
  12419. previous: 'Pagina anterioara',
  12420. last: 'Ultima pagina'
  12421. },
  12422. menu: {
  12423. text: 'Alege coloane:'
  12424. },
  12425. sort: {
  12426. ascending: 'Ordoneaza crescator',
  12427. descending: 'Ordoneaza descrescator',
  12428. none: 'Fara ordonare',
  12429. remove: 'Sterge ordonarea'
  12430. },
  12431. column: {
  12432. hide: 'Ascunde coloana'
  12433. },
  12434. aggregation: {
  12435. count: 'total linii: ',
  12436. sum: 'total: ',
  12437. avg: 'medie: ',
  12438. min: 'min: ',
  12439. max: 'max: '
  12440. },
  12441. pinning: {
  12442. pinLeft: 'Pin la stanga',
  12443. pinRight: 'Pin la dreapta',
  12444. unpin: 'Sterge pinul'
  12445. },
  12446. columnMenu: {
  12447. close: 'Inchide'
  12448. },
  12449. gridMenu: {
  12450. aria: {
  12451. buttonLabel: 'Grid Menu'
  12452. },
  12453. columns: 'Coloane:',
  12454. importerTitle: 'Incarca fisier',
  12455. exporterAllAsCsv: 'Exporta toate datele ca csv',
  12456. exporterVisibleAsCsv: 'Exporta datele vizibile ca csv',
  12457. exporterSelectedAsCsv: 'Exporta datele selectate ca csv',
  12458. exporterAllAsPdf: 'Exporta toate datele ca pdf',
  12459. exporterVisibleAsPdf: 'Exporta datele vizibile ca pdf',
  12460. exporterSelectedAsPdf: 'Exporta datele selectate ca csv pdf',
  12461. clearAllFilters: 'Sterge toate filtrele'
  12462. },
  12463. importer: {
  12464. noHeaders: 'Numele coloanelor nu a putut fi incarcat, acest fisier are un header?',
  12465. noObjects: 'Datele nu au putut fi incarcate, exista date in fisier in afara numelor de coloane?',
  12466. invalidCsv: 'Fisierul nu a putut fi procesat, ati incarcat un CSV valid ?',
  12467. invalidJson: 'Fisierul nu a putut fi procesat, ati incarcat un Json valid?',
  12468. jsonNotArray: 'Json-ul incarcat trebuie sa contina un array, inchidere.'
  12469. },
  12470. pagination: {
  12471. aria: {
  12472. pageToFirst: 'Prima pagina',
  12473. pageBack: 'O pagina inapoi',
  12474. pageSelected: 'Pagina selectata',
  12475. pageForward: 'O pagina inainte',
  12476. pageToLast: 'Ultima pagina'
  12477. },
  12478. sizes: 'Elemente per pagina',
  12479. totalItems: 'elemente',
  12480. through: 'prin',
  12481. of: 'of'
  12482. },
  12483. grouping: {
  12484. group: 'Grupeaza',
  12485. ungroup: 'Opreste gruparea',
  12486. aggregate_count: 'Agg: Count',
  12487. aggregate_sum: 'Agg: Sum',
  12488. aggregate_max: 'Agg: Max',
  12489. aggregate_min: 'Agg: Min',
  12490. aggregate_avg: 'Agg: Avg',
  12491. aggregate_remove: 'Agg: Remove'
  12492. }
  12493. });
  12494. return $delegate;
  12495. }]);
  12496. }]);
  12497. })();
  12498. (function () {
  12499. angular.module('ui.grid').config(['$provide', function($provide) {
  12500. $provide.decorator('i18nService', ['$delegate', function($delegate) {
  12501. $delegate.add('ru', {
  12502. headerCell: {
  12503. aria: {
  12504. defaultFilterLabel: 'Фильтр столбца',
  12505. removeFilter: 'Удалить фильтр',
  12506. columnMenuButtonLabel: 'Меню столбца'
  12507. },
  12508. priority: 'Приоритет:',
  12509. filterLabel: "Фильтр столбца: "
  12510. },
  12511. aggregate: {
  12512. label: 'элементы'
  12513. },
  12514. groupPanel: {
  12515. description: 'Для группировки по столбцу перетащите сюда его название.'
  12516. },
  12517. search: {
  12518. placeholder: 'Поиск...',
  12519. showingItems: 'Показать элементы:',
  12520. selectedItems: 'Выбранные элементы:',
  12521. totalItems: 'Всего элементов:',
  12522. size: 'Размер страницы:',
  12523. first: 'Первая страница',
  12524. next: 'Следующая страница',
  12525. previous: 'Предыдущая страница',
  12526. last: 'Последняя страница'
  12527. },
  12528. menu: {
  12529. text: 'Выбрать столбцы:'
  12530. },
  12531. sort: {
  12532. ascending: 'По возрастанию',
  12533. descending: 'По убыванию',
  12534. none: 'Без сортировки',
  12535. remove: 'Убрать сортировку'
  12536. },
  12537. column: {
  12538. hide: 'Спрятать столбец'
  12539. },
  12540. aggregation: {
  12541. count: 'всего строк: ',
  12542. sum: 'итого: ',
  12543. avg: 'среднее: ',
  12544. min: 'мин: ',
  12545. max: 'макс: '
  12546. },
  12547. pinning: {
  12548. pinLeft: 'Закрепить слева',
  12549. pinRight: 'Закрепить справа',
  12550. unpin: 'Открепить'
  12551. },
  12552. columnMenu: {
  12553. close: 'Закрыть'
  12554. },
  12555. gridMenu: {
  12556. aria: {
  12557. buttonLabel: 'Меню'
  12558. },
  12559. columns: 'Столбцы:',
  12560. importerTitle: 'Импортировать файл',
  12561. exporterAllAsCsv: 'Экспортировать всё в CSV',
  12562. exporterVisibleAsCsv: 'Экспортировать видимые данные в CSV',
  12563. exporterSelectedAsCsv: 'Экспортировать выбранные данные в CSV',
  12564. exporterAllAsPdf: 'Экспортировать всё в PDF',
  12565. exporterVisibleAsPdf: 'Экспортировать видимые данные в PDF',
  12566. exporterSelectedAsPdf: 'Экспортировать выбранные данные в PDF',
  12567. clearAllFilters: 'Очистите все фильтры'
  12568. },
  12569. importer: {
  12570. noHeaders: 'Не удалось получить названия столбцов, есть ли в файле заголовок?',
  12571. noObjects: 'Не удалось получить данные, есть ли в файле строки кроме заголовка?',
  12572. invalidCsv: 'Не удалось обработать файл, это правильный CSV-файл?',
  12573. invalidJson: 'Не удалось обработать файл, это правильный JSON?',
  12574. jsonNotArray: 'Импортируемый JSON-файл должен содержать массив, операция отменена.'
  12575. },
  12576. pagination: {
  12577. aria: {
  12578. pageToFirst: 'Первая страница',
  12579. pageBack: 'Предыдущая страница',
  12580. pageSelected: 'Выбранная страница',
  12581. pageForward: 'Следующая страница',
  12582. pageToLast: 'Последняя страница'
  12583. },
  12584. sizes: 'строк на страницу',
  12585. totalItems: 'строк',
  12586. through: 'по',
  12587. of: 'из'
  12588. },
  12589. grouping: {
  12590. group: 'Группировать',
  12591. ungroup: 'Разгруппировать',
  12592. aggregate_count: 'Группировать: Count',
  12593. aggregate_sum: 'Для группы: Сумма',
  12594. aggregate_max: 'Для группы: Максимум',
  12595. aggregate_min: 'Для группы: Минимум',
  12596. aggregate_avg: 'Для группы: Среднее',
  12597. aggregate_remove: 'Для группы: Пусто'
  12598. }
  12599. });
  12600. return $delegate;
  12601. }]);
  12602. }]);
  12603. })();
  12604. (function () {
  12605. angular.module('ui.grid').config(['$provide', function($provide) {
  12606. $provide.decorator('i18nService', ['$delegate', function($delegate) {
  12607. $delegate.add('sk', {
  12608. aggregate: {
  12609. label: 'items'
  12610. },
  12611. groupPanel: {
  12612. description: 'Pretiahni sem názov stĺpca pre zoskupenie podľa toho stĺpca.'
  12613. },
  12614. search: {
  12615. placeholder: 'Hľadaj...',
  12616. showingItems: 'Zobrazujem položky:',
  12617. selectedItems: 'Vybraté položky:',
  12618. totalItems: 'Počet položiek:',
  12619. size: 'Počet:',
  12620. first: 'Prvá strana',
  12621. next: 'Ďalšia strana',
  12622. previous: 'Predchádzajúca strana',
  12623. last: 'Posledná strana'
  12624. },
  12625. menu: {
  12626. text: 'Vyberte stĺpce:'
  12627. },
  12628. sort: {
  12629. ascending: 'Zotriediť vzostupne',
  12630. descending: 'Zotriediť zostupne',
  12631. remove: 'Vymazať triedenie'
  12632. },
  12633. aggregation: {
  12634. count: 'total rows: ',
  12635. sum: 'total: ',
  12636. avg: 'avg: ',
  12637. min: 'min: ',
  12638. max: 'max: '
  12639. },
  12640. gridMenu: {
  12641. columns: 'Columns:',
  12642. importerTitle: 'Import file',
  12643. exporterAllAsCsv: 'Export all data as csv',
  12644. exporterVisibleAsCsv: 'Export visible data as csv',
  12645. exporterSelectedAsCsv: 'Export selected data as csv',
  12646. exporterAllAsPdf: 'Export all data as pdf',
  12647. exporterVisibleAsPdf: 'Export visible data as pdf',
  12648. exporterSelectedAsPdf: 'Export selected data as pdf',
  12649. exporterAllAsExcel: 'Export all data as excel',
  12650. exporterVisibleAsExcel: 'Export visible data as excel',
  12651. exporterSelectedAsExcel: 'Export selected data as excel',
  12652. clearAllFilters: 'Clear all filters'
  12653. },
  12654. importer: {
  12655. noHeaders: 'Column names were unable to be derived, does the file have a header?',
  12656. noObjects: 'Objects were not able to be derived, was there data in the file other than headers?',
  12657. invalidCsv: 'File was unable to be processed, is it valid CSV?',
  12658. invalidJson: 'File was unable to be processed, is it valid Json?',
  12659. jsonNotArray: 'Imported json file must contain an array, aborting.'
  12660. }
  12661. });
  12662. return $delegate;
  12663. }]);
  12664. }]);
  12665. })();
  12666. (function () {
  12667. angular.module('ui.grid').config(['$provide', function($provide) {
  12668. $provide.decorator('i18nService', ['$delegate', function($delegate) {
  12669. $delegate.add('sv', {
  12670. aggregate: {
  12671. label: 'Artiklar'
  12672. },
  12673. groupPanel: {
  12674. description: 'Dra en kolumnrubrik hit och släpp den för att gruppera efter den kolumnen.'
  12675. },
  12676. search: {
  12677. placeholder: 'Sök...',
  12678. showingItems: 'Visar artiklar:',
  12679. selectedItems: 'Valda artiklar:',
  12680. totalItems: 'Antal artiklar:',
  12681. size: 'Sidstorlek:',
  12682. first: 'Första sidan',
  12683. next: 'Nästa sida',
  12684. previous: 'Föregående sida',
  12685. last: 'Sista sidan'
  12686. },
  12687. menu: {
  12688. text: 'Välj kolumner:'
  12689. },
  12690. sort: {
  12691. ascending: 'Sortera stigande',
  12692. descending: 'Sortera fallande',
  12693. remove: 'Inaktivera sortering'
  12694. },
  12695. column: {
  12696. hide: 'Göm kolumn'
  12697. },
  12698. aggregation: {
  12699. count: 'Antal rader: ',
  12700. sum: 'Summa: ',
  12701. avg: 'Genomsnitt: ',
  12702. min: 'Min: ',
  12703. max: 'Max: '
  12704. },
  12705. pinning: {
  12706. pinLeft: 'Fäst vänster',
  12707. pinRight: 'Fäst höger',
  12708. unpin: 'Lösgör'
  12709. },
  12710. gridMenu: {
  12711. columns: 'Kolumner:',
  12712. importerTitle: 'Importera fil',
  12713. exporterAllAsCsv: 'Exportera all data som CSV',
  12714. exporterVisibleAsCsv: 'Exportera synlig data som CSV',
  12715. exporterSelectedAsCsv: 'Exportera markerad data som CSV',
  12716. exporterAllAsPdf: 'Exportera all data som PDF',
  12717. exporterVisibleAsPdf: 'Exportera synlig data som PDF',
  12718. exporterSelectedAsPdf: 'Exportera markerad data som PDF',
  12719. clearAllFilters: 'Rengör alla filter'
  12720. },
  12721. importer: {
  12722. noHeaders: 'Kolumnnamn kunde inte härledas. Har filen ett sidhuvud?',
  12723. noObjects: 'Objekt kunde inte härledas. Har filen data undantaget sidhuvud?',
  12724. invalidCsv: 'Filen kunde inte behandlas, är den en giltig CSV?',
  12725. invalidJson: 'Filen kunde inte behandlas, är den en giltig JSON?',
  12726. jsonNotArray: 'Importerad JSON-fil måste innehålla ett fält. Import avbruten.'
  12727. },
  12728. pagination: {
  12729. sizes: 'Artiklar per sida',
  12730. totalItems: 'Artiklar'
  12731. }
  12732. });
  12733. return $delegate;
  12734. }]);
  12735. }]);
  12736. })();
  12737. (function () {
  12738. angular.module('ui.grid').config(['$provide', function($provide) {
  12739. $provide.decorator('i18nService', ['$delegate', function($delegate) {
  12740. $delegate.add('ta', {
  12741. aggregate: {
  12742. label: 'உருப்படிகள்'
  12743. },
  12744. groupPanel: {
  12745. description: 'ஒரு பத்தியை குழுவாக அமைக்க அப்பத்தியின் தலைப்பை இங்கே இழுத்து வரவும் '
  12746. },
  12747. search: {
  12748. placeholder: 'தேடல் ...',
  12749. showingItems: 'உருப்படிகளை காண்பித்தல்:',
  12750. selectedItems: 'தேர்ந்தெடுக்கப்பட்ட உருப்படிகள்:',
  12751. totalItems: 'மொத்த உருப்படிகள்:',
  12752. size: 'பக்க அளவு: ',
  12753. first: 'முதல் பக்கம்',
  12754. next: 'அடுத்த பக்கம்',
  12755. previous: 'முந்தைய பக்கம் ',
  12756. last: 'இறுதி பக்கம்'
  12757. },
  12758. menu: {
  12759. text: 'பத்திகளை தேர்ந்தெடு:'
  12760. },
  12761. sort: {
  12762. ascending: 'மேலிருந்து கீழாக',
  12763. descending: 'கீழிருந்து மேலாக',
  12764. remove: 'வரிசையை நீக்கு'
  12765. },
  12766. column: {
  12767. hide: 'பத்தியை மறைத்து வை '
  12768. },
  12769. aggregation: {
  12770. count: 'மொத்த வரிகள்:',
  12771. sum: 'மொத்தம்: ',
  12772. avg: 'சராசரி: ',
  12773. min: 'குறைந்தபட்ச: ',
  12774. max: 'அதிகபட்ச: '
  12775. },
  12776. pinning: {
  12777. pinLeft: 'இடதுபுறமாக தைக்க ',
  12778. pinRight: 'வலதுபுறமாக தைக்க',
  12779. unpin: 'பிரி'
  12780. },
  12781. gridMenu: {
  12782. columns: 'பத்திகள்:',
  12783. importerTitle: 'கோப்பு : படித்தல்',
  12784. exporterAllAsCsv: 'எல்லா தரவுகளையும் கோப்பாக்கு: csv',
  12785. exporterVisibleAsCsv: 'இருக்கும் தரவுகளை கோப்பாக்கு: csv',
  12786. exporterSelectedAsCsv: 'தேர்ந்தெடுத்த தரவுகளை கோப்பாக்கு: csv',
  12787. exporterAllAsPdf: 'எல்லா தரவுகளையும் கோப்பாக்கு: pdf',
  12788. exporterVisibleAsPdf: 'இருக்கும் தரவுகளை கோப்பாக்கு: pdf',
  12789. exporterSelectedAsPdf: 'தேர்ந்தெடுத்த தரவுகளை கோப்பாக்கு: pdf',
  12790. clearAllFilters: 'Clear all filters'
  12791. },
  12792. importer: {
  12793. noHeaders: 'பத்தியின் தலைப்புகளை பெற இயலவில்லை, கோப்பிற்கு தலைப்பு உள்ளதா?',
  12794. noObjects: 'இலக்குகளை உருவாக்க முடியவில்லை, கோப்பில் தலைப்புகளை தவிர தரவு ஏதேனும் உள்ளதா? ',
  12795. invalidCsv: 'சரிவர நடைமுறை படுத்த இயலவில்லை, கோப்பு சரிதானா? - csv',
  12796. invalidJson: 'சரிவர நடைமுறை படுத்த இயலவில்லை, கோப்பு சரிதானா? - json',
  12797. jsonNotArray: 'படித்த கோப்பில் வரிசைகள் உள்ளது, நடைமுறை ரத்து செய் : json'
  12798. },
  12799. pagination: {
  12800. sizes : 'உருப்படிகள் / பக்கம்',
  12801. totalItems : 'உருப்படிகள் '
  12802. },
  12803. grouping: {
  12804. group : 'குழு',
  12805. ungroup : 'பிரி',
  12806. aggregate_count : 'மதிப்பீட்டு : எண்ணு',
  12807. aggregate_sum : 'மதிப்பீட்டு : கூட்டல்',
  12808. aggregate_max : 'மதிப்பீட்டு : அதிகபட்சம்',
  12809. aggregate_min : 'மதிப்பீட்டு : குறைந்தபட்சம்',
  12810. aggregate_avg : 'மதிப்பீட்டு : சராசரி',
  12811. aggregate_remove : 'மதிப்பீட்டு : நீக்கு'
  12812. }
  12813. });
  12814. return $delegate;
  12815. }]);
  12816. }]);
  12817. })();
  12818. (function () {
  12819. angular.module('ui.grid').config(['$provide', function($provide) {
  12820. $provide.decorator('i18nService', ['$delegate', function($delegate) {
  12821. $delegate.add('tr', {
  12822. headerCell: {
  12823. aria: {
  12824. defaultFilterLabel: 'Sütun için filtre',
  12825. removeFilter: 'Filtreyi Kaldır',
  12826. columnMenuButtonLabel: 'Sütun Menüsü'
  12827. },
  12828. priority: 'Öncelik:',
  12829. filterLabel: "Sütun için filtre: "
  12830. },
  12831. aggregate: {
  12832. label: 'kayıtlar'
  12833. },
  12834. groupPanel: {
  12835. description: 'Sütuna göre gruplamak için sütun başlığını buraya sürükleyin ve bırakın.'
  12836. },
  12837. search: {
  12838. placeholder: 'Arama...',
  12839. showingItems: 'Gösterilen Kayıt:',
  12840. selectedItems: 'Seçili Kayıt:',
  12841. totalItems: 'Toplam Kayıt:',
  12842. size: 'Sayfa Boyutu:',
  12843. first: 'İlk Sayfa',
  12844. next: 'Sonraki Sayfa',
  12845. previous: 'Önceki Sayfa',
  12846. last: 'Son Sayfa'
  12847. },
  12848. menu: {
  12849. text: 'Sütunları Seç:'
  12850. },
  12851. sort: {
  12852. ascending: 'Artan Sırada Sırala',
  12853. descending: 'Azalan Sırada Sırala',
  12854. none: 'Sıralama Yapma',
  12855. remove: 'Sıralamayı Kaldır'
  12856. },
  12857. column: {
  12858. hide: 'Sütunu Gizle'
  12859. },
  12860. aggregation: {
  12861. count: 'toplam satır: ',
  12862. sum: 'toplam: ',
  12863. avg: 'ort: ',
  12864. min: 'min: ',
  12865. max: 'maks: '
  12866. },
  12867. pinning: {
  12868. pinLeft: 'Sola Sabitle',
  12869. pinRight: 'Sağa Sabitle',
  12870. unpin: 'Sabitlemeyi Kaldır'
  12871. },
  12872. columnMenu: {
  12873. close: 'Kapat'
  12874. },
  12875. gridMenu: {
  12876. aria: {
  12877. buttonLabel: 'Tablo Menü'
  12878. },
  12879. columns: 'Sütunlar:',
  12880. importerTitle: 'Dosya içeri aktar',
  12881. exporterAllAsCsv: 'Bütün veriyi CSV olarak dışarı aktar',
  12882. exporterVisibleAsCsv: 'Görünen veriyi CSV olarak dışarı aktar',
  12883. exporterSelectedAsCsv: 'Seçili veriyi CSV olarak dışarı aktar',
  12884. exporterAllAsPdf: 'Bütün veriyi PDF olarak dışarı aktar',
  12885. exporterVisibleAsPdf: 'Görünen veriyi PDF olarak dışarı aktar',
  12886. exporterSelectedAsPdf: 'Seçili veriyi PDF olarak dışarı aktar',
  12887. clearAllFilters: 'Bütün filtreleri kaldır'
  12888. },
  12889. importer: {
  12890. noHeaders: 'Sütun isimleri üretilemiyor, dosyanın bir başlığı var mı?',
  12891. noObjects: 'Nesneler üretilemiyor, dosyada başlıktan başka bir veri var mı?',
  12892. invalidCsv: 'Dosya işlenemedi, geçerli bir CSV dosyası mı?',
  12893. invalidJson: 'Dosya işlenemedi, geçerli bir Json dosyası mı?',
  12894. jsonNotArray: 'Alınan Json dosyasında bir dizi bulunmalıdır, işlem iptal ediliyor.'
  12895. },
  12896. pagination: {
  12897. aria: {
  12898. pageToFirst: 'İlk sayfaya',
  12899. pageBack: 'Geri git',
  12900. pageSelected: 'Seçili sayfa',
  12901. pageForward: 'İleri git',
  12902. pageToLast: 'Sona git'
  12903. },
  12904. sizes: 'Sayfadaki nesne sayısı',
  12905. totalItems: 'kayıtlar',
  12906. through: '', //note(fsw) : turkish dont have this preposition
  12907. of: '' //note(fsw) : turkish dont have this preposition
  12908. },
  12909. grouping: {
  12910. group: 'Grupla',
  12911. ungroup: 'Gruplama',
  12912. aggregate_count: 'Yekun: Sayı',
  12913. aggregate_sum: 'Yekun: Toplam',
  12914. aggregate_max: 'Yekun: Maks',
  12915. aggregate_min: 'Yekun: Min',
  12916. aggregate_avg: 'Yekun: Ort',
  12917. aggregate_remove: 'Yekun: Sil'
  12918. }
  12919. });
  12920. return $delegate;
  12921. }]);
  12922. }]);
  12923. })();
  12924. (function () {
  12925. angular.module('ui.grid').config(['$provide', function($provide) {
  12926. $provide.decorator('i18nService', ['$delegate', function($delegate) {
  12927. $delegate.add('ua', {
  12928. headerCell: {
  12929. aria: {
  12930. defaultFilterLabel: 'Фільтр стовпчика',
  12931. removeFilter: 'Видалити фільтр',
  12932. columnMenuButtonLabel: 'Меню ствпчика'
  12933. },
  12934. priority: 'Пріоритет:',
  12935. filterLabel: "Фільтр стовпчика: "
  12936. },
  12937. aggregate: {
  12938. label: 'елементи'
  12939. },
  12940. groupPanel: {
  12941. description: 'Для групування за стовпчиком перетягніть сюди його назву.'
  12942. },
  12943. search: {
  12944. placeholder: 'Пошук...',
  12945. showingItems: 'Показати елементи:',
  12946. selectedItems: 'Обрані елементи:',
  12947. totalItems: 'Усього елементів:',
  12948. size: 'Розмір сторінки:',
  12949. first: 'Перша сторінка',
  12950. next: 'Наступна сторінка',
  12951. previous: 'Попередня сторінка',
  12952. last: 'Остання сторінка'
  12953. },
  12954. menu: {
  12955. text: 'Обрати ствпчики:'
  12956. },
  12957. sort: {
  12958. ascending: 'За зростанням',
  12959. descending: 'За спаданням',
  12960. none: 'Без сортування',
  12961. remove: 'Прибрати сортування'
  12962. },
  12963. column: {
  12964. hide: 'Приховати стовпчик'
  12965. },
  12966. aggregation: {
  12967. count: 'усього рядків: ',
  12968. sum: 'ітого: ',
  12969. avg: 'середнє: ',
  12970. min: 'мін: ',
  12971. max: 'макс: '
  12972. },
  12973. pinning: {
  12974. pinLeft: 'Закріпити ліворуч',
  12975. pinRight: 'Закріпити праворуч',
  12976. unpin: 'Відкріпити'
  12977. },
  12978. columnMenu: {
  12979. close: 'Закрити'
  12980. },
  12981. gridMenu: {
  12982. aria: {
  12983. buttonLabel: 'Меню'
  12984. },
  12985. columns: 'Стовпчики:',
  12986. importerTitle: 'Імпортувати файл',
  12987. exporterAllAsCsv: 'Експортувати все в CSV',
  12988. exporterVisibleAsCsv: 'Експортувати видимі дані в CSV',
  12989. exporterSelectedAsCsv: 'Експортувати обрані дані в CSV',
  12990. exporterAllAsPdf: 'Експортувати все в PDF',
  12991. exporterVisibleAsPdf: 'Експортувати видимі дані в PDF',
  12992. exporterSelectedAsPdf: 'Експортувати обрані дані в PDF',
  12993. clearAllFilters: 'Очистити всі фільтри'
  12994. },
  12995. importer: {
  12996. noHeaders: 'Не вдалося отримати назви стовпчиків, чи є в файлі заголовок?',
  12997. noObjects: 'Не вдалося отримати дані, чи є в файлі рядки окрім заголовка?',
  12998. invalidCsv: 'Не вдалося обробити файл, чи це коректний CSV-файл?',
  12999. invalidJson: 'Не вдалося обробити файл, чи це коректний JSON?',
  13000. jsonNotArray: 'JSON-файл що імпортується повинен містити масив, операцію скасовано.'
  13001. },
  13002. pagination: {
  13003. aria: {
  13004. pageToFirst: 'Перша сторінка',
  13005. pageBack: 'Попередня сторінка',
  13006. pageSelected: 'Обрана сторінка',
  13007. pageForward: 'Наступна сторінка',
  13008. pageToLast: 'Остання сторінка'
  13009. },
  13010. sizes: 'рядків на сторінку',
  13011. totalItems: 'рядків',
  13012. through: 'по',
  13013. of: 'з'
  13014. },
  13015. grouping: {
  13016. group: 'Групувати',
  13017. ungroup: 'Розгрупувати',
  13018. aggregate_count: 'Групувати: Кількість',
  13019. aggregate_sum: 'Для групи: Сума',
  13020. aggregate_max: 'Для групи: Максимум',
  13021. aggregate_min: 'Для групи: Мінімум',
  13022. aggregate_avg: 'Для групи: Серднє',
  13023. aggregate_remove: 'Для групи: Пусто'
  13024. }
  13025. });
  13026. return $delegate;
  13027. }]);
  13028. }]);
  13029. })();
  13030. /**
  13031. * @ngdoc overview
  13032. * @name ui.grid.i18n
  13033. * @description
  13034. *
  13035. * # ui.grid.i18n
  13036. * This module provides i18n functions to ui.grid and any application that wants to use it
  13037. *
  13038. * <div doc-module-components="ui.grid.i18n"></div>
  13039. */
  13040. (function () {
  13041. var DIRECTIVE_ALIASES = ['uiT', 'uiTranslate'];
  13042. var FILTER_ALIASES = ['t', 'uiTranslate'];
  13043. var module = angular.module('ui.grid.i18n');
  13044. /**
  13045. * @ngdoc object
  13046. * @name ui.grid.i18n.constant:i18nConstants
  13047. *
  13048. * @description constants available in i18n module
  13049. */
  13050. module.constant('i18nConstants', {
  13051. MISSING: '[MISSING]',
  13052. UPDATE_EVENT: '$uiI18n',
  13053. LOCALE_DIRECTIVE_ALIAS: 'uiI18n',
  13054. // default to english
  13055. DEFAULT_LANG: 'en'
  13056. });
  13057. // module.config(['$provide', function($provide) {
  13058. // $provide.decorator('i18nService', ['$delegate', function($delegate) {}])}]);
  13059. /**
  13060. * @ngdoc service
  13061. * @name ui.grid.i18n.service:i18nService
  13062. *
  13063. * @description Services for i18n
  13064. */
  13065. module.service('i18nService', ['$log', 'i18nConstants', '$rootScope',
  13066. function ($log, i18nConstants, $rootScope) {
  13067. var langCache = {
  13068. _langs: {},
  13069. current: null,
  13070. get: function (lang) {
  13071. return this._langs[lang.toLowerCase()];
  13072. },
  13073. add: function (lang, strings) {
  13074. var lower = lang.toLowerCase();
  13075. if (!this._langs[lower]) {
  13076. this._langs[lower] = {};
  13077. }
  13078. angular.extend(this._langs[lower], strings);
  13079. },
  13080. getAllLangs: function () {
  13081. var langs = [];
  13082. if (!this._langs) {
  13083. return langs;
  13084. }
  13085. for (var key in this._langs) {
  13086. langs.push(key);
  13087. }
  13088. return langs;
  13089. },
  13090. setCurrent: function (lang) {
  13091. this.current = lang.toLowerCase();
  13092. },
  13093. getCurrentLang: function () {
  13094. return this.current;
  13095. }
  13096. };
  13097. var service = {
  13098. /**
  13099. * @ngdoc service
  13100. * @name add
  13101. * @methodOf ui.grid.i18n.service:i18nService
  13102. * @description Adds the languages and strings to the cache. Decorate this service to
  13103. * add more translation strings
  13104. * @param {string} lang language to add
  13105. * @param {object} stringMaps of strings to add grouped by property names
  13106. * @example
  13107. * <pre>
  13108. * i18nService.add('en', {
  13109. * aggregate: {
  13110. * label1: 'items',
  13111. * label2: 'some more items'
  13112. * }
  13113. * },
  13114. * groupPanel: {
  13115. * description: 'Drag a column header here and drop it to group by that column.'
  13116. * }
  13117. * }
  13118. * </pre>
  13119. */
  13120. add: function (langs, stringMaps) {
  13121. if (typeof(langs) === 'object') {
  13122. angular.forEach(langs, function (lang) {
  13123. if (lang) {
  13124. langCache.add(lang, stringMaps);
  13125. }
  13126. });
  13127. } else {
  13128. langCache.add(langs, stringMaps);
  13129. }
  13130. },
  13131. /**
  13132. * @ngdoc service
  13133. * @name getAllLangs
  13134. * @methodOf ui.grid.i18n.service:i18nService
  13135. * @description return all currently loaded languages
  13136. * @returns {array} string
  13137. */
  13138. getAllLangs: function () {
  13139. return langCache.getAllLangs();
  13140. },
  13141. /**
  13142. * @ngdoc service
  13143. * @name get
  13144. * @methodOf ui.grid.i18n.service:i18nService
  13145. * @description return all currently loaded languages
  13146. * @param {string} lang to return. If not specified, returns current language
  13147. * @returns {object} the translation string maps for the language
  13148. */
  13149. get: function (lang) {
  13150. var language = lang ? lang : service.getCurrentLang();
  13151. return langCache.get(language);
  13152. },
  13153. /**
  13154. * @ngdoc service
  13155. * @name getSafeText
  13156. * @methodOf ui.grid.i18n.service:i18nService
  13157. * @description returns the text specified in the path or a Missing text if text is not found
  13158. * @param {String} path property path to use for retrieving text from string map
  13159. * @param {String} [lang] to return. If not specified, returns current language
  13160. * @returns {object} the translation for the path
  13161. * @example
  13162. * <pre>
  13163. * i18nService.getSafeText('sort.ascending')
  13164. * </pre>
  13165. */
  13166. getSafeText: function (path, lang) {
  13167. var language = lang || service.getCurrentLang();
  13168. var trans = langCache.get(language);
  13169. if (!trans) {
  13170. return i18nConstants.MISSING;
  13171. }
  13172. var paths = path.split('.');
  13173. var current = trans;
  13174. for (var i = 0; i < paths.length; ++i) {
  13175. if (current[paths[i]] === undefined || current[paths[i]] === null) {
  13176. return i18nConstants.MISSING;
  13177. } else {
  13178. current = current[paths[i]];
  13179. }
  13180. }
  13181. return current;
  13182. },
  13183. /**
  13184. * @ngdoc service
  13185. * @name setCurrentLang
  13186. * @methodOf ui.grid.i18n.service:i18nService
  13187. * @description sets the current language to use in the application
  13188. * $broadcasts the i18nConstants.UPDATE_EVENT on the $rootScope
  13189. * @param {string} lang to set
  13190. * @example
  13191. * <pre>
  13192. * i18nService.setCurrentLang('fr');
  13193. * </pre>
  13194. */
  13195. setCurrentLang: function (lang) {
  13196. if (lang) {
  13197. langCache.setCurrent(lang);
  13198. $rootScope.$broadcast(i18nConstants.UPDATE_EVENT);
  13199. }
  13200. },
  13201. /**
  13202. * @ngdoc service
  13203. * @name getCurrentLang
  13204. * @methodOf ui.grid.i18n.service:i18nService
  13205. * @description returns the current language used in the application
  13206. */
  13207. getCurrentLang: function () {
  13208. var lang = langCache.getCurrentLang();
  13209. if (!lang) {
  13210. lang = i18nConstants.DEFAULT_LANG;
  13211. langCache.setCurrent(lang);
  13212. }
  13213. return lang;
  13214. }
  13215. };
  13216. return service;
  13217. }]);
  13218. var localeDirective = function (i18nService, i18nConstants) {
  13219. return {
  13220. compile: function () {
  13221. return {
  13222. pre: function ($scope, $elm, $attrs) {
  13223. var alias = i18nConstants.LOCALE_DIRECTIVE_ALIAS;
  13224. // check for watchable property
  13225. var lang = $scope.$eval($attrs[alias]);
  13226. if (lang) {
  13227. $scope.$watch($attrs[alias], function () {
  13228. i18nService.setCurrentLang(lang);
  13229. });
  13230. } else if ($attrs.$$observers) {
  13231. $attrs.$observe(alias, function () {
  13232. i18nService.setCurrentLang($attrs[alias] || i18nConstants.DEFAULT_LANG);
  13233. });
  13234. }
  13235. }
  13236. };
  13237. }
  13238. };
  13239. };
  13240. module.directive('uiI18n', ['i18nService', 'i18nConstants', localeDirective]);
  13241. // directive syntax
  13242. var uitDirective = function ($parse, i18nService, i18nConstants) {
  13243. return {
  13244. restrict: 'EA',
  13245. compile: function () {
  13246. return {
  13247. pre: function ($scope, $elm, $attrs) {
  13248. var alias1 = DIRECTIVE_ALIASES[0],
  13249. alias2 = DIRECTIVE_ALIASES[1];
  13250. var token = $attrs[alias1] || $attrs[alias2] || $elm.html();
  13251. var missing = i18nConstants.MISSING + token;
  13252. var observer;
  13253. if ($attrs.$$observers) {
  13254. var prop = $attrs[alias1] ? alias1 : alias2;
  13255. observer = $attrs.$observe(prop, function (result) {
  13256. if (result) {
  13257. $elm.html($parse(result)(i18nService.getCurrentLang()) || missing);
  13258. }
  13259. });
  13260. }
  13261. var getter = $parse(token);
  13262. var listener = $scope.$on(i18nConstants.UPDATE_EVENT, function (evt) {
  13263. if (observer) {
  13264. observer($attrs[alias1] || $attrs[alias2]);
  13265. } else {
  13266. // set text based on i18n current language
  13267. $elm.html(getter(i18nService.get()) || missing);
  13268. }
  13269. });
  13270. $scope.$on('$destroy', listener);
  13271. $elm.html(getter(i18nService.get()) || missing);
  13272. }
  13273. };
  13274. }
  13275. };
  13276. };
  13277. angular.forEach( DIRECTIVE_ALIASES, function ( alias ) {
  13278. module.directive( alias, ['$parse', 'i18nService', 'i18nConstants', uitDirective] );
  13279. } );
  13280. // optional filter syntax
  13281. var uitFilter = function ($parse, i18nService, i18nConstants) {
  13282. return function (data) {
  13283. var getter = $parse(data);
  13284. // set text based on i18n current language
  13285. return getter(i18nService.get()) || i18nConstants.MISSING + data;
  13286. };
  13287. };
  13288. angular.forEach( FILTER_ALIASES, function ( alias ) {
  13289. module.filter( alias, ['$parse', 'i18nService', 'i18nConstants', uitFilter] );
  13290. } );
  13291. })();
  13292. (function() {
  13293. angular.module('ui.grid').config(['$provide', function($provide) {
  13294. $provide.decorator('i18nService', ['$delegate', function($delegate) {
  13295. $delegate.add('zh-cn', {
  13296. headerCell: {
  13297. aria: {
  13298. defaultFilterLabel: '列过滤器',
  13299. removeFilter: '移除过滤器',
  13300. columnMenuButtonLabel: '列菜单'
  13301. },
  13302. priority: '优先级:',
  13303. filterLabel: "列过滤器: "
  13304. },
  13305. aggregate: {
  13306. label: '行'
  13307. },
  13308. groupPanel: {
  13309. description: '拖曳表头到此处进行分组'
  13310. },
  13311. search: {
  13312. placeholder: '查找',
  13313. showingItems: '已显示行数:',
  13314. selectedItems: '已选择行数:',
  13315. totalItems: '总行数:',
  13316. size: '每页显示行数:',
  13317. first: '首页',
  13318. next: '下一页',
  13319. previous: '上一页',
  13320. last: '末页'
  13321. },
  13322. menu: {
  13323. text: '选择列:'
  13324. },
  13325. sort: {
  13326. ascending: '升序',
  13327. descending: '降序',
  13328. none: '无序',
  13329. remove: '取消排序'
  13330. },
  13331. column: {
  13332. hide: '隐藏列'
  13333. },
  13334. aggregation: {
  13335. count: '计数:',
  13336. sum: '求和:',
  13337. avg: '均值:',
  13338. min: '最小值:',
  13339. max: '最大值:'
  13340. },
  13341. pinning: {
  13342. pinLeft: '左侧固定',
  13343. pinRight: '右侧固定',
  13344. unpin: '取消固定'
  13345. },
  13346. columnMenu: {
  13347. close: '关闭'
  13348. },
  13349. gridMenu: {
  13350. aria: {
  13351. buttonLabel: '表格菜单'
  13352. },
  13353. columns: '列:',
  13354. importerTitle: '导入文件',
  13355. exporterAllAsCsv: '导出全部数据到CSV',
  13356. exporterVisibleAsCsv: '导出可见数据到CSV',
  13357. exporterSelectedAsCsv: '导出已选数据到CSV',
  13358. exporterAllAsPdf: '导出全部数据到PDF',
  13359. exporterVisibleAsPdf: '导出可见数据到PDF',
  13360. exporterSelectedAsPdf: '导出已选数据到PDF',
  13361. clearAllFilters: '清除所有过滤器'
  13362. },
  13363. importer: {
  13364. noHeaders: '无法获取列名,确定文件包含表头?',
  13365. noObjects: '无法获取数据,确定文件包含数据?',
  13366. invalidCsv: '无法处理文件,确定是合法的CSV文件?',
  13367. invalidJson: '无法处理文件,确定是合法的JSON文件?',
  13368. jsonNotArray: '导入的文件不是JSON数组!'
  13369. },
  13370. pagination: {
  13371. aria: {
  13372. pageToFirst: '第一页',
  13373. pageBack: '上一页',
  13374. pageSelected: '当前页',
  13375. pageForward: '下一页',
  13376. pageToLast: '最后一页'
  13377. },
  13378. sizes: '行每页',
  13379. totalItems: '行',
  13380. through: '至',
  13381. of: '共'
  13382. },
  13383. grouping: {
  13384. group: '分组',
  13385. ungroup: '取消分组',
  13386. aggregate_count: '合计: 计数',
  13387. aggregate_sum: '合计: 求和',
  13388. aggregate_max: '合计: 最大',
  13389. aggregate_min: '合计: 最小',
  13390. aggregate_avg: '合计: 平均',
  13391. aggregate_remove: '合计: 移除'
  13392. }
  13393. });
  13394. return $delegate;
  13395. }]);
  13396. }]);
  13397. })();
  13398. (function() {
  13399. angular.module('ui.grid').config(['$provide', function($provide) {
  13400. $provide.decorator('i18nService', ['$delegate', function($delegate) {
  13401. $delegate.add('zh-tw', {
  13402. aggregate: {
  13403. label: '行'
  13404. },
  13405. groupPanel: {
  13406. description: '拖曳表頭到此處進行分組'
  13407. },
  13408. search: {
  13409. placeholder: '查找',
  13410. showingItems: '已顯示行數:',
  13411. selectedItems: '已選擇行數:',
  13412. totalItems: '總行數:',
  13413. size: '每頁顯示行數:',
  13414. first: '首頁',
  13415. next: '下壹頁',
  13416. previous: '上壹頁',
  13417. last: '末頁'
  13418. },
  13419. menu: {
  13420. text: '選擇列:'
  13421. },
  13422. sort: {
  13423. ascending: '升序',
  13424. descending: '降序',
  13425. remove: '取消排序'
  13426. },
  13427. column: {
  13428. hide: '隱藏列'
  13429. },
  13430. aggregation: {
  13431. count: '計數:',
  13432. sum: '求和:',
  13433. avg: '均值:',
  13434. min: '最小值:',
  13435. max: '最大值:'
  13436. },
  13437. pinning: {
  13438. pinLeft: '左側固定',
  13439. pinRight: '右側固定',
  13440. unpin: '取消固定'
  13441. },
  13442. gridMenu: {
  13443. columns: '列:',
  13444. importerTitle: '導入文件',
  13445. exporterAllAsCsv: '導出全部數據到CSV',
  13446. exporterVisibleAsCsv: '導出可見數據到CSV',
  13447. exporterSelectedAsCsv: '導出已選數據到CSV',
  13448. exporterAllAsPdf: '導出全部數據到PDF',
  13449. exporterVisibleAsPdf: '導出可見數據到PDF',
  13450. exporterSelectedAsPdf: '導出已選數據到PDF',
  13451. clearAllFilters: '清除所有过滤器'
  13452. },
  13453. importer: {
  13454. noHeaders: '無法獲取列名,確定文件包含表頭?',
  13455. noObjects: '無法獲取數據,確定文件包含數據?',
  13456. invalidCsv: '無法處理文件,確定是合法的CSV文件?',
  13457. invalidJson: '無法處理文件,確定是合法的JSON文件?',
  13458. jsonNotArray: '導入的文件不是JSON數組!'
  13459. },
  13460. pagination: {
  13461. sizes: '行每頁',
  13462. totalItems: '行'
  13463. }
  13464. });
  13465. return $delegate;
  13466. }]);
  13467. }]);
  13468. })();
  13469. angular.module('ui.grid').run(['$templateCache', function($templateCache) {
  13470. 'use strict';
  13471. $templateCache.put('ui-grid/ui-grid-filter',
  13472. "<div class=\"ui-grid-filter-container\" ng-style=\"col.extraStyle\" ng-repeat=\"colFilter in col.filters\" ng-class=\"{'ui-grid-filter-cancel-button-hidden' : colFilter.disableCancelFilterButton === true }\"><div ng-if=\"colFilter.type !== 'select'\"><input type=\"text\" class=\"ui-grid-filter-input ui-grid-filter-input-{{$index}}\" ng-model=\"colFilter.term\" ng-attr-placeholder=\"{{colFilter.placeholder || ''}}\" aria-label=\"{{colFilter.ariaLabel || aria.defaultFilterLabel}}\"><div role=\"button\" class=\"ui-grid-filter-button\" ng-click=\"removeFilter(colFilter, $index)\" ng-if=\"!colFilter.disableCancelFilterButton\" ng-disabled=\"colFilter.term === undefined || colFilter.term === null || colFilter.term === ''\" ng-show=\"colFilter.term !== undefined && colFilter.term !== null && colFilter.term !== ''\"><i class=\"ui-grid-icon-cancel\" ui-grid-one-bind-aria-label=\"aria.removeFilter\">&nbsp;</i></div></div><div ng-if=\"colFilter.type === 'select'\"><select class=\"ui-grid-filter-select ui-grid-filter-input-{{$index}}\" ng-model=\"colFilter.term\" ng-show=\"colFilter.selectOptions.length > 0\" ng-attr-placeholder=\"{{colFilter.placeholder || aria.defaultFilterLabel}}\" aria-label=\"{{colFilter.ariaLabel || ''}}\" ng-options=\"option.value as option.label for option in colFilter.selectOptions\"><option value=\"\"></option></select><div role=\"button\" class=\"ui-grid-filter-button-select\" ng-click=\"removeFilter(colFilter, $index)\" ng-if=\"!colFilter.disableCancelFilterButton\" ng-disabled=\"colFilter.term === undefined || colFilter.term === null || colFilter.term === ''\" ng-show=\"colFilter.term !== undefined && colFilter.term != null\"><i class=\"ui-grid-icon-cancel\" ui-grid-one-bind-aria-label=\"aria.removeFilter\">&nbsp;</i></div></div></div>"
  13473. );
  13474. $templateCache.put('ui-grid/ui-grid-footer',
  13475. "<div class=\"ui-grid-footer-panel ui-grid-footer-aggregates-row\"><!-- tfooter --><div class=\"ui-grid-footer ui-grid-footer-viewport\"><div class=\"ui-grid-footer-canvas\"><div class=\"ui-grid-footer-cell-wrapper\" ng-style=\"colContainer.headerCellWrapperStyle()\"><div role=\"row\" class=\"ui-grid-footer-cell-row\"><div ui-grid-footer-cell role=\"gridcell\" ng-repeat=\"col in colContainer.renderedColumns track by col.uid\" col=\"col\" render-index=\"$index\" class=\"ui-grid-footer-cell ui-grid-clearfix\"></div></div></div></div></div></div>"
  13476. );
  13477. $templateCache.put('ui-grid/ui-grid-grid-footer',
  13478. "<div class=\"ui-grid-footer-info ui-grid-grid-footer\"><span>{{'search.totalItems' | t}} {{grid.rows.length}}</span> <span ng-if=\"grid.renderContainers.body.visibleRowCache.length !== grid.rows.length\" class=\"ngLabel\">({{\"search.showingItems\" | t}} {{grid.renderContainers.body.visibleRowCache.length}})</span></div>"
  13479. );
  13480. $templateCache.put('ui-grid/ui-grid-header',
  13481. "<div role=\"rowgroup\" class=\"ui-grid-header\"><!-- theader --><div class=\"ui-grid-top-panel\"><div class=\"ui-grid-header-viewport\"><div class=\"ui-grid-header-canvas\"><div class=\"ui-grid-header-cell-wrapper\" ng-style=\"colContainer.headerCellWrapperStyle()\"><div role=\"row\" class=\"ui-grid-header-cell-row\"><div class=\"ui-grid-header-cell ui-grid-clearfix\" ng-repeat=\"col in colContainer.renderedColumns track by col.uid\" ui-grid-header-cell col=\"col\" render-index=\"$index\"></div></div></div></div></div></div></div>"
  13482. );
  13483. $templateCache.put('ui-grid/ui-grid-menu-button',
  13484. "<div class=\"ui-grid-menu-button\"><div role=\"button\" ui-grid-one-bind-id-grid=\"'grid-menu'\" class=\"ui-grid-icon-container\" ng-click=\"toggleMenu()\" aria-haspopup=\"true\"><i class=\"ui-grid-icon-menu\" ui-grid-one-bind-aria-label=\"i18n.aria.buttonLabel\">&nbsp;</i></div><div ui-grid-menu menu-items=\"menuItems\"></div></div>"
  13485. );
  13486. $templateCache.put('ui-grid/ui-grid-no-header',
  13487. "<div class=\"ui-grid-top-panel\"></div>"
  13488. );
  13489. $templateCache.put('ui-grid/ui-grid-row',
  13490. "<div ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>"
  13491. );
  13492. $templateCache.put('ui-grid/ui-grid',
  13493. "<div ui-i18n=\"en\" class=\"ui-grid\"><!-- TODO (c0bra): add \"scoped\" attr here, eventually? --><style ui-grid-style>.grid{{ grid.id }} {\n" +
  13494. " /* Styles for the grid */\n" +
  13495. " }\n" +
  13496. "\n" +
  13497. " .grid{{ grid.id }} .ui-grid-row, .grid{{ grid.id }} .ui-grid-cell, .grid{{ grid.id }} .ui-grid-cell .ui-grid-vertical-bar {\n" +
  13498. " height: {{ grid.options.rowHeight }}px;\n" +
  13499. " }\n" +
  13500. "\n" +
  13501. " .grid{{ grid.id }} .ui-grid-row:last-child .ui-grid-cell {\n" +
  13502. " border-bottom-width: {{ (((grid.getVisibleRowCount() * grid.options.rowHeight) < grid.getViewportHeight()) && '1') || '0' }}px;\n" +
  13503. " }\n" +
  13504. "\n" +
  13505. " {{ grid.verticalScrollbarStyles }}\n" +
  13506. " {{ grid.horizontalScrollbarStyles }}\n" +
  13507. "\n" +
  13508. " /*\n" +
  13509. " .ui-grid[dir=rtl] .ui-grid-viewport {\n" +
  13510. " padding-left: {{ grid.verticalScrollbarWidth }}px;\n" +
  13511. " }\n" +
  13512. " */\n" +
  13513. "\n" +
  13514. " {{ grid.customStyles }}</style><div class=\"ui-grid-contents-wrapper\" role=\"grid\"><div ui-grid-menu-button ng-if=\"grid.options.enableGridMenu\"></div><div ng-if=\"grid.hasLeftContainer()\" style=\"width: 0\" ui-grid-pinned-container=\"'left'\"></div><div ui-grid-render-container container-id=\"'body'\" col-container-name=\"'body'\" row-container-name=\"'body'\" bind-scroll-horizontal=\"true\" bind-scroll-vertical=\"true\" enable-horizontal-scrollbar=\"grid.options.enableHorizontalScrollbar\" enable-vertical-scrollbar=\"grid.options.enableVerticalScrollbar\"></div><div ng-if=\"grid.hasRightContainer()\" style=\"width: 0\" ui-grid-pinned-container=\"'right'\"></div><div ui-grid-grid-footer ng-if=\"grid.options.showGridFooter\"></div><div ui-grid-column-menu ng-if=\"grid.options.enableColumnMenus\"></div><div ng-transclude></div></div></div>"
  13515. );
  13516. $templateCache.put('ui-grid/uiGridCell',
  13517. "<div class=\"ui-grid-cell-contents\" title=\"TOOLTIP\">{{COL_FIELD CUSTOM_FILTERS}}</div>"
  13518. );
  13519. $templateCache.put('ui-grid/uiGridColumnMenu',
  13520. "<div class=\"ui-grid-column-menu\"><div ui-grid-menu menu-items=\"menuItems\"><!-- <div class=\"ui-grid-column-menu\">\n" +
  13521. " <div class=\"inner\" ng-show=\"menuShown\">\n" +
  13522. " <ul>\n" +
  13523. " <div ng-show=\"grid.options.enableSorting\">\n" +
  13524. " <li ng-click=\"sortColumn($event, asc)\" ng-class=\"{ 'selected' : col.sort.direction == asc }\"><i class=\"ui-grid-icon-sort-alt-up\"></i> Sort Ascending</li>\n" +
  13525. " <li ng-click=\"sortColumn($event, desc)\" ng-class=\"{ 'selected' : col.sort.direction == desc }\"><i class=\"ui-grid-icon-sort-alt-down\"></i> Sort Descending</li>\n" +
  13526. " <li ng-show=\"col.sort.direction\" ng-click=\"unsortColumn()\"><i class=\"ui-grid-icon-cancel\"></i> Remove Sort</li>\n" +
  13527. " </div>\n" +
  13528. " </ul>\n" +
  13529. " </div>\n" +
  13530. " </div> --></div></div>"
  13531. );
  13532. $templateCache.put('ui-grid/uiGridFooterCell',
  13533. "<div class=\"ui-grid-cell-contents\" col-index=\"renderIndex\"><div>{{ col.getAggregationText() + ( col.getAggregationValue() CUSTOM_FILTERS ) }}</div></div>"
  13534. );
  13535. $templateCache.put('ui-grid/uiGridHeaderCell',
  13536. "<div role=\"columnheader\" ng-class=\"{ 'sortable': sortable, 'ui-grid-header-cell-last-col': isLastCol }\" ui-grid-one-bind-aria-labelledby-grid=\"col.uid + '-header-text ' + col.uid + '-sortdir-text'\" aria-sort=\"{{col.sort.direction == asc ? 'ascending' : ( col.sort.direction == desc ? 'descending' : (!col.sort.direction ? 'none' : 'other'))}}\"><div role=\"button\" tabindex=\"0\" ng-keydown=\"handleKeyDown($event)\" class=\"ui-grid-cell-contents ui-grid-header-cell-primary-focus\" col-index=\"renderIndex\" title=\"TOOLTIP\"><span class=\"ui-grid-header-cell-label\" ui-grid-one-bind-id-grid=\"col.uid + '-header-text'\">{{ col.displayName CUSTOM_FILTERS }}</span> <span ui-grid-one-bind-id-grid=\"col.uid + '-sortdir-text'\" ui-grid-visible=\"col.sort.direction\" aria-label=\"{{getSortDirectionAriaLabel()}}\"><i ng-class=\"{ 'ui-grid-icon-up-dir': col.sort.direction == asc, 'ui-grid-icon-down-dir': col.sort.direction == desc, 'ui-grid-icon-blank': !col.sort.direction }\" title=\"{{isSortPriorityVisible() ? i18n.headerCell.priority + ' ' + ( col.sort.priority + 1 ) : null}}\" aria-hidden=\"true\"></i> <sub ui-grid-visible=\"isSortPriorityVisible()\" class=\"ui-grid-sort-priority-number\">{{col.sort.priority + 1}}</sub></span></div><div role=\"button\" tabindex=\"0\" ui-grid-one-bind-id-grid=\"col.uid + '-menu-button'\" class=\"ui-grid-column-menu-button\" ng-if=\"grid.options.enableColumnMenus && !col.isRowHeader && col.colDef.enableColumnMenu !== false\" ng-click=\"toggleMenu($event)\" ng-keydown=\"headerCellArrowKeyDown($event)\" ui-grid-one-bind-aria-label=\"i18n.headerCell.aria.columnMenuButtonLabel\" aria-haspopup=\"true\"><i class=\"ui-grid-icon-angle-down\" aria-hidden=\"true\">&nbsp;</i></div><div ui-grid-filter></div></div>"
  13537. );
  13538. $templateCache.put('ui-grid/uiGridMenu',
  13539. "<div class=\"ui-grid-menu\" ng-show=\"shown\"><style ui-grid-style>{{dynamicStyles}}</style><div class=\"ui-grid-menu-mid\" ng-show=\"shownMid\"><div class=\"ui-grid-menu-inner\" ng-if=\"shown\"><ul role=\"menu\" class=\"ui-grid-menu-items\"><li ng-repeat=\"item in menuItems\" role=\"menuitem\" ui-grid-menu-item ui-grid-one-bind-id=\"'menuitem-'+$index\" action=\"item.action\" name=\"item.title\" active=\"item.active\" icon=\"item.icon\" shown=\"item.shown\" context=\"item.context\" template-url=\"item.templateUrl\" leave-open=\"item.leaveOpen\" screen-reader-only=\"item.screenReaderOnly\"></li></ul></div></div></div>"
  13540. );
  13541. $templateCache.put('ui-grid/uiGridMenuItem',
  13542. "<button type=\"button\" class=\"ui-grid-menu-item\" ng-click=\"itemAction($event, title)\" ng-show=\"itemShown()\" ng-class=\"{ 'ui-grid-menu-item-active': active(), 'ui-grid-sr-only': (!focus && screenReaderOnly) }\" aria-pressed=\"{{active()}}\" tabindex=\"0\" ng-focus=\"focus=true\" ng-blur=\"focus=false\"><i ng-class=\"icon\" aria-hidden=\"true\">&nbsp;</i> {{ label() }}</button>"
  13543. );
  13544. $templateCache.put('ui-grid/uiGridRenderContainer',
  13545. "<div role=\"presentation\" ui-grid-one-bind-id-grid=\"'grid-container'\" class=\"ui-grid-render-container\" ng-style=\"{ 'margin-left': colContainer.getMargin('left') + 'px', 'margin-right': colContainer.getMargin('right') + 'px' }\"><!-- All of these dom elements are replaced in place --><div ui-grid-header></div><div ui-grid-viewport></div><div ng-if=\"colContainer.needsHScrollbarPlaceholder()\" class=\"ui-grid-scrollbar-placeholder\" ng-style=\"{height:colContainer.grid.scrollbarHeight + 'px'}\"></div><ui-grid-footer ng-if=\"grid.options.showColumnFooter\"></ui-grid-footer></div>"
  13546. );
  13547. $templateCache.put('ui-grid/uiGridViewport',
  13548. "<div role=\"rowgroup\" class=\"ui-grid-viewport\" ng-style=\"colContainer.getViewportStyle()\"><!-- tbody --><div class=\"ui-grid-canvas\"><div ng-repeat=\"(rowRenderIndex, row) in rowContainer.renderedRows track by $index\" class=\"ui-grid-row\" ng-style=\"Viewport.rowStyle(rowRenderIndex)\"><div role=\"row\" ui-grid-row=\"row\" row-render-index=\"rowRenderIndex\"></div></div></div></div>"
  13549. );
  13550. $templateCache.put('ui-grid/cellEditor',
  13551. "<div><form name=\"inputForm\"><input type=\"INPUT_TYPE\" ng-class=\"'colt' + col.uid\" ui-grid-editor ng-model=\"MODEL_COL_FIELD\"></form></div>"
  13552. );
  13553. $templateCache.put('ui-grid/dropdownEditor',
  13554. "<div><form name=\"inputForm\"><select ng-class=\"'colt' + col.uid\" ui-grid-edit-dropdown ng-model=\"MODEL_COL_FIELD\" ng-options=\"field[editDropdownIdLabel] as field[editDropdownValueLabel] CUSTOM_FILTERS for field in editDropdownOptionsArray\"></select></form></div>"
  13555. );
  13556. $templateCache.put('ui-grid/fileChooserEditor',
  13557. "<div><form name=\"inputForm\"><input ng-class=\"'colt' + col.uid\" ui-grid-edit-file-chooser type=\"file\" id=\"files\" name=\"files[]\" ng-model=\"MODEL_COL_FIELD\"></form></div>"
  13558. );
  13559. $templateCache.put('ui-grid/emptyBaseLayerContainer',
  13560. "<div class=\"ui-grid-empty-base-layer-container ui-grid-canvas\"><div class=\"ui-grid-row\" ng-repeat=\"(rowRenderIndex, row) in grid.baseLayer.emptyRows track by $index\" ng-style=\"Viewport.rowStyle(rowRenderIndex)\"><div><div><div ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.colDef.name\" class=\"ui-grid-cell {{ col.getColClass(false) }}\"></div></div></div></div></div>"
  13561. );
  13562. $templateCache.put('ui-grid/expandableRow',
  13563. "<div ui-grid-expandable-row ng-if=\"expandableRow.shouldRenderExpand()\" class=\"expandableRow\" style=\"float:left; margin-top: 1px; margin-bottom: 1px\" ng-style=\"{width: (grid.renderContainers.body.getCanvasWidth()) + 'px', height: row.expandedRowHeight + 'px'}\"></div>"
  13564. );
  13565. $templateCache.put('ui-grid/expandableRowHeader',
  13566. "<div class=\"ui-grid-row-header-cell ui-grid-expandable-buttons-cell\"><div class=\"ui-grid-cell-contents\"><i ng-if=\"!(row.groupHeader==true || row.entity.subGridOptions.disableRowExpandable)\" ng-class=\"{ 'ui-grid-icon-plus-squared' : !row.isExpanded, 'ui-grid-icon-minus-squared' : row.isExpanded }\" ng-click=\"grid.api.expandable.toggleRowExpansion(row.entity)\"></i></div></div>"
  13567. );
  13568. $templateCache.put('ui-grid/expandableScrollFiller',
  13569. "<div ng-if=\"expandableRow.shouldRenderFiller()\" ng-class=\"{scrollFiller:true, scrollFillerClass:(colContainer.name === 'body')}\" ng-style=\"{ width: (grid.getViewportWidth()) + 'px', height: row.expandedRowHeight + 2 + 'px', 'margin-left': grid.options.rowHeader.rowHeaderWidth + 'px' }\"><i class=\"ui-grid-icon-spin5 ui-grid-animate-spin\" ng-style=\"{'margin-top': ( row.expandedRowHeight/2 - 5) + 'px', 'margin-left' : ((grid.getViewportWidth() - grid.options.rowHeader.rowHeaderWidth)/2 - 5) + 'px'}\"></i></div>"
  13570. );
  13571. $templateCache.put('ui-grid/expandableTopRowHeader',
  13572. "<div class=\"ui-grid-row-header-cell ui-grid-expandable-buttons-cell\"><div class=\"ui-grid-cell-contents\"><span class=\"ui-grid-cell-empty\" ng-if=\"!grid.options.showExpandAllButton\"></span> <button type=\"button\" class=\"ui-grid-icon-button\" ng-if=\"grid.options.showExpandAllButton\" ng-class=\"{ 'ui-grid-icon-plus-squared' : !grid.expandable.expandedAll, 'ui-grid-icon-minus-squared' : grid.expandable.expandedAll }\" ng-click=\"grid.api.expandable.toggleAllRows()\"></button></div></div>"
  13573. );
  13574. $templateCache.put('ui-grid/csvLink',
  13575. "<span class=\"ui-grid-exporter-csv-link-span\"><a href=\"data:text/csv;charset=UTF-8,CSV_CONTENT\" download=\"FILE_NAME\">LINK_LABEL</a></span>"
  13576. );
  13577. $templateCache.put('ui-grid/importerMenuItem',
  13578. "<li class=\"ui-grid-menu-item\"><form><input class=\"ui-grid-importer-file-chooser\" type=\"file\" id=\"files\" name=\"files[]\"></form></li>"
  13579. );
  13580. $templateCache.put('ui-grid/importerMenuItemContainer',
  13581. "<div ui-grid-importer-menu-item></div>"
  13582. );
  13583. $templateCache.put('ui-grid/pagination',
  13584. "<div class=\"ui-grid-pager-panel\" ui-grid-pager ng-show=\"grid.options.enablePaginationControls\"><div role=\"navigation\" class=\"ui-grid-pager-container\"><div class=\"ui-grid-pager-control\"><button type=\"button\" class=\"ui-grid-pager-first\" ui-grid-one-bind-title=\"aria.pageToFirst\" ui-grid-one-bind-aria-label=\"aria.pageToFirst\" ng-click=\"pageFirstPageClick()\" ng-disabled=\"cantPageBackward()\"><div ng-class=\"grid.isRTL() ? 'last-triangle' : 'first-triangle'\"><div ng-class=\"grid.isRTL() ? 'last-bar-rtl' : 'first-bar'\"></div></div></button> <button type=\"button\" class=\"ui-grid-pager-previous\" ui-grid-one-bind-title=\"aria.pageBack\" ui-grid-one-bind-aria-label=\"aria.pageBack\" ng-click=\"pagePreviousPageClick()\" ng-disabled=\"cantPageBackward()\"><div ng-class=\"grid.isRTL() ? 'last-triangle prev-triangle' : 'first-triangle prev-triangle'\"></div></button> <input type=\"number\" ui-grid-one-bind-title=\"aria.pageSelected\" ui-grid-one-bind-aria-label=\"aria.pageSelected\" class=\"ui-grid-pager-control-input\" ng-model=\"grid.options.paginationCurrentPage\" min=\"1\" max=\"{{ paginationApi.getTotalPages() }}\" required> <span class=\"ui-grid-pager-max-pages-number\" ng-show=\"paginationApi.getTotalPages() > 0\"><abbr ui-grid-one-bind-title=\"paginationOf\">/</abbr> {{ paginationApi.getTotalPages() }}</span> <button type=\"button\" class=\"ui-grid-pager-next\" ui-grid-one-bind-title=\"aria.pageForward\" ui-grid-one-bind-aria-label=\"aria.pageForward\" ng-click=\"pageNextPageClick()\" ng-disabled=\"cantPageForward()\"><div ng-class=\"grid.isRTL() ? 'first-triangle next-triangle' : 'last-triangle next-triangle'\"></div></button> <button type=\"button\" class=\"ui-grid-pager-last\" ui-grid-one-bind-title=\"aria.pageToLast\" ui-grid-one-bind-aria-label=\"aria.pageToLast\" ng-click=\"pageLastPageClick()\" ng-disabled=\"cantPageToLast()\"><div ng-class=\"grid.isRTL() ? 'first-triangle' : 'last-triangle'\"><div ng-class=\"grid.isRTL() ? 'first-bar-rtl' : 'last-bar'\"></div></div></button></div><div class=\"ui-grid-pager-row-count-picker\" ng-if=\"grid.options.paginationPageSizes.length > 1 && !grid.options.useCustomPagination\"><select ui-grid-one-bind-aria-labelledby-grid=\"'items-per-page-label'\" ng-model=\"grid.options.paginationPageSize\" ng-options=\"o as o for o in grid.options.paginationPageSizes\"></select><span ui-grid-one-bind-id-grid=\"'items-per-page-label'\" class=\"ui-grid-pager-row-count-label\">&nbsp;{{sizesLabel}}</span></div><span ng-if=\"grid.options.paginationPageSizes.length <= 1\" class=\"ui-grid-pager-row-count-label\">{{grid.options.paginationPageSize}}&nbsp;{{sizesLabel}}</span></div><div class=\"ui-grid-pager-count-container\"><div class=\"ui-grid-pager-count\"><span ng-show=\"grid.options.totalItems > 0\">{{ 1 + paginationApi.getFirstRowIndex() }} <abbr ui-grid-one-bind-title=\"paginationThrough\">-</abbr> {{ 1 + paginationApi.getLastRowIndex() }} {{paginationOf}} {{grid.options.totalItems}} {{totalItemsLabel}}</span></div></div></div>"
  13585. );
  13586. $templateCache.put('ui-grid/columnResizer',
  13587. "<div ui-grid-column-resizer ng-if=\"grid.options.enableColumnResizing\" class=\"ui-grid-column-resizer\" col=\"col\" position=\"right\" render-index=\"renderIndex\" unselectable=\"on\"></div>"
  13588. );
  13589. $templateCache.put('ui-grid/gridFooterSelectedItems',
  13590. "<span ng-if=\"grid.selection.selectedCount !== 0 && grid.options.enableFooterTotalSelected\">({{\"search.selectedItems\" | t}} {{grid.selection.selectedCount}})</span>"
  13591. );
  13592. $templateCache.put('ui-grid/selectionHeaderCell',
  13593. "<div><!-- <div class=\"ui-grid-vertical-bar\">&nbsp;</div> --><div class=\"ui-grid-cell-contents\" col-index=\"renderIndex\"><ui-grid-selection-select-all-buttons ng-if=\"grid.options.enableSelectAll\" role=\"checkbox\" ng-model=\"grid.selection.selectAll\"></ui-grid-selection-select-all-buttons></div></div>"
  13594. );
  13595. $templateCache.put('ui-grid/selectionRowHeader',
  13596. "<div class=\"ui-grid-disable-selection\"><div class=\"ui-grid-cell-contents\"><ui-grid-selection-row-header-buttons></ui-grid-selection-row-header-buttons></div></div>"
  13597. );
  13598. $templateCache.put('ui-grid/selectionRowHeaderButtons',
  13599. "<div class=\"ui-grid-selection-row-header-buttons ui-grid-icon-ok\" ng-class=\"{'ui-grid-row-selected': row.isSelected}\" ng-click=\"selectButtonClick(row, $event)\" ng-keydown=\"selectButtonKeyDown(row, $event)\" role=\"checkbox\" ng-model=\"row.isSelected\">&nbsp;</div>"
  13600. );
  13601. $templateCache.put('ui-grid/selectionSelectAllButtons',
  13602. "<div role=\"button\" class=\"ui-grid-selection-row-header-buttons ui-grid-icon-ok\" ng-class=\"{'ui-grid-all-selected': grid.selection.selectAll}\" ng-click=\"headerButtonClick($event)\" ng-keydown=\"headerButtonKeyDown($event)\"></div>"
  13603. );
  13604. $templateCache.put('ui-grid/treeBaseExpandAllButtons',
  13605. "<div class=\"ui-grid-tree-base-row-header-buttons\" ng-class=\"{'ui-grid-icon-minus-squared': grid.treeBase.numberLevels > 0 && grid.treeBase.expandAll, 'ui-grid-icon-plus-squared': grid.treeBase.numberLevels > 0 && !grid.treeBase.expandAll}\" ng-click=\"headerButtonClick($event)\"></div>"
  13606. );
  13607. $templateCache.put('ui-grid/treeBaseHeaderCell',
  13608. "<div><div class=\"ui-grid-cell-contents\" col-index=\"renderIndex\"><ui-grid-tree-base-expand-all-buttons ng-if=\"grid.options.enableExpandAll\"></ui-grid-tree-base-expand-all-buttons></div></div>"
  13609. );
  13610. $templateCache.put('ui-grid/treeBaseRowHeader',
  13611. "<div class=\"ui-grid-cell-contents\"><ui-grid-tree-base-row-header-buttons></ui-grid-tree-base-row-header-buttons></div>"
  13612. );
  13613. $templateCache.put('ui-grid/treeBaseRowHeaderButtons',
  13614. "<div class=\"ui-grid-tree-base-row-header-buttons\" ng-class=\"{'ui-grid-tree-base-header': row.treeLevel > -1 }\" ng-click=\"treeButtonClick(row, $event)\"><i ng-class=\"{'ui-grid-icon-minus-squared': ( ( grid.options.showTreeExpandNoChildren && row.treeLevel > -1 ) || ( row.treeNode.children && row.treeNode.children.length > 0 ) ) && row.treeNode.state === 'expanded', 'ui-grid-icon-plus-squared': ( ( grid.options.showTreeExpandNoChildren && row.treeLevel > -1 ) || ( row.treeNode.children && row.treeNode.children.length > 0 ) ) && row.treeNode.state === 'collapsed'}\" ng-style=\"{'padding-left': grid.options.treeIndent * row.treeLevel + 'px'}\"></i> &nbsp;</div>"
  13615. );
  13616. $templateCache.put('ui-grid/cellTitleValidator',
  13617. "<div class=\"ui-grid-cell-contents\" ng-class=\"{invalid:grid.validate.isInvalid(row.entity,col.colDef)}\" title=\"{{grid.validate.getTitleFormattedErrors(row.entity,col.colDef)}}\">{{COL_FIELD CUSTOM_FILTERS}}</div>"
  13618. );
  13619. $templateCache.put('ui-grid/cellTooltipValidator',
  13620. "<div class=\"ui-grid-cell-contents\" ng-class=\"{invalid:grid.validate.isInvalid(row.entity,col.colDef)}\" tooltip-html-unsafe=\"{{grid.validate.getFormattedErrors(row.entity,col.colDef)}}\" tooltip-enable=\"grid.validate.isInvalid(row.entity,col.colDef)\" tooltip-append-to-body=\"true\" tooltip-placement=\"top\" title=\"TOOLTIP\">{{COL_FIELD CUSTOM_FILTERS}}</div>"
  13621. );
  13622. }]);