datatables.js 442 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500
  1. /*
  2. * MDBootstrap integration with Datatables
  3. * Learn more: https://mdbootstrap.com/docs/jquery/tables/datatables/
  4. * About MDBootstrap: https://mdbootstrap.com/
  5. *
  6. * This combined file was created by the DataTables downloader builder:
  7. * https://datatables.net/download
  8. *
  9. * To rebuild or modify this file with the latest versions of the included
  10. * software please visit:
  11. * https://datatables.net/download/#bs4/dt-1.10.18
  12. *
  13. * Included libraries:
  14. * DataTables 1.10.18
  15. */
  16. /*! DataTables 1.10.18
  17. * ©2008-2018 SpryMedia Ltd - datatables.net/license
  18. */
  19. /**
  20. * @summary DataTables
  21. * @description Paginate, search and order HTML tables
  22. * @version 1.10.18
  23. * @file jquery.dataTables.js
  24. * @author SpryMedia Ltd
  25. * @contact www.datatables.net
  26. * @copyright Copyright 2008-2018 SpryMedia Ltd.
  27. *
  28. * This source file is free software, available under the following license:
  29. * MIT license - http://datatables.net/license
  30. *
  31. * This source file is distributed in the hope that it will be useful, but
  32. * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  33. * or FITNESS FOR A PARTICULAR PURPOSE. See the license files for details.
  34. *
  35. * For details please refer to: http://www.datatables.net
  36. */
  37. /*jslint evil: true, undef: true, browser: true */
  38. /*globals $,require,jQuery,define,_selector_run,_selector_opts,_selector_first,_selector_row_indexes,_ext,_Api,_api_register,_api_registerPlural,_re_new_lines,_re_html,_re_formatted_numeric,_re_escape_regex,_empty,_intVal,_numToDecimal,_isNumber,_isHtml,_htmlNumeric,_pluck,_pluck_order,_range,_stripHtml,_unique,_fnBuildAjax,_fnAjaxUpdate,_fnAjaxParameters,_fnAjaxUpdateDraw,_fnAjaxDataSrc,_fnAddColumn,_fnColumnOptions,_fnAdjustColumnSizing,_fnVisibleToColumnIndex,_fnColumnIndexToVisible,_fnVisbleColumns,_fnGetColumns,_fnColumnTypes,_fnApplyColumnDefs,_fnHungarianMap,_fnCamelToHungarian,_fnLanguageCompat,_fnBrowserDetect,_fnAddData,_fnAddTr,_fnNodeToDataIndex,_fnNodeToColumnIndex,_fnGetCellData,_fnSetCellData,_fnSplitObjNotation,_fnGetObjectDataFn,_fnSetObjectDataFn,_fnGetDataMaster,_fnClearTable,_fnDeleteIndex,_fnInvalidate,_fnGetRowElements,_fnCreateTr,_fnBuildHead,_fnDrawHead,_fnDraw,_fnReDraw,_fnAddOptionsHtml,_fnDetectHeader,_fnGetUniqueThs,_fnFeatureHtmlFilter,_fnFilterComplete,_fnFilterCustom,_fnFilterColumn,_fnFilter,_fnFilterCreateSearch,_fnEscapeRegex,_fnFilterData,_fnFeatureHtmlInfo,_fnUpdateInfo,_fnInfoMacros,_fnInitialise,_fnInitComplete,_fnLengthChange,_fnFeatureHtmlLength,_fnFeatureHtmlPaginate,_fnPageChange,_fnFeatureHtmlProcessing,_fnProcessingDisplay,_fnFeatureHtmlTable,_fnScrollDraw,_fnApplyToChildren,_fnCalculateColumnWidths,_fnThrottle,_fnConvertToWidth,_fnGetWidestNode,_fnGetMaxLenString,_fnStringToCss,_fnSortFlatten,_fnSort,_fnSortAria,_fnSortListener,_fnSortAttachListener,_fnSortingClasses,_fnSortData,_fnSaveState,_fnLoadState,_fnSettingsFromNode,_fnLog,_fnMap,_fnBindAction,_fnCallbackReg,_fnCallbackFire,_fnLengthOverflow,_fnRenderer,_fnDataSource,_fnRowAttributes*/
  39. (function( factory ) {
  40. "use strict";
  41. if ( typeof define === 'function' && define.amd ) {
  42. // AMD
  43. define( ['jquery'], function ( $ ) {
  44. return factory( $, window, document );
  45. } );
  46. }
  47. else if ( typeof exports === 'object' ) {
  48. // CommonJS
  49. module.exports = function (root, $) {
  50. if ( ! root ) {
  51. // CommonJS environments without a window global must pass a
  52. // root. This will give an error otherwise
  53. root = window;
  54. }
  55. if ( ! $ ) {
  56. $ = typeof window !== 'undefined' ? // jQuery's factory checks for a global window
  57. require('jquery') :
  58. require('jquery')( root );
  59. }
  60. return factory( $, root, root.document );
  61. };
  62. }
  63. else {
  64. // Browser
  65. factory( jQuery, window, document );
  66. }
  67. }
  68. (function( $, window, document, undefined ) {
  69. "use strict";
  70. /**
  71. * DataTables is a plug-in for the jQuery Javascript library. It is a highly
  72. * flexible tool, based upon the foundations of progressive enhancement,
  73. * which will add advanced interaction controls to any HTML table. For a
  74. * full list of features please refer to
  75. * [DataTables.net](href="http://datatables.net).
  76. *
  77. * Note that the `DataTable` object is not a global variable but is aliased
  78. * to `jQuery.fn.DataTable` and `jQuery.fn.dataTable` through which it may
  79. * be accessed.
  80. *
  81. * @class
  82. * @param {object} [init={}] Configuration object for DataTables. Options
  83. * are defined by {@link DataTable.defaults}
  84. * @requires jQuery 1.7+
  85. *
  86. * @example
  87. * // Basic initialisation
  88. * $(document).ready( function {
  89. * $('#example').dataTable();
  90. * } );
  91. *
  92. * @example
  93. * // Initialisation with configuration options - in this case, disable
  94. * // pagination and sorting.
  95. * $(document).ready( function {
  96. * $('#example').dataTable( {
  97. * "paginate": false,
  98. * "sort": false
  99. * } );
  100. * } );
  101. */
  102. var DataTable = function ( options )
  103. {
  104. /**
  105. * Perform a jQuery selector action on the table's TR elements (from the tbody) and
  106. * return the resulting jQuery object.
  107. * @param {string|node|jQuery} sSelector jQuery selector or node collection to act on
  108. * @param {object} [oOpts] Optional parameters for modifying the rows to be included
  109. * @param {string} [oOpts.filter=none] Select TR elements that meet the current filter
  110. * criterion ("applied") or all TR elements (i.e. no filter).
  111. * @param {string} [oOpts.order=current] Order of the TR elements in the processed array.
  112. * Can be either 'current', whereby the current sorting of the table is used, or
  113. * 'original' whereby the original order the data was read into the table is used.
  114. * @param {string} [oOpts.page=all] Limit the selection to the currently displayed page
  115. * ("current") or not ("all"). If 'current' is given, then order is assumed to be
  116. * 'current' and filter is 'applied', regardless of what they might be given as.
  117. * @returns {object} jQuery object, filtered by the given selector.
  118. * @dtopt API
  119. * @deprecated Since v1.10
  120. *
  121. * @example
  122. * $(document).ready(function() {
  123. * var oTable = $('#example').dataTable();
  124. *
  125. * // Highlight every second row
  126. * oTable.$('tr:odd').css('backgroundColor', 'blue');
  127. * } );
  128. *
  129. * @example
  130. * $(document).ready(function() {
  131. * var oTable = $('#example').dataTable();
  132. *
  133. * // Filter to rows with 'Webkit' in them, add a background colour and then
  134. * // remove the filter, thus highlighting the 'Webkit' rows only.
  135. * oTable.fnFilter('Webkit');
  136. * oTable.$('tr', {"search": "applied"}).css('backgroundColor', 'blue');
  137. * oTable.fnFilter('');
  138. * } );
  139. */
  140. this.$ = function ( sSelector, oOpts )
  141. {
  142. return this.api(true).$( sSelector, oOpts );
  143. };
  144. /**
  145. * Almost identical to $ in operation, but in this case returns the data for the matched
  146. * rows - as such, the jQuery selector used should match TR row nodes or TD/TH cell nodes
  147. * rather than any descendants, so the data can be obtained for the row/cell. If matching
  148. * rows are found, the data returned is the original data array/object that was used to
  149. * create the row (or a generated array if from a DOM source).
  150. *
  151. * This method is often useful in-combination with $ where both functions are given the
  152. * same parameters and the array indexes will match identically.
  153. * @param {string|node|jQuery} sSelector jQuery selector or node collection to act on
  154. * @param {object} [oOpts] Optional parameters for modifying the rows to be included
  155. * @param {string} [oOpts.filter=none] Select elements that meet the current filter
  156. * criterion ("applied") or all elements (i.e. no filter).
  157. * @param {string} [oOpts.order=current] Order of the data in the processed array.
  158. * Can be either 'current', whereby the current sorting of the table is used, or
  159. * 'original' whereby the original order the data was read into the table is used.
  160. * @param {string} [oOpts.page=all] Limit the selection to the currently displayed page
  161. * ("current") or not ("all"). If 'current' is given, then order is assumed to be
  162. * 'current' and filter is 'applied', regardless of what they might be given as.
  163. * @returns {array} Data for the matched elements. If any elements, as a result of the
  164. * selector, were not TR, TD or TH elements in the DataTable, they will have a null
  165. * entry in the array.
  166. * @dtopt API
  167. * @deprecated Since v1.10
  168. *
  169. * @example
  170. * $(document).ready(function() {
  171. * var oTable = $('#example').dataTable();
  172. *
  173. * // Get the data from the first row in the table
  174. * var data = oTable._('tr:first');
  175. *
  176. * // Do something useful with the data
  177. * alert( "First cell is: "+data[0] );
  178. * } );
  179. *
  180. * @example
  181. * $(document).ready(function() {
  182. * var oTable = $('#example').dataTable();
  183. *
  184. * // Filter to 'Webkit' and get all data for
  185. * oTable.fnFilter('Webkit');
  186. * var data = oTable._('tr', {"search": "applied"});
  187. *
  188. * // Do something with the data
  189. * alert( data.length+" rows matched the search" );
  190. * } );
  191. */
  192. this._ = function ( sSelector, oOpts )
  193. {
  194. return this.api(true).rows( sSelector, oOpts ).data();
  195. };
  196. /**
  197. * Create a DataTables Api instance, with the currently selected tables for
  198. * the Api's context.
  199. * @param {boolean} [traditional=false] Set the API instance's context to be
  200. * only the table referred to by the `DataTable.ext.iApiIndex` option, as was
  201. * used in the API presented by DataTables 1.9- (i.e. the traditional mode),
  202. * or if all tables captured in the jQuery object should be used.
  203. * @return {DataTables.Api}
  204. */
  205. this.api = function ( traditional )
  206. {
  207. return traditional ?
  208. new _Api(
  209. _fnSettingsFromNode( this[ _ext.iApiIndex ] )
  210. ) :
  211. new _Api( this );
  212. };
  213. /**
  214. * Add a single new row or multiple rows of data to the table. Please note
  215. * that this is suitable for client-side processing only - if you are using
  216. * server-side processing (i.e. "bServerSide": true), then to add data, you
  217. * must add it to the data source, i.e. the server-side, through an Ajax call.
  218. * @param {array|object} data The data to be added to the table. This can be:
  219. * <ul>
  220. * <li>1D array of data - add a single row with the data provided</li>
  221. * <li>2D array of arrays - add multiple rows in a single call</li>
  222. * <li>object - data object when using <i>mData</i></li>
  223. * <li>array of objects - multiple data objects when using <i>mData</i></li>
  224. * </ul>
  225. * @param {bool} [redraw=true] redraw the table or not
  226. * @returns {array} An array of integers, representing the list of indexes in
  227. * <i>aoData</i> ({@link DataTable.models.oSettings}) that have been added to
  228. * the table.
  229. * @dtopt API
  230. * @deprecated Since v1.10
  231. *
  232. * @example
  233. * // Global var for counter
  234. * var giCount = 2;
  235. *
  236. * $(document).ready(function() {
  237. * $('#example').dataTable();
  238. * } );
  239. *
  240. * function fnClickAddRow() {
  241. * $('#example').dataTable().fnAddData( [
  242. * giCount+".1",
  243. * giCount+".2",
  244. * giCount+".3",
  245. * giCount+".4" ]
  246. * );
  247. *
  248. * giCount++;
  249. * }
  250. */
  251. this.fnAddData = function( data, redraw )
  252. {
  253. var api = this.api( true );
  254. /* Check if we want to add multiple rows or not */
  255. var rows = $.isArray(data) && ( $.isArray(data[0]) || $.isPlainObject(data[0]) ) ?
  256. api.rows.add( data ) :
  257. api.row.add( data );
  258. if ( redraw === undefined || redraw ) {
  259. api.draw();
  260. }
  261. return rows.flatten().toArray();
  262. };
  263. /**
  264. * This function will make DataTables recalculate the column sizes, based on the data
  265. * contained in the table and the sizes applied to the columns (in the DOM, CSS or
  266. * through the sWidth parameter). This can be useful when the width of the table's
  267. * parent element changes (for example a window resize).
  268. * @param {boolean} [bRedraw=true] Redraw the table or not, you will typically want to
  269. * @dtopt API
  270. * @deprecated Since v1.10
  271. *
  272. * @example
  273. * $(document).ready(function() {
  274. * var oTable = $('#example').dataTable( {
  275. * "sScrollY": "200px",
  276. * "bPaginate": false
  277. * } );
  278. *
  279. * $(window).on('resize', function () {
  280. * oTable.fnAdjustColumnSizing();
  281. * } );
  282. * } );
  283. */
  284. this.fnAdjustColumnSizing = function ( bRedraw )
  285. {
  286. var api = this.api( true ).columns.adjust();
  287. var settings = api.settings()[0];
  288. var scroll = settings.oScroll;
  289. if ( bRedraw === undefined || bRedraw ) {
  290. api.draw( false );
  291. }
  292. else if ( scroll.sX !== "" || scroll.sY !== "" ) {
  293. /* If not redrawing, but scrolling, we want to apply the new column sizes anyway */
  294. _fnScrollDraw( settings );
  295. }
  296. };
  297. /**
  298. * Quickly and simply clear a table
  299. * @param {bool} [bRedraw=true] redraw the table or not
  300. * @dtopt API
  301. * @deprecated Since v1.10
  302. *
  303. * @example
  304. * $(document).ready(function() {
  305. * var oTable = $('#example').dataTable();
  306. *
  307. * // Immediately 'nuke' the current rows (perhaps waiting for an Ajax callback...)
  308. * oTable.fnClearTable();
  309. * } );
  310. */
  311. this.fnClearTable = function( bRedraw )
  312. {
  313. var api = this.api( true ).clear();
  314. if ( bRedraw === undefined || bRedraw ) {
  315. api.draw();
  316. }
  317. };
  318. /**
  319. * The exact opposite of 'opening' a row, this function will close any rows which
  320. * are currently 'open'.
  321. * @param {node} nTr the table row to 'close'
  322. * @returns {int} 0 on success, or 1 if failed (can't find the row)
  323. * @dtopt API
  324. * @deprecated Since v1.10
  325. *
  326. * @example
  327. * $(document).ready(function() {
  328. * var oTable;
  329. *
  330. * // 'open' an information row when a row is clicked on
  331. * $('#example tbody tr').click( function () {
  332. * if ( oTable.fnIsOpen(this) ) {
  333. * oTable.fnClose( this );
  334. * } else {
  335. * oTable.fnOpen( this, "Temporary row opened", "info_row" );
  336. * }
  337. * } );
  338. *
  339. * oTable = $('#example').dataTable();
  340. * } );
  341. */
  342. this.fnClose = function( nTr )
  343. {
  344. this.api( true ).row( nTr ).child.hide();
  345. };
  346. /**
  347. * Remove a row for the table
  348. * @param {mixed} target The index of the row from aoData to be deleted, or
  349. * the TR element you want to delete
  350. * @param {function|null} [callBack] Callback function
  351. * @param {bool} [redraw=true] Redraw the table or not
  352. * @returns {array} The row that was deleted
  353. * @dtopt API
  354. * @deprecated Since v1.10
  355. *
  356. * @example
  357. * $(document).ready(function() {
  358. * var oTable = $('#example').dataTable();
  359. *
  360. * // Immediately remove the first row
  361. * oTable.fnDeleteRow( 0 );
  362. * } );
  363. */
  364. this.fnDeleteRow = function( target, callback, redraw )
  365. {
  366. var api = this.api( true );
  367. var rows = api.rows( target );
  368. var settings = rows.settings()[0];
  369. var data = settings.aoData[ rows[0][0] ];
  370. rows.remove();
  371. if ( callback ) {
  372. callback.call( this, settings, data );
  373. }
  374. if ( redraw === undefined || redraw ) {
  375. api.draw();
  376. }
  377. return data;
  378. };
  379. /**
  380. * Restore the table to it's original state in the DOM by removing all of DataTables
  381. * enhancements, alterations to the DOM structure of the table and event listeners.
  382. * @param {boolean} [remove=false] Completely remove the table from the DOM
  383. * @dtopt API
  384. * @deprecated Since v1.10
  385. *
  386. * @example
  387. * $(document).ready(function() {
  388. * // This example is fairly pointless in reality, but shows how fnDestroy can be used
  389. * var oTable = $('#example').dataTable();
  390. * oTable.fnDestroy();
  391. * } );
  392. */
  393. this.fnDestroy = function ( remove )
  394. {
  395. this.api( true ).destroy( remove );
  396. };
  397. /**
  398. * Redraw the table
  399. * @param {bool} [complete=true] Re-filter and resort (if enabled) the table before the draw.
  400. * @dtopt API
  401. * @deprecated Since v1.10
  402. *
  403. * @example
  404. * $(document).ready(function() {
  405. * var oTable = $('#example').dataTable();
  406. *
  407. * // Re-draw the table - you wouldn't want to do it here, but it's an example :-)
  408. * oTable.fnDraw();
  409. * } );
  410. */
  411. this.fnDraw = function( complete )
  412. {
  413. // Note that this isn't an exact match to the old call to _fnDraw - it takes
  414. // into account the new data, but can hold position.
  415. this.api( true ).draw( complete );
  416. };
  417. /**
  418. * Filter the input based on data
  419. * @param {string} sInput String to filter the table on
  420. * @param {int|null} [iColumn] Column to limit filtering to
  421. * @param {bool} [bRegex=false] Treat as regular expression or not
  422. * @param {bool} [bSmart=true] Perform smart filtering or not
  423. * @param {bool} [bShowGlobal=true] Show the input global filter in it's input box(es)
  424. * @param {bool} [bCaseInsensitive=true] Do case-insensitive matching (true) or not (false)
  425. * @dtopt API
  426. * @deprecated Since v1.10
  427. *
  428. * @example
  429. * $(document).ready(function() {
  430. * var oTable = $('#example').dataTable();
  431. *
  432. * // Sometime later - filter...
  433. * oTable.fnFilter( 'test string' );
  434. * } );
  435. */
  436. this.fnFilter = function( sInput, iColumn, bRegex, bSmart, bShowGlobal, bCaseInsensitive )
  437. {
  438. var api = this.api( true );
  439. if ( iColumn === null || iColumn === undefined ) {
  440. api.search( sInput, bRegex, bSmart, bCaseInsensitive );
  441. }
  442. else {
  443. api.column( iColumn ).search( sInput, bRegex, bSmart, bCaseInsensitive );
  444. }
  445. api.draw();
  446. };
  447. /**
  448. * Get the data for the whole table, an individual row or an individual cell based on the
  449. * provided parameters.
  450. * @param {int|node} [src] A TR row node, TD/TH cell node or an integer. If given as
  451. * a TR node then the data source for the whole row will be returned. If given as a
  452. * TD/TH cell node then iCol will be automatically calculated and the data for the
  453. * cell returned. If given as an integer, then this is treated as the aoData internal
  454. * data index for the row (see fnGetPosition) and the data for that row used.
  455. * @param {int} [col] Optional column index that you want the data of.
  456. * @returns {array|object|string} If mRow is undefined, then the data for all rows is
  457. * returned. If mRow is defined, just data for that row, and is iCol is
  458. * defined, only data for the designated cell is returned.
  459. * @dtopt API
  460. * @deprecated Since v1.10
  461. *
  462. * @example
  463. * // Row data
  464. * $(document).ready(function() {
  465. * oTable = $('#example').dataTable();
  466. *
  467. * oTable.$('tr').click( function () {
  468. * var data = oTable.fnGetData( this );
  469. * // ... do something with the array / object of data for the row
  470. * } );
  471. * } );
  472. *
  473. * @example
  474. * // Individual cell data
  475. * $(document).ready(function() {
  476. * oTable = $('#example').dataTable();
  477. *
  478. * oTable.$('td').click( function () {
  479. * var sData = oTable.fnGetData( this );
  480. * alert( 'The cell clicked on had the value of '+sData );
  481. * } );
  482. * } );
  483. */
  484. this.fnGetData = function( src, col )
  485. {
  486. var api = this.api( true );
  487. if ( src !== undefined ) {
  488. var type = src.nodeName ? src.nodeName.toLowerCase() : '';
  489. return col !== undefined || type == 'td' || type == 'th' ?
  490. api.cell( src, col ).data() :
  491. api.row( src ).data() || null;
  492. }
  493. return api.data().toArray();
  494. };
  495. /**
  496. * Get an array of the TR nodes that are used in the table's body. Note that you will
  497. * typically want to use the '$' API method in preference to this as it is more
  498. * flexible.
  499. * @param {int} [iRow] Optional row index for the TR element you want
  500. * @returns {array|node} If iRow is undefined, returns an array of all TR elements
  501. * in the table's body, or iRow is defined, just the TR element requested.
  502. * @dtopt API
  503. * @deprecated Since v1.10
  504. *
  505. * @example
  506. * $(document).ready(function() {
  507. * var oTable = $('#example').dataTable();
  508. *
  509. * // Get the nodes from the table
  510. * var nNodes = oTable.fnGetNodes( );
  511. * } );
  512. */
  513. this.fnGetNodes = function( iRow )
  514. {
  515. var api = this.api( true );
  516. return iRow !== undefined ?
  517. api.row( iRow ).node() :
  518. api.rows().nodes().flatten().toArray();
  519. };
  520. /**
  521. * Get the array indexes of a particular cell from it's DOM element
  522. * and column index including hidden columns
  523. * @param {node} node this can either be a TR, TD or TH in the table's body
  524. * @returns {int} If nNode is given as a TR, then a single index is returned, or
  525. * if given as a cell, an array of [row index, column index (visible),
  526. * column index (all)] is given.
  527. * @dtopt API
  528. * @deprecated Since v1.10
  529. *
  530. * @example
  531. * $(document).ready(function() {
  532. * $('#example tbody td').click( function () {
  533. * // Get the position of the current data from the node
  534. * var aPos = oTable.fnGetPosition( this );
  535. *
  536. * // Get the data array for this row
  537. * var aData = oTable.fnGetData( aPos[0] );
  538. *
  539. * // Update the data array and return the value
  540. * aData[ aPos[1] ] = 'clicked';
  541. * this.innerHTML = 'clicked';
  542. * } );
  543. *
  544. * // Init DataTables
  545. * oTable = $('#example').dataTable();
  546. * } );
  547. */
  548. this.fnGetPosition = function( node )
  549. {
  550. var api = this.api( true );
  551. var nodeName = node.nodeName.toUpperCase();
  552. if ( nodeName == 'TR' ) {
  553. return api.row( node ).index();
  554. }
  555. else if ( nodeName == 'TD' || nodeName == 'TH' ) {
  556. var cell = api.cell( node ).index();
  557. return [
  558. cell.row,
  559. cell.columnVisible,
  560. cell.column
  561. ];
  562. }
  563. return null;
  564. };
  565. /**
  566. * Check to see if a row is 'open' or not.
  567. * @param {node} nTr the table row to check
  568. * @returns {boolean} true if the row is currently open, false otherwise
  569. * @dtopt API
  570. * @deprecated Since v1.10
  571. *
  572. * @example
  573. * $(document).ready(function() {
  574. * var oTable;
  575. *
  576. * // 'open' an information row when a row is clicked on
  577. * $('#example tbody tr').click( function () {
  578. * if ( oTable.fnIsOpen(this) ) {
  579. * oTable.fnClose( this );
  580. * } else {
  581. * oTable.fnOpen( this, "Temporary row opened", "info_row" );
  582. * }
  583. * } );
  584. *
  585. * oTable = $('#example').dataTable();
  586. * } );
  587. */
  588. this.fnIsOpen = function( nTr )
  589. {
  590. return this.api( true ).row( nTr ).child.isShown();
  591. };
  592. /**
  593. * This function will place a new row directly after a row which is currently
  594. * on display on the page, with the HTML contents that is passed into the
  595. * function. This can be used, for example, to ask for confirmation that a
  596. * particular record should be deleted.
  597. * @param {node} nTr The table row to 'open'
  598. * @param {string|node|jQuery} mHtml The HTML to put into the row
  599. * @param {string} sClass Class to give the new TD cell
  600. * @returns {node} The row opened. Note that if the table row passed in as the
  601. * first parameter, is not found in the table, this method will silently
  602. * return.
  603. * @dtopt API
  604. * @deprecated Since v1.10
  605. *
  606. * @example
  607. * $(document).ready(function() {
  608. * var oTable;
  609. *
  610. * // 'open' an information row when a row is clicked on
  611. * $('#example tbody tr').click( function () {
  612. * if ( oTable.fnIsOpen(this) ) {
  613. * oTable.fnClose( this );
  614. * } else {
  615. * oTable.fnOpen( this, "Temporary row opened", "info_row" );
  616. * }
  617. * } );
  618. *
  619. * oTable = $('#example').dataTable();
  620. * } );
  621. */
  622. this.fnOpen = function( nTr, mHtml, sClass )
  623. {
  624. return this.api( true )
  625. .row( nTr )
  626. .child( mHtml, sClass )
  627. .show()
  628. .child()[0];
  629. };
  630. /**
  631. * Change the pagination - provides the internal logic for pagination in a simple API
  632. * function. With this function you can have a DataTables table go to the next,
  633. * previous, first or last pages.
  634. * @param {string|int} mAction Paging action to take: "first", "previous", "next" or "last"
  635. * or page number to jump to (integer), note that page 0 is the first page.
  636. * @param {bool} [bRedraw=true] Redraw the table or not
  637. * @dtopt API
  638. * @deprecated Since v1.10
  639. *
  640. * @example
  641. * $(document).ready(function() {
  642. * var oTable = $('#example').dataTable();
  643. * oTable.fnPageChange( 'next' );
  644. * } );
  645. */
  646. this.fnPageChange = function ( mAction, bRedraw )
  647. {
  648. var api = this.api( true ).page( mAction );
  649. if ( bRedraw === undefined || bRedraw ) {
  650. api.draw(false);
  651. }
  652. };
  653. /**
  654. * Show a particular column
  655. * @param {int} iCol The column whose display should be changed
  656. * @param {bool} bShow Show (true) or hide (false) the column
  657. * @param {bool} [bRedraw=true] Redraw the table or not
  658. * @dtopt API
  659. * @deprecated Since v1.10
  660. *
  661. * @example
  662. * $(document).ready(function() {
  663. * var oTable = $('#example').dataTable();
  664. *
  665. * // Hide the second column after initialisation
  666. * oTable.fnSetColumnVis( 1, false );
  667. * } );
  668. */
  669. this.fnSetColumnVis = function ( iCol, bShow, bRedraw )
  670. {
  671. var api = this.api( true ).column( iCol ).visible( bShow );
  672. if ( bRedraw === undefined || bRedraw ) {
  673. api.columns.adjust().draw();
  674. }
  675. };
  676. /**
  677. * Get the settings for a particular table for external manipulation
  678. * @returns {object} DataTables settings object. See
  679. * {@link DataTable.models.oSettings}
  680. * @dtopt API
  681. * @deprecated Since v1.10
  682. *
  683. * @example
  684. * $(document).ready(function() {
  685. * var oTable = $('#example').dataTable();
  686. * var oSettings = oTable.fnSettings();
  687. *
  688. * // Show an example parameter from the settings
  689. * alert( oSettings._iDisplayStart );
  690. * } );
  691. */
  692. this.fnSettings = function()
  693. {
  694. return _fnSettingsFromNode( this[_ext.iApiIndex] );
  695. };
  696. /**
  697. * Sort the table by a particular column
  698. * @param {int} iCol the data index to sort on. Note that this will not match the
  699. * 'display index' if you have hidden data entries
  700. * @dtopt API
  701. * @deprecated Since v1.10
  702. *
  703. * @example
  704. * $(document).ready(function() {
  705. * var oTable = $('#example').dataTable();
  706. *
  707. * // Sort immediately with columns 0 and 1
  708. * oTable.fnSort( [ [0,'asc'], [1,'asc'] ] );
  709. * } );
  710. */
  711. this.fnSort = function( aaSort )
  712. {
  713. this.api( true ).order( aaSort ).draw();
  714. };
  715. /**
  716. * Attach a sort listener to an element for a given column
  717. * @param {node} nNode the element to attach the sort listener to
  718. * @param {int} iColumn the column that a click on this node will sort on
  719. * @param {function} [fnCallback] callback function when sort is run
  720. * @dtopt API
  721. * @deprecated Since v1.10
  722. *
  723. * @example
  724. * $(document).ready(function() {
  725. * var oTable = $('#example').dataTable();
  726. *
  727. * // Sort on column 1, when 'sorter' is clicked on
  728. * oTable.fnSortListener( document.getElementById('sorter'), 1 );
  729. * } );
  730. */
  731. this.fnSortListener = function( nNode, iColumn, fnCallback )
  732. {
  733. this.api( true ).order.listener( nNode, iColumn, fnCallback );
  734. };
  735. /**
  736. * Update a table cell or row - this method will accept either a single value to
  737. * update the cell with, an array of values with one element for each column or
  738. * an object in the same format as the original data source. The function is
  739. * self-referencing in order to make the multi column updates easier.
  740. * @param {object|array|string} mData Data to update the cell/row with
  741. * @param {node|int} mRow TR element you want to update or the aoData index
  742. * @param {int} [iColumn] The column to update, give as null or undefined to
  743. * update a whole row.
  744. * @param {bool} [bRedraw=true] Redraw the table or not
  745. * @param {bool} [bAction=true] Perform pre-draw actions or not
  746. * @returns {int} 0 on success, 1 on error
  747. * @dtopt API
  748. * @deprecated Since v1.10
  749. *
  750. * @example
  751. * $(document).ready(function() {
  752. * var oTable = $('#example').dataTable();
  753. * oTable.fnUpdate( 'Example update', 0, 0 ); // Single cell
  754. * oTable.fnUpdate( ['a', 'b', 'c', 'd', 'e'], $('tbody tr')[0] ); // Row
  755. * } );
  756. */
  757. this.fnUpdate = function( mData, mRow, iColumn, bRedraw, bAction )
  758. {
  759. var api = this.api( true );
  760. if ( iColumn === undefined || iColumn === null ) {
  761. api.row( mRow ).data( mData );
  762. }
  763. else {
  764. api.cell( mRow, iColumn ).data( mData );
  765. }
  766. if ( bAction === undefined || bAction ) {
  767. api.columns.adjust();
  768. }
  769. if ( bRedraw === undefined || bRedraw ) {
  770. api.draw();
  771. }
  772. return 0;
  773. };
  774. /**
  775. * Provide a common method for plug-ins to check the version of DataTables being used, in order
  776. * to ensure compatibility.
  777. * @param {string} sVersion Version string to check for, in the format "X.Y.Z". Note that the
  778. * formats "X" and "X.Y" are also acceptable.
  779. * @returns {boolean} true if this version of DataTables is greater or equal to the required
  780. * version, or false if this version of DataTales is not suitable
  781. * @method
  782. * @dtopt API
  783. * @deprecated Since v1.10
  784. *
  785. * @example
  786. * $(document).ready(function() {
  787. * var oTable = $('#example').dataTable();
  788. * alert( oTable.fnVersionCheck( '1.9.0' ) );
  789. * } );
  790. */
  791. this.fnVersionCheck = _ext.fnVersionCheck;
  792. var _that = this;
  793. var emptyInit = options === undefined;
  794. var len = this.length;
  795. if ( emptyInit ) {
  796. options = {};
  797. }
  798. this.oApi = this.internal = _ext.internal;
  799. // Extend with old style plug-in API methods
  800. for ( var fn in DataTable.ext.internal ) {
  801. if ( fn ) {
  802. this[fn] = _fnExternApiFunc(fn);
  803. }
  804. }
  805. this.each(function() {
  806. // For each initialisation we want to give it a clean initialisation
  807. // object that can be bashed around
  808. var o = {};
  809. var oInit = len > 1 ? // optimisation for single table case
  810. _fnExtend( o, options, true ) :
  811. options;
  812. /*global oInit,_that,emptyInit*/
  813. var i=0, iLen, j, jLen, k, kLen;
  814. var sId = this.getAttribute( 'id' );
  815. var bInitHandedOff = false;
  816. var defaults = DataTable.defaults;
  817. var $this = $(this);
  818. /* Sanity check */
  819. if ( this.nodeName.toLowerCase() != 'table' )
  820. {
  821. _fnLog( null, 0, 'Non-table node initialisation ('+this.nodeName+')', 2 );
  822. return;
  823. }
  824. /* Backwards compatibility for the defaults */
  825. _fnCompatOpts( defaults );
  826. _fnCompatCols( defaults.column );
  827. /* Convert the camel-case defaults to Hungarian */
  828. _fnCamelToHungarian( defaults, defaults, true );
  829. _fnCamelToHungarian( defaults.column, defaults.column, true );
  830. /* Setting up the initialisation object */
  831. _fnCamelToHungarian( defaults, $.extend( oInit, $this.data() ) );
  832. /* Check to see if we are re-initialising a table */
  833. var allSettings = DataTable.settings;
  834. for ( i=0, iLen=allSettings.length ; i<iLen ; i++ )
  835. {
  836. var s = allSettings[i];
  837. /* Base check on table node */
  838. if (
  839. s.nTable == this ||
  840. (s.nTHead && s.nTHead.parentNode == this) ||
  841. (s.nTFoot && s.nTFoot.parentNode == this)
  842. ) {
  843. var bRetrieve = oInit.bRetrieve !== undefined ? oInit.bRetrieve : defaults.bRetrieve;
  844. var bDestroy = oInit.bDestroy !== undefined ? oInit.bDestroy : defaults.bDestroy;
  845. if ( emptyInit || bRetrieve )
  846. {
  847. return s.oInstance;
  848. }
  849. else if ( bDestroy )
  850. {
  851. s.oInstance.fnDestroy();
  852. break;
  853. }
  854. else
  855. {
  856. _fnLog( s, 0, 'Cannot reinitialise DataTable', 3 );
  857. return;
  858. }
  859. }
  860. /* If the element we are initialising has the same ID as a table which was previously
  861. * initialised, but the table nodes don't match (from before) then we destroy the old
  862. * instance by simply deleting it. This is under the assumption that the table has been
  863. * destroyed by other methods. Anyone using non-id selectors will need to do this manually
  864. */
  865. if ( s.sTableId == this.id )
  866. {
  867. allSettings.splice( i, 1 );
  868. break;
  869. }
  870. }
  871. /* Ensure the table has an ID - required for accessibility */
  872. if ( sId === null || sId === "" )
  873. {
  874. sId = "DataTables_Table_"+(DataTable.ext._unique++);
  875. this.id = sId;
  876. }
  877. /* Create the settings object for this table and set some of the default parameters */
  878. var oSettings = $.extend( true, {}, DataTable.models.oSettings, {
  879. "sDestroyWidth": $this[0].style.width,
  880. "sInstance": sId,
  881. "sTableId": sId
  882. } );
  883. oSettings.nTable = this;
  884. oSettings.oApi = _that.internal;
  885. oSettings.oInit = oInit;
  886. allSettings.push( oSettings );
  887. // Need to add the instance after the instance after the settings object has been added
  888. // to the settings array, so we can self reference the table instance if more than one
  889. oSettings.oInstance = (_that.length===1) ? _that : $this.dataTable();
  890. // Backwards compatibility, before we apply all the defaults
  891. _fnCompatOpts( oInit );
  892. _fnLanguageCompat( oInit.oLanguage );
  893. // If the length menu is given, but the init display length is not, use the length menu
  894. if ( oInit.aLengthMenu && ! oInit.iDisplayLength )
  895. {
  896. oInit.iDisplayLength = $.isArray( oInit.aLengthMenu[0] ) ?
  897. oInit.aLengthMenu[0][0] : oInit.aLengthMenu[0];
  898. }
  899. // Apply the defaults and init options to make a single init object will all
  900. // options defined from defaults and instance options.
  901. oInit = _fnExtend( $.extend( true, {}, defaults ), oInit );
  902. // Map the initialisation options onto the settings object
  903. _fnMap( oSettings.oFeatures, oInit, [
  904. "bPaginate",
  905. "bLengthChange",
  906. "bFilter",
  907. "bSort",
  908. "bSortMulti",
  909. "bInfo",
  910. "bProcessing",
  911. "bAutoWidth",
  912. "bSortClasses",
  913. "bServerSide",
  914. "bDeferRender"
  915. ] );
  916. _fnMap( oSettings, oInit, [
  917. "asStripeClasses",
  918. "ajax",
  919. "fnServerData",
  920. "fnFormatNumber",
  921. "sServerMethod",
  922. "aaSorting",
  923. "aaSortingFixed",
  924. "aLengthMenu",
  925. "sPaginationType",
  926. "sAjaxSource",
  927. "sAjaxDataProp",
  928. "iStateDuration",
  929. "sDom",
  930. "bSortCellsTop",
  931. "iTabIndex",
  932. "fnStateLoadCallback",
  933. "fnStateSaveCallback",
  934. "renderer",
  935. "searchDelay",
  936. "rowId",
  937. [ "iCookieDuration", "iStateDuration" ], // backwards compat
  938. [ "oSearch", "oPreviousSearch" ],
  939. [ "aoSearchCols", "aoPreSearchCols" ],
  940. [ "iDisplayLength", "_iDisplayLength" ]
  941. ] );
  942. _fnMap( oSettings.oScroll, oInit, [
  943. [ "sScrollX", "sX" ],
  944. [ "sScrollXInner", "sXInner" ],
  945. [ "sScrollY", "sY" ],
  946. [ "bScrollCollapse", "bCollapse" ]
  947. ] );
  948. _fnMap( oSettings.oLanguage, oInit, "fnInfoCallback" );
  949. /* Callback functions which are array driven */
  950. _fnCallbackReg( oSettings, 'aoDrawCallback', oInit.fnDrawCallback, 'user' );
  951. _fnCallbackReg( oSettings, 'aoServerParams', oInit.fnServerParams, 'user' );
  952. _fnCallbackReg( oSettings, 'aoStateSaveParams', oInit.fnStateSaveParams, 'user' );
  953. _fnCallbackReg( oSettings, 'aoStateLoadParams', oInit.fnStateLoadParams, 'user' );
  954. _fnCallbackReg( oSettings, 'aoStateLoaded', oInit.fnStateLoaded, 'user' );
  955. _fnCallbackReg( oSettings, 'aoRowCallback', oInit.fnRowCallback, 'user' );
  956. _fnCallbackReg( oSettings, 'aoRowCreatedCallback', oInit.fnCreatedRow, 'user' );
  957. _fnCallbackReg( oSettings, 'aoHeaderCallback', oInit.fnHeaderCallback, 'user' );
  958. _fnCallbackReg( oSettings, 'aoFooterCallback', oInit.fnFooterCallback, 'user' );
  959. _fnCallbackReg( oSettings, 'aoInitComplete', oInit.fnInitComplete, 'user' );
  960. _fnCallbackReg( oSettings, 'aoPreDrawCallback', oInit.fnPreDrawCallback, 'user' );
  961. oSettings.rowIdFn = _fnGetObjectDataFn( oInit.rowId );
  962. /* Browser support detection */
  963. _fnBrowserDetect( oSettings );
  964. var oClasses = oSettings.oClasses;
  965. $.extend( oClasses, DataTable.ext.classes, oInit.oClasses );
  966. $this.addClass( oClasses.sTable );
  967. if ( oSettings.iInitDisplayStart === undefined )
  968. {
  969. /* Display start point, taking into account the save saving */
  970. oSettings.iInitDisplayStart = oInit.iDisplayStart;
  971. oSettings._iDisplayStart = oInit.iDisplayStart;
  972. }
  973. if ( oInit.iDeferLoading !== null )
  974. {
  975. oSettings.bDeferLoading = true;
  976. var tmp = $.isArray( oInit.iDeferLoading );
  977. oSettings._iRecordsDisplay = tmp ? oInit.iDeferLoading[0] : oInit.iDeferLoading;
  978. oSettings._iRecordsTotal = tmp ? oInit.iDeferLoading[1] : oInit.iDeferLoading;
  979. }
  980. /* Language definitions */
  981. var oLanguage = oSettings.oLanguage;
  982. $.extend( true, oLanguage, oInit.oLanguage );
  983. if ( oLanguage.sUrl )
  984. {
  985. /* Get the language definitions from a file - because this Ajax call makes the language
  986. * get async to the remainder of this function we use bInitHandedOff to indicate that
  987. * _fnInitialise will be fired by the returned Ajax handler, rather than the constructor
  988. */
  989. $.ajax( {
  990. dataType: 'json',
  991. url: oLanguage.sUrl,
  992. success: function ( json ) {
  993. _fnLanguageCompat( json );
  994. _fnCamelToHungarian( defaults.oLanguage, json );
  995. $.extend( true, oLanguage, json );
  996. _fnInitialise( oSettings );
  997. },
  998. error: function () {
  999. // Error occurred loading language file, continue on as best we can
  1000. _fnInitialise( oSettings );
  1001. }
  1002. } );
  1003. bInitHandedOff = true;
  1004. }
  1005. /*
  1006. * Stripes
  1007. */
  1008. if ( oInit.asStripeClasses === null )
  1009. {
  1010. oSettings.asStripeClasses =[
  1011. oClasses.sStripeOdd,
  1012. oClasses.sStripeEven
  1013. ];
  1014. }
  1015. /* Remove row stripe classes if they are already on the table row */
  1016. var stripeClasses = oSettings.asStripeClasses;
  1017. var rowOne = $this.children('tbody').find('tr').eq(0);
  1018. if ( $.inArray( true, $.map( stripeClasses, function(el, i) {
  1019. return rowOne.hasClass(el);
  1020. } ) ) !== -1 ) {
  1021. $('tbody tr', this).removeClass( stripeClasses.join(' ') );
  1022. oSettings.asDestroyStripes = stripeClasses.slice();
  1023. }
  1024. /*
  1025. * Columns
  1026. * See if we should load columns automatically or use defined ones
  1027. */
  1028. var anThs = [];
  1029. var aoColumnsInit;
  1030. var nThead = this.getElementsByTagName('thead');
  1031. if ( nThead.length !== 0 )
  1032. {
  1033. _fnDetectHeader( oSettings.aoHeader, nThead[0] );
  1034. anThs = _fnGetUniqueThs( oSettings );
  1035. }
  1036. /* If not given a column array, generate one with nulls */
  1037. if ( oInit.aoColumns === null )
  1038. {
  1039. aoColumnsInit = [];
  1040. for ( i=0, iLen=anThs.length ; i<iLen ; i++ )
  1041. {
  1042. aoColumnsInit.push( null );
  1043. }
  1044. }
  1045. else
  1046. {
  1047. aoColumnsInit = oInit.aoColumns;
  1048. }
  1049. /* Add the columns */
  1050. for ( i=0, iLen=aoColumnsInit.length ; i<iLen ; i++ )
  1051. {
  1052. _fnAddColumn( oSettings, anThs ? anThs[i] : null );
  1053. }
  1054. /* Apply the column definitions */
  1055. _fnApplyColumnDefs( oSettings, oInit.aoColumnDefs, aoColumnsInit, function (iCol, oDef) {
  1056. _fnColumnOptions( oSettings, iCol, oDef );
  1057. } );
  1058. /* HTML5 attribute detection - build an mData object automatically if the
  1059. * attributes are found
  1060. */
  1061. if ( rowOne.length ) {
  1062. var a = function ( cell, name ) {
  1063. return cell.getAttribute( 'data-'+name ) !== null ? name : null;
  1064. };
  1065. $( rowOne[0] ).children('th, td').each( function (i, cell) {
  1066. var col = oSettings.aoColumns[i];
  1067. if ( col.mData === i ) {
  1068. var sort = a( cell, 'sort' ) || a( cell, 'order' );
  1069. var filter = a( cell, 'filter' ) || a( cell, 'search' );
  1070. if ( sort !== null || filter !== null ) {
  1071. col.mData = {
  1072. _: i+'.display',
  1073. sort: sort !== null ? i+'.@data-'+sort : undefined,
  1074. type: sort !== null ? i+'.@data-'+sort : undefined,
  1075. filter: filter !== null ? i+'.@data-'+filter : undefined
  1076. };
  1077. _fnColumnOptions( oSettings, i );
  1078. }
  1079. }
  1080. } );
  1081. }
  1082. var features = oSettings.oFeatures;
  1083. var loadedInit = function () {
  1084. /*
  1085. * Sorting
  1086. * @todo For modularisation (1.11) this needs to do into a sort start up handler
  1087. */
  1088. // If aaSorting is not defined, then we use the first indicator in asSorting
  1089. // in case that has been altered, so the default sort reflects that option
  1090. if ( oInit.aaSorting === undefined ) {
  1091. var sorting = oSettings.aaSorting;
  1092. for ( i=0, iLen=sorting.length ; i<iLen ; i++ ) {
  1093. sorting[i][1] = oSettings.aoColumns[ i ].asSorting[0];
  1094. }
  1095. }
  1096. /* Do a first pass on the sorting classes (allows any size changes to be taken into
  1097. * account, and also will apply sorting disabled classes if disabled
  1098. */
  1099. _fnSortingClasses( oSettings );
  1100. if ( features.bSort ) {
  1101. _fnCallbackReg( oSettings, 'aoDrawCallback', function () {
  1102. if ( oSettings.bSorted ) {
  1103. var aSort = _fnSortFlatten( oSettings );
  1104. var sortedColumns = {};
  1105. $.each( aSort, function (i, val) {
  1106. sortedColumns[ val.src ] = val.dir;
  1107. } );
  1108. _fnCallbackFire( oSettings, null, 'order', [oSettings, aSort, sortedColumns] );
  1109. _fnSortAria( oSettings );
  1110. }
  1111. } );
  1112. }
  1113. _fnCallbackReg( oSettings, 'aoDrawCallback', function () {
  1114. if ( oSettings.bSorted || _fnDataSource( oSettings ) === 'ssp' || features.bDeferRender ) {
  1115. _fnSortingClasses( oSettings );
  1116. }
  1117. }, 'sc' );
  1118. /*
  1119. * Final init
  1120. * Cache the header, body and footer as required, creating them if needed
  1121. */
  1122. // Work around for Webkit bug 83867 - store the caption-side before removing from doc
  1123. var captions = $this.children('caption').each( function () {
  1124. this._captionSide = $(this).css('caption-side');
  1125. } );
  1126. var thead = $this.children('thead');
  1127. if ( thead.length === 0 ) {
  1128. thead = $('<thead/>').appendTo($this);
  1129. }
  1130. oSettings.nTHead = thead[0];
  1131. var tbody = $this.children('tbody');
  1132. if ( tbody.length === 0 ) {
  1133. tbody = $('<tbody/>').appendTo($this);
  1134. }
  1135. oSettings.nTBody = tbody[0];
  1136. var tfoot = $this.children('tfoot');
  1137. if ( tfoot.length === 0 && captions.length > 0 && (oSettings.oScroll.sX !== "" || oSettings.oScroll.sY !== "") ) {
  1138. // If we are a scrolling table, and no footer has been given, then we need to create
  1139. // a tfoot element for the caption element to be appended to
  1140. tfoot = $('<tfoot/>').appendTo($this);
  1141. }
  1142. if ( tfoot.length === 0 || tfoot.children().length === 0 ) {
  1143. $this.addClass( oClasses.sNoFooter );
  1144. }
  1145. else if ( tfoot.length > 0 ) {
  1146. oSettings.nTFoot = tfoot[0];
  1147. _fnDetectHeader( oSettings.aoFooter, oSettings.nTFoot );
  1148. }
  1149. /* Check if there is data passing into the constructor */
  1150. if ( oInit.aaData ) {
  1151. for ( i=0 ; i<oInit.aaData.length ; i++ ) {
  1152. _fnAddData( oSettings, oInit.aaData[ i ] );
  1153. }
  1154. }
  1155. else if ( oSettings.bDeferLoading || _fnDataSource( oSettings ) == 'dom' ) {
  1156. /* Grab the data from the page - only do this when deferred loading or no Ajax
  1157. * source since there is no point in reading the DOM data if we are then going
  1158. * to replace it with Ajax data
  1159. */
  1160. _fnAddTr( oSettings, $(oSettings.nTBody).children('tr') );
  1161. }
  1162. /* Copy the data index array */
  1163. oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();
  1164. /* Initialisation complete - table can be drawn */
  1165. oSettings.bInitialised = true;
  1166. /* Check if we need to initialise the table (it might not have been handed off to the
  1167. * language processor)
  1168. */
  1169. if ( bInitHandedOff === false ) {
  1170. _fnInitialise( oSettings );
  1171. }
  1172. };
  1173. /* Must be done after everything which can be overridden by the state saving! */
  1174. if ( oInit.bStateSave )
  1175. {
  1176. features.bStateSave = true;
  1177. _fnCallbackReg( oSettings, 'aoDrawCallback', _fnSaveState, 'state_save' );
  1178. _fnLoadState( oSettings, oInit, loadedInit );
  1179. }
  1180. else {
  1181. loadedInit();
  1182. }
  1183. } );
  1184. _that = null;
  1185. return this;
  1186. };
  1187. /*
  1188. * It is useful to have variables which are scoped locally so only the
  1189. * DataTables functions can access them and they don't leak into global space.
  1190. * At the same time these functions are often useful over multiple files in the
  1191. * core and API, so we list, or at least document, all variables which are used
  1192. * by DataTables as private variables here. This also ensures that there is no
  1193. * clashing of variable names and that they can easily referenced for reuse.
  1194. */
  1195. // Defined else where
  1196. // _selector_run
  1197. // _selector_opts
  1198. // _selector_first
  1199. // _selector_row_indexes
  1200. var _ext; // DataTable.ext
  1201. var _Api; // DataTable.Api
  1202. var _api_register; // DataTable.Api.register
  1203. var _api_registerPlural; // DataTable.Api.registerPlural
  1204. var _re_dic = {};
  1205. var _re_new_lines = /[\r\n]/g;
  1206. var _re_html = /<.*?>/g;
  1207. // This is not strict ISO8601 - Date.parse() is quite lax, although
  1208. // implementations differ between browsers.
  1209. var _re_date = /^\d{2,4}[\.\/\-]\d{1,2}[\.\/\-]\d{1,2}([T ]{1}\d{1,2}[:\.]\d{2}([\.:]\d{2})?)?$/;
  1210. // Escape regular expression special characters
  1211. var _re_escape_regex = new RegExp( '(\\' + [ '/', '.', '*', '+', '?', '|', '(', ')', '[', ']', '{', '}', '\\', '$', '^', '-' ].join('|\\') + ')', 'g' );
  1212. // http://en.wikipedia.org/wiki/Foreign_exchange_market
  1213. // - \u20BD - Russian ruble.
  1214. // - \u20a9 - South Korean Won
  1215. // - \u20BA - Turkish Lira
  1216. // - \u20B9 - Indian Rupee
  1217. // - R - Brazil (R$) and South Africa
  1218. // - fr - Swiss Franc
  1219. // - kr - Swedish krona, Norwegian krone and Danish krone
  1220. // - \u2009 is thin space and \u202F is narrow no-break space, both used in many
  1221. // - Ƀ - Bitcoin
  1222. // - Ξ - Ethereum
  1223. // standards as thousands separators.
  1224. var _re_formatted_numeric = /[',$£€¥%\u2009\u202F\u20BD\u20a9\u20BArfkɃΞ]/gi;
  1225. var _empty = function ( d ) {
  1226. return !d || d === true || d === '-' ? true : false;
  1227. };
  1228. var _intVal = function ( s ) {
  1229. var integer = parseInt( s, 10 );
  1230. return !isNaN(integer) && isFinite(s) ? integer : null;
  1231. };
  1232. // Convert from a formatted number with characters other than `.` as the
  1233. // decimal place, to a Javascript number
  1234. var _numToDecimal = function ( num, decimalPoint ) {
  1235. // Cache created regular expressions for speed as this function is called often
  1236. if ( ! _re_dic[ decimalPoint ] ) {
  1237. _re_dic[ decimalPoint ] = new RegExp( _fnEscapeRegex( decimalPoint ), 'g' );
  1238. }
  1239. return typeof num === 'string' && decimalPoint !== '.' ?
  1240. num.replace( /\./g, '' ).replace( _re_dic[ decimalPoint ], '.' ) :
  1241. num;
  1242. };
  1243. var _isNumber = function ( d, decimalPoint, formatted ) {
  1244. var strType = typeof d === 'string';
  1245. // If empty return immediately so there must be a number if it is a
  1246. // formatted string (this stops the string "k", or "kr", etc being detected
  1247. // as a formatted number for currency
  1248. if ( _empty( d ) ) {
  1249. return true;
  1250. }
  1251. if ( decimalPoint && strType ) {
  1252. d = _numToDecimal( d, decimalPoint );
  1253. }
  1254. if ( formatted && strType ) {
  1255. d = d.replace( _re_formatted_numeric, '' );
  1256. }
  1257. return !isNaN( parseFloat(d) ) && isFinite( d );
  1258. };
  1259. // A string without HTML in it can be considered to be HTML still
  1260. var _isHtml = function ( d ) {
  1261. return _empty( d ) || typeof d === 'string';
  1262. };
  1263. var _htmlNumeric = function ( d, decimalPoint, formatted ) {
  1264. if ( _empty( d ) ) {
  1265. return true;
  1266. }
  1267. var html = _isHtml( d );
  1268. return ! html ?
  1269. null :
  1270. _isNumber( _stripHtml( d ), decimalPoint, formatted ) ?
  1271. true :
  1272. null;
  1273. };
  1274. var _pluck = function ( a, prop, prop2 ) {
  1275. var out = [];
  1276. var i=0, ien=a.length;
  1277. // Could have the test in the loop for slightly smaller code, but speed
  1278. // is essential here
  1279. if ( prop2 !== undefined ) {
  1280. for ( ; i<ien ; i++ ) {
  1281. if ( a[i] && a[i][ prop ] ) {
  1282. out.push( a[i][ prop ][ prop2 ] );
  1283. }
  1284. }
  1285. }
  1286. else {
  1287. for ( ; i<ien ; i++ ) {
  1288. if ( a[i] ) {
  1289. out.push( a[i][ prop ] );
  1290. }
  1291. }
  1292. }
  1293. return out;
  1294. };
  1295. // Basically the same as _pluck, but rather than looping over `a` we use `order`
  1296. // as the indexes to pick from `a`
  1297. var _pluck_order = function ( a, order, prop, prop2 )
  1298. {
  1299. var out = [];
  1300. var i=0, ien=order.length;
  1301. // Could have the test in the loop for slightly smaller code, but speed
  1302. // is essential here
  1303. if ( prop2 !== undefined ) {
  1304. for ( ; i<ien ; i++ ) {
  1305. if ( a[ order[i] ][ prop ] ) {
  1306. out.push( a[ order[i] ][ prop ][ prop2 ] );
  1307. }
  1308. }
  1309. }
  1310. else {
  1311. for ( ; i<ien ; i++ ) {
  1312. out.push( a[ order[i] ][ prop ] );
  1313. }
  1314. }
  1315. return out;
  1316. };
  1317. var _range = function ( len, start )
  1318. {
  1319. var out = [];
  1320. var end;
  1321. if ( start === undefined ) {
  1322. start = 0;
  1323. end = len;
  1324. }
  1325. else {
  1326. end = start;
  1327. start = len;
  1328. }
  1329. for ( var i=start ; i<end ; i++ ) {
  1330. out.push( i );
  1331. }
  1332. return out;
  1333. };
  1334. var _removeEmpty = function ( a )
  1335. {
  1336. var out = [];
  1337. for ( var i=0, ien=a.length ; i<ien ; i++ ) {
  1338. if ( a[i] ) { // careful - will remove all falsy values!
  1339. out.push( a[i] );
  1340. }
  1341. }
  1342. return out;
  1343. };
  1344. var _stripHtml = function ( d ) {
  1345. return d.replace( _re_html, '' );
  1346. };
  1347. /**
  1348. * Determine if all values in the array are unique. This means we can short
  1349. * cut the _unique method at the cost of a single loop. A sorted array is used
  1350. * to easily check the values.
  1351. *
  1352. * @param {array} src Source array
  1353. * @return {boolean} true if all unique, false otherwise
  1354. * @ignore
  1355. */
  1356. var _areAllUnique = function ( src ) {
  1357. if ( src.length < 2 ) {
  1358. return true;
  1359. }
  1360. var sorted = src.slice().sort();
  1361. var last = sorted[0];
  1362. for ( var i=1, ien=sorted.length ; i<ien ; i++ ) {
  1363. if ( sorted[i] === last ) {
  1364. return false;
  1365. }
  1366. last = sorted[i];
  1367. }
  1368. return true;
  1369. };
  1370. /**
  1371. * Find the unique elements in a source array.
  1372. *
  1373. * @param {array} src Source array
  1374. * @return {array} Array of unique items
  1375. * @ignore
  1376. */
  1377. var _unique = function ( src )
  1378. {
  1379. if ( _areAllUnique( src ) ) {
  1380. return src.slice();
  1381. }
  1382. // A faster unique method is to use object keys to identify used values,
  1383. // but this doesn't work with arrays or objects, which we must also
  1384. // consider. See jsperf.com/compare-array-unique-versions/4 for more
  1385. // information.
  1386. var
  1387. out = [],
  1388. val,
  1389. i, ien=src.length,
  1390. j, k=0;
  1391. again: for ( i=0 ; i<ien ; i++ ) {
  1392. val = src[i];
  1393. for ( j=0 ; j<k ; j++ ) {
  1394. if ( out[j] === val ) {
  1395. continue again;
  1396. }
  1397. }
  1398. out.push( val );
  1399. k++;
  1400. }
  1401. return out;
  1402. };
  1403. /**
  1404. * DataTables utility methods
  1405. *
  1406. * This namespace provides helper methods that DataTables uses internally to
  1407. * create a DataTable, but which are not exclusively used only for DataTables.
  1408. * These methods can be used by extension authors to save the duplication of
  1409. * code.
  1410. *
  1411. * @namespace
  1412. */
  1413. DataTable.util = {
  1414. /**
  1415. * Throttle the calls to a function. Arguments and context are maintained
  1416. * for the throttled function.
  1417. *
  1418. * @param {function} fn Function to be called
  1419. * @param {integer} freq Call frequency in mS
  1420. * @return {function} Wrapped function
  1421. */
  1422. throttle: function ( fn, freq ) {
  1423. var
  1424. frequency = freq !== undefined ? freq : 200,
  1425. last,
  1426. timer;
  1427. return function () {
  1428. var
  1429. that = this,
  1430. now = +new Date(),
  1431. args = arguments;
  1432. if ( last && now < last + frequency ) {
  1433. clearTimeout( timer );
  1434. timer = setTimeout( function () {
  1435. last = undefined;
  1436. fn.apply( that, args );
  1437. }, frequency );
  1438. }
  1439. else {
  1440. last = now;
  1441. fn.apply( that, args );
  1442. }
  1443. };
  1444. },
  1445. /**
  1446. * Escape a string such that it can be used in a regular expression
  1447. *
  1448. * @param {string} val string to escape
  1449. * @returns {string} escaped string
  1450. */
  1451. escapeRegex: function ( val ) {
  1452. return val.replace( _re_escape_regex, '\\$1' );
  1453. }
  1454. };
  1455. /**
  1456. * Create a mapping object that allows camel case parameters to be looked up
  1457. * for their Hungarian counterparts. The mapping is stored in a private
  1458. * parameter called `_hungarianMap` which can be accessed on the source object.
  1459. * @param {object} o
  1460. * @memberof DataTable#oApi
  1461. */
  1462. function _fnHungarianMap ( o )
  1463. {
  1464. var
  1465. hungarian = 'a aa ai ao as b fn i m o s ',
  1466. match,
  1467. newKey,
  1468. map = {};
  1469. $.each( o, function (key, val) {
  1470. match = key.match(/^([^A-Z]+?)([A-Z])/);
  1471. if ( match && hungarian.indexOf(match[1]+' ') !== -1 )
  1472. {
  1473. newKey = key.replace( match[0], match[2].toLowerCase() );
  1474. map[ newKey ] = key;
  1475. if ( match[1] === 'o' )
  1476. {
  1477. _fnHungarianMap( o[key] );
  1478. }
  1479. }
  1480. } );
  1481. o._hungarianMap = map;
  1482. }
  1483. /**
  1484. * Convert from camel case parameters to Hungarian, based on a Hungarian map
  1485. * created by _fnHungarianMap.
  1486. * @param {object} src The model object which holds all parameters that can be
  1487. * mapped.
  1488. * @param {object} user The object to convert from camel case to Hungarian.
  1489. * @param {boolean} force When set to `true`, properties which already have a
  1490. * Hungarian value in the `user` object will be overwritten. Otherwise they
  1491. * won't be.
  1492. * @memberof DataTable#oApi
  1493. */
  1494. function _fnCamelToHungarian ( src, user, force )
  1495. {
  1496. if ( ! src._hungarianMap ) {
  1497. _fnHungarianMap( src );
  1498. }
  1499. var hungarianKey;
  1500. $.each( user, function (key, val) {
  1501. hungarianKey = src._hungarianMap[ key ];
  1502. if ( hungarianKey !== undefined && (force || user[hungarianKey] === undefined) )
  1503. {
  1504. // For objects, we need to buzz down into the object to copy parameters
  1505. if ( hungarianKey.charAt(0) === 'o' )
  1506. {
  1507. // Copy the camelCase options over to the hungarian
  1508. if ( ! user[ hungarianKey ] ) {
  1509. user[ hungarianKey ] = {};
  1510. }
  1511. $.extend( true, user[hungarianKey], user[key] );
  1512. _fnCamelToHungarian( src[hungarianKey], user[hungarianKey], force );
  1513. }
  1514. else {
  1515. user[hungarianKey] = user[ key ];
  1516. }
  1517. }
  1518. } );
  1519. }
  1520. /**
  1521. * Language compatibility - when certain options are given, and others aren't, we
  1522. * need to duplicate the values over, in order to provide backwards compatibility
  1523. * with older language files.
  1524. * @param {object} oSettings dataTables settings object
  1525. * @memberof DataTable#oApi
  1526. */
  1527. function _fnLanguageCompat( lang )
  1528. {
  1529. // Note the use of the Hungarian notation for the parameters in this method as
  1530. // this is called after the mapping of camelCase to Hungarian
  1531. var defaults = DataTable.defaults.oLanguage;
  1532. // Default mapping
  1533. var defaultDecimal = defaults.sDecimal;
  1534. if ( defaultDecimal ) {
  1535. _addNumericSort( defaultDecimal );
  1536. }
  1537. if ( lang ) {
  1538. var zeroRecords = lang.sZeroRecords;
  1539. // Backwards compatibility - if there is no sEmptyTable given, then use the same as
  1540. // sZeroRecords - assuming that is given.
  1541. if ( ! lang.sEmptyTable && zeroRecords &&
  1542. defaults.sEmptyTable === "No data available in table" )
  1543. {
  1544. _fnMap( lang, lang, 'sZeroRecords', 'sEmptyTable' );
  1545. }
  1546. // Likewise with loading records
  1547. if ( ! lang.sLoadingRecords && zeroRecords &&
  1548. defaults.sLoadingRecords === "Loading..." )
  1549. {
  1550. _fnMap( lang, lang, 'sZeroRecords', 'sLoadingRecords' );
  1551. }
  1552. // Old parameter name of the thousands separator mapped onto the new
  1553. if ( lang.sInfoThousands ) {
  1554. lang.sThousands = lang.sInfoThousands;
  1555. }
  1556. var decimal = lang.sDecimal;
  1557. if ( decimal && defaultDecimal !== decimal ) {
  1558. _addNumericSort( decimal );
  1559. }
  1560. }
  1561. }
  1562. /**
  1563. * Map one parameter onto another
  1564. * @param {object} o Object to map
  1565. * @param {*} knew The new parameter name
  1566. * @param {*} old The old parameter name
  1567. */
  1568. var _fnCompatMap = function ( o, knew, old ) {
  1569. if ( o[ knew ] !== undefined ) {
  1570. o[ old ] = o[ knew ];
  1571. }
  1572. };
  1573. /**
  1574. * Provide backwards compatibility for the main DT options. Note that the new
  1575. * options are mapped onto the old parameters, so this is an external interface
  1576. * change only.
  1577. * @param {object} init Object to map
  1578. */
  1579. function _fnCompatOpts ( init )
  1580. {
  1581. _fnCompatMap( init, 'ordering', 'bSort' );
  1582. _fnCompatMap( init, 'orderMulti', 'bSortMulti' );
  1583. _fnCompatMap( init, 'orderClasses', 'bSortClasses' );
  1584. _fnCompatMap( init, 'orderCellsTop', 'bSortCellsTop' );
  1585. _fnCompatMap( init, 'order', 'aaSorting' );
  1586. _fnCompatMap( init, 'orderFixed', 'aaSortingFixed' );
  1587. _fnCompatMap( init, 'paging', 'bPaginate' );
  1588. _fnCompatMap( init, 'pagingType', 'sPaginationType' );
  1589. _fnCompatMap( init, 'pageLength', 'iDisplayLength' );
  1590. _fnCompatMap( init, 'searching', 'bFilter' );
  1591. // Boolean initialisation of x-scrolling
  1592. if ( typeof init.sScrollX === 'boolean' ) {
  1593. init.sScrollX = init.sScrollX ? '100%' : '';
  1594. }
  1595. if ( typeof init.scrollX === 'boolean' ) {
  1596. init.scrollX = init.scrollX ? '100%' : '';
  1597. }
  1598. // Column search objects are in an array, so it needs to be converted
  1599. // element by element
  1600. var searchCols = init.aoSearchCols;
  1601. if ( searchCols ) {
  1602. for ( var i=0, ien=searchCols.length ; i<ien ; i++ ) {
  1603. if ( searchCols[i] ) {
  1604. _fnCamelToHungarian( DataTable.models.oSearch, searchCols[i] );
  1605. }
  1606. }
  1607. }
  1608. }
  1609. /**
  1610. * Provide backwards compatibility for column options. Note that the new options
  1611. * are mapped onto the old parameters, so this is an external interface change
  1612. * only.
  1613. * @param {object} init Object to map
  1614. */
  1615. function _fnCompatCols ( init )
  1616. {
  1617. _fnCompatMap( init, 'orderable', 'bSortable' );
  1618. _fnCompatMap( init, 'orderData', 'aDataSort' );
  1619. _fnCompatMap( init, 'orderSequence', 'asSorting' );
  1620. _fnCompatMap( init, 'orderDataType', 'sortDataType' );
  1621. // orderData can be given as an integer
  1622. var dataSort = init.aDataSort;
  1623. if ( typeof dataSort === 'number' && ! $.isArray( dataSort ) ) {
  1624. init.aDataSort = [ dataSort ];
  1625. }
  1626. }
  1627. /**
  1628. * Browser feature detection for capabilities, quirks
  1629. * @param {object} settings dataTables settings object
  1630. * @memberof DataTable#oApi
  1631. */
  1632. function _fnBrowserDetect( settings )
  1633. {
  1634. // We don't need to do this every time DataTables is constructed, the values
  1635. // calculated are specific to the browser and OS configuration which we
  1636. // don't expect to change between initialisations
  1637. if ( ! DataTable.__browser ) {
  1638. var browser = {};
  1639. DataTable.__browser = browser;
  1640. // Scrolling feature / quirks detection
  1641. var n = $('<div/>')
  1642. .css( {
  1643. position: 'fixed',
  1644. top: 0,
  1645. left: $(window).scrollLeft()*-1, // allow for scrolling
  1646. height: 1,
  1647. width: 1,
  1648. overflow: 'hidden'
  1649. } )
  1650. .append(
  1651. $('<div/>')
  1652. .css( {
  1653. position: 'absolute',
  1654. top: 1,
  1655. left: 1,
  1656. width: 100,
  1657. overflow: 'scroll'
  1658. } )
  1659. .append(
  1660. $('<div/>')
  1661. .css( {
  1662. width: '100%',
  1663. height: 10
  1664. } )
  1665. )
  1666. )
  1667. .appendTo( 'body' );
  1668. var outer = n.children();
  1669. var inner = outer.children();
  1670. // Numbers below, in order, are:
  1671. // inner.offsetWidth, inner.clientWidth, outer.offsetWidth, outer.clientWidth
  1672. //
  1673. // IE6 XP: 100 100 100 83
  1674. // IE7 Vista: 100 100 100 83
  1675. // IE 8+ Windows: 83 83 100 83
  1676. // Evergreen Windows: 83 83 100 83
  1677. // Evergreen Mac with scrollbars: 85 85 100 85
  1678. // Evergreen Mac without scrollbars: 100 100 100 100
  1679. // Get scrollbar width
  1680. browser.barWidth = outer[0].offsetWidth - outer[0].clientWidth;
  1681. // IE6/7 will oversize a width 100% element inside a scrolling element, to
  1682. // include the width of the scrollbar, while other browsers ensure the inner
  1683. // element is contained without forcing scrolling
  1684. browser.bScrollOversize = inner[0].offsetWidth === 100 && outer[0].clientWidth !== 100;
  1685. // In rtl text layout, some browsers (most, but not all) will place the
  1686. // scrollbar on the left, rather than the right.
  1687. browser.bScrollbarLeft = Math.round( inner.offset().left ) !== 1;
  1688. // IE8- don't provide height and width for getBoundingClientRect
  1689. browser.bBounding = n[0].getBoundingClientRect().width ? true : false;
  1690. n.remove();
  1691. }
  1692. $.extend( settings.oBrowser, DataTable.__browser );
  1693. settings.oScroll.iBarWidth = DataTable.__browser.barWidth;
  1694. }
  1695. /**
  1696. * Array.prototype reduce[Right] method, used for browsers which don't support
  1697. * JS 1.6. Done this way to reduce code size, since we iterate either way
  1698. * @param {object} settings dataTables settings object
  1699. * @memberof DataTable#oApi
  1700. */
  1701. function _fnReduce ( that, fn, init, start, end, inc )
  1702. {
  1703. var
  1704. i = start,
  1705. value,
  1706. isSet = false;
  1707. if ( init !== undefined ) {
  1708. value = init;
  1709. isSet = true;
  1710. }
  1711. while ( i !== end ) {
  1712. if ( ! that.hasOwnProperty(i) ) {
  1713. continue;
  1714. }
  1715. value = isSet ?
  1716. fn( value, that[i], i, that ) :
  1717. that[i];
  1718. isSet = true;
  1719. i += inc;
  1720. }
  1721. return value;
  1722. }
  1723. /**
  1724. * Add a column to the list used for the table with default values
  1725. * @param {object} oSettings dataTables settings object
  1726. * @param {node} nTh The th element for this column
  1727. * @memberof DataTable#oApi
  1728. */
  1729. function _fnAddColumn( oSettings, nTh )
  1730. {
  1731. // Add column to aoColumns array
  1732. var oDefaults = DataTable.defaults.column;
  1733. var iCol = oSettings.aoColumns.length;
  1734. var oCol = $.extend( {}, DataTable.models.oColumn, oDefaults, {
  1735. "nTh": nTh ? nTh : document.createElement('th'),
  1736. "sTitle": oDefaults.sTitle ? oDefaults.sTitle : nTh ? nTh.innerHTML : '',
  1737. "aDataSort": oDefaults.aDataSort ? oDefaults.aDataSort : [iCol],
  1738. "mData": oDefaults.mData ? oDefaults.mData : iCol,
  1739. idx: iCol
  1740. } );
  1741. oSettings.aoColumns.push( oCol );
  1742. // Add search object for column specific search. Note that the `searchCols[ iCol ]`
  1743. // passed into extend can be undefined. This allows the user to give a default
  1744. // with only some of the parameters defined, and also not give a default
  1745. var searchCols = oSettings.aoPreSearchCols;
  1746. searchCols[ iCol ] = $.extend( {}, DataTable.models.oSearch, searchCols[ iCol ] );
  1747. // Use the default column options function to initialise classes etc
  1748. _fnColumnOptions( oSettings, iCol, $(nTh).data() );
  1749. }
  1750. /**
  1751. * Apply options for a column
  1752. * @param {object} oSettings dataTables settings object
  1753. * @param {int} iCol column index to consider
  1754. * @param {object} oOptions object with sType, bVisible and bSearchable etc
  1755. * @memberof DataTable#oApi
  1756. */
  1757. function _fnColumnOptions( oSettings, iCol, oOptions )
  1758. {
  1759. var oCol = oSettings.aoColumns[ iCol ];
  1760. var oClasses = oSettings.oClasses;
  1761. var th = $(oCol.nTh);
  1762. // Try to get width information from the DOM. We can't get it from CSS
  1763. // as we'd need to parse the CSS stylesheet. `width` option can override
  1764. if ( ! oCol.sWidthOrig ) {
  1765. // Width attribute
  1766. oCol.sWidthOrig = th.attr('width') || null;
  1767. // Style attribute
  1768. var t = (th.attr('style') || '').match(/width:\s*(\d+[pxem%]+)/);
  1769. if ( t ) {
  1770. oCol.sWidthOrig = t[1];
  1771. }
  1772. }
  1773. /* User specified column options */
  1774. if ( oOptions !== undefined && oOptions !== null )
  1775. {
  1776. // Backwards compatibility
  1777. _fnCompatCols( oOptions );
  1778. // Map camel case parameters to their Hungarian counterparts
  1779. _fnCamelToHungarian( DataTable.defaults.column, oOptions );
  1780. /* Backwards compatibility for mDataProp */
  1781. if ( oOptions.mDataProp !== undefined && !oOptions.mData )
  1782. {
  1783. oOptions.mData = oOptions.mDataProp;
  1784. }
  1785. if ( oOptions.sType )
  1786. {
  1787. oCol._sManualType = oOptions.sType;
  1788. }
  1789. // `class` is a reserved word in Javascript, so we need to provide
  1790. // the ability to use a valid name for the camel case input
  1791. if ( oOptions.className && ! oOptions.sClass )
  1792. {
  1793. oOptions.sClass = oOptions.className;
  1794. }
  1795. if ( oOptions.sClass ) {
  1796. th.addClass( oOptions.sClass );
  1797. }
  1798. $.extend( oCol, oOptions );
  1799. _fnMap( oCol, oOptions, "sWidth", "sWidthOrig" );
  1800. /* iDataSort to be applied (backwards compatibility), but aDataSort will take
  1801. * priority if defined
  1802. */
  1803. if ( oOptions.iDataSort !== undefined )
  1804. {
  1805. oCol.aDataSort = [ oOptions.iDataSort ];
  1806. }
  1807. _fnMap( oCol, oOptions, "aDataSort" );
  1808. }
  1809. /* Cache the data get and set functions for speed */
  1810. var mDataSrc = oCol.mData;
  1811. var mData = _fnGetObjectDataFn( mDataSrc );
  1812. var mRender = oCol.mRender ? _fnGetObjectDataFn( oCol.mRender ) : null;
  1813. var attrTest = function( src ) {
  1814. return typeof src === 'string' && src.indexOf('@') !== -1;
  1815. };
  1816. oCol._bAttrSrc = $.isPlainObject( mDataSrc ) && (
  1817. attrTest(mDataSrc.sort) || attrTest(mDataSrc.type) || attrTest(mDataSrc.filter)
  1818. );
  1819. oCol._setter = null;
  1820. oCol.fnGetData = function (rowData, type, meta) {
  1821. var innerData = mData( rowData, type, undefined, meta );
  1822. return mRender && type ?
  1823. mRender( innerData, type, rowData, meta ) :
  1824. innerData;
  1825. };
  1826. oCol.fnSetData = function ( rowData, val, meta ) {
  1827. return _fnSetObjectDataFn( mDataSrc )( rowData, val, meta );
  1828. };
  1829. // Indicate if DataTables should read DOM data as an object or array
  1830. // Used in _fnGetRowElements
  1831. if ( typeof mDataSrc !== 'number' ) {
  1832. oSettings._rowReadObject = true;
  1833. }
  1834. /* Feature sorting overrides column specific when off */
  1835. if ( !oSettings.oFeatures.bSort )
  1836. {
  1837. oCol.bSortable = false;
  1838. th.addClass( oClasses.sSortableNone ); // Have to add class here as order event isn't called
  1839. }
  1840. /* Check that the class assignment is correct for sorting */
  1841. var bAsc = $.inArray('asc', oCol.asSorting) !== -1;
  1842. var bDesc = $.inArray('desc', oCol.asSorting) !== -1;
  1843. if ( !oCol.bSortable || (!bAsc && !bDesc) )
  1844. {
  1845. oCol.sSortingClass = oClasses.sSortableNone;
  1846. oCol.sSortingClassJUI = "";
  1847. }
  1848. else if ( bAsc && !bDesc )
  1849. {
  1850. oCol.sSortingClass = oClasses.sSortableAsc;
  1851. oCol.sSortingClassJUI = oClasses.sSortJUIAscAllowed;
  1852. }
  1853. else if ( !bAsc && bDesc )
  1854. {
  1855. oCol.sSortingClass = oClasses.sSortableDesc;
  1856. oCol.sSortingClassJUI = oClasses.sSortJUIDescAllowed;
  1857. }
  1858. else
  1859. {
  1860. oCol.sSortingClass = oClasses.sSortable;
  1861. oCol.sSortingClassJUI = oClasses.sSortJUI;
  1862. }
  1863. }
  1864. /**
  1865. * Adjust the table column widths for new data. Note: you would probably want to
  1866. * do a redraw after calling this function!
  1867. * @param {object} settings dataTables settings object
  1868. * @memberof DataTable#oApi
  1869. */
  1870. function _fnAdjustColumnSizing ( settings )
  1871. {
  1872. /* Not interested in doing column width calculation if auto-width is disabled */
  1873. if ( settings.oFeatures.bAutoWidth !== false )
  1874. {
  1875. var columns = settings.aoColumns;
  1876. _fnCalculateColumnWidths( settings );
  1877. for ( var i=0 , iLen=columns.length ; i<iLen ; i++ )
  1878. {
  1879. columns[i].nTh.style.width = columns[i].sWidth;
  1880. }
  1881. }
  1882. var scroll = settings.oScroll;
  1883. if ( scroll.sY !== '' || scroll.sX !== '')
  1884. {
  1885. _fnScrollDraw( settings );
  1886. }
  1887. _fnCallbackFire( settings, null, 'column-sizing', [settings] );
  1888. }
  1889. /**
  1890. * Covert the index of a visible column to the index in the data array (take account
  1891. * of hidden columns)
  1892. * @param {object} oSettings dataTables settings object
  1893. * @param {int} iMatch Visible column index to lookup
  1894. * @returns {int} i the data index
  1895. * @memberof DataTable#oApi
  1896. */
  1897. function _fnVisibleToColumnIndex( oSettings, iMatch )
  1898. {
  1899. var aiVis = _fnGetColumns( oSettings, 'bVisible' );
  1900. return typeof aiVis[iMatch] === 'number' ?
  1901. aiVis[iMatch] :
  1902. null;
  1903. }
  1904. /**
  1905. * Covert the index of an index in the data array and convert it to the visible
  1906. * column index (take account of hidden columns)
  1907. * @param {int} iMatch Column index to lookup
  1908. * @param {object} oSettings dataTables settings object
  1909. * @returns {int} i the data index
  1910. * @memberof DataTable#oApi
  1911. */
  1912. function _fnColumnIndexToVisible( oSettings, iMatch )
  1913. {
  1914. var aiVis = _fnGetColumns( oSettings, 'bVisible' );
  1915. var iPos = $.inArray( iMatch, aiVis );
  1916. return iPos !== -1 ? iPos : null;
  1917. }
  1918. /**
  1919. * Get the number of visible columns
  1920. * @param {object} oSettings dataTables settings object
  1921. * @returns {int} i the number of visible columns
  1922. * @memberof DataTable#oApi
  1923. */
  1924. function _fnVisbleColumns( oSettings )
  1925. {
  1926. var vis = 0;
  1927. // No reduce in IE8, use a loop for now
  1928. $.each( oSettings.aoColumns, function ( i, col ) {
  1929. if ( col.bVisible && $(col.nTh).css('display') !== 'none' ) {
  1930. vis++;
  1931. }
  1932. } );
  1933. return vis;
  1934. }
  1935. /**
  1936. * Get an array of column indexes that match a given property
  1937. * @param {object} oSettings dataTables settings object
  1938. * @param {string} sParam Parameter in aoColumns to look for - typically
  1939. * bVisible or bSearchable
  1940. * @returns {array} Array of indexes with matched properties
  1941. * @memberof DataTable#oApi
  1942. */
  1943. function _fnGetColumns( oSettings, sParam )
  1944. {
  1945. var a = [];
  1946. $.map( oSettings.aoColumns, function(val, i) {
  1947. if ( val[sParam] ) {
  1948. a.push( i );
  1949. }
  1950. } );
  1951. return a;
  1952. }
  1953. /**
  1954. * Calculate the 'type' of a column
  1955. * @param {object} settings dataTables settings object
  1956. * @memberof DataTable#oApi
  1957. */
  1958. function _fnColumnTypes ( settings )
  1959. {
  1960. var columns = settings.aoColumns;
  1961. var data = settings.aoData;
  1962. var types = DataTable.ext.type.detect;
  1963. var i, ien, j, jen, k, ken;
  1964. var col, cell, detectedType, cache;
  1965. // For each column, spin over the
  1966. for ( i=0, ien=columns.length ; i<ien ; i++ ) {
  1967. col = columns[i];
  1968. cache = [];
  1969. if ( ! col.sType && col._sManualType ) {
  1970. col.sType = col._sManualType;
  1971. }
  1972. else if ( ! col.sType ) {
  1973. for ( j=0, jen=types.length ; j<jen ; j++ ) {
  1974. for ( k=0, ken=data.length ; k<ken ; k++ ) {
  1975. // Use a cache array so we only need to get the type data
  1976. // from the formatter once (when using multiple detectors)
  1977. if ( cache[k] === undefined ) {
  1978. cache[k] = _fnGetCellData( settings, k, i, 'type' );
  1979. }
  1980. detectedType = types[j]( cache[k], settings );
  1981. // If null, then this type can't apply to this column, so
  1982. // rather than testing all cells, break out. There is an
  1983. // exception for the last type which is `html`. We need to
  1984. // scan all rows since it is possible to mix string and HTML
  1985. // types
  1986. if ( ! detectedType && j !== types.length-1 ) {
  1987. break;
  1988. }
  1989. // Only a single match is needed for html type since it is
  1990. // bottom of the pile and very similar to string
  1991. if ( detectedType === 'html' ) {
  1992. break;
  1993. }
  1994. }
  1995. // Type is valid for all data points in the column - use this
  1996. // type
  1997. if ( detectedType ) {
  1998. col.sType = detectedType;
  1999. break;
  2000. }
  2001. }
  2002. // Fall back - if no type was detected, always use string
  2003. if ( ! col.sType ) {
  2004. col.sType = 'string';
  2005. }
  2006. }
  2007. }
  2008. }
  2009. /**
  2010. * Take the column definitions and static columns arrays and calculate how
  2011. * they relate to column indexes. The callback function will then apply the
  2012. * definition found for a column to a suitable configuration object.
  2013. * @param {object} oSettings dataTables settings object
  2014. * @param {array} aoColDefs The aoColumnDefs array that is to be applied
  2015. * @param {array} aoCols The aoColumns array that defines columns individually
  2016. * @param {function} fn Callback function - takes two parameters, the calculated
  2017. * column index and the definition for that column.
  2018. * @memberof DataTable#oApi
  2019. */
  2020. function _fnApplyColumnDefs( oSettings, aoColDefs, aoCols, fn )
  2021. {
  2022. var i, iLen, j, jLen, k, kLen, def;
  2023. var columns = oSettings.aoColumns;
  2024. // Column definitions with aTargets
  2025. if ( aoColDefs )
  2026. {
  2027. /* Loop over the definitions array - loop in reverse so first instance has priority */
  2028. for ( i=aoColDefs.length-1 ; i>=0 ; i-- )
  2029. {
  2030. def = aoColDefs[i];
  2031. /* Each definition can target multiple columns, as it is an array */
  2032. var aTargets = def.targets !== undefined ?
  2033. def.targets :
  2034. def.aTargets;
  2035. if ( ! $.isArray( aTargets ) )
  2036. {
  2037. aTargets = [ aTargets ];
  2038. }
  2039. for ( j=0, jLen=aTargets.length ; j<jLen ; j++ )
  2040. {
  2041. if ( typeof aTargets[j] === 'number' && aTargets[j] >= 0 )
  2042. {
  2043. /* Add columns that we don't yet know about */
  2044. while( columns.length <= aTargets[j] )
  2045. {
  2046. _fnAddColumn( oSettings );
  2047. }
  2048. /* Integer, basic index */
  2049. fn( aTargets[j], def );
  2050. }
  2051. else if ( typeof aTargets[j] === 'number' && aTargets[j] < 0 )
  2052. {
  2053. /* Negative integer, right to left column counting */
  2054. fn( columns.length+aTargets[j], def );
  2055. }
  2056. else if ( typeof aTargets[j] === 'string' )
  2057. {
  2058. /* Class name matching on TH element */
  2059. for ( k=0, kLen=columns.length ; k<kLen ; k++ )
  2060. {
  2061. if ( aTargets[j] == "_all" ||
  2062. $(columns[k].nTh).hasClass( aTargets[j] ) )
  2063. {
  2064. fn( k, def );
  2065. }
  2066. }
  2067. }
  2068. }
  2069. }
  2070. }
  2071. // Statically defined columns array
  2072. if ( aoCols )
  2073. {
  2074. for ( i=0, iLen=aoCols.length ; i<iLen ; i++ )
  2075. {
  2076. fn( i, aoCols[i] );
  2077. }
  2078. }
  2079. }
  2080. /**
  2081. * Add a data array to the table, creating DOM node etc. This is the parallel to
  2082. * _fnGatherData, but for adding rows from a Javascript source, rather than a
  2083. * DOM source.
  2084. * @param {object} oSettings dataTables settings object
  2085. * @param {array} aData data array to be added
  2086. * @param {node} [nTr] TR element to add to the table - optional. If not given,
  2087. * DataTables will create a row automatically
  2088. * @param {array} [anTds] Array of TD|TH elements for the row - must be given
  2089. * if nTr is.
  2090. * @returns {int} >=0 if successful (index of new aoData entry), -1 if failed
  2091. * @memberof DataTable#oApi
  2092. */
  2093. function _fnAddData ( oSettings, aDataIn, nTr, anTds )
  2094. {
  2095. /* Create the object for storing information about this new row */
  2096. var iRow = oSettings.aoData.length;
  2097. var oData = $.extend( true, {}, DataTable.models.oRow, {
  2098. src: nTr ? 'dom' : 'data',
  2099. idx: iRow
  2100. } );
  2101. oData._aData = aDataIn;
  2102. oSettings.aoData.push( oData );
  2103. /* Create the cells */
  2104. var nTd, sThisType;
  2105. var columns = oSettings.aoColumns;
  2106. // Invalidate the column types as the new data needs to be revalidated
  2107. for ( var i=0, iLen=columns.length ; i<iLen ; i++ )
  2108. {
  2109. columns[i].sType = null;
  2110. }
  2111. /* Add to the display array */
  2112. oSettings.aiDisplayMaster.push( iRow );
  2113. var id = oSettings.rowIdFn( aDataIn );
  2114. if ( id !== undefined ) {
  2115. oSettings.aIds[ id ] = oData;
  2116. }
  2117. /* Create the DOM information, or register it if already present */
  2118. if ( nTr || ! oSettings.oFeatures.bDeferRender )
  2119. {
  2120. _fnCreateTr( oSettings, iRow, nTr, anTds );
  2121. }
  2122. return iRow;
  2123. }
  2124. /**
  2125. * Add one or more TR elements to the table. Generally we'd expect to
  2126. * use this for reading data from a DOM sourced table, but it could be
  2127. * used for an TR element. Note that if a TR is given, it is used (i.e.
  2128. * it is not cloned).
  2129. * @param {object} settings dataTables settings object
  2130. * @param {array|node|jQuery} trs The TR element(s) to add to the table
  2131. * @returns {array} Array of indexes for the added rows
  2132. * @memberof DataTable#oApi
  2133. */
  2134. function _fnAddTr( settings, trs )
  2135. {
  2136. var row;
  2137. // Allow an individual node to be passed in
  2138. if ( ! (trs instanceof $) ) {
  2139. trs = $(trs);
  2140. }
  2141. return trs.map( function (i, el) {
  2142. row = _fnGetRowElements( settings, el );
  2143. return _fnAddData( settings, row.data, el, row.cells );
  2144. } );
  2145. }
  2146. /**
  2147. * Take a TR element and convert it to an index in aoData
  2148. * @param {object} oSettings dataTables settings object
  2149. * @param {node} n the TR element to find
  2150. * @returns {int} index if the node is found, null if not
  2151. * @memberof DataTable#oApi
  2152. */
  2153. function _fnNodeToDataIndex( oSettings, n )
  2154. {
  2155. return (n._DT_RowIndex!==undefined) ? n._DT_RowIndex : null;
  2156. }
  2157. /**
  2158. * Take a TD element and convert it into a column data index (not the visible index)
  2159. * @param {object} oSettings dataTables settings object
  2160. * @param {int} iRow The row number the TD/TH can be found in
  2161. * @param {node} n The TD/TH element to find
  2162. * @returns {int} index if the node is found, -1 if not
  2163. * @memberof DataTable#oApi
  2164. */
  2165. function _fnNodeToColumnIndex( oSettings, iRow, n )
  2166. {
  2167. return $.inArray( n, oSettings.aoData[ iRow ].anCells );
  2168. }
  2169. /**
  2170. * Get the data for a given cell from the internal cache, taking into account data mapping
  2171. * @param {object} settings dataTables settings object
  2172. * @param {int} rowIdx aoData row id
  2173. * @param {int} colIdx Column index
  2174. * @param {string} type data get type ('display', 'type' 'filter' 'sort')
  2175. * @returns {*} Cell data
  2176. * @memberof DataTable#oApi
  2177. */
  2178. function _fnGetCellData( settings, rowIdx, colIdx, type )
  2179. {
  2180. var draw = settings.iDraw;
  2181. var col = settings.aoColumns[colIdx];
  2182. var rowData = settings.aoData[rowIdx]._aData;
  2183. var defaultContent = col.sDefaultContent;
  2184. var cellData = col.fnGetData( rowData, type, {
  2185. settings: settings,
  2186. row: rowIdx,
  2187. col: colIdx
  2188. } );
  2189. if ( cellData === undefined ) {
  2190. if ( settings.iDrawError != draw && defaultContent === null ) {
  2191. _fnLog( settings, 0, "Requested unknown parameter "+
  2192. (typeof col.mData=='function' ? '{function}' : "'"+col.mData+"'")+
  2193. " for row "+rowIdx+", column "+colIdx, 4 );
  2194. settings.iDrawError = draw;
  2195. }
  2196. return defaultContent;
  2197. }
  2198. // When the data source is null and a specific data type is requested (i.e.
  2199. // not the original data), we can use default column data
  2200. if ( (cellData === rowData || cellData === null) && defaultContent !== null && type !== undefined ) {
  2201. cellData = defaultContent;
  2202. }
  2203. else if ( typeof cellData === 'function' ) {
  2204. // If the data source is a function, then we run it and use the return,
  2205. // executing in the scope of the data object (for instances)
  2206. return cellData.call( rowData );
  2207. }
  2208. if ( cellData === null && type == 'display' ) {
  2209. return '';
  2210. }
  2211. return cellData;
  2212. }
  2213. /**
  2214. * Set the value for a specific cell, into the internal data cache
  2215. * @param {object} settings dataTables settings object
  2216. * @param {int} rowIdx aoData row id
  2217. * @param {int} colIdx Column index
  2218. * @param {*} val Value to set
  2219. * @memberof DataTable#oApi
  2220. */
  2221. function _fnSetCellData( settings, rowIdx, colIdx, val )
  2222. {
  2223. var col = settings.aoColumns[colIdx];
  2224. var rowData = settings.aoData[rowIdx]._aData;
  2225. col.fnSetData( rowData, val, {
  2226. settings: settings,
  2227. row: rowIdx,
  2228. col: colIdx
  2229. } );
  2230. }
  2231. // Private variable that is used to match action syntax in the data property object
  2232. var __reArray = /\[.*?\]$/;
  2233. var __reFn = /\(\)$/;
  2234. /**
  2235. * Split string on periods, taking into account escaped periods
  2236. * @param {string} str String to split
  2237. * @return {array} Split string
  2238. */
  2239. function _fnSplitObjNotation( str )
  2240. {
  2241. return $.map( str.match(/(\\.|[^\.])+/g) || [''], function ( s ) {
  2242. return s.replace(/\\\./g, '.');
  2243. } );
  2244. }
  2245. /**
  2246. * Return a function that can be used to get data from a source object, taking
  2247. * into account the ability to use nested objects as a source
  2248. * @param {string|int|function} mSource The data source for the object
  2249. * @returns {function} Data get function
  2250. * @memberof DataTable#oApi
  2251. */
  2252. function _fnGetObjectDataFn( mSource )
  2253. {
  2254. if ( $.isPlainObject( mSource ) )
  2255. {
  2256. /* Build an object of get functions, and wrap them in a single call */
  2257. var o = {};
  2258. $.each( mSource, function (key, val) {
  2259. if ( val ) {
  2260. o[key] = _fnGetObjectDataFn( val );
  2261. }
  2262. } );
  2263. return function (data, type, row, meta) {
  2264. var t = o[type] || o._;
  2265. return t !== undefined ?
  2266. t(data, type, row, meta) :
  2267. data;
  2268. };
  2269. }
  2270. else if ( mSource === null )
  2271. {
  2272. /* Give an empty string for rendering / sorting etc */
  2273. return function (data) { // type, row and meta also passed, but not used
  2274. return data;
  2275. };
  2276. }
  2277. else if ( typeof mSource === 'function' )
  2278. {
  2279. return function (data, type, row, meta) {
  2280. return mSource( data, type, row, meta );
  2281. };
  2282. }
  2283. else if ( typeof mSource === 'string' && (mSource.indexOf('.') !== -1 ||
  2284. mSource.indexOf('[') !== -1 || mSource.indexOf('(') !== -1) )
  2285. {
  2286. /* If there is a . in the source string then the data source is in a
  2287. * nested object so we loop over the data for each level to get the next
  2288. * level down. On each loop we test for undefined, and if found immediately
  2289. * return. This allows entire objects to be missing and sDefaultContent to
  2290. * be used if defined, rather than throwing an error
  2291. */
  2292. var fetchData = function (data, type, src) {
  2293. var arrayNotation, funcNotation, out, innerSrc;
  2294. if ( src !== "" )
  2295. {
  2296. var a = _fnSplitObjNotation( src );
  2297. for ( var i=0, iLen=a.length ; i<iLen ; i++ )
  2298. {
  2299. // Check if we are dealing with special notation
  2300. arrayNotation = a[i].match(__reArray);
  2301. funcNotation = a[i].match(__reFn);
  2302. if ( arrayNotation )
  2303. {
  2304. // Array notation
  2305. a[i] = a[i].replace(__reArray, '');
  2306. // Condition allows simply [] to be passed in
  2307. if ( a[i] !== "" ) {
  2308. data = data[ a[i] ];
  2309. }
  2310. out = [];
  2311. // Get the remainder of the nested object to get
  2312. a.splice( 0, i+1 );
  2313. innerSrc = a.join('.');
  2314. // Traverse each entry in the array getting the properties requested
  2315. if ( $.isArray( data ) ) {
  2316. for ( var j=0, jLen=data.length ; j<jLen ; j++ ) {
  2317. out.push( fetchData( data[j], type, innerSrc ) );
  2318. }
  2319. }
  2320. // If a string is given in between the array notation indicators, that
  2321. // is used to join the strings together, otherwise an array is returned
  2322. var join = arrayNotation[0].substring(1, arrayNotation[0].length-1);
  2323. data = (join==="") ? out : out.join(join);
  2324. // The inner call to fetchData has already traversed through the remainder
  2325. // of the source requested, so we exit from the loop
  2326. break;
  2327. }
  2328. else if ( funcNotation )
  2329. {
  2330. // Function call
  2331. a[i] = a[i].replace(__reFn, '');
  2332. data = data[ a[i] ]();
  2333. continue;
  2334. }
  2335. if ( data === null || data[ a[i] ] === undefined )
  2336. {
  2337. return undefined;
  2338. }
  2339. data = data[ a[i] ];
  2340. }
  2341. }
  2342. return data;
  2343. };
  2344. return function (data, type) { // row and meta also passed, but not used
  2345. return fetchData( data, type, mSource );
  2346. };
  2347. }
  2348. else
  2349. {
  2350. /* Array or flat object mapping */
  2351. return function (data, type) { // row and meta also passed, but not used
  2352. return data[mSource];
  2353. };
  2354. }
  2355. }
  2356. /**
  2357. * Return a function that can be used to set data from a source object, taking
  2358. * into account the ability to use nested objects as a source
  2359. * @param {string|int|function} mSource The data source for the object
  2360. * @returns {function} Data set function
  2361. * @memberof DataTable#oApi
  2362. */
  2363. function _fnSetObjectDataFn( mSource )
  2364. {
  2365. if ( $.isPlainObject( mSource ) )
  2366. {
  2367. /* Unlike get, only the underscore (global) option is used for for
  2368. * setting data since we don't know the type here. This is why an object
  2369. * option is not documented for `mData` (which is read/write), but it is
  2370. * for `mRender` which is read only.
  2371. */
  2372. return _fnSetObjectDataFn( mSource._ );
  2373. }
  2374. else if ( mSource === null )
  2375. {
  2376. /* Nothing to do when the data source is null */
  2377. return function () {};
  2378. }
  2379. else if ( typeof mSource === 'function' )
  2380. {
  2381. return function (data, val, meta) {
  2382. mSource( data, 'set', val, meta );
  2383. };
  2384. }
  2385. else if ( typeof mSource === 'string' && (mSource.indexOf('.') !== -1 ||
  2386. mSource.indexOf('[') !== -1 || mSource.indexOf('(') !== -1) )
  2387. {
  2388. /* Like the get, we need to get data from a nested object */
  2389. var setData = function (data, val, src) {
  2390. var a = _fnSplitObjNotation( src ), b;
  2391. var aLast = a[a.length-1];
  2392. var arrayNotation, funcNotation, o, innerSrc;
  2393. for ( var i=0, iLen=a.length-1 ; i<iLen ; i++ )
  2394. {
  2395. // Check if we are dealing with an array notation request
  2396. arrayNotation = a[i].match(__reArray);
  2397. funcNotation = a[i].match(__reFn);
  2398. if ( arrayNotation )
  2399. {
  2400. a[i] = a[i].replace(__reArray, '');
  2401. data[ a[i] ] = [];
  2402. // Get the remainder of the nested object to set so we can recurse
  2403. b = a.slice();
  2404. b.splice( 0, i+1 );
  2405. innerSrc = b.join('.');
  2406. // Traverse each entry in the array setting the properties requested
  2407. if ( $.isArray( val ) )
  2408. {
  2409. for ( var j=0, jLen=val.length ; j<jLen ; j++ )
  2410. {
  2411. o = {};
  2412. setData( o, val[j], innerSrc );
  2413. data[ a[i] ].push( o );
  2414. }
  2415. }
  2416. else
  2417. {
  2418. // We've been asked to save data to an array, but it
  2419. // isn't array data to be saved. Best that can be done
  2420. // is to just save the value.
  2421. data[ a[i] ] = val;
  2422. }
  2423. // The inner call to setData has already traversed through the remainder
  2424. // of the source and has set the data, thus we can exit here
  2425. return;
  2426. }
  2427. else if ( funcNotation )
  2428. {
  2429. // Function call
  2430. a[i] = a[i].replace(__reFn, '');
  2431. data = data[ a[i] ]( val );
  2432. }
  2433. // If the nested object doesn't currently exist - since we are
  2434. // trying to set the value - create it
  2435. if ( data[ a[i] ] === null || data[ a[i] ] === undefined )
  2436. {
  2437. data[ a[i] ] = {};
  2438. }
  2439. data = data[ a[i] ];
  2440. }
  2441. // Last item in the input - i.e, the actual set
  2442. if ( aLast.match(__reFn ) )
  2443. {
  2444. // Function call
  2445. data = data[ aLast.replace(__reFn, '') ]( val );
  2446. }
  2447. else
  2448. {
  2449. // If array notation is used, we just want to strip it and use the property name
  2450. // and assign the value. If it isn't used, then we get the result we want anyway
  2451. data[ aLast.replace(__reArray, '') ] = val;
  2452. }
  2453. };
  2454. return function (data, val) { // meta is also passed in, but not used
  2455. return setData( data, val, mSource );
  2456. };
  2457. }
  2458. else
  2459. {
  2460. /* Array or flat object mapping */
  2461. return function (data, val) { // meta is also passed in, but not used
  2462. data[mSource] = val;
  2463. };
  2464. }
  2465. }
  2466. /**
  2467. * Return an array with the full table data
  2468. * @param {object} oSettings dataTables settings object
  2469. * @returns array {array} aData Master data array
  2470. * @memberof DataTable#oApi
  2471. */
  2472. function _fnGetDataMaster ( settings )
  2473. {
  2474. return _pluck( settings.aoData, '_aData' );
  2475. }
  2476. /**
  2477. * Nuke the table
  2478. * @param {object} oSettings dataTables settings object
  2479. * @memberof DataTable#oApi
  2480. */
  2481. function _fnClearTable( settings )
  2482. {
  2483. settings.aoData.length = 0;
  2484. settings.aiDisplayMaster.length = 0;
  2485. settings.aiDisplay.length = 0;
  2486. settings.aIds = {};
  2487. }
  2488. /**
  2489. * Take an array of integers (index array) and remove a target integer (value - not
  2490. * the key!)
  2491. * @param {array} a Index array to target
  2492. * @param {int} iTarget value to find
  2493. * @memberof DataTable#oApi
  2494. */
  2495. function _fnDeleteIndex( a, iTarget, splice )
  2496. {
  2497. var iTargetIndex = -1;
  2498. for ( var i=0, iLen=a.length ; i<iLen ; i++ )
  2499. {
  2500. if ( a[i] == iTarget )
  2501. {
  2502. iTargetIndex = i;
  2503. }
  2504. else if ( a[i] > iTarget )
  2505. {
  2506. a[i]--;
  2507. }
  2508. }
  2509. if ( iTargetIndex != -1 && splice === undefined )
  2510. {
  2511. a.splice( iTargetIndex, 1 );
  2512. }
  2513. }
  2514. /**
  2515. * Mark cached data as invalid such that a re-read of the data will occur when
  2516. * the cached data is next requested. Also update from the data source object.
  2517. *
  2518. * @param {object} settings DataTables settings object
  2519. * @param {int} rowIdx Row index to invalidate
  2520. * @param {string} [src] Source to invalidate from: undefined, 'auto', 'dom'
  2521. * or 'data'
  2522. * @param {int} [colIdx] Column index to invalidate. If undefined the whole
  2523. * row will be invalidated
  2524. * @memberof DataTable#oApi
  2525. *
  2526. * @todo For the modularisation of v1.11 this will need to become a callback, so
  2527. * the sort and filter methods can subscribe to it. That will required
  2528. * initialisation options for sorting, which is why it is not already baked in
  2529. */
  2530. function _fnInvalidate( settings, rowIdx, src, colIdx )
  2531. {
  2532. var row = settings.aoData[ rowIdx ];
  2533. var i, ien;
  2534. var cellWrite = function ( cell, col ) {
  2535. // This is very frustrating, but in IE if you just write directly
  2536. // to innerHTML, and elements that are overwritten are GC'ed,
  2537. // even if there is a reference to them elsewhere
  2538. while ( cell.childNodes.length ) {
  2539. cell.removeChild( cell.firstChild );
  2540. }
  2541. cell.innerHTML = _fnGetCellData( settings, rowIdx, col, 'display' );
  2542. };
  2543. // Are we reading last data from DOM or the data object?
  2544. if ( src === 'dom' || ((! src || src === 'auto') && row.src === 'dom') ) {
  2545. // Read the data from the DOM
  2546. row._aData = _fnGetRowElements(
  2547. settings, row, colIdx, colIdx === undefined ? undefined : row._aData
  2548. )
  2549. .data;
  2550. }
  2551. else {
  2552. // Reading from data object, update the DOM
  2553. var cells = row.anCells;
  2554. if ( cells ) {
  2555. if ( colIdx !== undefined ) {
  2556. cellWrite( cells[colIdx], colIdx );
  2557. }
  2558. else {
  2559. for ( i=0, ien=cells.length ; i<ien ; i++ ) {
  2560. cellWrite( cells[i], i );
  2561. }
  2562. }
  2563. }
  2564. }
  2565. // For both row and cell invalidation, the cached data for sorting and
  2566. // filtering is nulled out
  2567. row._aSortData = null;
  2568. row._aFilterData = null;
  2569. // Invalidate the type for a specific column (if given) or all columns since
  2570. // the data might have changed
  2571. var cols = settings.aoColumns;
  2572. if ( colIdx !== undefined ) {
  2573. cols[ colIdx ].sType = null;
  2574. }
  2575. else {
  2576. for ( i=0, ien=cols.length ; i<ien ; i++ ) {
  2577. cols[i].sType = null;
  2578. }
  2579. // Update DataTables special `DT_*` attributes for the row
  2580. _fnRowAttributes( settings, row );
  2581. }
  2582. }
  2583. /**
  2584. * Build a data source object from an HTML row, reading the contents of the
  2585. * cells that are in the row.
  2586. *
  2587. * @param {object} settings DataTables settings object
  2588. * @param {node|object} TR element from which to read data or existing row
  2589. * object from which to re-read the data from the cells
  2590. * @param {int} [colIdx] Optional column index
  2591. * @param {array|object} [d] Data source object. If `colIdx` is given then this
  2592. * parameter should also be given and will be used to write the data into.
  2593. * Only the column in question will be written
  2594. * @returns {object} Object with two parameters: `data` the data read, in
  2595. * document order, and `cells` and array of nodes (they can be useful to the
  2596. * caller, so rather than needing a second traversal to get them, just return
  2597. * them from here).
  2598. * @memberof DataTable#oApi
  2599. */
  2600. function _fnGetRowElements( settings, row, colIdx, d )
  2601. {
  2602. var
  2603. tds = [],
  2604. td = row.firstChild,
  2605. name, col, o, i=0, contents,
  2606. columns = settings.aoColumns,
  2607. objectRead = settings._rowReadObject;
  2608. // Allow the data object to be passed in, or construct
  2609. d = d !== undefined ?
  2610. d :
  2611. objectRead ?
  2612. {} :
  2613. [];
  2614. var attr = function ( str, td ) {
  2615. if ( typeof str === 'string' ) {
  2616. var idx = str.indexOf('@');
  2617. if ( idx !== -1 ) {
  2618. var attr = str.substring( idx+1 );
  2619. var setter = _fnSetObjectDataFn( str );
  2620. setter( d, td.getAttribute( attr ) );
  2621. }
  2622. }
  2623. };
  2624. // Read data from a cell and store into the data object
  2625. var cellProcess = function ( cell ) {
  2626. if ( colIdx === undefined || colIdx === i ) {
  2627. col = columns[i];
  2628. contents = $.trim(cell.innerHTML);
  2629. if ( col && col._bAttrSrc ) {
  2630. var setter = _fnSetObjectDataFn( col.mData._ );
  2631. setter( d, contents );
  2632. attr( col.mData.sort, cell );
  2633. attr( col.mData.type, cell );
  2634. attr( col.mData.filter, cell );
  2635. }
  2636. else {
  2637. // Depending on the `data` option for the columns the data can
  2638. // be read to either an object or an array.
  2639. if ( objectRead ) {
  2640. if ( ! col._setter ) {
  2641. // Cache the setter function
  2642. col._setter = _fnSetObjectDataFn( col.mData );
  2643. }
  2644. col._setter( d, contents );
  2645. }
  2646. else {
  2647. d[i] = contents;
  2648. }
  2649. }
  2650. }
  2651. i++;
  2652. };
  2653. if ( td ) {
  2654. // `tr` element was passed in
  2655. while ( td ) {
  2656. name = td.nodeName.toUpperCase();
  2657. if ( name == "TD" || name == "TH" ) {
  2658. cellProcess( td );
  2659. tds.push( td );
  2660. }
  2661. td = td.nextSibling;
  2662. }
  2663. }
  2664. else {
  2665. // Existing row object passed in
  2666. tds = row.anCells;
  2667. for ( var j=0, jen=tds.length ; j<jen ; j++ ) {
  2668. cellProcess( tds[j] );
  2669. }
  2670. }
  2671. // Read the ID from the DOM if present
  2672. var rowNode = row.firstChild ? row : row.nTr;
  2673. if ( rowNode ) {
  2674. var id = rowNode.getAttribute( 'id' );
  2675. if ( id ) {
  2676. _fnSetObjectDataFn( settings.rowId )( d, id );
  2677. }
  2678. }
  2679. return {
  2680. data: d,
  2681. cells: tds
  2682. };
  2683. }
  2684. /**
  2685. * Create a new TR element (and it's TD children) for a row
  2686. * @param {object} oSettings dataTables settings object
  2687. * @param {int} iRow Row to consider
  2688. * @param {node} [nTrIn] TR element to add to the table - optional. If not given,
  2689. * DataTables will create a row automatically
  2690. * @param {array} [anTds] Array of TD|TH elements for the row - must be given
  2691. * if nTr is.
  2692. * @memberof DataTable#oApi
  2693. */
  2694. function _fnCreateTr ( oSettings, iRow, nTrIn, anTds )
  2695. {
  2696. var
  2697. row = oSettings.aoData[iRow],
  2698. rowData = row._aData,
  2699. cells = [],
  2700. nTr, nTd, oCol,
  2701. i, iLen;
  2702. if ( row.nTr === null )
  2703. {
  2704. nTr = nTrIn || document.createElement('tr');
  2705. row.nTr = nTr;
  2706. row.anCells = cells;
  2707. /* Use a private property on the node to allow reserve mapping from the node
  2708. * to the aoData array for fast look up
  2709. */
  2710. nTr._DT_RowIndex = iRow;
  2711. /* Special parameters can be given by the data source to be used on the row */
  2712. _fnRowAttributes( oSettings, row );
  2713. /* Process each column */
  2714. for ( i=0, iLen=oSettings.aoColumns.length ; i<iLen ; i++ )
  2715. {
  2716. oCol = oSettings.aoColumns[i];
  2717. nTd = nTrIn ? anTds[i] : document.createElement( oCol.sCellType );
  2718. nTd._DT_CellIndex = {
  2719. row: iRow,
  2720. column: i
  2721. };
  2722. cells.push( nTd );
  2723. // Need to create the HTML if new, or if a rendering function is defined
  2724. if ( (!nTrIn || oCol.mRender || oCol.mData !== i) &&
  2725. (!$.isPlainObject(oCol.mData) || oCol.mData._ !== i+'.display')
  2726. ) {
  2727. nTd.innerHTML = _fnGetCellData( oSettings, iRow, i, 'display' );
  2728. }
  2729. /* Add user defined class */
  2730. if ( oCol.sClass )
  2731. {
  2732. nTd.className += ' '+oCol.sClass;
  2733. }
  2734. // Visibility - add or remove as required
  2735. if ( oCol.bVisible && ! nTrIn )
  2736. {
  2737. nTr.appendChild( nTd );
  2738. }
  2739. else if ( ! oCol.bVisible && nTrIn )
  2740. {
  2741. nTd.parentNode.removeChild( nTd );
  2742. }
  2743. if ( oCol.fnCreatedCell )
  2744. {
  2745. oCol.fnCreatedCell.call( oSettings.oInstance,
  2746. nTd, _fnGetCellData( oSettings, iRow, i ), rowData, iRow, i
  2747. );
  2748. }
  2749. }
  2750. _fnCallbackFire( oSettings, 'aoRowCreatedCallback', null, [nTr, rowData, iRow, cells] );
  2751. }
  2752. // Remove once webkit bug 131819 and Chromium bug 365619 have been resolved
  2753. // and deployed
  2754. row.nTr.setAttribute( 'role', 'row' );
  2755. }
  2756. /**
  2757. * Add attributes to a row based on the special `DT_*` parameters in a data
  2758. * source object.
  2759. * @param {object} settings DataTables settings object
  2760. * @param {object} DataTables row object for the row to be modified
  2761. * @memberof DataTable#oApi
  2762. */
  2763. function _fnRowAttributes( settings, row )
  2764. {
  2765. var tr = row.nTr;
  2766. var data = row._aData;
  2767. if ( tr ) {
  2768. var id = settings.rowIdFn( data );
  2769. if ( id ) {
  2770. tr.id = id;
  2771. }
  2772. if ( data.DT_RowClass ) {
  2773. // Remove any classes added by DT_RowClass before
  2774. var a = data.DT_RowClass.split(' ');
  2775. row.__rowc = row.__rowc ?
  2776. _unique( row.__rowc.concat( a ) ) :
  2777. a;
  2778. $(tr)
  2779. .removeClass( row.__rowc.join(' ') )
  2780. .addClass( data.DT_RowClass );
  2781. }
  2782. if ( data.DT_RowAttr ) {
  2783. $(tr).attr( data.DT_RowAttr );
  2784. }
  2785. if ( data.DT_RowData ) {
  2786. $(tr).data( data.DT_RowData );
  2787. }
  2788. }
  2789. }
  2790. /**
  2791. * Create the HTML header for the table
  2792. * @param {object} oSettings dataTables settings object
  2793. * @memberof DataTable#oApi
  2794. */
  2795. function _fnBuildHead( oSettings )
  2796. {
  2797. var i, ien, cell, row, column;
  2798. var thead = oSettings.nTHead;
  2799. var tfoot = oSettings.nTFoot;
  2800. var createHeader = $('th, td', thead).length === 0;
  2801. var classes = oSettings.oClasses;
  2802. var columns = oSettings.aoColumns;
  2803. if ( createHeader ) {
  2804. row = $('<tr/>').appendTo( thead );
  2805. }
  2806. for ( i=0, ien=columns.length ; i<ien ; i++ ) {
  2807. column = columns[i];
  2808. cell = $( column.nTh ).addClass( column.sClass );
  2809. if ( createHeader ) {
  2810. cell.appendTo( row );
  2811. }
  2812. // 1.11 move into sorting
  2813. if ( oSettings.oFeatures.bSort ) {
  2814. cell.addClass( column.sSortingClass );
  2815. if ( column.bSortable !== false ) {
  2816. cell
  2817. .attr( 'tabindex', oSettings.iTabIndex )
  2818. .attr( 'aria-controls', oSettings.sTableId );
  2819. _fnSortAttachListener( oSettings, column.nTh, i );
  2820. }
  2821. }
  2822. if ( column.sTitle != cell[0].innerHTML ) {
  2823. cell.html( column.sTitle );
  2824. }
  2825. _fnRenderer( oSettings, 'header' )(
  2826. oSettings, cell, column, classes
  2827. );
  2828. }
  2829. if ( createHeader ) {
  2830. _fnDetectHeader( oSettings.aoHeader, thead );
  2831. }
  2832. /* ARIA role for the rows */
  2833. $(thead).find('>tr').attr('role', 'row');
  2834. /* Deal with the footer - add classes if required */
  2835. $(thead).find('>tr>th, >tr>td').addClass( classes.sHeaderTH );
  2836. $(tfoot).find('>tr>th, >tr>td').addClass( classes.sFooterTH );
  2837. // Cache the footer cells. Note that we only take the cells from the first
  2838. // row in the footer. If there is more than one row the user wants to
  2839. // interact with, they need to use the table().foot() method. Note also this
  2840. // allows cells to be used for multiple columns using colspan
  2841. if ( tfoot !== null ) {
  2842. var cells = oSettings.aoFooter[0];
  2843. for ( i=0, ien=cells.length ; i<ien ; i++ ) {
  2844. column = columns[i];
  2845. column.nTf = cells[i].cell;
  2846. if ( column.sClass ) {
  2847. $(column.nTf).addClass( column.sClass );
  2848. }
  2849. }
  2850. }
  2851. }
  2852. /**
  2853. * Draw the header (or footer) element based on the column visibility states. The
  2854. * methodology here is to use the layout array from _fnDetectHeader, modified for
  2855. * the instantaneous column visibility, to construct the new layout. The grid is
  2856. * traversed over cell at a time in a rows x columns grid fashion, although each
  2857. * cell insert can cover multiple elements in the grid - which is tracks using the
  2858. * aApplied array. Cell inserts in the grid will only occur where there isn't
  2859. * already a cell in that position.
  2860. * @param {object} oSettings dataTables settings object
  2861. * @param array {objects} aoSource Layout array from _fnDetectHeader
  2862. * @param {boolean} [bIncludeHidden=false] If true then include the hidden columns in the calc,
  2863. * @memberof DataTable#oApi
  2864. */
  2865. function _fnDrawHead( oSettings, aoSource, bIncludeHidden )
  2866. {
  2867. var i, iLen, j, jLen, k, kLen, n, nLocalTr;
  2868. var aoLocal = [];
  2869. var aApplied = [];
  2870. var iColumns = oSettings.aoColumns.length;
  2871. var iRowspan, iColspan;
  2872. if ( ! aoSource )
  2873. {
  2874. return;
  2875. }
  2876. if ( bIncludeHidden === undefined )
  2877. {
  2878. bIncludeHidden = false;
  2879. }
  2880. /* Make a copy of the master layout array, but without the visible columns in it */
  2881. for ( i=0, iLen=aoSource.length ; i<iLen ; i++ )
  2882. {
  2883. aoLocal[i] = aoSource[i].slice();
  2884. aoLocal[i].nTr = aoSource[i].nTr;
  2885. /* Remove any columns which are currently hidden */
  2886. for ( j=iColumns-1 ; j>=0 ; j-- )
  2887. {
  2888. if ( !oSettings.aoColumns[j].bVisible && !bIncludeHidden )
  2889. {
  2890. aoLocal[i].splice( j, 1 );
  2891. }
  2892. }
  2893. /* Prep the applied array - it needs an element for each row */
  2894. aApplied.push( [] );
  2895. }
  2896. for ( i=0, iLen=aoLocal.length ; i<iLen ; i++ )
  2897. {
  2898. nLocalTr = aoLocal[i].nTr;
  2899. /* All cells are going to be replaced, so empty out the row */
  2900. if ( nLocalTr )
  2901. {
  2902. while( (n = nLocalTr.firstChild) )
  2903. {
  2904. nLocalTr.removeChild( n );
  2905. }
  2906. }
  2907. for ( j=0, jLen=aoLocal[i].length ; j<jLen ; j++ )
  2908. {
  2909. iRowspan = 1;
  2910. iColspan = 1;
  2911. /* Check to see if there is already a cell (row/colspan) covering our target
  2912. * insert point. If there is, then there is nothing to do.
  2913. */
  2914. if ( aApplied[i][j] === undefined )
  2915. {
  2916. nLocalTr.appendChild( aoLocal[i][j].cell );
  2917. aApplied[i][j] = 1;
  2918. /* Expand the cell to cover as many rows as needed */
  2919. while ( aoLocal[i+iRowspan] !== undefined &&
  2920. aoLocal[i][j].cell == aoLocal[i+iRowspan][j].cell )
  2921. {
  2922. aApplied[i+iRowspan][j] = 1;
  2923. iRowspan++;
  2924. }
  2925. /* Expand the cell to cover as many columns as needed */
  2926. while ( aoLocal[i][j+iColspan] !== undefined &&
  2927. aoLocal[i][j].cell == aoLocal[i][j+iColspan].cell )
  2928. {
  2929. /* Must update the applied array over the rows for the columns */
  2930. for ( k=0 ; k<iRowspan ; k++ )
  2931. {
  2932. aApplied[i+k][j+iColspan] = 1;
  2933. }
  2934. iColspan++;
  2935. }
  2936. /* Do the actual expansion in the DOM */
  2937. $(aoLocal[i][j].cell)
  2938. .attr('rowspan', iRowspan)
  2939. .attr('colspan', iColspan);
  2940. }
  2941. }
  2942. }
  2943. }
  2944. /**
  2945. * Insert the required TR nodes into the table for display
  2946. * @param {object} oSettings dataTables settings object
  2947. * @memberof DataTable#oApi
  2948. */
  2949. function _fnDraw( oSettings )
  2950. {
  2951. /* Provide a pre-callback function which can be used to cancel the draw is false is returned */
  2952. var aPreDraw = _fnCallbackFire( oSettings, 'aoPreDrawCallback', 'preDraw', [oSettings] );
  2953. if ( $.inArray( false, aPreDraw ) !== -1 )
  2954. {
  2955. _fnProcessingDisplay( oSettings, false );
  2956. return;
  2957. }
  2958. var i, iLen, n;
  2959. var anRows = [];
  2960. var iRowCount = 0;
  2961. var asStripeClasses = oSettings.asStripeClasses;
  2962. var iStripes = asStripeClasses.length;
  2963. var iOpenRows = oSettings.aoOpenRows.length;
  2964. var oLang = oSettings.oLanguage;
  2965. var iInitDisplayStart = oSettings.iInitDisplayStart;
  2966. var bServerSide = _fnDataSource( oSettings ) == 'ssp';
  2967. var aiDisplay = oSettings.aiDisplay;
  2968. oSettings.bDrawing = true;
  2969. /* Check and see if we have an initial draw position from state saving */
  2970. if ( iInitDisplayStart !== undefined && iInitDisplayStart !== -1 )
  2971. {
  2972. oSettings._iDisplayStart = bServerSide ?
  2973. iInitDisplayStart :
  2974. iInitDisplayStart >= oSettings.fnRecordsDisplay() ?
  2975. 0 :
  2976. iInitDisplayStart;
  2977. oSettings.iInitDisplayStart = -1;
  2978. }
  2979. var iDisplayStart = oSettings._iDisplayStart;
  2980. var iDisplayEnd = oSettings.fnDisplayEnd();
  2981. /* Server-side processing draw intercept */
  2982. if ( oSettings.bDeferLoading )
  2983. {
  2984. oSettings.bDeferLoading = false;
  2985. oSettings.iDraw++;
  2986. _fnProcessingDisplay( oSettings, false );
  2987. }
  2988. else if ( !bServerSide )
  2989. {
  2990. oSettings.iDraw++;
  2991. }
  2992. else if ( !oSettings.bDestroying && !_fnAjaxUpdate( oSettings ) )
  2993. {
  2994. return;
  2995. }
  2996. if ( aiDisplay.length !== 0 )
  2997. {
  2998. var iStart = bServerSide ? 0 : iDisplayStart;
  2999. var iEnd = bServerSide ? oSettings.aoData.length : iDisplayEnd;
  3000. for ( var j=iStart ; j<iEnd ; j++ )
  3001. {
  3002. var iDataIndex = aiDisplay[j];
  3003. var aoData = oSettings.aoData[ iDataIndex ];
  3004. if ( aoData.nTr === null )
  3005. {
  3006. _fnCreateTr( oSettings, iDataIndex );
  3007. }
  3008. var nRow = aoData.nTr;
  3009. /* Remove the old striping classes and then add the new one */
  3010. if ( iStripes !== 0 )
  3011. {
  3012. var sStripe = asStripeClasses[ iRowCount % iStripes ];
  3013. if ( aoData._sRowStripe != sStripe )
  3014. {
  3015. $(nRow).removeClass( aoData._sRowStripe ).addClass( sStripe );
  3016. aoData._sRowStripe = sStripe;
  3017. }
  3018. }
  3019. // Row callback functions - might want to manipulate the row
  3020. // iRowCount and j are not currently documented. Are they at all
  3021. // useful?
  3022. _fnCallbackFire( oSettings, 'aoRowCallback', null,
  3023. [nRow, aoData._aData, iRowCount, j, iDataIndex] );
  3024. anRows.push( nRow );
  3025. iRowCount++;
  3026. }
  3027. }
  3028. else
  3029. {
  3030. /* Table is empty - create a row with an empty message in it */
  3031. var sZero = oLang.sZeroRecords;
  3032. if ( oSettings.iDraw == 1 && _fnDataSource( oSettings ) == 'ajax' )
  3033. {
  3034. sZero = oLang.sLoadingRecords;
  3035. }
  3036. else if ( oLang.sEmptyTable && oSettings.fnRecordsTotal() === 0 )
  3037. {
  3038. sZero = oLang.sEmptyTable;
  3039. }
  3040. anRows[ 0 ] = $( '<tr/>', { 'class': iStripes ? asStripeClasses[0] : '' } )
  3041. .append( $('<td />', {
  3042. 'valign': 'top',
  3043. 'colSpan': _fnVisbleColumns( oSettings ),
  3044. 'class': oSettings.oClasses.sRowEmpty
  3045. } ).html( sZero ) )[0];
  3046. }
  3047. /* Header and footer callbacks */
  3048. _fnCallbackFire( oSettings, 'aoHeaderCallback', 'header', [ $(oSettings.nTHead).children('tr')[0],
  3049. _fnGetDataMaster( oSettings ), iDisplayStart, iDisplayEnd, aiDisplay ] );
  3050. _fnCallbackFire( oSettings, 'aoFooterCallback', 'footer', [ $(oSettings.nTFoot).children('tr')[0],
  3051. _fnGetDataMaster( oSettings ), iDisplayStart, iDisplayEnd, aiDisplay ] );
  3052. var body = $(oSettings.nTBody);
  3053. body.children().detach();
  3054. body.append( $(anRows) );
  3055. /* Call all required callback functions for the end of a draw */
  3056. _fnCallbackFire( oSettings, 'aoDrawCallback', 'draw', [oSettings] );
  3057. /* Draw is complete, sorting and filtering must be as well */
  3058. oSettings.bSorted = false;
  3059. oSettings.bFiltered = false;
  3060. oSettings.bDrawing = false;
  3061. }
  3062. /**
  3063. * Redraw the table - taking account of the various features which are enabled
  3064. * @param {object} oSettings dataTables settings object
  3065. * @param {boolean} [holdPosition] Keep the current paging position. By default
  3066. * the paging is reset to the first page
  3067. * @memberof DataTable#oApi
  3068. */
  3069. function _fnReDraw( settings, holdPosition )
  3070. {
  3071. var
  3072. features = settings.oFeatures,
  3073. sort = features.bSort,
  3074. filter = features.bFilter;
  3075. if ( sort ) {
  3076. _fnSort( settings );
  3077. }
  3078. if ( filter ) {
  3079. _fnFilterComplete( settings, settings.oPreviousSearch );
  3080. }
  3081. else {
  3082. // No filtering, so we want to just use the display master
  3083. settings.aiDisplay = settings.aiDisplayMaster.slice();
  3084. }
  3085. if ( holdPosition !== true ) {
  3086. settings._iDisplayStart = 0;
  3087. }
  3088. // Let any modules know about the draw hold position state (used by
  3089. // scrolling internally)
  3090. settings._drawHold = holdPosition;
  3091. _fnDraw( settings );
  3092. settings._drawHold = false;
  3093. }
  3094. /**
  3095. * Add the options to the page HTML for the table
  3096. * @param {object} oSettings dataTables settings object
  3097. * @memberof DataTable#oApi
  3098. */
  3099. function _fnAddOptionsHtml ( oSettings )
  3100. {
  3101. var classes = oSettings.oClasses;
  3102. var table = $(oSettings.nTable);
  3103. var holding = $('<div/>').insertBefore( table ); // Holding element for speed
  3104. var features = oSettings.oFeatures;
  3105. // All DataTables are wrapped in a div
  3106. var insert = $('<div/>', {
  3107. id: oSettings.sTableId+'_wrapper',
  3108. 'class': classes.sWrapper + (oSettings.nTFoot ? '' : ' '+classes.sNoFooter)
  3109. } );
  3110. oSettings.nHolding = holding[0];
  3111. oSettings.nTableWrapper = insert[0];
  3112. oSettings.nTableReinsertBefore = oSettings.nTable.nextSibling;
  3113. /* Loop over the user set positioning and place the elements as needed */
  3114. var aDom = oSettings.sDom.split('');
  3115. var featureNode, cOption, nNewNode, cNext, sAttr, j;
  3116. for ( var i=0 ; i<aDom.length ; i++ )
  3117. {
  3118. featureNode = null;
  3119. cOption = aDom[i];
  3120. if ( cOption == '<' )
  3121. {
  3122. /* New container div */
  3123. nNewNode = $('<div/>')[0];
  3124. /* Check to see if we should append an id and/or a class name to the container */
  3125. cNext = aDom[i+1];
  3126. if ( cNext == "'" || cNext == '"' )
  3127. {
  3128. sAttr = "";
  3129. j = 2;
  3130. while ( aDom[i+j] != cNext )
  3131. {
  3132. sAttr += aDom[i+j];
  3133. j++;
  3134. }
  3135. /* Replace jQuery UI constants @todo depreciated */
  3136. if ( sAttr == "H" )
  3137. {
  3138. sAttr = classes.sJUIHeader;
  3139. }
  3140. else if ( sAttr == "F" )
  3141. {
  3142. sAttr = classes.sJUIFooter;
  3143. }
  3144. /* The attribute can be in the format of "#id.class", "#id" or "class" This logic
  3145. * breaks the string into parts and applies them as needed
  3146. */
  3147. if ( sAttr.indexOf('.') != -1 )
  3148. {
  3149. var aSplit = sAttr.split('.');
  3150. nNewNode.id = aSplit[0].substr(1, aSplit[0].length-1);
  3151. nNewNode.className = aSplit[1];
  3152. }
  3153. else if ( sAttr.charAt(0) == "#" )
  3154. {
  3155. nNewNode.id = sAttr.substr(1, sAttr.length-1);
  3156. }
  3157. else
  3158. {
  3159. nNewNode.className = sAttr;
  3160. }
  3161. i += j; /* Move along the position array */
  3162. }
  3163. insert.append( nNewNode );
  3164. insert = $(nNewNode);
  3165. }
  3166. else if ( cOption == '>' )
  3167. {
  3168. /* End container div */
  3169. insert = insert.parent();
  3170. }
  3171. // @todo Move options into their own plugins?
  3172. else if ( cOption == 'l' && features.bPaginate && features.bLengthChange )
  3173. {
  3174. /* Length */
  3175. featureNode = _fnFeatureHtmlLength( oSettings );
  3176. }
  3177. else if ( cOption == 'f' && features.bFilter )
  3178. {
  3179. /* Filter */
  3180. featureNode = _fnFeatureHtmlFilter( oSettings );
  3181. }
  3182. else if ( cOption == 'r' && features.bProcessing )
  3183. {
  3184. /* pRocessing */
  3185. featureNode = _fnFeatureHtmlProcessing( oSettings );
  3186. }
  3187. else if ( cOption == 't' )
  3188. {
  3189. /* Table */
  3190. featureNode = _fnFeatureHtmlTable( oSettings );
  3191. }
  3192. else if ( cOption == 'i' && features.bInfo )
  3193. {
  3194. /* Info */
  3195. featureNode = _fnFeatureHtmlInfo( oSettings );
  3196. }
  3197. else if ( cOption == 'p' && features.bPaginate )
  3198. {
  3199. /* Pagination */
  3200. featureNode = _fnFeatureHtmlPaginate( oSettings );
  3201. }
  3202. else if ( DataTable.ext.feature.length !== 0 )
  3203. {
  3204. /* Plug-in features */
  3205. var aoFeatures = DataTable.ext.feature;
  3206. for ( var k=0, kLen=aoFeatures.length ; k<kLen ; k++ )
  3207. {
  3208. if ( cOption == aoFeatures[k].cFeature )
  3209. {
  3210. featureNode = aoFeatures[k].fnInit( oSettings );
  3211. break;
  3212. }
  3213. }
  3214. }
  3215. /* Add to the 2D features array */
  3216. if ( featureNode )
  3217. {
  3218. var aanFeatures = oSettings.aanFeatures;
  3219. if ( ! aanFeatures[cOption] )
  3220. {
  3221. aanFeatures[cOption] = [];
  3222. }
  3223. aanFeatures[cOption].push( featureNode );
  3224. insert.append( featureNode );
  3225. }
  3226. }
  3227. /* Built our DOM structure - replace the holding div with what we want */
  3228. holding.replaceWith( insert );
  3229. oSettings.nHolding = null;
  3230. }
  3231. /**
  3232. * Use the DOM source to create up an array of header cells. The idea here is to
  3233. * create a layout grid (array) of rows x columns, which contains a reference
  3234. * to the cell that that point in the grid (regardless of col/rowspan), such that
  3235. * any column / row could be removed and the new grid constructed
  3236. * @param array {object} aLayout Array to store the calculated layout in
  3237. * @param {node} nThead The header/footer element for the table
  3238. * @memberof DataTable#oApi
  3239. */
  3240. function _fnDetectHeader ( aLayout, nThead )
  3241. {
  3242. var nTrs = $(nThead).children('tr');
  3243. var nTr, nCell;
  3244. var i, k, l, iLen, jLen, iColShifted, iColumn, iColspan, iRowspan;
  3245. var bUnique;
  3246. var fnShiftCol = function ( a, i, j ) {
  3247. var k = a[i];
  3248. while ( k[j] ) {
  3249. j++;
  3250. }
  3251. return j;
  3252. };
  3253. aLayout.splice( 0, aLayout.length );
  3254. /* We know how many rows there are in the layout - so prep it */
  3255. for ( i=0, iLen=nTrs.length ; i<iLen ; i++ )
  3256. {
  3257. aLayout.push( [] );
  3258. }
  3259. /* Calculate a layout array */
  3260. for ( i=0, iLen=nTrs.length ; i<iLen ; i++ )
  3261. {
  3262. nTr = nTrs[i];
  3263. iColumn = 0;
  3264. /* For every cell in the row... */
  3265. nCell = nTr.firstChild;
  3266. while ( nCell ) {
  3267. if ( nCell.nodeName.toUpperCase() == "TD" ||
  3268. nCell.nodeName.toUpperCase() == "TH" )
  3269. {
  3270. /* Get the col and rowspan attributes from the DOM and sanitise them */
  3271. iColspan = nCell.getAttribute('colspan') * 1;
  3272. iRowspan = nCell.getAttribute('rowspan') * 1;
  3273. iColspan = (!iColspan || iColspan===0 || iColspan===1) ? 1 : iColspan;
  3274. iRowspan = (!iRowspan || iRowspan===0 || iRowspan===1) ? 1 : iRowspan;
  3275. /* There might be colspan cells already in this row, so shift our target
  3276. * accordingly
  3277. */
  3278. iColShifted = fnShiftCol( aLayout, i, iColumn );
  3279. /* Cache calculation for unique columns */
  3280. bUnique = iColspan === 1 ? true : false;
  3281. /* If there is col / rowspan, copy the information into the layout grid */
  3282. for ( l=0 ; l<iColspan ; l++ )
  3283. {
  3284. for ( k=0 ; k<iRowspan ; k++ )
  3285. {
  3286. aLayout[i+k][iColShifted+l] = {
  3287. "cell": nCell,
  3288. "unique": bUnique
  3289. };
  3290. aLayout[i+k].nTr = nTr;
  3291. }
  3292. }
  3293. }
  3294. nCell = nCell.nextSibling;
  3295. }
  3296. }
  3297. }
  3298. /**
  3299. * Get an array of unique th elements, one for each column
  3300. * @param {object} oSettings dataTables settings object
  3301. * @param {node} nHeader automatically detect the layout from this node - optional
  3302. * @param {array} aLayout thead/tfoot layout from _fnDetectHeader - optional
  3303. * @returns array {node} aReturn list of unique th's
  3304. * @memberof DataTable#oApi
  3305. */
  3306. function _fnGetUniqueThs ( oSettings, nHeader, aLayout )
  3307. {
  3308. var aReturn = [];
  3309. if ( !aLayout )
  3310. {
  3311. aLayout = oSettings.aoHeader;
  3312. if ( nHeader )
  3313. {
  3314. aLayout = [];
  3315. _fnDetectHeader( aLayout, nHeader );
  3316. }
  3317. }
  3318. for ( var i=0, iLen=aLayout.length ; i<iLen ; i++ )
  3319. {
  3320. for ( var j=0, jLen=aLayout[i].length ; j<jLen ; j++ )
  3321. {
  3322. if ( aLayout[i][j].unique &&
  3323. (!aReturn[j] || !oSettings.bSortCellsTop) )
  3324. {
  3325. aReturn[j] = aLayout[i][j].cell;
  3326. }
  3327. }
  3328. }
  3329. return aReturn;
  3330. }
  3331. /**
  3332. * Create an Ajax call based on the table's settings, taking into account that
  3333. * parameters can have multiple forms, and backwards compatibility.
  3334. *
  3335. * @param {object} oSettings dataTables settings object
  3336. * @param {array} data Data to send to the server, required by
  3337. * DataTables - may be augmented by developer callbacks
  3338. * @param {function} fn Callback function to run when data is obtained
  3339. */
  3340. function _fnBuildAjax( oSettings, data, fn )
  3341. {
  3342. // Compatibility with 1.9-, allow fnServerData and event to manipulate
  3343. _fnCallbackFire( oSettings, 'aoServerParams', 'serverParams', [data] );
  3344. // Convert to object based for 1.10+ if using the old array scheme which can
  3345. // come from server-side processing or serverParams
  3346. if ( data && $.isArray(data) ) {
  3347. var tmp = {};
  3348. var rbracket = /(.*?)\[\]$/;
  3349. $.each( data, function (key, val) {
  3350. var match = val.name.match(rbracket);
  3351. if ( match ) {
  3352. // Support for arrays
  3353. var name = match[0];
  3354. if ( ! tmp[ name ] ) {
  3355. tmp[ name ] = [];
  3356. }
  3357. tmp[ name ].push( val.value );
  3358. }
  3359. else {
  3360. tmp[val.name] = val.value;
  3361. }
  3362. } );
  3363. data = tmp;
  3364. }
  3365. var ajaxData;
  3366. var ajax = oSettings.ajax;
  3367. var instance = oSettings.oInstance;
  3368. var callback = function ( json ) {
  3369. _fnCallbackFire( oSettings, null, 'xhr', [oSettings, json, oSettings.jqXHR] );
  3370. fn( json );
  3371. };
  3372. if ( $.isPlainObject( ajax ) && ajax.data )
  3373. {
  3374. ajaxData = ajax.data;
  3375. var newData = typeof ajaxData === 'function' ?
  3376. ajaxData( data, oSettings ) : // fn can manipulate data or return
  3377. ajaxData; // an object object or array to merge
  3378. // If the function returned something, use that alone
  3379. data = typeof ajaxData === 'function' && newData ?
  3380. newData :
  3381. $.extend( true, data, newData );
  3382. // Remove the data property as we've resolved it already and don't want
  3383. // jQuery to do it again (it is restored at the end of the function)
  3384. delete ajax.data;
  3385. }
  3386. var baseAjax = {
  3387. "data": data,
  3388. "success": function (json) {
  3389. var error = json.error || json.sError;
  3390. if ( error ) {
  3391. _fnLog( oSettings, 0, error );
  3392. }
  3393. oSettings.json = json;
  3394. callback( json );
  3395. },
  3396. "dataType": "json",
  3397. "cache": false,
  3398. "type": oSettings.sServerMethod,
  3399. "error": function (xhr, error, thrown) {
  3400. var ret = _fnCallbackFire( oSettings, null, 'xhr', [oSettings, null, oSettings.jqXHR] );
  3401. if ( $.inArray( true, ret ) === -1 ) {
  3402. if ( error == "parsererror" ) {
  3403. _fnLog( oSettings, 0, 'Invalid JSON response', 1 );
  3404. }
  3405. else if ( xhr.readyState === 4 ) {
  3406. _fnLog( oSettings, 0, 'Ajax error', 7 );
  3407. }
  3408. }
  3409. _fnProcessingDisplay( oSettings, false );
  3410. }
  3411. };
  3412. // Store the data submitted for the API
  3413. oSettings.oAjaxData = data;
  3414. // Allow plug-ins and external processes to modify the data
  3415. _fnCallbackFire( oSettings, null, 'preXhr', [oSettings, data] );
  3416. if ( oSettings.fnServerData )
  3417. {
  3418. // DataTables 1.9- compatibility
  3419. oSettings.fnServerData.call( instance,
  3420. oSettings.sAjaxSource,
  3421. $.map( data, function (val, key) { // Need to convert back to 1.9 trad format
  3422. return { name: key, value: val };
  3423. } ),
  3424. callback,
  3425. oSettings
  3426. );
  3427. }
  3428. else if ( oSettings.sAjaxSource || typeof ajax === 'string' )
  3429. {
  3430. // DataTables 1.9- compatibility
  3431. oSettings.jqXHR = $.ajax( $.extend( baseAjax, {
  3432. url: ajax || oSettings.sAjaxSource
  3433. } ) );
  3434. }
  3435. else if ( typeof ajax === 'function' )
  3436. {
  3437. // Is a function - let the caller define what needs to be done
  3438. oSettings.jqXHR = ajax.call( instance, data, callback, oSettings );
  3439. }
  3440. else
  3441. {
  3442. // Object to extend the base settings
  3443. oSettings.jqXHR = $.ajax( $.extend( baseAjax, ajax ) );
  3444. // Restore for next time around
  3445. ajax.data = ajaxData;
  3446. }
  3447. }
  3448. /**
  3449. * Update the table using an Ajax call
  3450. * @param {object} settings dataTables settings object
  3451. * @returns {boolean} Block the table drawing or not
  3452. * @memberof DataTable#oApi
  3453. */
  3454. function _fnAjaxUpdate( settings )
  3455. {
  3456. if ( settings.bAjaxDataGet ) {
  3457. settings.iDraw++;
  3458. _fnProcessingDisplay( settings, true );
  3459. _fnBuildAjax(
  3460. settings,
  3461. _fnAjaxParameters( settings ),
  3462. function(json) {
  3463. _fnAjaxUpdateDraw( settings, json );
  3464. }
  3465. );
  3466. return false;
  3467. }
  3468. return true;
  3469. }
  3470. /**
  3471. * Build up the parameters in an object needed for a server-side processing
  3472. * request. Note that this is basically done twice, is different ways - a modern
  3473. * method which is used by default in DataTables 1.10 which uses objects and
  3474. * arrays, or the 1.9- method with is name / value pairs. 1.9 method is used if
  3475. * the sAjaxSource option is used in the initialisation, or the legacyAjax
  3476. * option is set.
  3477. * @param {object} oSettings dataTables settings object
  3478. * @returns {bool} block the table drawing or not
  3479. * @memberof DataTable#oApi
  3480. */
  3481. function _fnAjaxParameters( settings )
  3482. {
  3483. var
  3484. columns = settings.aoColumns,
  3485. columnCount = columns.length,
  3486. features = settings.oFeatures,
  3487. preSearch = settings.oPreviousSearch,
  3488. preColSearch = settings.aoPreSearchCols,
  3489. i, data = [], dataProp, column, columnSearch,
  3490. sort = _fnSortFlatten( settings ),
  3491. displayStart = settings._iDisplayStart,
  3492. displayLength = features.bPaginate !== false ?
  3493. settings._iDisplayLength :
  3494. -1;
  3495. var param = function ( name, value ) {
  3496. data.push( { 'name': name, 'value': value } );
  3497. };
  3498. // DataTables 1.9- compatible method
  3499. param( 'sEcho', settings.iDraw );
  3500. param( 'iColumns', columnCount );
  3501. param( 'sColumns', _pluck( columns, 'sName' ).join(',') );
  3502. param( 'iDisplayStart', displayStart );
  3503. param( 'iDisplayLength', displayLength );
  3504. // DataTables 1.10+ method
  3505. var d = {
  3506. draw: settings.iDraw,
  3507. columns: [],
  3508. order: [],
  3509. start: displayStart,
  3510. length: displayLength,
  3511. search: {
  3512. value: preSearch.sSearch,
  3513. regex: preSearch.bRegex
  3514. }
  3515. };
  3516. for ( i=0 ; i<columnCount ; i++ ) {
  3517. column = columns[i];
  3518. columnSearch = preColSearch[i];
  3519. dataProp = typeof column.mData=="function" ? 'function' : column.mData ;
  3520. d.columns.push( {
  3521. data: dataProp,
  3522. name: column.sName,
  3523. searchable: column.bSearchable,
  3524. orderable: column.bSortable,
  3525. search: {
  3526. value: columnSearch.sSearch,
  3527. regex: columnSearch.bRegex
  3528. }
  3529. } );
  3530. param( "mDataProp_"+i, dataProp );
  3531. if ( features.bFilter ) {
  3532. param( 'sSearch_'+i, columnSearch.sSearch );
  3533. param( 'bRegex_'+i, columnSearch.bRegex );
  3534. param( 'bSearchable_'+i, column.bSearchable );
  3535. }
  3536. if ( features.bSort ) {
  3537. param( 'bSortable_'+i, column.bSortable );
  3538. }
  3539. }
  3540. if ( features.bFilter ) {
  3541. param( 'sSearch', preSearch.sSearch );
  3542. param( 'bRegex', preSearch.bRegex );
  3543. }
  3544. if ( features.bSort ) {
  3545. $.each( sort, function ( i, val ) {
  3546. d.order.push( { column: val.col, dir: val.dir } );
  3547. param( 'iSortCol_'+i, val.col );
  3548. param( 'sSortDir_'+i, val.dir );
  3549. } );
  3550. param( 'iSortingCols', sort.length );
  3551. }
  3552. // If the legacy.ajax parameter is null, then we automatically decide which
  3553. // form to use, based on sAjaxSource
  3554. var legacy = DataTable.ext.legacy.ajax;
  3555. if ( legacy === null ) {
  3556. return settings.sAjaxSource ? data : d;
  3557. }
  3558. // Otherwise, if legacy has been specified then we use that to decide on the
  3559. // form
  3560. return legacy ? data : d;
  3561. }
  3562. /**
  3563. * Data the data from the server (nuking the old) and redraw the table
  3564. * @param {object} oSettings dataTables settings object
  3565. * @param {object} json json data return from the server.
  3566. * @param {string} json.sEcho Tracking flag for DataTables to match requests
  3567. * @param {int} json.iTotalRecords Number of records in the data set, not accounting for filtering
  3568. * @param {int} json.iTotalDisplayRecords Number of records in the data set, accounting for filtering
  3569. * @param {array} json.aaData The data to display on this page
  3570. * @param {string} [json.sColumns] Column ordering (sName, comma separated)
  3571. * @memberof DataTable#oApi
  3572. */
  3573. function _fnAjaxUpdateDraw ( settings, json )
  3574. {
  3575. // v1.10 uses camelCase variables, while 1.9 uses Hungarian notation.
  3576. // Support both
  3577. var compat = function ( old, modern ) {
  3578. return json[old] !== undefined ? json[old] : json[modern];
  3579. };
  3580. var data = _fnAjaxDataSrc( settings, json );
  3581. var draw = compat( 'sEcho', 'draw' );
  3582. var recordsTotal = compat( 'iTotalRecords', 'recordsTotal' );
  3583. var recordsFiltered = compat( 'iTotalDisplayRecords', 'recordsFiltered' );
  3584. if ( draw ) {
  3585. // Protect against out of sequence returns
  3586. if ( draw*1 < settings.iDraw ) {
  3587. return;
  3588. }
  3589. settings.iDraw = draw * 1;
  3590. }
  3591. _fnClearTable( settings );
  3592. settings._iRecordsTotal = parseInt(recordsTotal, 10);
  3593. settings._iRecordsDisplay = parseInt(recordsFiltered, 10);
  3594. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  3595. _fnAddData( settings, data[i] );
  3596. }
  3597. settings.aiDisplay = settings.aiDisplayMaster.slice();
  3598. settings.bAjaxDataGet = false;
  3599. _fnDraw( settings );
  3600. if ( ! settings._bInitComplete ) {
  3601. _fnInitComplete( settings, json );
  3602. }
  3603. settings.bAjaxDataGet = true;
  3604. _fnProcessingDisplay( settings, false );
  3605. }
  3606. /**
  3607. * Get the data from the JSON data source to use for drawing a table. Using
  3608. * `_fnGetObjectDataFn` allows the data to be sourced from a property of the
  3609. * source object, or from a processing function.
  3610. * @param {object} oSettings dataTables settings object
  3611. * @param {object} json Data source object / array from the server
  3612. * @return {array} Array of data to use
  3613. */
  3614. function _fnAjaxDataSrc ( oSettings, json )
  3615. {
  3616. var dataSrc = $.isPlainObject( oSettings.ajax ) && oSettings.ajax.dataSrc !== undefined ?
  3617. oSettings.ajax.dataSrc :
  3618. oSettings.sAjaxDataProp; // Compatibility with 1.9-.
  3619. // Compatibility with 1.9-. In order to read from aaData, check if the
  3620. // default has been changed, if not, check for aaData
  3621. if ( dataSrc === 'data' ) {
  3622. return json.aaData || json[dataSrc];
  3623. }
  3624. return dataSrc !== "" ?
  3625. _fnGetObjectDataFn( dataSrc )( json ) :
  3626. json;
  3627. }
  3628. /**
  3629. * Generate the node required for filtering text
  3630. * @returns {node} Filter control element
  3631. * @param {object} oSettings dataTables settings object
  3632. * @memberof DataTable#oApi
  3633. */
  3634. function _fnFeatureHtmlFilter ( settings )
  3635. {
  3636. var classes = settings.oClasses;
  3637. var tableId = settings.sTableId;
  3638. var language = settings.oLanguage;
  3639. var previousSearch = settings.oPreviousSearch;
  3640. var features = settings.aanFeatures;
  3641. var input = '<input type="search" class="'+classes.sFilterInput+'"/>';
  3642. var str = language.sSearch;
  3643. str = str.match(/_INPUT_/) ?
  3644. str.replace('_INPUT_', input) :
  3645. str+input;
  3646. var filter = $('<div/>', {
  3647. 'id': ! features.f ? tableId+'_filter' : null,
  3648. 'class': classes.sFilter
  3649. } )
  3650. .append( $('<label/>' ).append( str ) );
  3651. var searchFn = function() {
  3652. /* Update all other filter input elements for the new display */
  3653. var n = features.f;
  3654. var val = !this.value ? "" : this.value; // mental IE8 fix :-(
  3655. /* Now do the filter */
  3656. if ( val != previousSearch.sSearch ) {
  3657. _fnFilterComplete( settings, {
  3658. "sSearch": val,
  3659. "bRegex": previousSearch.bRegex,
  3660. "bSmart": previousSearch.bSmart ,
  3661. "bCaseInsensitive": previousSearch.bCaseInsensitive
  3662. } );
  3663. // Need to redraw, without resorting
  3664. settings._iDisplayStart = 0;
  3665. _fnDraw( settings );
  3666. }
  3667. };
  3668. var searchDelay = settings.searchDelay !== null ?
  3669. settings.searchDelay :
  3670. _fnDataSource( settings ) === 'ssp' ?
  3671. 400 :
  3672. 0;
  3673. var jqFilter = $('input', filter)
  3674. .val( previousSearch.sSearch )
  3675. .attr( 'placeholder', language.sSearchPlaceholder )
  3676. .on(
  3677. 'keyup.DT search.DT input.DT paste.DT cut.DT',
  3678. searchDelay ?
  3679. _fnThrottle( searchFn, searchDelay ) :
  3680. searchFn
  3681. )
  3682. .on( 'keypress.DT', function(e) {
  3683. /* Prevent form submission */
  3684. if ( e.keyCode == 13 ) {
  3685. return false;
  3686. }
  3687. } )
  3688. .attr('aria-controls', tableId);
  3689. // Update the input elements whenever the table is filtered
  3690. $(settings.nTable).on( 'search.dt.DT', function ( ev, s ) {
  3691. if ( settings === s ) {
  3692. // IE9 throws an 'unknown error' if document.activeElement is used
  3693. // inside an iframe or frame...
  3694. try {
  3695. if ( jqFilter[0] !== document.activeElement ) {
  3696. jqFilter.val( previousSearch.sSearch );
  3697. }
  3698. }
  3699. catch ( e ) {}
  3700. }
  3701. } );
  3702. return filter[0];
  3703. }
  3704. /**
  3705. * Filter the table using both the global filter and column based filtering
  3706. * @param {object} oSettings dataTables settings object
  3707. * @param {object} oSearch search information
  3708. * @param {int} [iForce] force a research of the master array (1) or not (undefined or 0)
  3709. * @memberof DataTable#oApi
  3710. */
  3711. function _fnFilterComplete ( oSettings, oInput, iForce )
  3712. {
  3713. var oPrevSearch = oSettings.oPreviousSearch;
  3714. var aoPrevSearch = oSettings.aoPreSearchCols;
  3715. var fnSaveFilter = function ( oFilter ) {
  3716. /* Save the filtering values */
  3717. oPrevSearch.sSearch = oFilter.sSearch;
  3718. oPrevSearch.bRegex = oFilter.bRegex;
  3719. oPrevSearch.bSmart = oFilter.bSmart;
  3720. oPrevSearch.bCaseInsensitive = oFilter.bCaseInsensitive;
  3721. };
  3722. var fnRegex = function ( o ) {
  3723. // Backwards compatibility with the bEscapeRegex option
  3724. return o.bEscapeRegex !== undefined ? !o.bEscapeRegex : o.bRegex;
  3725. };
  3726. // Resolve any column types that are unknown due to addition or invalidation
  3727. // @todo As per sort - can this be moved into an event handler?
  3728. _fnColumnTypes( oSettings );
  3729. /* In server-side processing all filtering is done by the server, so no point hanging around here */
  3730. if ( _fnDataSource( oSettings ) != 'ssp' )
  3731. {
  3732. /* Global filter */
  3733. _fnFilter( oSettings, oInput.sSearch, iForce, fnRegex(oInput), oInput.bSmart, oInput.bCaseInsensitive );
  3734. fnSaveFilter( oInput );
  3735. /* Now do the individual column filter */
  3736. for ( var i=0 ; i<aoPrevSearch.length ; i++ )
  3737. {
  3738. _fnFilterColumn( oSettings, aoPrevSearch[i].sSearch, i, fnRegex(aoPrevSearch[i]),
  3739. aoPrevSearch[i].bSmart, aoPrevSearch[i].bCaseInsensitive );
  3740. }
  3741. /* Custom filtering */
  3742. _fnFilterCustom( oSettings );
  3743. }
  3744. else
  3745. {
  3746. fnSaveFilter( oInput );
  3747. }
  3748. /* Tell the draw function we have been filtering */
  3749. oSettings.bFiltered = true;
  3750. _fnCallbackFire( oSettings, null, 'search', [oSettings] );
  3751. }
  3752. /**
  3753. * Apply custom filtering functions
  3754. * @param {object} oSettings dataTables settings object
  3755. * @memberof DataTable#oApi
  3756. */
  3757. function _fnFilterCustom( settings )
  3758. {
  3759. var filters = DataTable.ext.search;
  3760. var displayRows = settings.aiDisplay;
  3761. var row, rowIdx;
  3762. for ( var i=0, ien=filters.length ; i<ien ; i++ ) {
  3763. var rows = [];
  3764. // Loop over each row and see if it should be included
  3765. for ( var j=0, jen=displayRows.length ; j<jen ; j++ ) {
  3766. rowIdx = displayRows[ j ];
  3767. row = settings.aoData[ rowIdx ];
  3768. if ( filters[i]( settings, row._aFilterData, rowIdx, row._aData, j ) ) {
  3769. rows.push( rowIdx );
  3770. }
  3771. }
  3772. // So the array reference doesn't break set the results into the
  3773. // existing array
  3774. displayRows.length = 0;
  3775. $.merge( displayRows, rows );
  3776. }
  3777. }
  3778. /**
  3779. * Filter the table on a per-column basis
  3780. * @param {object} oSettings dataTables settings object
  3781. * @param {string} sInput string to filter on
  3782. * @param {int} iColumn column to filter
  3783. * @param {bool} bRegex treat search string as a regular expression or not
  3784. * @param {bool} bSmart use smart filtering or not
  3785. * @param {bool} bCaseInsensitive Do case insenstive matching or not
  3786. * @memberof DataTable#oApi
  3787. */
  3788. function _fnFilterColumn ( settings, searchStr, colIdx, regex, smart, caseInsensitive )
  3789. {
  3790. if ( searchStr === '' ) {
  3791. return;
  3792. }
  3793. var data;
  3794. var out = [];
  3795. var display = settings.aiDisplay;
  3796. var rpSearch = _fnFilterCreateSearch( searchStr, regex, smart, caseInsensitive );
  3797. for ( var i=0 ; i<display.length ; i++ ) {
  3798. data = settings.aoData[ display[i] ]._aFilterData[ colIdx ];
  3799. if ( rpSearch.test( data ) ) {
  3800. out.push( display[i] );
  3801. }
  3802. }
  3803. settings.aiDisplay = out;
  3804. }
  3805. /**
  3806. * Filter the data table based on user input and draw the table
  3807. * @param {object} settings dataTables settings object
  3808. * @param {string} input string to filter on
  3809. * @param {int} force optional - force a research of the master array (1) or not (undefined or 0)
  3810. * @param {bool} regex treat as a regular expression or not
  3811. * @param {bool} smart perform smart filtering or not
  3812. * @param {bool} caseInsensitive Do case insenstive matching or not
  3813. * @memberof DataTable#oApi
  3814. */
  3815. function _fnFilter( settings, input, force, regex, smart, caseInsensitive )
  3816. {
  3817. var rpSearch = _fnFilterCreateSearch( input, regex, smart, caseInsensitive );
  3818. var prevSearch = settings.oPreviousSearch.sSearch;
  3819. var displayMaster = settings.aiDisplayMaster;
  3820. var display, invalidated, i;
  3821. var filtered = [];
  3822. // Need to take account of custom filtering functions - always filter
  3823. if ( DataTable.ext.search.length !== 0 ) {
  3824. force = true;
  3825. }
  3826. // Check if any of the rows were invalidated
  3827. invalidated = _fnFilterData( settings );
  3828. // If the input is blank - we just want the full data set
  3829. if ( input.length <= 0 ) {
  3830. settings.aiDisplay = displayMaster.slice();
  3831. }
  3832. else {
  3833. // New search - start from the master array
  3834. if ( invalidated ||
  3835. force ||
  3836. prevSearch.length > input.length ||
  3837. input.indexOf(prevSearch) !== 0 ||
  3838. settings.bSorted // On resort, the display master needs to be
  3839. // re-filtered since indexes will have changed
  3840. ) {
  3841. settings.aiDisplay = displayMaster.slice();
  3842. }
  3843. // Search the display array
  3844. display = settings.aiDisplay;
  3845. for ( i=0 ; i<display.length ; i++ ) {
  3846. if ( rpSearch.test( settings.aoData[ display[i] ]._sFilterRow ) ) {
  3847. filtered.push( display[i] );
  3848. }
  3849. }
  3850. settings.aiDisplay = filtered;
  3851. }
  3852. }
  3853. /**
  3854. * Build a regular expression object suitable for searching a table
  3855. * @param {string} sSearch string to search for
  3856. * @param {bool} bRegex treat as a regular expression or not
  3857. * @param {bool} bSmart perform smart filtering or not
  3858. * @param {bool} bCaseInsensitive Do case insensitive matching or not
  3859. * @returns {RegExp} constructed object
  3860. * @memberof DataTable#oApi
  3861. */
  3862. function _fnFilterCreateSearch( search, regex, smart, caseInsensitive )
  3863. {
  3864. search = regex ?
  3865. search :
  3866. _fnEscapeRegex( search );
  3867. if ( smart ) {
  3868. /* For smart filtering we want to allow the search to work regardless of
  3869. * word order. We also want double quoted text to be preserved, so word
  3870. * order is important - a la google. So this is what we want to
  3871. * generate:
  3872. *
  3873. * ^(?=.*?\bone\b)(?=.*?\btwo three\b)(?=.*?\bfour\b).*$
  3874. */
  3875. var a = $.map( search.match( /"[^"]+"|[^ ]+/g ) || [''], function ( word ) {
  3876. if ( word.charAt(0) === '"' ) {
  3877. var m = word.match( /^"(.*)"$/ );
  3878. word = m ? m[1] : word;
  3879. }
  3880. return word.replace('"', '');
  3881. } );
  3882. search = '^(?=.*?'+a.join( ')(?=.*?' )+').*$';
  3883. }
  3884. return new RegExp( search, caseInsensitive ? 'i' : '' );
  3885. }
  3886. /**
  3887. * Escape a string such that it can be used in a regular expression
  3888. * @param {string} sVal string to escape
  3889. * @returns {string} escaped string
  3890. * @memberof DataTable#oApi
  3891. */
  3892. var _fnEscapeRegex = DataTable.util.escapeRegex;
  3893. var __filter_div = $('<div>')[0];
  3894. var __filter_div_textContent = __filter_div.textContent !== undefined;
  3895. // Update the filtering data for each row if needed (by invalidation or first run)
  3896. function _fnFilterData ( settings )
  3897. {
  3898. var columns = settings.aoColumns;
  3899. var column;
  3900. var i, j, ien, jen, filterData, cellData, row;
  3901. var fomatters = DataTable.ext.type.search;
  3902. var wasInvalidated = false;
  3903. for ( i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  3904. row = settings.aoData[i];
  3905. if ( ! row._aFilterData ) {
  3906. filterData = [];
  3907. for ( j=0, jen=columns.length ; j<jen ; j++ ) {
  3908. column = columns[j];
  3909. if ( column.bSearchable ) {
  3910. cellData = _fnGetCellData( settings, i, j, 'filter' );
  3911. if ( fomatters[ column.sType ] ) {
  3912. cellData = fomatters[ column.sType ]( cellData );
  3913. }
  3914. // Search in DataTables 1.10 is string based. In 1.11 this
  3915. // should be altered to also allow strict type checking.
  3916. if ( cellData === null ) {
  3917. cellData = '';
  3918. }
  3919. if ( typeof cellData !== 'string' && cellData.toString ) {
  3920. cellData = cellData.toString();
  3921. }
  3922. }
  3923. else {
  3924. cellData = '';
  3925. }
  3926. // If it looks like there is an HTML entity in the string,
  3927. // attempt to decode it so sorting works as expected. Note that
  3928. // we could use a single line of jQuery to do this, but the DOM
  3929. // method used here is much faster http://jsperf.com/html-decode
  3930. if ( cellData.indexOf && cellData.indexOf('&') !== -1 ) {
  3931. __filter_div.innerHTML = cellData;
  3932. cellData = __filter_div_textContent ?
  3933. __filter_div.textContent :
  3934. __filter_div.innerText;
  3935. }
  3936. if ( cellData.replace ) {
  3937. cellData = cellData.replace(/[\r\n]/g, '');
  3938. }
  3939. filterData.push( cellData );
  3940. }
  3941. row._aFilterData = filterData;
  3942. row._sFilterRow = filterData.join(' ');
  3943. wasInvalidated = true;
  3944. }
  3945. }
  3946. return wasInvalidated;
  3947. }
  3948. /**
  3949. * Convert from the internal Hungarian notation to camelCase for external
  3950. * interaction
  3951. * @param {object} obj Object to convert
  3952. * @returns {object} Inverted object
  3953. * @memberof DataTable#oApi
  3954. */
  3955. function _fnSearchToCamel ( obj )
  3956. {
  3957. return {
  3958. search: obj.sSearch,
  3959. smart: obj.bSmart,
  3960. regex: obj.bRegex,
  3961. caseInsensitive: obj.bCaseInsensitive
  3962. };
  3963. }
  3964. /**
  3965. * Convert from camelCase notation to the internal Hungarian. We could use the
  3966. * Hungarian convert function here, but this is cleaner
  3967. * @param {object} obj Object to convert
  3968. * @returns {object} Inverted object
  3969. * @memberof DataTable#oApi
  3970. */
  3971. function _fnSearchToHung ( obj )
  3972. {
  3973. return {
  3974. sSearch: obj.search,
  3975. bSmart: obj.smart,
  3976. bRegex: obj.regex,
  3977. bCaseInsensitive: obj.caseInsensitive
  3978. };
  3979. }
  3980. /**
  3981. * Generate the node required for the info display
  3982. * @param {object} oSettings dataTables settings object
  3983. * @returns {node} Information element
  3984. * @memberof DataTable#oApi
  3985. */
  3986. function _fnFeatureHtmlInfo ( settings )
  3987. {
  3988. var
  3989. tid = settings.sTableId,
  3990. nodes = settings.aanFeatures.i,
  3991. n = $('<div/>', {
  3992. 'class': settings.oClasses.sInfo,
  3993. 'id': ! nodes ? tid+'_info' : null
  3994. } );
  3995. if ( ! nodes ) {
  3996. // Update display on each draw
  3997. settings.aoDrawCallback.push( {
  3998. "fn": _fnUpdateInfo,
  3999. "sName": "information"
  4000. } );
  4001. n
  4002. .attr( 'role', 'status' )
  4003. .attr( 'aria-live', 'polite' );
  4004. // Table is described by our info div
  4005. $(settings.nTable).attr( 'aria-describedby', tid+'_info' );
  4006. }
  4007. return n[0];
  4008. }
  4009. /**
  4010. * Update the information elements in the display
  4011. * @param {object} settings dataTables settings object
  4012. * @memberof DataTable#oApi
  4013. */
  4014. function _fnUpdateInfo ( settings )
  4015. {
  4016. /* Show information about the table */
  4017. var nodes = settings.aanFeatures.i;
  4018. if ( nodes.length === 0 ) {
  4019. return;
  4020. }
  4021. var
  4022. lang = settings.oLanguage,
  4023. start = settings._iDisplayStart+1,
  4024. end = settings.fnDisplayEnd(),
  4025. max = settings.fnRecordsTotal(),
  4026. total = settings.fnRecordsDisplay(),
  4027. out = total ?
  4028. lang.sInfo :
  4029. lang.sInfoEmpty;
  4030. if ( total !== max ) {
  4031. /* Record set after filtering */
  4032. out += ' ' + lang.sInfoFiltered;
  4033. }
  4034. // Convert the macros
  4035. out += lang.sInfoPostFix;
  4036. out = _fnInfoMacros( settings, out );
  4037. var callback = lang.fnInfoCallback;
  4038. if ( callback !== null ) {
  4039. out = callback.call( settings.oInstance,
  4040. settings, start, end, max, total, out
  4041. );
  4042. }
  4043. $(nodes).html( out );
  4044. }
  4045. function _fnInfoMacros ( settings, str )
  4046. {
  4047. // When infinite scrolling, we are always starting at 1. _iDisplayStart is used only
  4048. // internally
  4049. var
  4050. formatter = settings.fnFormatNumber,
  4051. start = settings._iDisplayStart+1,
  4052. len = settings._iDisplayLength,
  4053. vis = settings.fnRecordsDisplay(),
  4054. all = len === -1;
  4055. return str.
  4056. replace(/_START_/g, formatter.call( settings, start ) ).
  4057. replace(/_END_/g, formatter.call( settings, settings.fnDisplayEnd() ) ).
  4058. replace(/_MAX_/g, formatter.call( settings, settings.fnRecordsTotal() ) ).
  4059. replace(/_TOTAL_/g, formatter.call( settings, vis ) ).
  4060. replace(/_PAGE_/g, formatter.call( settings, all ? 1 : Math.ceil( start / len ) ) ).
  4061. replace(/_PAGES_/g, formatter.call( settings, all ? 1 : Math.ceil( vis / len ) ) );
  4062. }
  4063. /**
  4064. * Draw the table for the first time, adding all required features
  4065. * @param {object} settings dataTables settings object
  4066. * @memberof DataTable#oApi
  4067. */
  4068. function _fnInitialise ( settings )
  4069. {
  4070. var i, iLen, iAjaxStart=settings.iInitDisplayStart;
  4071. var columns = settings.aoColumns, column;
  4072. var features = settings.oFeatures;
  4073. var deferLoading = settings.bDeferLoading; // value modified by the draw
  4074. /* Ensure that the table data is fully initialised */
  4075. if ( ! settings.bInitialised ) {
  4076. setTimeout( function(){ _fnInitialise( settings ); }, 200 );
  4077. return;
  4078. }
  4079. /* Show the display HTML options */
  4080. _fnAddOptionsHtml( settings );
  4081. /* Build and draw the header / footer for the table */
  4082. _fnBuildHead( settings );
  4083. _fnDrawHead( settings, settings.aoHeader );
  4084. _fnDrawHead( settings, settings.aoFooter );
  4085. /* Okay to show that something is going on now */
  4086. _fnProcessingDisplay( settings, true );
  4087. /* Calculate sizes for columns */
  4088. if ( features.bAutoWidth ) {
  4089. _fnCalculateColumnWidths( settings );
  4090. }
  4091. for ( i=0, iLen=columns.length ; i<iLen ; i++ ) {
  4092. column = columns[i];
  4093. if ( column.sWidth ) {
  4094. column.nTh.style.width = _fnStringToCss( column.sWidth );
  4095. }
  4096. }
  4097. _fnCallbackFire( settings, null, 'preInit', [settings] );
  4098. // If there is default sorting required - let's do it. The sort function
  4099. // will do the drawing for us. Otherwise we draw the table regardless of the
  4100. // Ajax source - this allows the table to look initialised for Ajax sourcing
  4101. // data (show 'loading' message possibly)
  4102. _fnReDraw( settings );
  4103. // Server-side processing init complete is done by _fnAjaxUpdateDraw
  4104. var dataSrc = _fnDataSource( settings );
  4105. if ( dataSrc != 'ssp' || deferLoading ) {
  4106. // if there is an ajax source load the data
  4107. if ( dataSrc == 'ajax' ) {
  4108. _fnBuildAjax( settings, [], function(json) {
  4109. var aData = _fnAjaxDataSrc( settings, json );
  4110. // Got the data - add it to the table
  4111. for ( i=0 ; i<aData.length ; i++ ) {
  4112. _fnAddData( settings, aData[i] );
  4113. }
  4114. // Reset the init display for cookie saving. We've already done
  4115. // a filter, and therefore cleared it before. So we need to make
  4116. // it appear 'fresh'
  4117. settings.iInitDisplayStart = iAjaxStart;
  4118. _fnReDraw( settings );
  4119. _fnProcessingDisplay( settings, false );
  4120. _fnInitComplete( settings, json );
  4121. }, settings );
  4122. }
  4123. else {
  4124. _fnProcessingDisplay( settings, false );
  4125. _fnInitComplete( settings );
  4126. }
  4127. }
  4128. }
  4129. /**
  4130. * Draw the table for the first time, adding all required features
  4131. * @param {object} oSettings dataTables settings object
  4132. * @param {object} [json] JSON from the server that completed the table, if using Ajax source
  4133. * with client-side processing (optional)
  4134. * @memberof DataTable#oApi
  4135. */
  4136. function _fnInitComplete ( settings, json )
  4137. {
  4138. settings._bInitComplete = true;
  4139. // When data was added after the initialisation (data or Ajax) we need to
  4140. // calculate the column sizing
  4141. if ( json || settings.oInit.aaData ) {
  4142. _fnAdjustColumnSizing( settings );
  4143. }
  4144. _fnCallbackFire( settings, null, 'plugin-init', [settings, json] );
  4145. _fnCallbackFire( settings, 'aoInitComplete', 'init', [settings, json] );
  4146. }
  4147. function _fnLengthChange ( settings, val )
  4148. {
  4149. var len = parseInt( val, 10 );
  4150. settings._iDisplayLength = len;
  4151. _fnLengthOverflow( settings );
  4152. // Fire length change event
  4153. _fnCallbackFire( settings, null, 'length', [settings, len] );
  4154. }
  4155. /**
  4156. * Generate the node required for user display length changing
  4157. * @param {object} settings dataTables settings object
  4158. * @returns {node} Display length feature node
  4159. * @memberof DataTable#oApi
  4160. */
  4161. function _fnFeatureHtmlLength ( settings )
  4162. {
  4163. var
  4164. classes = settings.oClasses,
  4165. tableId = settings.sTableId,
  4166. menu = settings.aLengthMenu,
  4167. d2 = $.isArray( menu[0] ),
  4168. lengths = d2 ? menu[0] : menu,
  4169. language = d2 ? menu[1] : menu;
  4170. var select = $('<select/>', {
  4171. 'name': tableId+'_length',
  4172. 'aria-controls': tableId,
  4173. 'class': classes.sLengthSelect
  4174. } );
  4175. for ( var i=0, ien=lengths.length ; i<ien ; i++ ) {
  4176. select[0][ i ] = new Option(
  4177. typeof language[i] === 'number' ?
  4178. settings.fnFormatNumber( language[i] ) :
  4179. language[i],
  4180. lengths[i]
  4181. );
  4182. }
  4183. var div = $('<div><label/></div>').addClass( classes.sLength );
  4184. if ( ! settings.aanFeatures.l ) {
  4185. div[0].id = tableId+'_length';
  4186. }
  4187. div.children().append(
  4188. settings.oLanguage.sLengthMenu.replace( '_MENU_', select[0].outerHTML )
  4189. );
  4190. // Can't use `select` variable as user might provide their own and the
  4191. // reference is broken by the use of outerHTML
  4192. $('select', div)
  4193. .val( settings._iDisplayLength )
  4194. .on( 'change.DT', function(e) {
  4195. _fnLengthChange( settings, $(this).val() );
  4196. _fnDraw( settings );
  4197. } );
  4198. // Update node value whenever anything changes the table's length
  4199. $(settings.nTable).on( 'length.dt.DT', function (e, s, len) {
  4200. if ( settings === s ) {
  4201. $('select', div).val( len );
  4202. }
  4203. } );
  4204. return div[0];
  4205. }
  4206. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  4207. * Note that most of the paging logic is done in
  4208. * DataTable.ext.pager
  4209. */
  4210. /**
  4211. * Generate the node required for default pagination
  4212. * @param {object} oSettings dataTables settings object
  4213. * @returns {node} Pagination feature node
  4214. * @memberof DataTable#oApi
  4215. */
  4216. function _fnFeatureHtmlPaginate ( settings )
  4217. {
  4218. var
  4219. type = settings.sPaginationType,
  4220. plugin = DataTable.ext.pager[ type ],
  4221. modern = typeof plugin === 'function',
  4222. redraw = function( settings ) {
  4223. _fnDraw( settings );
  4224. },
  4225. node = $('<div/>').addClass( settings.oClasses.sPaging + type )[0],
  4226. features = settings.aanFeatures;
  4227. if ( ! modern ) {
  4228. plugin.fnInit( settings, node, redraw );
  4229. }
  4230. /* Add a draw callback for the pagination on first instance, to update the paging display */
  4231. if ( ! features.p )
  4232. {
  4233. node.id = settings.sTableId+'_paginate';
  4234. settings.aoDrawCallback.push( {
  4235. "fn": function( settings ) {
  4236. if ( modern ) {
  4237. var
  4238. start = settings._iDisplayStart,
  4239. len = settings._iDisplayLength,
  4240. visRecords = settings.fnRecordsDisplay(),
  4241. all = len === -1,
  4242. page = all ? 0 : Math.ceil( start / len ),
  4243. pages = all ? 1 : Math.ceil( visRecords / len ),
  4244. buttons = plugin(page, pages),
  4245. i, ien;
  4246. for ( i=0, ien=features.p.length ; i<ien ; i++ ) {
  4247. _fnRenderer( settings, 'pageButton' )(
  4248. settings, features.p[i], i, buttons, page, pages
  4249. );
  4250. }
  4251. }
  4252. else {
  4253. plugin.fnUpdate( settings, redraw );
  4254. }
  4255. },
  4256. "sName": "pagination"
  4257. } );
  4258. }
  4259. return node;
  4260. }
  4261. /**
  4262. * Alter the display settings to change the page
  4263. * @param {object} settings DataTables settings object
  4264. * @param {string|int} action Paging action to take: "first", "previous",
  4265. * "next" or "last" or page number to jump to (integer)
  4266. * @param [bool] redraw Automatically draw the update or not
  4267. * @returns {bool} true page has changed, false - no change
  4268. * @memberof DataTable#oApi
  4269. */
  4270. function _fnPageChange ( settings, action, redraw )
  4271. {
  4272. var
  4273. start = settings._iDisplayStart,
  4274. len = settings._iDisplayLength,
  4275. records = settings.fnRecordsDisplay();
  4276. if ( records === 0 || len === -1 )
  4277. {
  4278. start = 0;
  4279. }
  4280. else if ( typeof action === "number" )
  4281. {
  4282. start = action * len;
  4283. if ( start > records )
  4284. {
  4285. start = 0;
  4286. }
  4287. }
  4288. else if ( action == "first" )
  4289. {
  4290. start = 0;
  4291. }
  4292. else if ( action == "previous" )
  4293. {
  4294. start = len >= 0 ?
  4295. start - len :
  4296. 0;
  4297. if ( start < 0 )
  4298. {
  4299. start = 0;
  4300. }
  4301. }
  4302. else if ( action == "next" )
  4303. {
  4304. if ( start + len < records )
  4305. {
  4306. start += len;
  4307. }
  4308. }
  4309. else if ( action == "last" )
  4310. {
  4311. start = Math.floor( (records-1) / len) * len;
  4312. }
  4313. else
  4314. {
  4315. _fnLog( settings, 0, "Unknown paging action: "+action, 5 );
  4316. }
  4317. var changed = settings._iDisplayStart !== start;
  4318. settings._iDisplayStart = start;
  4319. if ( changed ) {
  4320. _fnCallbackFire( settings, null, 'page', [settings] );
  4321. if ( redraw ) {
  4322. _fnDraw( settings );
  4323. }
  4324. }
  4325. return changed;
  4326. }
  4327. /**
  4328. * Generate the node required for the processing node
  4329. * @param {object} settings dataTables settings object
  4330. * @returns {node} Processing element
  4331. * @memberof DataTable#oApi
  4332. */
  4333. function _fnFeatureHtmlProcessing ( settings )
  4334. {
  4335. return $('<div/>', {
  4336. 'id': ! settings.aanFeatures.r ? settings.sTableId+'_processing' : null,
  4337. 'class': settings.oClasses.sProcessing
  4338. } )
  4339. .html( settings.oLanguage.sProcessing )
  4340. .insertBefore( settings.nTable )[0];
  4341. }
  4342. /**
  4343. * Display or hide the processing indicator
  4344. * @param {object} settings dataTables settings object
  4345. * @param {bool} show Show the processing indicator (true) or not (false)
  4346. * @memberof DataTable#oApi
  4347. */
  4348. function _fnProcessingDisplay ( settings, show )
  4349. {
  4350. if ( settings.oFeatures.bProcessing ) {
  4351. $(settings.aanFeatures.r).css( 'display', show ? 'block' : 'none' );
  4352. }
  4353. _fnCallbackFire( settings, null, 'processing', [settings, show] );
  4354. }
  4355. /**
  4356. * Add any control elements for the table - specifically scrolling
  4357. * @param {object} settings dataTables settings object
  4358. * @returns {node} Node to add to the DOM
  4359. * @memberof DataTable#oApi
  4360. */
  4361. function _fnFeatureHtmlTable ( settings )
  4362. {
  4363. var table = $(settings.nTable);
  4364. // Add the ARIA grid role to the table
  4365. table.attr( 'role', 'grid' );
  4366. // Scrolling from here on in
  4367. var scroll = settings.oScroll;
  4368. if ( scroll.sX === '' && scroll.sY === '' ) {
  4369. return settings.nTable;
  4370. }
  4371. var scrollX = scroll.sX;
  4372. var scrollY = scroll.sY;
  4373. var classes = settings.oClasses;
  4374. var caption = table.children('caption');
  4375. var captionSide = caption.length ? caption[0]._captionSide : null;
  4376. var headerClone = $( table[0].cloneNode(false) );
  4377. var footerClone = $( table[0].cloneNode(false) );
  4378. var footer = table.children('tfoot');
  4379. var _div = '<div/>';
  4380. var size = function ( s ) {
  4381. return !s ? null : _fnStringToCss( s );
  4382. };
  4383. if ( ! footer.length ) {
  4384. footer = null;
  4385. }
  4386. /*
  4387. * The HTML structure that we want to generate in this function is:
  4388. * div - scroller
  4389. * div - scroll head
  4390. * div - scroll head inner
  4391. * table - scroll head table
  4392. * thead - thead
  4393. * div - scroll body
  4394. * table - table (master table)
  4395. * thead - thead clone for sizing
  4396. * tbody - tbody
  4397. * div - scroll foot
  4398. * div - scroll foot inner
  4399. * table - scroll foot table
  4400. * tfoot - tfoot
  4401. */
  4402. var scroller = $( _div, { 'class': classes.sScrollWrapper } )
  4403. .append(
  4404. $(_div, { 'class': classes.sScrollHead } )
  4405. .css( {
  4406. overflow: 'hidden',
  4407. position: 'relative',
  4408. border: 0,
  4409. width: scrollX ? size(scrollX) : '100%'
  4410. } )
  4411. .append(
  4412. $(_div, { 'class': classes.sScrollHeadInner } )
  4413. .css( {
  4414. 'box-sizing': 'content-box',
  4415. width: scroll.sXInner || '100%'
  4416. } )
  4417. .append(
  4418. headerClone
  4419. .removeAttr('id')
  4420. .css( 'margin-left', 0 )
  4421. .append( captionSide === 'top' ? caption : null )
  4422. .append(
  4423. table.children('thead')
  4424. )
  4425. )
  4426. )
  4427. )
  4428. .append(
  4429. $(_div, { 'class': classes.sScrollBody } )
  4430. .css( {
  4431. position: 'relative',
  4432. overflow: 'auto',
  4433. width: size( scrollX )
  4434. } )
  4435. .append( table )
  4436. );
  4437. if ( footer ) {
  4438. scroller.append(
  4439. $(_div, { 'class': classes.sScrollFoot } )
  4440. .css( {
  4441. overflow: 'hidden',
  4442. border: 0,
  4443. width: scrollX ? size(scrollX) : '100%'
  4444. } )
  4445. .append(
  4446. $(_div, { 'class': classes.sScrollFootInner } )
  4447. .append(
  4448. footerClone
  4449. .removeAttr('id')
  4450. .css( 'margin-left', 0 )
  4451. .append( captionSide === 'bottom' ? caption : null )
  4452. .append(
  4453. table.children('tfoot')
  4454. )
  4455. )
  4456. )
  4457. );
  4458. }
  4459. var children = scroller.children();
  4460. var scrollHead = children[0];
  4461. var scrollBody = children[1];
  4462. var scrollFoot = footer ? children[2] : null;
  4463. // When the body is scrolled, then we also want to scroll the headers
  4464. if ( scrollX ) {
  4465. $(scrollBody).on( 'scroll.DT', function (e) {
  4466. var scrollLeft = this.scrollLeft;
  4467. scrollHead.scrollLeft = scrollLeft;
  4468. if ( footer ) {
  4469. scrollFoot.scrollLeft = scrollLeft;
  4470. }
  4471. } );
  4472. }
  4473. $(scrollBody).css(
  4474. scrollY && scroll.bCollapse ? 'max-height' : 'height',
  4475. scrollY
  4476. );
  4477. settings.nScrollHead = scrollHead;
  4478. settings.nScrollBody = scrollBody;
  4479. settings.nScrollFoot = scrollFoot;
  4480. // On redraw - align columns
  4481. settings.aoDrawCallback.push( {
  4482. "fn": _fnScrollDraw,
  4483. "sName": "scrolling"
  4484. } );
  4485. return scroller[0];
  4486. }
  4487. /**
  4488. * Update the header, footer and body tables for resizing - i.e. column
  4489. * alignment.
  4490. *
  4491. * Welcome to the most horrible function DataTables. The process that this
  4492. * function follows is basically:
  4493. * 1. Re-create the table inside the scrolling div
  4494. * 2. Take live measurements from the DOM
  4495. * 3. Apply the measurements to align the columns
  4496. * 4. Clean up
  4497. *
  4498. * @param {object} settings dataTables settings object
  4499. * @memberof DataTable#oApi
  4500. */
  4501. function _fnScrollDraw ( settings )
  4502. {
  4503. // Given that this is such a monster function, a lot of variables are use
  4504. // to try and keep the minimised size as small as possible
  4505. var
  4506. scroll = settings.oScroll,
  4507. scrollX = scroll.sX,
  4508. scrollXInner = scroll.sXInner,
  4509. scrollY = scroll.sY,
  4510. barWidth = scroll.iBarWidth,
  4511. divHeader = $(settings.nScrollHead),
  4512. divHeaderStyle = divHeader[0].style,
  4513. divHeaderInner = divHeader.children('div'),
  4514. divHeaderInnerStyle = divHeaderInner[0].style,
  4515. divHeaderTable = divHeaderInner.children('table'),
  4516. divBodyEl = settings.nScrollBody,
  4517. divBody = $(divBodyEl),
  4518. divBodyStyle = divBodyEl.style,
  4519. divFooter = $(settings.nScrollFoot),
  4520. divFooterInner = divFooter.children('div'),
  4521. divFooterTable = divFooterInner.children('table'),
  4522. header = $(settings.nTHead),
  4523. table = $(settings.nTable),
  4524. tableEl = table[0],
  4525. tableStyle = tableEl.style,
  4526. footer = settings.nTFoot ? $(settings.nTFoot) : null,
  4527. browser = settings.oBrowser,
  4528. ie67 = browser.bScrollOversize,
  4529. dtHeaderCells = _pluck( settings.aoColumns, 'nTh' ),
  4530. headerTrgEls, footerTrgEls,
  4531. headerSrcEls, footerSrcEls,
  4532. headerCopy, footerCopy,
  4533. headerWidths=[], footerWidths=[],
  4534. headerContent=[], footerContent=[],
  4535. idx, correction, sanityWidth,
  4536. zeroOut = function(nSizer) {
  4537. var style = nSizer.style;
  4538. style.paddingTop = "0";
  4539. style.paddingBottom = "0";
  4540. style.borderTopWidth = "0";
  4541. style.borderBottomWidth = "0";
  4542. style.height = 0;
  4543. };
  4544. // If the scrollbar visibility has changed from the last draw, we need to
  4545. // adjust the column sizes as the table width will have changed to account
  4546. // for the scrollbar
  4547. var scrollBarVis = divBodyEl.scrollHeight > divBodyEl.clientHeight;
  4548. if ( settings.scrollBarVis !== scrollBarVis && settings.scrollBarVis !== undefined ) {
  4549. settings.scrollBarVis = scrollBarVis;
  4550. _fnAdjustColumnSizing( settings );
  4551. return; // adjust column sizing will call this function again
  4552. }
  4553. else {
  4554. settings.scrollBarVis = scrollBarVis;
  4555. }
  4556. /*
  4557. * 1. Re-create the table inside the scrolling div
  4558. */
  4559. // Remove the old minimised thead and tfoot elements in the inner table
  4560. table.children('thead, tfoot').remove();
  4561. if ( footer ) {
  4562. footerCopy = footer.clone().prependTo( table );
  4563. footerTrgEls = footer.find('tr'); // the original tfoot is in its own table and must be sized
  4564. footerSrcEls = footerCopy.find('tr');
  4565. }
  4566. // Clone the current header and footer elements and then place it into the inner table
  4567. headerCopy = header.clone().prependTo( table );
  4568. headerTrgEls = header.find('tr'); // original header is in its own table
  4569. headerSrcEls = headerCopy.find('tr');
  4570. headerCopy.find('th, td').removeAttr('tabindex');
  4571. /*
  4572. * 2. Take live measurements from the DOM - do not alter the DOM itself!
  4573. */
  4574. // Remove old sizing and apply the calculated column widths
  4575. // Get the unique column headers in the newly created (cloned) header. We want to apply the
  4576. // calculated sizes to this header
  4577. if ( ! scrollX )
  4578. {
  4579. divBodyStyle.width = '100%';
  4580. divHeader[0].style.width = '100%';
  4581. }
  4582. $.each( _fnGetUniqueThs( settings, headerCopy ), function ( i, el ) {
  4583. idx = _fnVisibleToColumnIndex( settings, i );
  4584. el.style.width = settings.aoColumns[idx].sWidth;
  4585. } );
  4586. if ( footer ) {
  4587. _fnApplyToChildren( function(n) {
  4588. n.style.width = "";
  4589. }, footerSrcEls );
  4590. }
  4591. // Size the table as a whole
  4592. sanityWidth = table.outerWidth();
  4593. if ( scrollX === "" ) {
  4594. // No x scrolling
  4595. tableStyle.width = "100%";
  4596. // IE7 will make the width of the table when 100% include the scrollbar
  4597. // - which is shouldn't. When there is a scrollbar we need to take this
  4598. // into account.
  4599. if ( ie67 && (table.find('tbody').height() > divBodyEl.offsetHeight ||
  4600. divBody.css('overflow-y') == "scroll")
  4601. ) {
  4602. tableStyle.width = _fnStringToCss( table.outerWidth() - barWidth);
  4603. }
  4604. // Recalculate the sanity width
  4605. sanityWidth = table.outerWidth();
  4606. }
  4607. else if ( scrollXInner !== "" ) {
  4608. // legacy x scroll inner has been given - use it
  4609. tableStyle.width = _fnStringToCss(scrollXInner);
  4610. // Recalculate the sanity width
  4611. sanityWidth = table.outerWidth();
  4612. }
  4613. // Hidden header should have zero height, so remove padding and borders. Then
  4614. // set the width based on the real headers
  4615. // Apply all styles in one pass
  4616. _fnApplyToChildren( zeroOut, headerSrcEls );
  4617. // Read all widths in next pass
  4618. _fnApplyToChildren( function(nSizer) {
  4619. headerContent.push( nSizer.innerHTML );
  4620. headerWidths.push( _fnStringToCss( $(nSizer).css('width') ) );
  4621. }, headerSrcEls );
  4622. // Apply all widths in final pass
  4623. _fnApplyToChildren( function(nToSize, i) {
  4624. // Only apply widths to the DataTables detected header cells - this
  4625. // prevents complex headers from having contradictory sizes applied
  4626. if ( $.inArray( nToSize, dtHeaderCells ) !== -1 ) {
  4627. nToSize.style.width = headerWidths[i];
  4628. }
  4629. }, headerTrgEls );
  4630. $(headerSrcEls).height(0);
  4631. /* Same again with the footer if we have one */
  4632. if ( footer )
  4633. {
  4634. _fnApplyToChildren( zeroOut, footerSrcEls );
  4635. _fnApplyToChildren( function(nSizer) {
  4636. footerContent.push( nSizer.innerHTML );
  4637. footerWidths.push( _fnStringToCss( $(nSizer).css('width') ) );
  4638. }, footerSrcEls );
  4639. _fnApplyToChildren( function(nToSize, i) {
  4640. nToSize.style.width = footerWidths[i];
  4641. }, footerTrgEls );
  4642. $(footerSrcEls).height(0);
  4643. }
  4644. /*
  4645. * 3. Apply the measurements
  4646. */
  4647. // "Hide" the header and footer that we used for the sizing. We need to keep
  4648. // the content of the cell so that the width applied to the header and body
  4649. // both match, but we want to hide it completely. We want to also fix their
  4650. // width to what they currently are
  4651. _fnApplyToChildren( function(nSizer, i) {
  4652. nSizer.innerHTML = '<div class="dataTables_sizing">'+headerContent[i]+'</div>';
  4653. nSizer.childNodes[0].style.height = "0";
  4654. nSizer.childNodes[0].style.overflow = "hidden";
  4655. nSizer.style.width = headerWidths[i];
  4656. }, headerSrcEls );
  4657. if ( footer )
  4658. {
  4659. _fnApplyToChildren( function(nSizer, i) {
  4660. nSizer.innerHTML = '<div class="dataTables_sizing">'+footerContent[i]+'</div>';
  4661. nSizer.childNodes[0].style.height = "0";
  4662. nSizer.childNodes[0].style.overflow = "hidden";
  4663. nSizer.style.width = footerWidths[i];
  4664. }, footerSrcEls );
  4665. }
  4666. // Sanity check that the table is of a sensible width. If not then we are going to get
  4667. // misalignment - try to prevent this by not allowing the table to shrink below its min width
  4668. if ( table.outerWidth() < sanityWidth )
  4669. {
  4670. // The min width depends upon if we have a vertical scrollbar visible or not */
  4671. correction = ((divBodyEl.scrollHeight > divBodyEl.offsetHeight ||
  4672. divBody.css('overflow-y') == "scroll")) ?
  4673. sanityWidth+barWidth :
  4674. sanityWidth;
  4675. // IE6/7 are a law unto themselves...
  4676. if ( ie67 && (divBodyEl.scrollHeight >
  4677. divBodyEl.offsetHeight || divBody.css('overflow-y') == "scroll")
  4678. ) {
  4679. tableStyle.width = _fnStringToCss( correction-barWidth );
  4680. }
  4681. // And give the user a warning that we've stopped the table getting too small
  4682. if ( scrollX === "" || scrollXInner !== "" ) {
  4683. _fnLog( settings, 1, 'Possible column misalignment', 6 );
  4684. }
  4685. }
  4686. else
  4687. {
  4688. correction = '100%';
  4689. }
  4690. // Apply to the container elements
  4691. divBodyStyle.width = _fnStringToCss( correction );
  4692. divHeaderStyle.width = _fnStringToCss( correction );
  4693. if ( footer ) {
  4694. settings.nScrollFoot.style.width = _fnStringToCss( correction );
  4695. }
  4696. /*
  4697. * 4. Clean up
  4698. */
  4699. if ( ! scrollY ) {
  4700. /* IE7< puts a vertical scrollbar in place (when it shouldn't be) due to subtracting
  4701. * the scrollbar height from the visible display, rather than adding it on. We need to
  4702. * set the height in order to sort this. Don't want to do it in any other browsers.
  4703. */
  4704. if ( ie67 ) {
  4705. divBodyStyle.height = _fnStringToCss( tableEl.offsetHeight+barWidth );
  4706. }
  4707. }
  4708. /* Finally set the width's of the header and footer tables */
  4709. var iOuterWidth = table.outerWidth();
  4710. divHeaderTable[0].style.width = _fnStringToCss( iOuterWidth );
  4711. divHeaderInnerStyle.width = _fnStringToCss( iOuterWidth );
  4712. // Figure out if there are scrollbar present - if so then we need a the header and footer to
  4713. // provide a bit more space to allow "overflow" scrolling (i.e. past the scrollbar)
  4714. var bScrolling = table.height() > divBodyEl.clientHeight || divBody.css('overflow-y') == "scroll";
  4715. var padding = 'padding' + (browser.bScrollbarLeft ? 'Left' : 'Right' );
  4716. divHeaderInnerStyle[ padding ] = bScrolling ? barWidth+"px" : "0px";
  4717. if ( footer ) {
  4718. divFooterTable[0].style.width = _fnStringToCss( iOuterWidth );
  4719. divFooterInner[0].style.width = _fnStringToCss( iOuterWidth );
  4720. divFooterInner[0].style[padding] = bScrolling ? barWidth+"px" : "0px";
  4721. }
  4722. // Correct DOM ordering for colgroup - comes before the thead
  4723. table.children('colgroup').insertBefore( table.children('thead') );
  4724. /* Adjust the position of the header in case we loose the y-scrollbar */
  4725. divBody.scroll();
  4726. // If sorting or filtering has occurred, jump the scrolling back to the top
  4727. // only if we aren't holding the position
  4728. if ( (settings.bSorted || settings.bFiltered) && ! settings._drawHold ) {
  4729. divBodyEl.scrollTop = 0;
  4730. }
  4731. }
  4732. /**
  4733. * Apply a given function to the display child nodes of an element array (typically
  4734. * TD children of TR rows
  4735. * @param {function} fn Method to apply to the objects
  4736. * @param array {nodes} an1 List of elements to look through for display children
  4737. * @param array {nodes} an2 Another list (identical structure to the first) - optional
  4738. * @memberof DataTable#oApi
  4739. */
  4740. function _fnApplyToChildren( fn, an1, an2 )
  4741. {
  4742. var index=0, i=0, iLen=an1.length;
  4743. var nNode1, nNode2;
  4744. while ( i < iLen ) {
  4745. nNode1 = an1[i].firstChild;
  4746. nNode2 = an2 ? an2[i].firstChild : null;
  4747. while ( nNode1 ) {
  4748. if ( nNode1.nodeType === 1 ) {
  4749. if ( an2 ) {
  4750. fn( nNode1, nNode2, index );
  4751. }
  4752. else {
  4753. fn( nNode1, index );
  4754. }
  4755. index++;
  4756. }
  4757. nNode1 = nNode1.nextSibling;
  4758. nNode2 = an2 ? nNode2.nextSibling : null;
  4759. }
  4760. i++;
  4761. }
  4762. }
  4763. var __re_html_remove = /<.*?>/g;
  4764. /**
  4765. * Calculate the width of columns for the table
  4766. * @param {object} oSettings dataTables settings object
  4767. * @memberof DataTable#oApi
  4768. */
  4769. function _fnCalculateColumnWidths ( oSettings )
  4770. {
  4771. var
  4772. table = oSettings.nTable,
  4773. columns = oSettings.aoColumns,
  4774. scroll = oSettings.oScroll,
  4775. scrollY = scroll.sY,
  4776. scrollX = scroll.sX,
  4777. scrollXInner = scroll.sXInner,
  4778. columnCount = columns.length,
  4779. visibleColumns = _fnGetColumns( oSettings, 'bVisible' ),
  4780. headerCells = $('th', oSettings.nTHead),
  4781. tableWidthAttr = table.getAttribute('width'), // from DOM element
  4782. tableContainer = table.parentNode,
  4783. userInputs = false,
  4784. i, column, columnIdx, width, outerWidth,
  4785. browser = oSettings.oBrowser,
  4786. ie67 = browser.bScrollOversize;
  4787. var styleWidth = table.style.width;
  4788. if ( styleWidth && styleWidth.indexOf('%') !== -1 ) {
  4789. tableWidthAttr = styleWidth;
  4790. }
  4791. /* Convert any user input sizes into pixel sizes */
  4792. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  4793. column = columns[ visibleColumns[i] ];
  4794. if ( column.sWidth !== null ) {
  4795. column.sWidth = _fnConvertToWidth( column.sWidthOrig, tableContainer );
  4796. userInputs = true;
  4797. }
  4798. }
  4799. /* If the number of columns in the DOM equals the number that we have to
  4800. * process in DataTables, then we can use the offsets that are created by
  4801. * the web- browser. No custom sizes can be set in order for this to happen,
  4802. * nor scrolling used
  4803. */
  4804. if ( ie67 || ! userInputs && ! scrollX && ! scrollY &&
  4805. columnCount == _fnVisbleColumns( oSettings ) &&
  4806. columnCount == headerCells.length
  4807. ) {
  4808. for ( i=0 ; i<columnCount ; i++ ) {
  4809. var colIdx = _fnVisibleToColumnIndex( oSettings, i );
  4810. if ( colIdx !== null ) {
  4811. columns[ colIdx ].sWidth = _fnStringToCss( headerCells.eq(i).width() );
  4812. }
  4813. }
  4814. }
  4815. else
  4816. {
  4817. // Otherwise construct a single row, worst case, table with the widest
  4818. // node in the data, assign any user defined widths, then insert it into
  4819. // the DOM and allow the browser to do all the hard work of calculating
  4820. // table widths
  4821. var tmpTable = $(table).clone() // don't use cloneNode - IE8 will remove events on the main table
  4822. .css( 'visibility', 'hidden' )
  4823. .removeAttr( 'id' );
  4824. // Clean up the table body
  4825. tmpTable.find('tbody tr').remove();
  4826. var tr = $('<tr/>').appendTo( tmpTable.find('tbody') );
  4827. // Clone the table header and footer - we can't use the header / footer
  4828. // from the cloned table, since if scrolling is active, the table's
  4829. // real header and footer are contained in different table tags
  4830. tmpTable.find('thead, tfoot').remove();
  4831. tmpTable
  4832. .append( $(oSettings.nTHead).clone() )
  4833. .append( $(oSettings.nTFoot).clone() );
  4834. // Remove any assigned widths from the footer (from scrolling)
  4835. tmpTable.find('tfoot th, tfoot td').css('width', '');
  4836. // Apply custom sizing to the cloned header
  4837. headerCells = _fnGetUniqueThs( oSettings, tmpTable.find('thead')[0] );
  4838. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  4839. column = columns[ visibleColumns[i] ];
  4840. headerCells[i].style.width = column.sWidthOrig !== null && column.sWidthOrig !== '' ?
  4841. _fnStringToCss( column.sWidthOrig ) :
  4842. '';
  4843. // For scrollX we need to force the column width otherwise the
  4844. // browser will collapse it. If this width is smaller than the
  4845. // width the column requires, then it will have no effect
  4846. if ( column.sWidthOrig && scrollX ) {
  4847. $( headerCells[i] ).append( $('<div/>').css( {
  4848. width: column.sWidthOrig,
  4849. margin: 0,
  4850. padding: 0,
  4851. border: 0,
  4852. height: 1
  4853. } ) );
  4854. }
  4855. }
  4856. // Find the widest cell for each column and put it into the table
  4857. if ( oSettings.aoData.length ) {
  4858. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  4859. columnIdx = visibleColumns[i];
  4860. column = columns[ columnIdx ];
  4861. $( _fnGetWidestNode( oSettings, columnIdx ) )
  4862. .clone( false )
  4863. .append( column.sContentPadding )
  4864. .appendTo( tr );
  4865. }
  4866. }
  4867. // Tidy the temporary table - remove name attributes so there aren't
  4868. // duplicated in the dom (radio elements for example)
  4869. $('[name]', tmpTable).removeAttr('name');
  4870. // Table has been built, attach to the document so we can work with it.
  4871. // A holding element is used, positioned at the top of the container
  4872. // with minimal height, so it has no effect on if the container scrolls
  4873. // or not. Otherwise it might trigger scrolling when it actually isn't
  4874. // needed
  4875. var holder = $('<div/>').css( scrollX || scrollY ?
  4876. {
  4877. position: 'absolute',
  4878. top: 0,
  4879. left: 0,
  4880. height: 1,
  4881. right: 0,
  4882. overflow: 'hidden'
  4883. } :
  4884. {}
  4885. )
  4886. .append( tmpTable )
  4887. .appendTo( tableContainer );
  4888. // When scrolling (X or Y) we want to set the width of the table as
  4889. // appropriate. However, when not scrolling leave the table width as it
  4890. // is. This results in slightly different, but I think correct behaviour
  4891. if ( scrollX && scrollXInner ) {
  4892. tmpTable.width( scrollXInner );
  4893. }
  4894. else if ( scrollX ) {
  4895. tmpTable.css( 'width', 'auto' );
  4896. tmpTable.removeAttr('width');
  4897. // If there is no width attribute or style, then allow the table to
  4898. // collapse
  4899. if ( tmpTable.width() < tableContainer.clientWidth && tableWidthAttr ) {
  4900. tmpTable.width( tableContainer.clientWidth );
  4901. }
  4902. }
  4903. else if ( scrollY ) {
  4904. tmpTable.width( tableContainer.clientWidth );
  4905. }
  4906. else if ( tableWidthAttr ) {
  4907. tmpTable.width( tableWidthAttr );
  4908. }
  4909. // Get the width of each column in the constructed table - we need to
  4910. // know the inner width (so it can be assigned to the other table's
  4911. // cells) and the outer width so we can calculate the full width of the
  4912. // table. This is safe since DataTables requires a unique cell for each
  4913. // column, but if ever a header can span multiple columns, this will
  4914. // need to be modified.
  4915. var total = 0;
  4916. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  4917. var cell = $(headerCells[i]);
  4918. var border = cell.outerWidth() - cell.width();
  4919. // Use getBounding... where possible (not IE8-) because it can give
  4920. // sub-pixel accuracy, which we then want to round up!
  4921. var bounding = browser.bBounding ?
  4922. Math.ceil( headerCells[i].getBoundingClientRect().width ) :
  4923. cell.outerWidth();
  4924. // Total is tracked to remove any sub-pixel errors as the outerWidth
  4925. // of the table might not equal the total given here (IE!).
  4926. total += bounding;
  4927. // Width for each column to use
  4928. columns[ visibleColumns[i] ].sWidth = _fnStringToCss( bounding - border );
  4929. }
  4930. table.style.width = _fnStringToCss( total );
  4931. // Finished with the table - ditch it
  4932. holder.remove();
  4933. }
  4934. // If there is a width attr, we want to attach an event listener which
  4935. // allows the table sizing to automatically adjust when the window is
  4936. // resized. Use the width attr rather than CSS, since we can't know if the
  4937. // CSS is a relative value or absolute - DOM read is always px.
  4938. if ( tableWidthAttr ) {
  4939. table.style.width = _fnStringToCss( tableWidthAttr );
  4940. }
  4941. if ( (tableWidthAttr || scrollX) && ! oSettings._reszEvt ) {
  4942. var bindResize = function () {
  4943. $(window).on('resize.DT-'+oSettings.sInstance, _fnThrottle( function () {
  4944. _fnAdjustColumnSizing( oSettings );
  4945. } ) );
  4946. };
  4947. // IE6/7 will crash if we bind a resize event handler on page load.
  4948. // To be removed in 1.11 which drops IE6/7 support
  4949. if ( ie67 ) {
  4950. setTimeout( bindResize, 1000 );
  4951. }
  4952. else {
  4953. bindResize();
  4954. }
  4955. oSettings._reszEvt = true;
  4956. }
  4957. }
  4958. /**
  4959. * Throttle the calls to a function. Arguments and context are maintained for
  4960. * the throttled function
  4961. * @param {function} fn Function to be called
  4962. * @param {int} [freq=200] call frequency in mS
  4963. * @returns {function} wrapped function
  4964. * @memberof DataTable#oApi
  4965. */
  4966. var _fnThrottle = DataTable.util.throttle;
  4967. /**
  4968. * Convert a CSS unit width to pixels (e.g. 2em)
  4969. * @param {string} width width to be converted
  4970. * @param {node} parent parent to get the with for (required for relative widths) - optional
  4971. * @returns {int} width in pixels
  4972. * @memberof DataTable#oApi
  4973. */
  4974. function _fnConvertToWidth ( width, parent )
  4975. {
  4976. if ( ! width ) {
  4977. return 0;
  4978. }
  4979. var n = $('<div/>')
  4980. .css( 'width', _fnStringToCss( width ) )
  4981. .appendTo( parent || document.body );
  4982. var val = n[0].offsetWidth;
  4983. n.remove();
  4984. return val;
  4985. }
  4986. /**
  4987. * Get the widest node
  4988. * @param {object} settings dataTables settings object
  4989. * @param {int} colIdx column of interest
  4990. * @returns {node} widest table node
  4991. * @memberof DataTable#oApi
  4992. */
  4993. function _fnGetWidestNode( settings, colIdx )
  4994. {
  4995. var idx = _fnGetMaxLenString( settings, colIdx );
  4996. if ( idx < 0 ) {
  4997. return null;
  4998. }
  4999. var data = settings.aoData[ idx ];
  5000. return ! data.nTr ? // Might not have been created when deferred rendering
  5001. $('<td/>').html( _fnGetCellData( settings, idx, colIdx, 'display' ) )[0] :
  5002. data.anCells[ colIdx ];
  5003. }
  5004. /**
  5005. * Get the maximum strlen for each data column
  5006. * @param {object} settings dataTables settings object
  5007. * @param {int} colIdx column of interest
  5008. * @returns {string} max string length for each column
  5009. * @memberof DataTable#oApi
  5010. */
  5011. function _fnGetMaxLenString( settings, colIdx )
  5012. {
  5013. var s, max=-1, maxIdx = -1;
  5014. for ( var i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  5015. s = _fnGetCellData( settings, i, colIdx, 'display' )+'';
  5016. s = s.replace( __re_html_remove, '' );
  5017. s = s.replace( /&nbsp;/g, ' ' );
  5018. if ( s.length > max ) {
  5019. max = s.length;
  5020. maxIdx = i;
  5021. }
  5022. }
  5023. return maxIdx;
  5024. }
  5025. /**
  5026. * Append a CSS unit (only if required) to a string
  5027. * @param {string} value to css-ify
  5028. * @returns {string} value with css unit
  5029. * @memberof DataTable#oApi
  5030. */
  5031. function _fnStringToCss( s )
  5032. {
  5033. if ( s === null ) {
  5034. return '0px';
  5035. }
  5036. if ( typeof s == 'number' ) {
  5037. return s < 0 ?
  5038. '0px' :
  5039. s+'px';
  5040. }
  5041. // Check it has a unit character already
  5042. return s.match(/\d$/) ?
  5043. s+'px' :
  5044. s;
  5045. }
  5046. function _fnSortFlatten ( settings )
  5047. {
  5048. var
  5049. i, iLen, k, kLen,
  5050. aSort = [],
  5051. aiOrig = [],
  5052. aoColumns = settings.aoColumns,
  5053. aDataSort, iCol, sType, srcCol,
  5054. fixed = settings.aaSortingFixed,
  5055. fixedObj = $.isPlainObject( fixed ),
  5056. nestedSort = [],
  5057. add = function ( a ) {
  5058. if ( a.length && ! $.isArray( a[0] ) ) {
  5059. // 1D array
  5060. nestedSort.push( a );
  5061. }
  5062. else {
  5063. // 2D array
  5064. $.merge( nestedSort, a );
  5065. }
  5066. };
  5067. // Build the sort array, with pre-fix and post-fix options if they have been
  5068. // specified
  5069. if ( $.isArray( fixed ) ) {
  5070. add( fixed );
  5071. }
  5072. if ( fixedObj && fixed.pre ) {
  5073. add( fixed.pre );
  5074. }
  5075. add( settings.aaSorting );
  5076. if (fixedObj && fixed.post ) {
  5077. add( fixed.post );
  5078. }
  5079. for ( i=0 ; i<nestedSort.length ; i++ )
  5080. {
  5081. srcCol = nestedSort[i][0];
  5082. aDataSort = aoColumns[ srcCol ].aDataSort;
  5083. for ( k=0, kLen=aDataSort.length ; k<kLen ; k++ )
  5084. {
  5085. iCol = aDataSort[k];
  5086. sType = aoColumns[ iCol ].sType || 'string';
  5087. if ( nestedSort[i]._idx === undefined ) {
  5088. nestedSort[i]._idx = $.inArray( nestedSort[i][1], aoColumns[iCol].asSorting );
  5089. }
  5090. aSort.push( {
  5091. src: srcCol,
  5092. col: iCol,
  5093. dir: nestedSort[i][1],
  5094. index: nestedSort[i]._idx,
  5095. type: sType,
  5096. formatter: DataTable.ext.type.order[ sType+"-pre" ]
  5097. } );
  5098. }
  5099. }
  5100. return aSort;
  5101. }
  5102. /**
  5103. * Change the order of the table
  5104. * @param {object} oSettings dataTables settings object
  5105. * @memberof DataTable#oApi
  5106. * @todo This really needs split up!
  5107. */
  5108. function _fnSort ( oSettings )
  5109. {
  5110. var
  5111. i, ien, iLen, j, jLen, k, kLen,
  5112. sDataType, nTh,
  5113. aiOrig = [],
  5114. oExtSort = DataTable.ext.type.order,
  5115. aoData = oSettings.aoData,
  5116. aoColumns = oSettings.aoColumns,
  5117. aDataSort, data, iCol, sType, oSort,
  5118. formatters = 0,
  5119. sortCol,
  5120. displayMaster = oSettings.aiDisplayMaster,
  5121. aSort;
  5122. // Resolve any column types that are unknown due to addition or invalidation
  5123. // @todo Can this be moved into a 'data-ready' handler which is called when
  5124. // data is going to be used in the table?
  5125. _fnColumnTypes( oSettings );
  5126. aSort = _fnSortFlatten( oSettings );
  5127. for ( i=0, ien=aSort.length ; i<ien ; i++ ) {
  5128. sortCol = aSort[i];
  5129. // Track if we can use the fast sort algorithm
  5130. if ( sortCol.formatter ) {
  5131. formatters++;
  5132. }
  5133. // Load the data needed for the sort, for each cell
  5134. _fnSortData( oSettings, sortCol.col );
  5135. }
  5136. /* No sorting required if server-side or no sorting array */
  5137. if ( _fnDataSource( oSettings ) != 'ssp' && aSort.length !== 0 )
  5138. {
  5139. // Create a value - key array of the current row positions such that we can use their
  5140. // current position during the sort, if values match, in order to perform stable sorting
  5141. for ( i=0, iLen=displayMaster.length ; i<iLen ; i++ ) {
  5142. aiOrig[ displayMaster[i] ] = i;
  5143. }
  5144. /* Do the sort - here we want multi-column sorting based on a given data source (column)
  5145. * and sorting function (from oSort) in a certain direction. It's reasonably complex to
  5146. * follow on it's own, but this is what we want (example two column sorting):
  5147. * fnLocalSorting = function(a,b){
  5148. * var iTest;
  5149. * iTest = oSort['string-asc']('data11', 'data12');
  5150. * if (iTest !== 0)
  5151. * return iTest;
  5152. * iTest = oSort['numeric-desc']('data21', 'data22');
  5153. * if (iTest !== 0)
  5154. * return iTest;
  5155. * return oSort['numeric-asc']( aiOrig[a], aiOrig[b] );
  5156. * }
  5157. * Basically we have a test for each sorting column, if the data in that column is equal,
  5158. * test the next column. If all columns match, then we use a numeric sort on the row
  5159. * positions in the original data array to provide a stable sort.
  5160. *
  5161. * Note - I know it seems excessive to have two sorting methods, but the first is around
  5162. * 15% faster, so the second is only maintained for backwards compatibility with sorting
  5163. * methods which do not have a pre-sort formatting function.
  5164. */
  5165. if ( formatters === aSort.length ) {
  5166. // All sort types have formatting functions
  5167. displayMaster.sort( function ( a, b ) {
  5168. var
  5169. x, y, k, test, sort,
  5170. len=aSort.length,
  5171. dataA = aoData[a]._aSortData,
  5172. dataB = aoData[b]._aSortData;
  5173. for ( k=0 ; k<len ; k++ ) {
  5174. sort = aSort[k];
  5175. x = dataA[ sort.col ];
  5176. y = dataB[ sort.col ];
  5177. test = x<y ? -1 : x>y ? 1 : 0;
  5178. if ( test !== 0 ) {
  5179. return sort.dir === 'asc' ? test : -test;
  5180. }
  5181. }
  5182. x = aiOrig[a];
  5183. y = aiOrig[b];
  5184. return x<y ? -1 : x>y ? 1 : 0;
  5185. } );
  5186. }
  5187. else {
  5188. // Depreciated - remove in 1.11 (providing a plug-in option)
  5189. // Not all sort types have formatting methods, so we have to call their sorting
  5190. // methods.
  5191. displayMaster.sort( function ( a, b ) {
  5192. var
  5193. x, y, k, l, test, sort, fn,
  5194. len=aSort.length,
  5195. dataA = aoData[a]._aSortData,
  5196. dataB = aoData[b]._aSortData;
  5197. for ( k=0 ; k<len ; k++ ) {
  5198. sort = aSort[k];
  5199. x = dataA[ sort.col ];
  5200. y = dataB[ sort.col ];
  5201. fn = oExtSort[ sort.type+"-"+sort.dir ] || oExtSort[ "string-"+sort.dir ];
  5202. test = fn( x, y );
  5203. if ( test !== 0 ) {
  5204. return test;
  5205. }
  5206. }
  5207. x = aiOrig[a];
  5208. y = aiOrig[b];
  5209. return x<y ? -1 : x>y ? 1 : 0;
  5210. } );
  5211. }
  5212. }
  5213. /* Tell the draw function that we have sorted the data */
  5214. oSettings.bSorted = true;
  5215. }
  5216. function _fnSortAria ( settings )
  5217. {
  5218. var label;
  5219. var nextSort;
  5220. var columns = settings.aoColumns;
  5221. var aSort = _fnSortFlatten( settings );
  5222. var oAria = settings.oLanguage.oAria;
  5223. // ARIA attributes - need to loop all columns, to update all (removing old
  5224. // attributes as needed)
  5225. for ( var i=0, iLen=columns.length ; i<iLen ; i++ )
  5226. {
  5227. var col = columns[i];
  5228. var asSorting = col.asSorting;
  5229. var sTitle = col.sTitle.replace( /<.*?>/g, "" );
  5230. var th = col.nTh;
  5231. // IE7 is throwing an error when setting these properties with jQuery's
  5232. // attr() and removeAttr() methods...
  5233. th.removeAttribute('aria-sort');
  5234. /* In ARIA only the first sorting column can be marked as sorting - no multi-sort option */
  5235. if ( col.bSortable ) {
  5236. if ( aSort.length > 0 && aSort[0].col == i ) {
  5237. th.setAttribute('aria-sort', aSort[0].dir=="asc" ? "ascending" : "descending" );
  5238. nextSort = asSorting[ aSort[0].index+1 ] || asSorting[0];
  5239. }
  5240. else {
  5241. nextSort = asSorting[0];
  5242. }
  5243. label = sTitle + ( nextSort === "asc" ?
  5244. oAria.sSortAscending :
  5245. oAria.sSortDescending
  5246. );
  5247. }
  5248. else {
  5249. label = sTitle;
  5250. }
  5251. th.setAttribute('aria-label', label);
  5252. }
  5253. }
  5254. /**
  5255. * Function to run on user sort request
  5256. * @param {object} settings dataTables settings object
  5257. * @param {node} attachTo node to attach the handler to
  5258. * @param {int} colIdx column sorting index
  5259. * @param {boolean} [append=false] Append the requested sort to the existing
  5260. * sort if true (i.e. multi-column sort)
  5261. * @param {function} [callback] callback function
  5262. * @memberof DataTable#oApi
  5263. */
  5264. function _fnSortListener ( settings, colIdx, append, callback )
  5265. {
  5266. var col = settings.aoColumns[ colIdx ];
  5267. var sorting = settings.aaSorting;
  5268. var asSorting = col.asSorting;
  5269. var nextSortIdx;
  5270. var next = function ( a, overflow ) {
  5271. var idx = a._idx;
  5272. if ( idx === undefined ) {
  5273. idx = $.inArray( a[1], asSorting );
  5274. }
  5275. return idx+1 < asSorting.length ?
  5276. idx+1 :
  5277. overflow ?
  5278. null :
  5279. 0;
  5280. };
  5281. // Convert to 2D array if needed
  5282. if ( typeof sorting[0] === 'number' ) {
  5283. sorting = settings.aaSorting = [ sorting ];
  5284. }
  5285. // If appending the sort then we are multi-column sorting
  5286. if ( append && settings.oFeatures.bSortMulti ) {
  5287. // Are we already doing some kind of sort on this column?
  5288. var sortIdx = $.inArray( colIdx, _pluck(sorting, '0') );
  5289. if ( sortIdx !== -1 ) {
  5290. // Yes, modify the sort
  5291. nextSortIdx = next( sorting[sortIdx], true );
  5292. if ( nextSortIdx === null && sorting.length === 1 ) {
  5293. nextSortIdx = 0; // can't remove sorting completely
  5294. }
  5295. if ( nextSortIdx === null ) {
  5296. sorting.splice( sortIdx, 1 );
  5297. }
  5298. else {
  5299. sorting[sortIdx][1] = asSorting[ nextSortIdx ];
  5300. sorting[sortIdx]._idx = nextSortIdx;
  5301. }
  5302. }
  5303. else {
  5304. // No sort on this column yet
  5305. sorting.push( [ colIdx, asSorting[0], 0 ] );
  5306. sorting[sorting.length-1]._idx = 0;
  5307. }
  5308. }
  5309. else if ( sorting.length && sorting[0][0] == colIdx ) {
  5310. // Single column - already sorting on this column, modify the sort
  5311. nextSortIdx = next( sorting[0] );
  5312. sorting.length = 1;
  5313. sorting[0][1] = asSorting[ nextSortIdx ];
  5314. sorting[0]._idx = nextSortIdx;
  5315. }
  5316. else {
  5317. // Single column - sort only on this column
  5318. sorting.length = 0;
  5319. sorting.push( [ colIdx, asSorting[0] ] );
  5320. sorting[0]._idx = 0;
  5321. }
  5322. // Run the sort by calling a full redraw
  5323. _fnReDraw( settings );
  5324. // callback used for async user interaction
  5325. if ( typeof callback == 'function' ) {
  5326. callback( settings );
  5327. }
  5328. }
  5329. /**
  5330. * Attach a sort handler (click) to a node
  5331. * @param {object} settings dataTables settings object
  5332. * @param {node} attachTo node to attach the handler to
  5333. * @param {int} colIdx column sorting index
  5334. * @param {function} [callback] callback function
  5335. * @memberof DataTable#oApi
  5336. */
  5337. function _fnSortAttachListener ( settings, attachTo, colIdx, callback )
  5338. {
  5339. var col = settings.aoColumns[ colIdx ];
  5340. _fnBindAction( attachTo, {}, function (e) {
  5341. /* If the column is not sortable - don't to anything */
  5342. if ( col.bSortable === false ) {
  5343. return;
  5344. }
  5345. // If processing is enabled use a timeout to allow the processing
  5346. // display to be shown - otherwise to it synchronously
  5347. if ( settings.oFeatures.bProcessing ) {
  5348. _fnProcessingDisplay( settings, true );
  5349. setTimeout( function() {
  5350. _fnSortListener( settings, colIdx, e.shiftKey, callback );
  5351. // In server-side processing, the draw callback will remove the
  5352. // processing display
  5353. if ( _fnDataSource( settings ) !== 'ssp' ) {
  5354. _fnProcessingDisplay( settings, false );
  5355. }
  5356. }, 0 );
  5357. }
  5358. else {
  5359. _fnSortListener( settings, colIdx, e.shiftKey, callback );
  5360. }
  5361. } );
  5362. }
  5363. /**
  5364. * Set the sorting classes on table's body, Note: it is safe to call this function
  5365. * when bSort and bSortClasses are false
  5366. * @param {object} oSettings dataTables settings object
  5367. * @memberof DataTable#oApi
  5368. */
  5369. function _fnSortingClasses( settings )
  5370. {
  5371. var oldSort = settings.aLastSort;
  5372. var sortClass = settings.oClasses.sSortColumn;
  5373. var sort = _fnSortFlatten( settings );
  5374. var features = settings.oFeatures;
  5375. var i, ien, colIdx;
  5376. if ( features.bSort && features.bSortClasses ) {
  5377. // Remove old sorting classes
  5378. for ( i=0, ien=oldSort.length ; i<ien ; i++ ) {
  5379. colIdx = oldSort[i].src;
  5380. // Remove column sorting
  5381. $( _pluck( settings.aoData, 'anCells', colIdx ) )
  5382. .removeClass( sortClass + (i<2 ? i+1 : 3) );
  5383. }
  5384. // Add new column sorting
  5385. for ( i=0, ien=sort.length ; i<ien ; i++ ) {
  5386. colIdx = sort[i].src;
  5387. $( _pluck( settings.aoData, 'anCells', colIdx ) )
  5388. .addClass( sortClass + (i<2 ? i+1 : 3) );
  5389. }
  5390. }
  5391. settings.aLastSort = sort;
  5392. }
  5393. // Get the data to sort a column, be it from cache, fresh (populating the
  5394. // cache), or from a sort formatter
  5395. function _fnSortData( settings, idx )
  5396. {
  5397. // Custom sorting function - provided by the sort data type
  5398. var column = settings.aoColumns[ idx ];
  5399. var customSort = DataTable.ext.order[ column.sSortDataType ];
  5400. var customData;
  5401. if ( customSort ) {
  5402. customData = customSort.call( settings.oInstance, settings, idx,
  5403. _fnColumnIndexToVisible( settings, idx )
  5404. );
  5405. }
  5406. // Use / populate cache
  5407. var row, cellData;
  5408. var formatter = DataTable.ext.type.order[ column.sType+"-pre" ];
  5409. for ( var i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  5410. row = settings.aoData[i];
  5411. if ( ! row._aSortData ) {
  5412. row._aSortData = [];
  5413. }
  5414. if ( ! row._aSortData[idx] || customSort ) {
  5415. cellData = customSort ?
  5416. customData[i] : // If there was a custom sort function, use data from there
  5417. _fnGetCellData( settings, i, idx, 'sort' );
  5418. row._aSortData[ idx ] = formatter ?
  5419. formatter( cellData ) :
  5420. cellData;
  5421. }
  5422. }
  5423. }
  5424. /**
  5425. * Save the state of a table
  5426. * @param {object} oSettings dataTables settings object
  5427. * @memberof DataTable#oApi
  5428. */
  5429. function _fnSaveState ( settings )
  5430. {
  5431. if ( !settings.oFeatures.bStateSave || settings.bDestroying )
  5432. {
  5433. return;
  5434. }
  5435. /* Store the interesting variables */
  5436. var state = {
  5437. time: +new Date(),
  5438. start: settings._iDisplayStart,
  5439. length: settings._iDisplayLength,
  5440. order: $.extend( true, [], settings.aaSorting ),
  5441. search: _fnSearchToCamel( settings.oPreviousSearch ),
  5442. columns: $.map( settings.aoColumns, function ( col, i ) {
  5443. return {
  5444. visible: col.bVisible,
  5445. search: _fnSearchToCamel( settings.aoPreSearchCols[i] )
  5446. };
  5447. } )
  5448. };
  5449. _fnCallbackFire( settings, "aoStateSaveParams", 'stateSaveParams', [settings, state] );
  5450. settings.oSavedState = state;
  5451. settings.fnStateSaveCallback.call( settings.oInstance, settings, state );
  5452. }
  5453. /**
  5454. * Attempt to load a saved table state
  5455. * @param {object} oSettings dataTables settings object
  5456. * @param {object} oInit DataTables init object so we can override settings
  5457. * @param {function} callback Callback to execute when the state has been loaded
  5458. * @memberof DataTable#oApi
  5459. */
  5460. function _fnLoadState ( settings, oInit, callback )
  5461. {
  5462. var i, ien;
  5463. var columns = settings.aoColumns;
  5464. var loaded = function ( s ) {
  5465. if ( ! s || ! s.time ) {
  5466. callback();
  5467. return;
  5468. }
  5469. // Allow custom and plug-in manipulation functions to alter the saved data set and
  5470. // cancelling of loading by returning false
  5471. var abStateLoad = _fnCallbackFire( settings, 'aoStateLoadParams', 'stateLoadParams', [settings, s] );
  5472. if ( $.inArray( false, abStateLoad ) !== -1 ) {
  5473. callback();
  5474. return;
  5475. }
  5476. // Reject old data
  5477. var duration = settings.iStateDuration;
  5478. if ( duration > 0 && s.time < +new Date() - (duration*1000) ) {
  5479. callback();
  5480. return;
  5481. }
  5482. // Number of columns have changed - all bets are off, no restore of settings
  5483. if ( s.columns && columns.length !== s.columns.length ) {
  5484. callback();
  5485. return;
  5486. }
  5487. // Store the saved state so it might be accessed at any time
  5488. settings.oLoadedState = $.extend( true, {}, s );
  5489. // Restore key features - todo - for 1.11 this needs to be done by
  5490. // subscribed events
  5491. if ( s.start !== undefined ) {
  5492. settings._iDisplayStart = s.start;
  5493. settings.iInitDisplayStart = s.start;
  5494. }
  5495. if ( s.length !== undefined ) {
  5496. settings._iDisplayLength = s.length;
  5497. }
  5498. // Order
  5499. if ( s.order !== undefined ) {
  5500. settings.aaSorting = [];
  5501. $.each( s.order, function ( i, col ) {
  5502. settings.aaSorting.push( col[0] >= columns.length ?
  5503. [ 0, col[1] ] :
  5504. col
  5505. );
  5506. } );
  5507. }
  5508. // Search
  5509. if ( s.search !== undefined ) {
  5510. $.extend( settings.oPreviousSearch, _fnSearchToHung( s.search ) );
  5511. }
  5512. // Columns
  5513. //
  5514. if ( s.columns ) {
  5515. for ( i=0, ien=s.columns.length ; i<ien ; i++ ) {
  5516. var col = s.columns[i];
  5517. // Visibility
  5518. if ( col.visible !== undefined ) {
  5519. columns[i].bVisible = col.visible;
  5520. }
  5521. // Search
  5522. if ( col.search !== undefined ) {
  5523. $.extend( settings.aoPreSearchCols[i], _fnSearchToHung( col.search ) );
  5524. }
  5525. }
  5526. }
  5527. _fnCallbackFire( settings, 'aoStateLoaded', 'stateLoaded', [settings, s] );
  5528. callback();
  5529. }
  5530. if ( ! settings.oFeatures.bStateSave ) {
  5531. callback();
  5532. return;
  5533. }
  5534. var state = settings.fnStateLoadCallback.call( settings.oInstance, settings, loaded );
  5535. if ( state !== undefined ) {
  5536. loaded( state );
  5537. }
  5538. // otherwise, wait for the loaded callback to be executed
  5539. }
  5540. /**
  5541. * Return the settings object for a particular table
  5542. * @param {node} table table we are using as a dataTable
  5543. * @returns {object} Settings object - or null if not found
  5544. * @memberof DataTable#oApi
  5545. */
  5546. function _fnSettingsFromNode ( table )
  5547. {
  5548. var settings = DataTable.settings;
  5549. var idx = $.inArray( table, _pluck( settings, 'nTable' ) );
  5550. return idx !== -1 ?
  5551. settings[ idx ] :
  5552. null;
  5553. }
  5554. /**
  5555. * Log an error message
  5556. * @param {object} settings dataTables settings object
  5557. * @param {int} level log error messages, or display them to the user
  5558. * @param {string} msg error message
  5559. * @param {int} tn Technical note id to get more information about the error.
  5560. * @memberof DataTable#oApi
  5561. */
  5562. function _fnLog( settings, level, msg, tn )
  5563. {
  5564. msg = 'DataTables warning: '+
  5565. (settings ? 'table id='+settings.sTableId+' - ' : '')+msg;
  5566. if ( tn ) {
  5567. msg += '. For more information about this error, please see '+
  5568. 'http://datatables.net/tn/'+tn;
  5569. }
  5570. if ( ! level ) {
  5571. // Backwards compatibility pre 1.10
  5572. var ext = DataTable.ext;
  5573. var type = ext.sErrMode || ext.errMode;
  5574. if ( settings ) {
  5575. _fnCallbackFire( settings, null, 'error', [ settings, tn, msg ] );
  5576. }
  5577. if ( type == 'alert' ) {
  5578. alert( msg );
  5579. }
  5580. else if ( type == 'throw' ) {
  5581. throw new Error(msg);
  5582. }
  5583. else if ( typeof type == 'function' ) {
  5584. type( settings, tn, msg );
  5585. }
  5586. }
  5587. else if ( window.console && console.log ) {
  5588. console.log( msg );
  5589. }
  5590. }
  5591. /**
  5592. * See if a property is defined on one object, if so assign it to the other object
  5593. * @param {object} ret target object
  5594. * @param {object} src source object
  5595. * @param {string} name property
  5596. * @param {string} [mappedName] name to map too - optional, name used if not given
  5597. * @memberof DataTable#oApi
  5598. */
  5599. function _fnMap( ret, src, name, mappedName )
  5600. {
  5601. if ( $.isArray( name ) ) {
  5602. $.each( name, function (i, val) {
  5603. if ( $.isArray( val ) ) {
  5604. _fnMap( ret, src, val[0], val[1] );
  5605. }
  5606. else {
  5607. _fnMap( ret, src, val );
  5608. }
  5609. } );
  5610. return;
  5611. }
  5612. if ( mappedName === undefined ) {
  5613. mappedName = name;
  5614. }
  5615. if ( src[name] !== undefined ) {
  5616. ret[mappedName] = src[name];
  5617. }
  5618. }
  5619. /**
  5620. * Extend objects - very similar to jQuery.extend, but deep copy objects, and
  5621. * shallow copy arrays. The reason we need to do this, is that we don't want to
  5622. * deep copy array init values (such as aaSorting) since the dev wouldn't be
  5623. * able to override them, but we do want to deep copy arrays.
  5624. * @param {object} out Object to extend
  5625. * @param {object} extender Object from which the properties will be applied to
  5626. * out
  5627. * @param {boolean} breakRefs If true, then arrays will be sliced to take an
  5628. * independent copy with the exception of the `data` or `aaData` parameters
  5629. * if they are present. This is so you can pass in a collection to
  5630. * DataTables and have that used as your data source without breaking the
  5631. * references
  5632. * @returns {object} out Reference, just for convenience - out === the return.
  5633. * @memberof DataTable#oApi
  5634. * @todo This doesn't take account of arrays inside the deep copied objects.
  5635. */
  5636. function _fnExtend( out, extender, breakRefs )
  5637. {
  5638. var val;
  5639. for ( var prop in extender ) {
  5640. if ( extender.hasOwnProperty(prop) ) {
  5641. val = extender[prop];
  5642. if ( $.isPlainObject( val ) ) {
  5643. if ( ! $.isPlainObject( out[prop] ) ) {
  5644. out[prop] = {};
  5645. }
  5646. $.extend( true, out[prop], val );
  5647. }
  5648. else if ( breakRefs && prop !== 'data' && prop !== 'aaData' && $.isArray(val) ) {
  5649. out[prop] = val.slice();
  5650. }
  5651. else {
  5652. out[prop] = val;
  5653. }
  5654. }
  5655. }
  5656. return out;
  5657. }
  5658. /**
  5659. * Bind an event handers to allow a click or return key to activate the callback.
  5660. * This is good for accessibility since a return on the keyboard will have the
  5661. * same effect as a click, if the element has focus.
  5662. * @param {element} n Element to bind the action to
  5663. * @param {object} oData Data object to pass to the triggered function
  5664. * @param {function} fn Callback function for when the event is triggered
  5665. * @memberof DataTable#oApi
  5666. */
  5667. function _fnBindAction( n, oData, fn )
  5668. {
  5669. $(n)
  5670. .on( 'click.DT', oData, function (e) {
  5671. $(n).blur(); // Remove focus outline for mouse users
  5672. fn(e);
  5673. } )
  5674. .on( 'keypress.DT', oData, function (e){
  5675. if ( e.which === 13 ) {
  5676. e.preventDefault();
  5677. fn(e);
  5678. }
  5679. } )
  5680. .on( 'selectstart.DT', function () {
  5681. /* Take the brutal approach to cancelling text selection */
  5682. return false;
  5683. } );
  5684. }
  5685. /**
  5686. * Register a callback function. Easily allows a callback function to be added to
  5687. * an array store of callback functions that can then all be called together.
  5688. * @param {object} oSettings dataTables settings object
  5689. * @param {string} sStore Name of the array storage for the callbacks in oSettings
  5690. * @param {function} fn Function to be called back
  5691. * @param {string} sName Identifying name for the callback (i.e. a label)
  5692. * @memberof DataTable#oApi
  5693. */
  5694. function _fnCallbackReg( oSettings, sStore, fn, sName )
  5695. {
  5696. if ( fn )
  5697. {
  5698. oSettings[sStore].push( {
  5699. "fn": fn,
  5700. "sName": sName
  5701. } );
  5702. }
  5703. }
  5704. /**
  5705. * Fire callback functions and trigger events. Note that the loop over the
  5706. * callback array store is done backwards! Further note that you do not want to
  5707. * fire off triggers in time sensitive applications (for example cell creation)
  5708. * as its slow.
  5709. * @param {object} settings dataTables settings object
  5710. * @param {string} callbackArr Name of the array storage for the callbacks in
  5711. * oSettings
  5712. * @param {string} eventName Name of the jQuery custom event to trigger. If
  5713. * null no trigger is fired
  5714. * @param {array} args Array of arguments to pass to the callback function /
  5715. * trigger
  5716. * @memberof DataTable#oApi
  5717. */
  5718. function _fnCallbackFire( settings, callbackArr, eventName, args )
  5719. {
  5720. var ret = [];
  5721. if ( callbackArr ) {
  5722. ret = $.map( settings[callbackArr].slice().reverse(), function (val, i) {
  5723. return val.fn.apply( settings.oInstance, args );
  5724. } );
  5725. }
  5726. if ( eventName !== null ) {
  5727. var e = $.Event( eventName+'.dt' );
  5728. $(settings.nTable).trigger( e, args );
  5729. ret.push( e.result );
  5730. }
  5731. return ret;
  5732. }
  5733. function _fnLengthOverflow ( settings )
  5734. {
  5735. var
  5736. start = settings._iDisplayStart,
  5737. end = settings.fnDisplayEnd(),
  5738. len = settings._iDisplayLength;
  5739. /* If we have space to show extra rows (backing up from the end point - then do so */
  5740. if ( start >= end )
  5741. {
  5742. start = end - len;
  5743. }
  5744. // Keep the start record on the current page
  5745. start -= (start % len);
  5746. if ( len === -1 || start < 0 )
  5747. {
  5748. start = 0;
  5749. }
  5750. settings._iDisplayStart = start;
  5751. }
  5752. function _fnRenderer( settings, type )
  5753. {
  5754. var renderer = settings.renderer;
  5755. var host = DataTable.ext.renderer[type];
  5756. if ( $.isPlainObject( renderer ) && renderer[type] ) {
  5757. // Specific renderer for this type. If available use it, otherwise use
  5758. // the default.
  5759. return host[renderer[type]] || host._;
  5760. }
  5761. else if ( typeof renderer === 'string' ) {
  5762. // Common renderer - if there is one available for this type use it,
  5763. // otherwise use the default
  5764. return host[renderer] || host._;
  5765. }
  5766. // Use the default
  5767. return host._;
  5768. }
  5769. /**
  5770. * Detect the data source being used for the table. Used to simplify the code
  5771. * a little (ajax) and to make it compress a little smaller.
  5772. *
  5773. * @param {object} settings dataTables settings object
  5774. * @returns {string} Data source
  5775. * @memberof DataTable#oApi
  5776. */
  5777. function _fnDataSource ( settings )
  5778. {
  5779. if ( settings.oFeatures.bServerSide ) {
  5780. return 'ssp';
  5781. }
  5782. else if ( settings.ajax || settings.sAjaxSource ) {
  5783. return 'ajax';
  5784. }
  5785. return 'dom';
  5786. }
  5787. /**
  5788. * Computed structure of the DataTables API, defined by the options passed to
  5789. * `DataTable.Api.register()` when building the API.
  5790. *
  5791. * The structure is built in order to speed creation and extension of the Api
  5792. * objects since the extensions are effectively pre-parsed.
  5793. *
  5794. * The array is an array of objects with the following structure, where this
  5795. * base array represents the Api prototype base:
  5796. *
  5797. * [
  5798. * {
  5799. * name: 'data' -- string - Property name
  5800. * val: function () {}, -- function - Api method (or undefined if just an object
  5801. * methodExt: [ ... ], -- array - Array of Api object definitions to extend the method result
  5802. * propExt: [ ... ] -- array - Array of Api object definitions to extend the property
  5803. * },
  5804. * {
  5805. * name: 'row'
  5806. * val: {},
  5807. * methodExt: [ ... ],
  5808. * propExt: [
  5809. * {
  5810. * name: 'data'
  5811. * val: function () {},
  5812. * methodExt: [ ... ],
  5813. * propExt: [ ... ]
  5814. * },
  5815. * ...
  5816. * ]
  5817. * }
  5818. * ]
  5819. *
  5820. * @type {Array}
  5821. * @ignore
  5822. */
  5823. var __apiStruct = [];
  5824. /**
  5825. * `Array.prototype` reference.
  5826. *
  5827. * @type object
  5828. * @ignore
  5829. */
  5830. var __arrayProto = Array.prototype;
  5831. /**
  5832. * Abstraction for `context` parameter of the `Api` constructor to allow it to
  5833. * take several different forms for ease of use.
  5834. *
  5835. * Each of the input parameter types will be converted to a DataTables settings
  5836. * object where possible.
  5837. *
  5838. * @param {string|node|jQuery|object} mixed DataTable identifier. Can be one
  5839. * of:
  5840. *
  5841. * * `string` - jQuery selector. Any DataTables' matching the given selector
  5842. * with be found and used.
  5843. * * `node` - `TABLE` node which has already been formed into a DataTable.
  5844. * * `jQuery` - A jQuery object of `TABLE` nodes.
  5845. * * `object` - DataTables settings object
  5846. * * `DataTables.Api` - API instance
  5847. * @return {array|null} Matching DataTables settings objects. `null` or
  5848. * `undefined` is returned if no matching DataTable is found.
  5849. * @ignore
  5850. */
  5851. var _toSettings = function ( mixed )
  5852. {
  5853. var idx, jq;
  5854. var settings = DataTable.settings;
  5855. var tables = $.map( settings, function (el, i) {
  5856. return el.nTable;
  5857. } );
  5858. if ( ! mixed ) {
  5859. return [];
  5860. }
  5861. else if ( mixed.nTable && mixed.oApi ) {
  5862. // DataTables settings object
  5863. return [ mixed ];
  5864. }
  5865. else if ( mixed.nodeName && mixed.nodeName.toLowerCase() === 'table' ) {
  5866. // Table node
  5867. idx = $.inArray( mixed, tables );
  5868. return idx !== -1 ? [ settings[idx] ] : null;
  5869. }
  5870. else if ( mixed && typeof mixed.settings === 'function' ) {
  5871. return mixed.settings().toArray();
  5872. }
  5873. else if ( typeof mixed === 'string' ) {
  5874. // jQuery selector
  5875. jq = $(mixed);
  5876. }
  5877. else if ( mixed instanceof $ ) {
  5878. // jQuery object (also DataTables instance)
  5879. jq = mixed;
  5880. }
  5881. if ( jq ) {
  5882. return jq.map( function(i) {
  5883. idx = $.inArray( this, tables );
  5884. return idx !== -1 ? settings[idx] : null;
  5885. } ).toArray();
  5886. }
  5887. };
  5888. /**
  5889. * DataTables API class - used to control and interface with one or more
  5890. * DataTables enhanced tables.
  5891. *
  5892. * The API class is heavily based on jQuery, presenting a chainable interface
  5893. * that you can use to interact with tables. Each instance of the API class has
  5894. * a "context" - i.e. the tables that it will operate on. This could be a single
  5895. * table, all tables on a page or a sub-set thereof.
  5896. *
  5897. * Additionally the API is designed to allow you to easily work with the data in
  5898. * the tables, retrieving and manipulating it as required. This is done by
  5899. * presenting the API class as an array like interface. The contents of the
  5900. * array depend upon the actions requested by each method (for example
  5901. * `rows().nodes()` will return an array of nodes, while `rows().data()` will
  5902. * return an array of objects or arrays depending upon your table's
  5903. * configuration). The API object has a number of array like methods (`push`,
  5904. * `pop`, `reverse` etc) as well as additional helper methods (`each`, `pluck`,
  5905. * `unique` etc) to assist your working with the data held in a table.
  5906. *
  5907. * Most methods (those which return an Api instance) are chainable, which means
  5908. * the return from a method call also has all of the methods available that the
  5909. * top level object had. For example, these two calls are equivalent:
  5910. *
  5911. * // Not chained
  5912. * api.row.add( {...} );
  5913. * api.draw();
  5914. *
  5915. * // Chained
  5916. * api.row.add( {...} ).draw();
  5917. *
  5918. * @class DataTable.Api
  5919. * @param {array|object|string|jQuery} context DataTable identifier. This is
  5920. * used to define which DataTables enhanced tables this API will operate on.
  5921. * Can be one of:
  5922. *
  5923. * * `string` - jQuery selector. Any DataTables' matching the given selector
  5924. * with be found and used.
  5925. * * `node` - `TABLE` node which has already been formed into a DataTable.
  5926. * * `jQuery` - A jQuery object of `TABLE` nodes.
  5927. * * `object` - DataTables settings object
  5928. * @param {array} [data] Data to initialise the Api instance with.
  5929. *
  5930. * @example
  5931. * // Direct initialisation during DataTables construction
  5932. * var api = $('#example').DataTable();
  5933. *
  5934. * @example
  5935. * // Initialisation using a DataTables jQuery object
  5936. * var api = $('#example').dataTable().api();
  5937. *
  5938. * @example
  5939. * // Initialisation as a constructor
  5940. * var api = new $.fn.DataTable.Api( 'table.dataTable' );
  5941. */
  5942. _Api = function ( context, data )
  5943. {
  5944. if ( ! (this instanceof _Api) ) {
  5945. return new _Api( context, data );
  5946. }
  5947. var settings = [];
  5948. var ctxSettings = function ( o ) {
  5949. var a = _toSettings( o );
  5950. if ( a ) {
  5951. settings = settings.concat( a );
  5952. }
  5953. };
  5954. if ( $.isArray( context ) ) {
  5955. for ( var i=0, ien=context.length ; i<ien ; i++ ) {
  5956. ctxSettings( context[i] );
  5957. }
  5958. }
  5959. else {
  5960. ctxSettings( context );
  5961. }
  5962. // Remove duplicates
  5963. this.context = _unique( settings );
  5964. // Initial data
  5965. if ( data ) {
  5966. $.merge( this, data );
  5967. }
  5968. // selector
  5969. this.selector = {
  5970. rows: null,
  5971. cols: null,
  5972. opts: null
  5973. };
  5974. _Api.extend( this, this, __apiStruct );
  5975. };
  5976. DataTable.Api = _Api;
  5977. // Don't destroy the existing prototype, just extend it. Required for jQuery 2's
  5978. // isPlainObject.
  5979. $.extend( _Api.prototype, {
  5980. any: function ()
  5981. {
  5982. return this.count() !== 0;
  5983. },
  5984. concat: __arrayProto.concat,
  5985. context: [], // array of table settings objects
  5986. count: function ()
  5987. {
  5988. return this.flatten().length;
  5989. },
  5990. each: function ( fn )
  5991. {
  5992. for ( var i=0, ien=this.length ; i<ien; i++ ) {
  5993. fn.call( this, this[i], i, this );
  5994. }
  5995. return this;
  5996. },
  5997. eq: function ( idx )
  5998. {
  5999. var ctx = this.context;
  6000. return ctx.length > idx ?
  6001. new _Api( ctx[idx], this[idx] ) :
  6002. null;
  6003. },
  6004. filter: function ( fn )
  6005. {
  6006. var a = [];
  6007. if ( __arrayProto.filter ) {
  6008. a = __arrayProto.filter.call( this, fn, this );
  6009. }
  6010. else {
  6011. // Compatibility for browsers without EMCA-252-5 (JS 1.6)
  6012. for ( var i=0, ien=this.length ; i<ien ; i++ ) {
  6013. if ( fn.call( this, this[i], i, this ) ) {
  6014. a.push( this[i] );
  6015. }
  6016. }
  6017. }
  6018. return new _Api( this.context, a );
  6019. },
  6020. flatten: function ()
  6021. {
  6022. var a = [];
  6023. return new _Api( this.context, a.concat.apply( a, this.toArray() ) );
  6024. },
  6025. join: __arrayProto.join,
  6026. indexOf: __arrayProto.indexOf || function (obj, start)
  6027. {
  6028. for ( var i=(start || 0), ien=this.length ; i<ien ; i++ ) {
  6029. if ( this[i] === obj ) {
  6030. return i;
  6031. }
  6032. }
  6033. return -1;
  6034. },
  6035. iterator: function ( flatten, type, fn, alwaysNew ) {
  6036. var
  6037. a = [], ret,
  6038. i, ien, j, jen,
  6039. context = this.context,
  6040. rows, items, item,
  6041. selector = this.selector;
  6042. // Argument shifting
  6043. if ( typeof flatten === 'string' ) {
  6044. alwaysNew = fn;
  6045. fn = type;
  6046. type = flatten;
  6047. flatten = false;
  6048. }
  6049. for ( i=0, ien=context.length ; i<ien ; i++ ) {
  6050. var apiInst = new _Api( context[i] );
  6051. if ( type === 'table' ) {
  6052. ret = fn.call( apiInst, context[i], i );
  6053. if ( ret !== undefined ) {
  6054. a.push( ret );
  6055. }
  6056. }
  6057. else if ( type === 'columns' || type === 'rows' ) {
  6058. // this has same length as context - one entry for each table
  6059. ret = fn.call( apiInst, context[i], this[i], i );
  6060. if ( ret !== undefined ) {
  6061. a.push( ret );
  6062. }
  6063. }
  6064. else if ( type === 'column' || type === 'column-rows' || type === 'row' || type === 'cell' ) {
  6065. // columns and rows share the same structure.
  6066. // 'this' is an array of column indexes for each context
  6067. items = this[i];
  6068. if ( type === 'column-rows' ) {
  6069. rows = _selector_row_indexes( context[i], selector.opts );
  6070. }
  6071. for ( j=0, jen=items.length ; j<jen ; j++ ) {
  6072. item = items[j];
  6073. if ( type === 'cell' ) {
  6074. ret = fn.call( apiInst, context[i], item.row, item.column, i, j );
  6075. }
  6076. else {
  6077. ret = fn.call( apiInst, context[i], item, i, j, rows );
  6078. }
  6079. if ( ret !== undefined ) {
  6080. a.push( ret );
  6081. }
  6082. }
  6083. }
  6084. }
  6085. if ( a.length || alwaysNew ) {
  6086. var api = new _Api( context, flatten ? a.concat.apply( [], a ) : a );
  6087. var apiSelector = api.selector;
  6088. apiSelector.rows = selector.rows;
  6089. apiSelector.cols = selector.cols;
  6090. apiSelector.opts = selector.opts;
  6091. return api;
  6092. }
  6093. return this;
  6094. },
  6095. lastIndexOf: __arrayProto.lastIndexOf || function (obj, start)
  6096. {
  6097. // Bit cheeky...
  6098. return this.indexOf.apply( this.toArray.reverse(), arguments );
  6099. },
  6100. length: 0,
  6101. map: function ( fn )
  6102. {
  6103. var a = [];
  6104. if ( __arrayProto.map ) {
  6105. a = __arrayProto.map.call( this, fn, this );
  6106. }
  6107. else {
  6108. // Compatibility for browsers without EMCA-252-5 (JS 1.6)
  6109. for ( var i=0, ien=this.length ; i<ien ; i++ ) {
  6110. a.push( fn.call( this, this[i], i ) );
  6111. }
  6112. }
  6113. return new _Api( this.context, a );
  6114. },
  6115. pluck: function ( prop )
  6116. {
  6117. return this.map( function ( el ) {
  6118. return el[ prop ];
  6119. } );
  6120. },
  6121. pop: __arrayProto.pop,
  6122. push: __arrayProto.push,
  6123. // Does not return an API instance
  6124. reduce: __arrayProto.reduce || function ( fn, init )
  6125. {
  6126. return _fnReduce( this, fn, init, 0, this.length, 1 );
  6127. },
  6128. reduceRight: __arrayProto.reduceRight || function ( fn, init )
  6129. {
  6130. return _fnReduce( this, fn, init, this.length-1, -1, -1 );
  6131. },
  6132. reverse: __arrayProto.reverse,
  6133. // Object with rows, columns and opts
  6134. selector: null,
  6135. shift: __arrayProto.shift,
  6136. slice: function () {
  6137. return new _Api( this.context, this );
  6138. },
  6139. sort: __arrayProto.sort, // ? name - order?
  6140. splice: __arrayProto.splice,
  6141. toArray: function ()
  6142. {
  6143. return __arrayProto.slice.call( this );
  6144. },
  6145. to$: function ()
  6146. {
  6147. return $( this );
  6148. },
  6149. toJQuery: function ()
  6150. {
  6151. return $( this );
  6152. },
  6153. unique: function ()
  6154. {
  6155. return new _Api( this.context, _unique(this) );
  6156. },
  6157. unshift: __arrayProto.unshift
  6158. } );
  6159. _Api.extend = function ( scope, obj, ext )
  6160. {
  6161. // Only extend API instances and static properties of the API
  6162. if ( ! ext.length || ! obj || ( ! (obj instanceof _Api) && ! obj.__dt_wrapper ) ) {
  6163. return;
  6164. }
  6165. var
  6166. i, ien,
  6167. j, jen,
  6168. struct, inner,
  6169. methodScoping = function ( scope, fn, struc ) {
  6170. return function () {
  6171. var ret = fn.apply( scope, arguments );
  6172. // Method extension
  6173. _Api.extend( ret, ret, struc.methodExt );
  6174. return ret;
  6175. };
  6176. };
  6177. for ( i=0, ien=ext.length ; i<ien ; i++ ) {
  6178. struct = ext[i];
  6179. // Value
  6180. obj[ struct.name ] = typeof struct.val === 'function' ?
  6181. methodScoping( scope, struct.val, struct ) :
  6182. $.isPlainObject( struct.val ) ?
  6183. {} :
  6184. struct.val;
  6185. obj[ struct.name ].__dt_wrapper = true;
  6186. // Property extension
  6187. _Api.extend( scope, obj[ struct.name ], struct.propExt );
  6188. }
  6189. };
  6190. // @todo - Is there need for an augment function?
  6191. // _Api.augment = function ( inst, name )
  6192. // {
  6193. // // Find src object in the structure from the name
  6194. // var parts = name.split('.');
  6195. // _Api.extend( inst, obj );
  6196. // };
  6197. // [
  6198. // {
  6199. // name: 'data' -- string - Property name
  6200. // val: function () {}, -- function - Api method (or undefined if just an object
  6201. // methodExt: [ ... ], -- array - Array of Api object definitions to extend the method result
  6202. // propExt: [ ... ] -- array - Array of Api object definitions to extend the property
  6203. // },
  6204. // {
  6205. // name: 'row'
  6206. // val: {},
  6207. // methodExt: [ ... ],
  6208. // propExt: [
  6209. // {
  6210. // name: 'data'
  6211. // val: function () {},
  6212. // methodExt: [ ... ],
  6213. // propExt: [ ... ]
  6214. // },
  6215. // ...
  6216. // ]
  6217. // }
  6218. // ]
  6219. _Api.register = _api_register = function ( name, val )
  6220. {
  6221. if ( $.isArray( name ) ) {
  6222. for ( var j=0, jen=name.length ; j<jen ; j++ ) {
  6223. _Api.register( name[j], val );
  6224. }
  6225. return;
  6226. }
  6227. var
  6228. i, ien,
  6229. heir = name.split('.'),
  6230. struct = __apiStruct,
  6231. key, method;
  6232. var find = function ( src, name ) {
  6233. for ( var i=0, ien=src.length ; i<ien ; i++ ) {
  6234. if ( src[i].name === name ) {
  6235. return src[i];
  6236. }
  6237. }
  6238. return null;
  6239. };
  6240. for ( i=0, ien=heir.length ; i<ien ; i++ ) {
  6241. method = heir[i].indexOf('()') !== -1;
  6242. key = method ?
  6243. heir[i].replace('()', '') :
  6244. heir[i];
  6245. var src = find( struct, key );
  6246. if ( ! src ) {
  6247. src = {
  6248. name: key,
  6249. val: {},
  6250. methodExt: [],
  6251. propExt: []
  6252. };
  6253. struct.push( src );
  6254. }
  6255. if ( i === ien-1 ) {
  6256. src.val = val;
  6257. }
  6258. else {
  6259. struct = method ?
  6260. src.methodExt :
  6261. src.propExt;
  6262. }
  6263. }
  6264. };
  6265. _Api.registerPlural = _api_registerPlural = function ( pluralName, singularName, val ) {
  6266. _Api.register( pluralName, val );
  6267. _Api.register( singularName, function () {
  6268. var ret = val.apply( this, arguments );
  6269. if ( ret === this ) {
  6270. // Returned item is the API instance that was passed in, return it
  6271. return this;
  6272. }
  6273. else if ( ret instanceof _Api ) {
  6274. // New API instance returned, want the value from the first item
  6275. // in the returned array for the singular result.
  6276. return ret.length ?
  6277. $.isArray( ret[0] ) ?
  6278. new _Api( ret.context, ret[0] ) : // Array results are 'enhanced'
  6279. ret[0] :
  6280. undefined;
  6281. }
  6282. // Non-API return - just fire it back
  6283. return ret;
  6284. } );
  6285. };
  6286. /**
  6287. * Selector for HTML tables. Apply the given selector to the give array of
  6288. * DataTables settings objects.
  6289. *
  6290. * @param {string|integer} [selector] jQuery selector string or integer
  6291. * @param {array} Array of DataTables settings objects to be filtered
  6292. * @return {array}
  6293. * @ignore
  6294. */
  6295. var __table_selector = function ( selector, a )
  6296. {
  6297. // Integer is used to pick out a table by index
  6298. if ( typeof selector === 'number' ) {
  6299. return [ a[ selector ] ];
  6300. }
  6301. // Perform a jQuery selector on the table nodes
  6302. var nodes = $.map( a, function (el, i) {
  6303. return el.nTable;
  6304. } );
  6305. return $(nodes)
  6306. .filter( selector )
  6307. .map( function (i) {
  6308. // Need to translate back from the table node to the settings
  6309. var idx = $.inArray( this, nodes );
  6310. return a[ idx ];
  6311. } )
  6312. .toArray();
  6313. };
  6314. /**
  6315. * Context selector for the API's context (i.e. the tables the API instance
  6316. * refers to.
  6317. *
  6318. * @name DataTable.Api#tables
  6319. * @param {string|integer} [selector] Selector to pick which tables the iterator
  6320. * should operate on. If not given, all tables in the current context are
  6321. * used. This can be given as a jQuery selector (for example `':gt(0)'`) to
  6322. * select multiple tables or as an integer to select a single table.
  6323. * @returns {DataTable.Api} Returns a new API instance if a selector is given.
  6324. */
  6325. _api_register( 'tables()', function ( selector ) {
  6326. // A new instance is created if there was a selector specified
  6327. return selector ?
  6328. new _Api( __table_selector( selector, this.context ) ) :
  6329. this;
  6330. } );
  6331. _api_register( 'table()', function ( selector ) {
  6332. var tables = this.tables( selector );
  6333. var ctx = tables.context;
  6334. // Truncate to the first matched table
  6335. return ctx.length ?
  6336. new _Api( ctx[0] ) :
  6337. tables;
  6338. } );
  6339. _api_registerPlural( 'tables().nodes()', 'table().node()' , function () {
  6340. return this.iterator( 'table', function ( ctx ) {
  6341. return ctx.nTable;
  6342. }, 1 );
  6343. } );
  6344. _api_registerPlural( 'tables().body()', 'table().body()' , function () {
  6345. return this.iterator( 'table', function ( ctx ) {
  6346. return ctx.nTBody;
  6347. }, 1 );
  6348. } );
  6349. _api_registerPlural( 'tables().header()', 'table().header()' , function () {
  6350. return this.iterator( 'table', function ( ctx ) {
  6351. return ctx.nTHead;
  6352. }, 1 );
  6353. } );
  6354. _api_registerPlural( 'tables().footer()', 'table().footer()' , function () {
  6355. return this.iterator( 'table', function ( ctx ) {
  6356. return ctx.nTFoot;
  6357. }, 1 );
  6358. } );
  6359. _api_registerPlural( 'tables().containers()', 'table().container()' , function () {
  6360. return this.iterator( 'table', function ( ctx ) {
  6361. return ctx.nTableWrapper;
  6362. }, 1 );
  6363. } );
  6364. /**
  6365. * Redraw the tables in the current context.
  6366. */
  6367. _api_register( 'draw()', function ( paging ) {
  6368. return this.iterator( 'table', function ( settings ) {
  6369. if ( paging === 'page' ) {
  6370. _fnDraw( settings );
  6371. }
  6372. else {
  6373. if ( typeof paging === 'string' ) {
  6374. paging = paging === 'full-hold' ?
  6375. false :
  6376. true;
  6377. }
  6378. _fnReDraw( settings, paging===false );
  6379. }
  6380. } );
  6381. } );
  6382. /**
  6383. * Get the current page index.
  6384. *
  6385. * @return {integer} Current page index (zero based)
  6386. *//**
  6387. * Set the current page.
  6388. *
  6389. * Note that if you attempt to show a page which does not exist, DataTables will
  6390. * not throw an error, but rather reset the paging.
  6391. *
  6392. * @param {integer|string} action The paging action to take. This can be one of:
  6393. * * `integer` - The page index to jump to
  6394. * * `string` - An action to take:
  6395. * * `first` - Jump to first page.
  6396. * * `next` - Jump to the next page
  6397. * * `previous` - Jump to previous page
  6398. * * `last` - Jump to the last page.
  6399. * @returns {DataTables.Api} this
  6400. */
  6401. _api_register( 'page()', function ( action ) {
  6402. if ( action === undefined ) {
  6403. return this.page.info().page; // not an expensive call
  6404. }
  6405. // else, have an action to take on all tables
  6406. return this.iterator( 'table', function ( settings ) {
  6407. _fnPageChange( settings, action );
  6408. } );
  6409. } );
  6410. /**
  6411. * Paging information for the first table in the current context.
  6412. *
  6413. * If you require paging information for another table, use the `table()` method
  6414. * with a suitable selector.
  6415. *
  6416. * @return {object} Object with the following properties set:
  6417. * * `page` - Current page index (zero based - i.e. the first page is `0`)
  6418. * * `pages` - Total number of pages
  6419. * * `start` - Display index for the first record shown on the current page
  6420. * * `end` - Display index for the last record shown on the current page
  6421. * * `length` - Display length (number of records). Note that generally `start
  6422. * + length = end`, but this is not always true, for example if there are
  6423. * only 2 records to show on the final page, with a length of 10.
  6424. * * `recordsTotal` - Full data set length
  6425. * * `recordsDisplay` - Data set length once the current filtering criterion
  6426. * are applied.
  6427. */
  6428. _api_register( 'page.info()', function ( action ) {
  6429. if ( this.context.length === 0 ) {
  6430. return undefined;
  6431. }
  6432. var
  6433. settings = this.context[0],
  6434. start = settings._iDisplayStart,
  6435. len = settings.oFeatures.bPaginate ? settings._iDisplayLength : -1,
  6436. visRecords = settings.fnRecordsDisplay(),
  6437. all = len === -1;
  6438. return {
  6439. "page": all ? 0 : Math.floor( start / len ),
  6440. "pages": all ? 1 : Math.ceil( visRecords / len ),
  6441. "start": start,
  6442. "end": settings.fnDisplayEnd(),
  6443. "length": len,
  6444. "recordsTotal": settings.fnRecordsTotal(),
  6445. "recordsDisplay": visRecords,
  6446. "serverSide": _fnDataSource( settings ) === 'ssp'
  6447. };
  6448. } );
  6449. /**
  6450. * Get the current page length.
  6451. *
  6452. * @return {integer} Current page length. Note `-1` indicates that all records
  6453. * are to be shown.
  6454. *//**
  6455. * Set the current page length.
  6456. *
  6457. * @param {integer} Page length to set. Use `-1` to show all records.
  6458. * @returns {DataTables.Api} this
  6459. */
  6460. _api_register( 'page.len()', function ( len ) {
  6461. // Note that we can't call this function 'length()' because `length`
  6462. // is a Javascript property of functions which defines how many arguments
  6463. // the function expects.
  6464. if ( len === undefined ) {
  6465. return this.context.length !== 0 ?
  6466. this.context[0]._iDisplayLength :
  6467. undefined;
  6468. }
  6469. // else, set the page length
  6470. return this.iterator( 'table', function ( settings ) {
  6471. _fnLengthChange( settings, len );
  6472. } );
  6473. } );
  6474. var __reload = function ( settings, holdPosition, callback ) {
  6475. // Use the draw event to trigger a callback
  6476. if ( callback ) {
  6477. var api = new _Api( settings );
  6478. api.one( 'draw', function () {
  6479. callback( api.ajax.json() );
  6480. } );
  6481. }
  6482. if ( _fnDataSource( settings ) == 'ssp' ) {
  6483. _fnReDraw( settings, holdPosition );
  6484. }
  6485. else {
  6486. _fnProcessingDisplay( settings, true );
  6487. // Cancel an existing request
  6488. var xhr = settings.jqXHR;
  6489. if ( xhr && xhr.readyState !== 4 ) {
  6490. xhr.abort();
  6491. }
  6492. // Trigger xhr
  6493. _fnBuildAjax( settings, [], function( json ) {
  6494. _fnClearTable( settings );
  6495. var data = _fnAjaxDataSrc( settings, json );
  6496. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  6497. _fnAddData( settings, data[i] );
  6498. }
  6499. _fnReDraw( settings, holdPosition );
  6500. _fnProcessingDisplay( settings, false );
  6501. } );
  6502. }
  6503. };
  6504. /**
  6505. * Get the JSON response from the last Ajax request that DataTables made to the
  6506. * server. Note that this returns the JSON from the first table in the current
  6507. * context.
  6508. *
  6509. * @return {object} JSON received from the server.
  6510. */
  6511. _api_register( 'ajax.json()', function () {
  6512. var ctx = this.context;
  6513. if ( ctx.length > 0 ) {
  6514. return ctx[0].json;
  6515. }
  6516. // else return undefined;
  6517. } );
  6518. /**
  6519. * Get the data submitted in the last Ajax request
  6520. */
  6521. _api_register( 'ajax.params()', function () {
  6522. var ctx = this.context;
  6523. if ( ctx.length > 0 ) {
  6524. return ctx[0].oAjaxData;
  6525. }
  6526. // else return undefined;
  6527. } );
  6528. /**
  6529. * Reload tables from the Ajax data source. Note that this function will
  6530. * automatically re-draw the table when the remote data has been loaded.
  6531. *
  6532. * @param {boolean} [reset=true] Reset (default) or hold the current paging
  6533. * position. A full re-sort and re-filter is performed when this method is
  6534. * called, which is why the pagination reset is the default action.
  6535. * @returns {DataTables.Api} this
  6536. */
  6537. _api_register( 'ajax.reload()', function ( callback, resetPaging ) {
  6538. return this.iterator( 'table', function (settings) {
  6539. __reload( settings, resetPaging===false, callback );
  6540. } );
  6541. } );
  6542. /**
  6543. * Get the current Ajax URL. Note that this returns the URL from the first
  6544. * table in the current context.
  6545. *
  6546. * @return {string} Current Ajax source URL
  6547. *//**
  6548. * Set the Ajax URL. Note that this will set the URL for all tables in the
  6549. * current context.
  6550. *
  6551. * @param {string} url URL to set.
  6552. * @returns {DataTables.Api} this
  6553. */
  6554. _api_register( 'ajax.url()', function ( url ) {
  6555. var ctx = this.context;
  6556. if ( url === undefined ) {
  6557. // get
  6558. if ( ctx.length === 0 ) {
  6559. return undefined;
  6560. }
  6561. ctx = ctx[0];
  6562. return ctx.ajax ?
  6563. $.isPlainObject( ctx.ajax ) ?
  6564. ctx.ajax.url :
  6565. ctx.ajax :
  6566. ctx.sAjaxSource;
  6567. }
  6568. // set
  6569. return this.iterator( 'table', function ( settings ) {
  6570. if ( $.isPlainObject( settings.ajax ) ) {
  6571. settings.ajax.url = url;
  6572. }
  6573. else {
  6574. settings.ajax = url;
  6575. }
  6576. // No need to consider sAjaxSource here since DataTables gives priority
  6577. // to `ajax` over `sAjaxSource`. So setting `ajax` here, renders any
  6578. // value of `sAjaxSource` redundant.
  6579. } );
  6580. } );
  6581. /**
  6582. * Load data from the newly set Ajax URL. Note that this method is only
  6583. * available when `ajax.url()` is used to set a URL. Additionally, this method
  6584. * has the same effect as calling `ajax.reload()` but is provided for
  6585. * convenience when setting a new URL. Like `ajax.reload()` it will
  6586. * automatically redraw the table once the remote data has been loaded.
  6587. *
  6588. * @returns {DataTables.Api} this
  6589. */
  6590. _api_register( 'ajax.url().load()', function ( callback, resetPaging ) {
  6591. // Same as a reload, but makes sense to present it for easy access after a
  6592. // url change
  6593. return this.iterator( 'table', function ( ctx ) {
  6594. __reload( ctx, resetPaging===false, callback );
  6595. } );
  6596. } );
  6597. var _selector_run = function ( type, selector, selectFn, settings, opts )
  6598. {
  6599. var
  6600. out = [], res,
  6601. a, i, ien, j, jen,
  6602. selectorType = typeof selector;
  6603. // Can't just check for isArray here, as an API or jQuery instance might be
  6604. // given with their array like look
  6605. if ( ! selector || selectorType === 'string' || selectorType === 'function' || selector.length === undefined ) {
  6606. selector = [ selector ];
  6607. }
  6608. for ( i=0, ien=selector.length ; i<ien ; i++ ) {
  6609. // Only split on simple strings - complex expressions will be jQuery selectors
  6610. a = selector[i] && selector[i].split && ! selector[i].match(/[\[\(:]/) ?
  6611. selector[i].split(',') :
  6612. [ selector[i] ];
  6613. for ( j=0, jen=a.length ; j<jen ; j++ ) {
  6614. res = selectFn( typeof a[j] === 'string' ? $.trim(a[j]) : a[j] );
  6615. if ( res && res.length ) {
  6616. out = out.concat( res );
  6617. }
  6618. }
  6619. }
  6620. // selector extensions
  6621. var ext = _ext.selector[ type ];
  6622. if ( ext.length ) {
  6623. for ( i=0, ien=ext.length ; i<ien ; i++ ) {
  6624. out = ext[i]( settings, opts, out );
  6625. }
  6626. }
  6627. return _unique( out );
  6628. };
  6629. var _selector_opts = function ( opts )
  6630. {
  6631. if ( ! opts ) {
  6632. opts = {};
  6633. }
  6634. // Backwards compatibility for 1.9- which used the terminology filter rather
  6635. // than search
  6636. if ( opts.filter && opts.search === undefined ) {
  6637. opts.search = opts.filter;
  6638. }
  6639. return $.extend( {
  6640. search: 'none',
  6641. order: 'current',
  6642. page: 'all'
  6643. }, opts );
  6644. };
  6645. var _selector_first = function ( inst )
  6646. {
  6647. // Reduce the API instance to the first item found
  6648. for ( var i=0, ien=inst.length ; i<ien ; i++ ) {
  6649. if ( inst[i].length > 0 ) {
  6650. // Assign the first element to the first item in the instance
  6651. // and truncate the instance and context
  6652. inst[0] = inst[i];
  6653. inst[0].length = 1;
  6654. inst.length = 1;
  6655. inst.context = [ inst.context[i] ];
  6656. return inst;
  6657. }
  6658. }
  6659. // Not found - return an empty instance
  6660. inst.length = 0;
  6661. return inst;
  6662. };
  6663. var _selector_row_indexes = function ( settings, opts )
  6664. {
  6665. var
  6666. i, ien, tmp, a=[],
  6667. displayFiltered = settings.aiDisplay,
  6668. displayMaster = settings.aiDisplayMaster;
  6669. var
  6670. search = opts.search, // none, applied, removed
  6671. order = opts.order, // applied, current, index (original - compatibility with 1.9)
  6672. page = opts.page; // all, current
  6673. if ( _fnDataSource( settings ) == 'ssp' ) {
  6674. // In server-side processing mode, most options are irrelevant since
  6675. // rows not shown don't exist and the index order is the applied order
  6676. // Removed is a special case - for consistency just return an empty
  6677. // array
  6678. return search === 'removed' ?
  6679. [] :
  6680. _range( 0, displayMaster.length );
  6681. }
  6682. else if ( page == 'current' ) {
  6683. // Current page implies that order=current and fitler=applied, since it is
  6684. // fairly senseless otherwise, regardless of what order and search actually
  6685. // are
  6686. for ( i=settings._iDisplayStart, ien=settings.fnDisplayEnd() ; i<ien ; i++ ) {
  6687. a.push( displayFiltered[i] );
  6688. }
  6689. }
  6690. else if ( order == 'current' || order == 'applied' ) {
  6691. if ( search == 'none') {
  6692. a = displayMaster.slice();
  6693. }
  6694. else if ( search == 'applied' ) {
  6695. a = displayFiltered.slice();
  6696. }
  6697. else if ( search == 'removed' ) {
  6698. // O(n+m) solution by creating a hash map
  6699. var displayFilteredMap = {};
  6700. for ( var i=0, ien=displayFiltered.length ; i<ien ; i++ ) {
  6701. displayFilteredMap[displayFiltered[i]] = null;
  6702. }
  6703. a = $.map( displayMaster, function (el) {
  6704. return ! displayFilteredMap.hasOwnProperty(el) ?
  6705. el :
  6706. null;
  6707. } );
  6708. }
  6709. }
  6710. else if ( order == 'index' || order == 'original' ) {
  6711. for ( i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  6712. if ( search == 'none' ) {
  6713. a.push( i );
  6714. }
  6715. else { // applied | removed
  6716. tmp = $.inArray( i, displayFiltered );
  6717. if ((tmp === -1 && search == 'removed') ||
  6718. (tmp >= 0 && search == 'applied') )
  6719. {
  6720. a.push( i );
  6721. }
  6722. }
  6723. }
  6724. }
  6725. return a;
  6726. };
  6727. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  6728. * Rows
  6729. *
  6730. * {} - no selector - use all available rows
  6731. * {integer} - row aoData index
  6732. * {node} - TR node
  6733. * {string} - jQuery selector to apply to the TR elements
  6734. * {array} - jQuery array of nodes, or simply an array of TR nodes
  6735. *
  6736. */
  6737. var __row_selector = function ( settings, selector, opts )
  6738. {
  6739. var rows;
  6740. var run = function ( sel ) {
  6741. var selInt = _intVal( sel );
  6742. var i, ien;
  6743. var aoData = settings.aoData;
  6744. // Short cut - selector is a number and no options provided (default is
  6745. // all records, so no need to check if the index is in there, since it
  6746. // must be - dev error if the index doesn't exist).
  6747. if ( selInt !== null && ! opts ) {
  6748. return [ selInt ];
  6749. }
  6750. if ( ! rows ) {
  6751. rows = _selector_row_indexes( settings, opts );
  6752. }
  6753. if ( selInt !== null && $.inArray( selInt, rows ) !== -1 ) {
  6754. // Selector - integer
  6755. return [ selInt ];
  6756. }
  6757. else if ( sel === null || sel === undefined || sel === '' ) {
  6758. // Selector - none
  6759. return rows;
  6760. }
  6761. // Selector - function
  6762. if ( typeof sel === 'function' ) {
  6763. return $.map( rows, function (idx) {
  6764. var row = aoData[ idx ];
  6765. return sel( idx, row._aData, row.nTr ) ? idx : null;
  6766. } );
  6767. }
  6768. // Selector - node
  6769. if ( sel.nodeName ) {
  6770. var rowIdx = sel._DT_RowIndex; // Property added by DT for fast lookup
  6771. var cellIdx = sel._DT_CellIndex;
  6772. if ( rowIdx !== undefined ) {
  6773. // Make sure that the row is actually still present in the table
  6774. return aoData[ rowIdx ] && aoData[ rowIdx ].nTr === sel ?
  6775. [ rowIdx ] :
  6776. [];
  6777. }
  6778. else if ( cellIdx ) {
  6779. return aoData[ cellIdx.row ] && aoData[ cellIdx.row ].nTr === sel ?
  6780. [ cellIdx.row ] :
  6781. [];
  6782. }
  6783. else {
  6784. var host = $(sel).closest('*[data-dt-row]');
  6785. return host.length ?
  6786. [ host.data('dt-row') ] :
  6787. [];
  6788. }
  6789. }
  6790. // ID selector. Want to always be able to select rows by id, regardless
  6791. // of if the tr element has been created or not, so can't rely upon
  6792. // jQuery here - hence a custom implementation. This does not match
  6793. // Sizzle's fast selector or HTML4 - in HTML5 the ID can be anything,
  6794. // but to select it using a CSS selector engine (like Sizzle or
  6795. // querySelect) it would need to need to be escaped for some characters.
  6796. // DataTables simplifies this for row selectors since you can select
  6797. // only a row. A # indicates an id any anything that follows is the id -
  6798. // unescaped.
  6799. if ( typeof sel === 'string' && sel.charAt(0) === '#' ) {
  6800. // get row index from id
  6801. var rowObj = settings.aIds[ sel.replace( /^#/, '' ) ];
  6802. if ( rowObj !== undefined ) {
  6803. return [ rowObj.idx ];
  6804. }
  6805. // need to fall through to jQuery in case there is DOM id that
  6806. // matches
  6807. }
  6808. // Get nodes in the order from the `rows` array with null values removed
  6809. var nodes = _removeEmpty(
  6810. _pluck_order( settings.aoData, rows, 'nTr' )
  6811. );
  6812. // Selector - jQuery selector string, array of nodes or jQuery object/
  6813. // As jQuery's .filter() allows jQuery objects to be passed in filter,
  6814. // it also allows arrays, so this will cope with all three options
  6815. return $(nodes)
  6816. .filter( sel )
  6817. .map( function () {
  6818. return this._DT_RowIndex;
  6819. } )
  6820. .toArray();
  6821. };
  6822. return _selector_run( 'row', selector, run, settings, opts );
  6823. };
  6824. _api_register( 'rows()', function ( selector, opts ) {
  6825. // argument shifting
  6826. if ( selector === undefined ) {
  6827. selector = '';
  6828. }
  6829. else if ( $.isPlainObject( selector ) ) {
  6830. opts = selector;
  6831. selector = '';
  6832. }
  6833. opts = _selector_opts( opts );
  6834. var inst = this.iterator( 'table', function ( settings ) {
  6835. return __row_selector( settings, selector, opts );
  6836. }, 1 );
  6837. // Want argument shifting here and in __row_selector?
  6838. inst.selector.rows = selector;
  6839. inst.selector.opts = opts;
  6840. return inst;
  6841. } );
  6842. _api_register( 'rows().nodes()', function () {
  6843. return this.iterator( 'row', function ( settings, row ) {
  6844. return settings.aoData[ row ].nTr || undefined;
  6845. }, 1 );
  6846. } );
  6847. _api_register( 'rows().data()', function () {
  6848. return this.iterator( true, 'rows', function ( settings, rows ) {
  6849. return _pluck_order( settings.aoData, rows, '_aData' );
  6850. }, 1 );
  6851. } );
  6852. _api_registerPlural( 'rows().cache()', 'row().cache()', function ( type ) {
  6853. return this.iterator( 'row', function ( settings, row ) {
  6854. var r = settings.aoData[ row ];
  6855. return type === 'search' ? r._aFilterData : r._aSortData;
  6856. }, 1 );
  6857. } );
  6858. _api_registerPlural( 'rows().invalidate()', 'row().invalidate()', function ( src ) {
  6859. return this.iterator( 'row', function ( settings, row ) {
  6860. _fnInvalidate( settings, row, src );
  6861. } );
  6862. } );
  6863. _api_registerPlural( 'rows().indexes()', 'row().index()', function () {
  6864. return this.iterator( 'row', function ( settings, row ) {
  6865. return row;
  6866. }, 1 );
  6867. } );
  6868. _api_registerPlural( 'rows().ids()', 'row().id()', function ( hash ) {
  6869. var a = [];
  6870. var context = this.context;
  6871. // `iterator` will drop undefined values, but in this case we want them
  6872. for ( var i=0, ien=context.length ; i<ien ; i++ ) {
  6873. for ( var j=0, jen=this[i].length ; j<jen ; j++ ) {
  6874. var id = context[i].rowIdFn( context[i].aoData[ this[i][j] ]._aData );
  6875. a.push( (hash === true ? '#' : '' )+ id );
  6876. }
  6877. }
  6878. return new _Api( context, a );
  6879. } );
  6880. _api_registerPlural( 'rows().remove()', 'row().remove()', function () {
  6881. var that = this;
  6882. this.iterator( 'row', function ( settings, row, thatIdx ) {
  6883. var data = settings.aoData;
  6884. var rowData = data[ row ];
  6885. var i, ien, j, jen;
  6886. var loopRow, loopCells;
  6887. data.splice( row, 1 );
  6888. // Update the cached indexes
  6889. for ( i=0, ien=data.length ; i<ien ; i++ ) {
  6890. loopRow = data[i];
  6891. loopCells = loopRow.anCells;
  6892. // Rows
  6893. if ( loopRow.nTr !== null ) {
  6894. loopRow.nTr._DT_RowIndex = i;
  6895. }
  6896. // Cells
  6897. if ( loopCells !== null ) {
  6898. for ( j=0, jen=loopCells.length ; j<jen ; j++ ) {
  6899. loopCells[j]._DT_CellIndex.row = i;
  6900. }
  6901. }
  6902. }
  6903. // Delete from the display arrays
  6904. _fnDeleteIndex( settings.aiDisplayMaster, row );
  6905. _fnDeleteIndex( settings.aiDisplay, row );
  6906. _fnDeleteIndex( that[ thatIdx ], row, false ); // maintain local indexes
  6907. // For server-side processing tables - subtract the deleted row from the count
  6908. if ( settings._iRecordsDisplay > 0 ) {
  6909. settings._iRecordsDisplay--;
  6910. }
  6911. // Check for an 'overflow' they case for displaying the table
  6912. _fnLengthOverflow( settings );
  6913. // Remove the row's ID reference if there is one
  6914. var id = settings.rowIdFn( rowData._aData );
  6915. if ( id !== undefined ) {
  6916. delete settings.aIds[ id ];
  6917. }
  6918. } );
  6919. this.iterator( 'table', function ( settings ) {
  6920. for ( var i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  6921. settings.aoData[i].idx = i;
  6922. }
  6923. } );
  6924. return this;
  6925. } );
  6926. _api_register( 'rows.add()', function ( rows ) {
  6927. var newRows = this.iterator( 'table', function ( settings ) {
  6928. var row, i, ien;
  6929. var out = [];
  6930. for ( i=0, ien=rows.length ; i<ien ; i++ ) {
  6931. row = rows[i];
  6932. if ( row.nodeName && row.nodeName.toUpperCase() === 'TR' ) {
  6933. out.push( _fnAddTr( settings, row )[0] );
  6934. }
  6935. else {
  6936. out.push( _fnAddData( settings, row ) );
  6937. }
  6938. }
  6939. return out;
  6940. }, 1 );
  6941. // Return an Api.rows() extended instance, so rows().nodes() etc can be used
  6942. var modRows = this.rows( -1 );
  6943. modRows.pop();
  6944. $.merge( modRows, newRows );
  6945. return modRows;
  6946. } );
  6947. /**
  6948. *
  6949. */
  6950. _api_register( 'row()', function ( selector, opts ) {
  6951. return _selector_first( this.rows( selector, opts ) );
  6952. } );
  6953. _api_register( 'row().data()', function ( data ) {
  6954. var ctx = this.context;
  6955. if ( data === undefined ) {
  6956. // Get
  6957. return ctx.length && this.length ?
  6958. ctx[0].aoData[ this[0] ]._aData :
  6959. undefined;
  6960. }
  6961. // Set
  6962. var row = ctx[0].aoData[ this[0] ];
  6963. row._aData = data;
  6964. // If the DOM has an id, and the data source is an array
  6965. if ( $.isArray( data ) && row.nTr.id ) {
  6966. _fnSetObjectDataFn( ctx[0].rowId )( data, row.nTr.id );
  6967. }
  6968. // Automatically invalidate
  6969. _fnInvalidate( ctx[0], this[0], 'data' );
  6970. return this;
  6971. } );
  6972. _api_register( 'row().node()', function () {
  6973. var ctx = this.context;
  6974. return ctx.length && this.length ?
  6975. ctx[0].aoData[ this[0] ].nTr || null :
  6976. null;
  6977. } );
  6978. _api_register( 'row.add()', function ( row ) {
  6979. // Allow a jQuery object to be passed in - only a single row is added from
  6980. // it though - the first element in the set
  6981. if ( row instanceof $ && row.length ) {
  6982. row = row[0];
  6983. }
  6984. var rows = this.iterator( 'table', function ( settings ) {
  6985. if ( row.nodeName && row.nodeName.toUpperCase() === 'TR' ) {
  6986. return _fnAddTr( settings, row )[0];
  6987. }
  6988. return _fnAddData( settings, row );
  6989. } );
  6990. // Return an Api.rows() extended instance, with the newly added row selected
  6991. return this.row( rows[0] );
  6992. } );
  6993. var __details_add = function ( ctx, row, data, klass )
  6994. {
  6995. // Convert to array of TR elements
  6996. var rows = [];
  6997. var addRow = function ( r, k ) {
  6998. // Recursion to allow for arrays of jQuery objects
  6999. if ( $.isArray( r ) || r instanceof $ ) {
  7000. for ( var i=0, ien=r.length ; i<ien ; i++ ) {
  7001. addRow( r[i], k );
  7002. }
  7003. return;
  7004. }
  7005. // If we get a TR element, then just add it directly - up to the dev
  7006. // to add the correct number of columns etc
  7007. if ( r.nodeName && r.nodeName.toLowerCase() === 'tr' ) {
  7008. rows.push( r );
  7009. }
  7010. else {
  7011. // Otherwise create a row with a wrapper
  7012. var created = $('<tr><td/></tr>').addClass( k );
  7013. $('td', created)
  7014. .addClass( k )
  7015. .html( r )
  7016. [0].colSpan = _fnVisbleColumns( ctx );
  7017. rows.push( created[0] );
  7018. }
  7019. };
  7020. addRow( data, klass );
  7021. if ( row._details ) {
  7022. row._details.detach();
  7023. }
  7024. row._details = $(rows);
  7025. // If the children were already shown, that state should be retained
  7026. if ( row._detailsShow ) {
  7027. row._details.insertAfter( row.nTr );
  7028. }
  7029. };
  7030. var __details_remove = function ( api, idx )
  7031. {
  7032. var ctx = api.context;
  7033. if ( ctx.length ) {
  7034. var row = ctx[0].aoData[ idx !== undefined ? idx : api[0] ];
  7035. if ( row && row._details ) {
  7036. row._details.remove();
  7037. row._detailsShow = undefined;
  7038. row._details = undefined;
  7039. }
  7040. }
  7041. };
  7042. var __details_display = function ( api, show ) {
  7043. var ctx = api.context;
  7044. if ( ctx.length && api.length ) {
  7045. var row = ctx[0].aoData[ api[0] ];
  7046. if ( row._details ) {
  7047. row._detailsShow = show;
  7048. if ( show ) {
  7049. row._details.insertAfter( row.nTr );
  7050. }
  7051. else {
  7052. row._details.detach();
  7053. }
  7054. __details_events( ctx[0] );
  7055. }
  7056. }
  7057. };
  7058. var __details_events = function ( settings )
  7059. {
  7060. var api = new _Api( settings );
  7061. var namespace = '.dt.DT_details';
  7062. var drawEvent = 'draw'+namespace;
  7063. var colvisEvent = 'column-visibility'+namespace;
  7064. var destroyEvent = 'destroy'+namespace;
  7065. var data = settings.aoData;
  7066. api.off( drawEvent +' '+ colvisEvent +' '+ destroyEvent );
  7067. if ( _pluck( data, '_details' ).length > 0 ) {
  7068. // On each draw, insert the required elements into the document
  7069. api.on( drawEvent, function ( e, ctx ) {
  7070. if ( settings !== ctx ) {
  7071. return;
  7072. }
  7073. api.rows( {page:'current'} ).eq(0).each( function (idx) {
  7074. // Internal data grab
  7075. var row = data[ idx ];
  7076. if ( row._detailsShow ) {
  7077. row._details.insertAfter( row.nTr );
  7078. }
  7079. } );
  7080. } );
  7081. // Column visibility change - update the colspan
  7082. api.on( colvisEvent, function ( e, ctx, idx, vis ) {
  7083. if ( settings !== ctx ) {
  7084. return;
  7085. }
  7086. // Update the colspan for the details rows (note, only if it already has
  7087. // a colspan)
  7088. var row, visible = _fnVisbleColumns( ctx );
  7089. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  7090. row = data[i];
  7091. if ( row._details ) {
  7092. row._details.children('td[colspan]').attr('colspan', visible );
  7093. }
  7094. }
  7095. } );
  7096. // Table destroyed - nuke any child rows
  7097. api.on( destroyEvent, function ( e, ctx ) {
  7098. if ( settings !== ctx ) {
  7099. return;
  7100. }
  7101. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  7102. if ( data[i]._details ) {
  7103. __details_remove( api, i );
  7104. }
  7105. }
  7106. } );
  7107. }
  7108. };
  7109. // Strings for the method names to help minification
  7110. var _emp = '';
  7111. var _child_obj = _emp+'row().child';
  7112. var _child_mth = _child_obj+'()';
  7113. // data can be:
  7114. // tr
  7115. // string
  7116. // jQuery or array of any of the above
  7117. _api_register( _child_mth, function ( data, klass ) {
  7118. var ctx = this.context;
  7119. if ( data === undefined ) {
  7120. // get
  7121. return ctx.length && this.length ?
  7122. ctx[0].aoData[ this[0] ]._details :
  7123. undefined;
  7124. }
  7125. else if ( data === true ) {
  7126. // show
  7127. this.child.show();
  7128. }
  7129. else if ( data === false ) {
  7130. // remove
  7131. __details_remove( this );
  7132. }
  7133. else if ( ctx.length && this.length ) {
  7134. // set
  7135. __details_add( ctx[0], ctx[0].aoData[ this[0] ], data, klass );
  7136. }
  7137. return this;
  7138. } );
  7139. _api_register( [
  7140. _child_obj+'.show()',
  7141. _child_mth+'.show()' // only when `child()` was called with parameters (without
  7142. ], function ( show ) { // it returns an object and this method is not executed)
  7143. __details_display( this, true );
  7144. return this;
  7145. } );
  7146. _api_register( [
  7147. _child_obj+'.hide()',
  7148. _child_mth+'.hide()' // only when `child()` was called with parameters (without
  7149. ], function () { // it returns an object and this method is not executed)
  7150. __details_display( this, false );
  7151. return this;
  7152. } );
  7153. _api_register( [
  7154. _child_obj+'.remove()',
  7155. _child_mth+'.remove()' // only when `child()` was called with parameters (without
  7156. ], function () { // it returns an object and this method is not executed)
  7157. __details_remove( this );
  7158. return this;
  7159. } );
  7160. _api_register( _child_obj+'.isShown()', function () {
  7161. var ctx = this.context;
  7162. if ( ctx.length && this.length ) {
  7163. // _detailsShown as false or undefined will fall through to return false
  7164. return ctx[0].aoData[ this[0] ]._detailsShow || false;
  7165. }
  7166. return false;
  7167. } );
  7168. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  7169. * Columns
  7170. *
  7171. * {integer} - column index (>=0 count from left, <0 count from right)
  7172. * "{integer}:visIdx" - visible column index (i.e. translate to column index) (>=0 count from left, <0 count from right)
  7173. * "{integer}:visible" - alias for {integer}:visIdx (>=0 count from left, <0 count from right)
  7174. * "{string}:name" - column name
  7175. * "{string}" - jQuery selector on column header nodes
  7176. *
  7177. */
  7178. // can be an array of these items, comma separated list, or an array of comma
  7179. // separated lists
  7180. var __re_column_selector = /^([^:]+):(name|visIdx|visible)$/;
  7181. // r1 and r2 are redundant - but it means that the parameters match for the
  7182. // iterator callback in columns().data()
  7183. var __columnData = function ( settings, column, r1, r2, rows ) {
  7184. var a = [];
  7185. for ( var row=0, ien=rows.length ; row<ien ; row++ ) {
  7186. a.push( _fnGetCellData( settings, rows[row], column ) );
  7187. }
  7188. return a;
  7189. };
  7190. var __column_selector = function ( settings, selector, opts )
  7191. {
  7192. var
  7193. columns = settings.aoColumns,
  7194. names = _pluck( columns, 'sName' ),
  7195. nodes = _pluck( columns, 'nTh' );
  7196. var run = function ( s ) {
  7197. var selInt = _intVal( s );
  7198. // Selector - all
  7199. if ( s === '' ) {
  7200. return _range( columns.length );
  7201. }
  7202. // Selector - index
  7203. if ( selInt !== null ) {
  7204. return [ selInt >= 0 ?
  7205. selInt : // Count from left
  7206. columns.length + selInt // Count from right (+ because its a negative value)
  7207. ];
  7208. }
  7209. // Selector = function
  7210. if ( typeof s === 'function' ) {
  7211. var rows = _selector_row_indexes( settings, opts );
  7212. return $.map( columns, function (col, idx) {
  7213. return s(
  7214. idx,
  7215. __columnData( settings, idx, 0, 0, rows ),
  7216. nodes[ idx ]
  7217. ) ? idx : null;
  7218. } );
  7219. }
  7220. // jQuery or string selector
  7221. var match = typeof s === 'string' ?
  7222. s.match( __re_column_selector ) :
  7223. '';
  7224. if ( match ) {
  7225. switch( match[2] ) {
  7226. case 'visIdx':
  7227. case 'visible':
  7228. var idx = parseInt( match[1], 10 );
  7229. // Visible index given, convert to column index
  7230. if ( idx < 0 ) {
  7231. // Counting from the right
  7232. var visColumns = $.map( columns, function (col,i) {
  7233. return col.bVisible ? i : null;
  7234. } );
  7235. return [ visColumns[ visColumns.length + idx ] ];
  7236. }
  7237. // Counting from the left
  7238. return [ _fnVisibleToColumnIndex( settings, idx ) ];
  7239. case 'name':
  7240. // match by name. `names` is column index complete and in order
  7241. return $.map( names, function (name, i) {
  7242. return name === match[1] ? i : null;
  7243. } );
  7244. default:
  7245. return [];
  7246. }
  7247. }
  7248. // Cell in the table body
  7249. if ( s.nodeName && s._DT_CellIndex ) {
  7250. return [ s._DT_CellIndex.column ];
  7251. }
  7252. // jQuery selector on the TH elements for the columns
  7253. var jqResult = $( nodes )
  7254. .filter( s )
  7255. .map( function () {
  7256. return $.inArray( this, nodes ); // `nodes` is column index complete and in order
  7257. } )
  7258. .toArray();
  7259. if ( jqResult.length || ! s.nodeName ) {
  7260. return jqResult;
  7261. }
  7262. // Otherwise a node which might have a `dt-column` data attribute, or be
  7263. // a child or such an element
  7264. var host = $(s).closest('*[data-dt-column]');
  7265. return host.length ?
  7266. [ host.data('dt-column') ] :
  7267. [];
  7268. };
  7269. return _selector_run( 'column', selector, run, settings, opts );
  7270. };
  7271. var __setColumnVis = function ( settings, column, vis ) {
  7272. var
  7273. cols = settings.aoColumns,
  7274. col = cols[ column ],
  7275. data = settings.aoData,
  7276. row, cells, i, ien, tr;
  7277. // Get
  7278. if ( vis === undefined ) {
  7279. return col.bVisible;
  7280. }
  7281. // Set
  7282. // No change
  7283. if ( col.bVisible === vis ) {
  7284. return;
  7285. }
  7286. if ( vis ) {
  7287. // Insert column
  7288. // Need to decide if we should use appendChild or insertBefore
  7289. var insertBefore = $.inArray( true, _pluck(cols, 'bVisible'), column+1 );
  7290. for ( i=0, ien=data.length ; i<ien ; i++ ) {
  7291. tr = data[i].nTr;
  7292. cells = data[i].anCells;
  7293. if ( tr ) {
  7294. // insertBefore can act like appendChild if 2nd arg is null
  7295. tr.insertBefore( cells[ column ], cells[ insertBefore ] || null );
  7296. }
  7297. }
  7298. }
  7299. else {
  7300. // Remove column
  7301. $( _pluck( settings.aoData, 'anCells', column ) ).detach();
  7302. }
  7303. // Common actions
  7304. col.bVisible = vis;
  7305. _fnDrawHead( settings, settings.aoHeader );
  7306. _fnDrawHead( settings, settings.aoFooter );
  7307. // Update colspan for no records display. Child rows and extensions will use their own
  7308. // listeners to do this - only need to update the empty table item here
  7309. if ( ! settings.aiDisplay.length ) {
  7310. $(settings.nTBody).find('td[colspan]').attr('colspan', _fnVisbleColumns(settings));
  7311. }
  7312. _fnSaveState( settings );
  7313. };
  7314. _api_register( 'columns()', function ( selector, opts ) {
  7315. // argument shifting
  7316. if ( selector === undefined ) {
  7317. selector = '';
  7318. }
  7319. else if ( $.isPlainObject( selector ) ) {
  7320. opts = selector;
  7321. selector = '';
  7322. }
  7323. opts = _selector_opts( opts );
  7324. var inst = this.iterator( 'table', function ( settings ) {
  7325. return __column_selector( settings, selector, opts );
  7326. }, 1 );
  7327. // Want argument shifting here and in _row_selector?
  7328. inst.selector.cols = selector;
  7329. inst.selector.opts = opts;
  7330. return inst;
  7331. } );
  7332. _api_registerPlural( 'columns().header()', 'column().header()', function ( selector, opts ) {
  7333. return this.iterator( 'column', function ( settings, column ) {
  7334. return settings.aoColumns[column].nTh;
  7335. }, 1 );
  7336. } );
  7337. _api_registerPlural( 'columns().footer()', 'column().footer()', function ( selector, opts ) {
  7338. return this.iterator( 'column', function ( settings, column ) {
  7339. return settings.aoColumns[column].nTf;
  7340. }, 1 );
  7341. } );
  7342. _api_registerPlural( 'columns().data()', 'column().data()', function () {
  7343. return this.iterator( 'column-rows', __columnData, 1 );
  7344. } );
  7345. _api_registerPlural( 'columns().dataSrc()', 'column().dataSrc()', function () {
  7346. return this.iterator( 'column', function ( settings, column ) {
  7347. return settings.aoColumns[column].mData;
  7348. }, 1 );
  7349. } );
  7350. _api_registerPlural( 'columns().cache()', 'column().cache()', function ( type ) {
  7351. return this.iterator( 'column-rows', function ( settings, column, i, j, rows ) {
  7352. return _pluck_order( settings.aoData, rows,
  7353. type === 'search' ? '_aFilterData' : '_aSortData', column
  7354. );
  7355. }, 1 );
  7356. } );
  7357. _api_registerPlural( 'columns().nodes()', 'column().nodes()', function () {
  7358. return this.iterator( 'column-rows', function ( settings, column, i, j, rows ) {
  7359. return _pluck_order( settings.aoData, rows, 'anCells', column ) ;
  7360. }, 1 );
  7361. } );
  7362. _api_registerPlural( 'columns().visible()', 'column().visible()', function ( vis, calc ) {
  7363. var ret = this.iterator( 'column', function ( settings, column ) {
  7364. if ( vis === undefined ) {
  7365. return settings.aoColumns[ column ].bVisible;
  7366. } // else
  7367. __setColumnVis( settings, column, vis );
  7368. } );
  7369. // Group the column visibility changes
  7370. if ( vis !== undefined ) {
  7371. // Second loop once the first is done for events
  7372. this.iterator( 'column', function ( settings, column ) {
  7373. _fnCallbackFire( settings, null, 'column-visibility', [settings, column, vis, calc] );
  7374. } );
  7375. if ( calc === undefined || calc ) {
  7376. this.columns.adjust();
  7377. }
  7378. }
  7379. return ret;
  7380. } );
  7381. _api_registerPlural( 'columns().indexes()', 'column().index()', function ( type ) {
  7382. return this.iterator( 'column', function ( settings, column ) {
  7383. return type === 'visible' ?
  7384. _fnColumnIndexToVisible( settings, column ) :
  7385. column;
  7386. }, 1 );
  7387. } );
  7388. _api_register( 'columns.adjust()', function () {
  7389. return this.iterator( 'table', function ( settings ) {
  7390. _fnAdjustColumnSizing( settings );
  7391. }, 1 );
  7392. } );
  7393. _api_register( 'column.index()', function ( type, idx ) {
  7394. if ( this.context.length !== 0 ) {
  7395. var ctx = this.context[0];
  7396. if ( type === 'fromVisible' || type === 'toData' ) {
  7397. return _fnVisibleToColumnIndex( ctx, idx );
  7398. }
  7399. else if ( type === 'fromData' || type === 'toVisible' ) {
  7400. return _fnColumnIndexToVisible( ctx, idx );
  7401. }
  7402. }
  7403. } );
  7404. _api_register( 'column()', function ( selector, opts ) {
  7405. return _selector_first( this.columns( selector, opts ) );
  7406. } );
  7407. var __cell_selector = function ( settings, selector, opts )
  7408. {
  7409. var data = settings.aoData;
  7410. var rows = _selector_row_indexes( settings, opts );
  7411. var cells = _removeEmpty( _pluck_order( data, rows, 'anCells' ) );
  7412. var allCells = $( [].concat.apply([], cells) );
  7413. var row;
  7414. var columns = settings.aoColumns.length;
  7415. var a, i, ien, j, o, host;
  7416. var run = function ( s ) {
  7417. var fnSelector = typeof s === 'function';
  7418. if ( s === null || s === undefined || fnSelector ) {
  7419. // All cells and function selectors
  7420. a = [];
  7421. for ( i=0, ien=rows.length ; i<ien ; i++ ) {
  7422. row = rows[i];
  7423. for ( j=0 ; j<columns ; j++ ) {
  7424. o = {
  7425. row: row,
  7426. column: j
  7427. };
  7428. if ( fnSelector ) {
  7429. // Selector - function
  7430. host = data[ row ];
  7431. if ( s( o, _fnGetCellData(settings, row, j), host.anCells ? host.anCells[j] : null ) ) {
  7432. a.push( o );
  7433. }
  7434. }
  7435. else {
  7436. // Selector - all
  7437. a.push( o );
  7438. }
  7439. }
  7440. }
  7441. return a;
  7442. }
  7443. // Selector - index
  7444. if ( $.isPlainObject( s ) ) {
  7445. // Valid cell index and its in the array of selectable rows
  7446. return s.column !== undefined && s.row !== undefined && $.inArray( s.row, rows ) !== -1 ?
  7447. [s] :
  7448. [];
  7449. }
  7450. // Selector - jQuery filtered cells
  7451. var jqResult = allCells
  7452. .filter( s )
  7453. .map( function (i, el) {
  7454. return { // use a new object, in case someone changes the values
  7455. row: el._DT_CellIndex.row,
  7456. column: el._DT_CellIndex.column
  7457. };
  7458. } )
  7459. .toArray();
  7460. if ( jqResult.length || ! s.nodeName ) {
  7461. return jqResult;
  7462. }
  7463. // Otherwise the selector is a node, and there is one last option - the
  7464. // element might be a child of an element which has dt-row and dt-column
  7465. // data attributes
  7466. host = $(s).closest('*[data-dt-row]');
  7467. return host.length ?
  7468. [ {
  7469. row: host.data('dt-row'),
  7470. column: host.data('dt-column')
  7471. } ] :
  7472. [];
  7473. };
  7474. return _selector_run( 'cell', selector, run, settings, opts );
  7475. };
  7476. _api_register( 'cells()', function ( rowSelector, columnSelector, opts ) {
  7477. // Argument shifting
  7478. if ( $.isPlainObject( rowSelector ) ) {
  7479. // Indexes
  7480. if ( rowSelector.row === undefined ) {
  7481. // Selector options in first parameter
  7482. opts = rowSelector;
  7483. rowSelector = null;
  7484. }
  7485. else {
  7486. // Cell index objects in first parameter
  7487. opts = columnSelector;
  7488. columnSelector = null;
  7489. }
  7490. }
  7491. if ( $.isPlainObject( columnSelector ) ) {
  7492. opts = columnSelector;
  7493. columnSelector = null;
  7494. }
  7495. // Cell selector
  7496. if ( columnSelector === null || columnSelector === undefined ) {
  7497. return this.iterator( 'table', function ( settings ) {
  7498. return __cell_selector( settings, rowSelector, _selector_opts( opts ) );
  7499. } );
  7500. }
  7501. // Row + column selector
  7502. var columns = this.columns( columnSelector );
  7503. var rows = this.rows( rowSelector );
  7504. var a, i, ien, j, jen;
  7505. this.iterator( 'table', function ( settings, idx ) {
  7506. a = [];
  7507. for ( i=0, ien=rows[idx].length ; i<ien ; i++ ) {
  7508. for ( j=0, jen=columns[idx].length ; j<jen ; j++ ) {
  7509. a.push( {
  7510. row: rows[idx][i],
  7511. column: columns[idx][j]
  7512. } );
  7513. }
  7514. }
  7515. }, 1 );
  7516. // Now pass through the cell selector for options
  7517. var cells = this.cells( a, opts );
  7518. $.extend( cells.selector, {
  7519. cols: columnSelector,
  7520. rows: rowSelector,
  7521. opts: opts
  7522. } );
  7523. return cells;
  7524. } );
  7525. _api_registerPlural( 'cells().nodes()', 'cell().node()', function () {
  7526. return this.iterator( 'cell', function ( settings, row, column ) {
  7527. var data = settings.aoData[ row ];
  7528. return data && data.anCells ?
  7529. data.anCells[ column ] :
  7530. undefined;
  7531. }, 1 );
  7532. } );
  7533. _api_register( 'cells().data()', function () {
  7534. return this.iterator( 'cell', function ( settings, row, column ) {
  7535. return _fnGetCellData( settings, row, column );
  7536. }, 1 );
  7537. } );
  7538. _api_registerPlural( 'cells().cache()', 'cell().cache()', function ( type ) {
  7539. type = type === 'search' ? '_aFilterData' : '_aSortData';
  7540. return this.iterator( 'cell', function ( settings, row, column ) {
  7541. return settings.aoData[ row ][ type ][ column ];
  7542. }, 1 );
  7543. } );
  7544. _api_registerPlural( 'cells().render()', 'cell().render()', function ( type ) {
  7545. return this.iterator( 'cell', function ( settings, row, column ) {
  7546. return _fnGetCellData( settings, row, column, type );
  7547. }, 1 );
  7548. } );
  7549. _api_registerPlural( 'cells().indexes()', 'cell().index()', function () {
  7550. return this.iterator( 'cell', function ( settings, row, column ) {
  7551. return {
  7552. row: row,
  7553. column: column,
  7554. columnVisible: _fnColumnIndexToVisible( settings, column )
  7555. };
  7556. }, 1 );
  7557. } );
  7558. _api_registerPlural( 'cells().invalidate()', 'cell().invalidate()', function ( src ) {
  7559. return this.iterator( 'cell', function ( settings, row, column ) {
  7560. _fnInvalidate( settings, row, src, column );
  7561. } );
  7562. } );
  7563. _api_register( 'cell()', function ( rowSelector, columnSelector, opts ) {
  7564. return _selector_first( this.cells( rowSelector, columnSelector, opts ) );
  7565. } );
  7566. _api_register( 'cell().data()', function ( data ) {
  7567. var ctx = this.context;
  7568. var cell = this[0];
  7569. if ( data === undefined ) {
  7570. // Get
  7571. return ctx.length && cell.length ?
  7572. _fnGetCellData( ctx[0], cell[0].row, cell[0].column ) :
  7573. undefined;
  7574. }
  7575. // Set
  7576. _fnSetCellData( ctx[0], cell[0].row, cell[0].column, data );
  7577. _fnInvalidate( ctx[0], cell[0].row, 'data', cell[0].column );
  7578. return this;
  7579. } );
  7580. /**
  7581. * Get current ordering (sorting) that has been applied to the table.
  7582. *
  7583. * @returns {array} 2D array containing the sorting information for the first
  7584. * table in the current context. Each element in the parent array represents
  7585. * a column being sorted upon (i.e. multi-sorting with two columns would have
  7586. * 2 inner arrays). The inner arrays may have 2 or 3 elements. The first is
  7587. * the column index that the sorting condition applies to, the second is the
  7588. * direction of the sort (`desc` or `asc`) and, optionally, the third is the
  7589. * index of the sorting order from the `column.sorting` initialisation array.
  7590. *//**
  7591. * Set the ordering for the table.
  7592. *
  7593. * @param {integer} order Column index to sort upon.
  7594. * @param {string} direction Direction of the sort to be applied (`asc` or `desc`)
  7595. * @returns {DataTables.Api} this
  7596. *//**
  7597. * Set the ordering for the table.
  7598. *
  7599. * @param {array} order 1D array of sorting information to be applied.
  7600. * @param {array} [...] Optional additional sorting conditions
  7601. * @returns {DataTables.Api} this
  7602. *//**
  7603. * Set the ordering for the table.
  7604. *
  7605. * @param {array} order 2D array of sorting information to be applied.
  7606. * @returns {DataTables.Api} this
  7607. */
  7608. _api_register( 'order()', function ( order, dir ) {
  7609. var ctx = this.context;
  7610. if ( order === undefined ) {
  7611. // get
  7612. return ctx.length !== 0 ?
  7613. ctx[0].aaSorting :
  7614. undefined;
  7615. }
  7616. // set
  7617. if ( typeof order === 'number' ) {
  7618. // Simple column / direction passed in
  7619. order = [ [ order, dir ] ];
  7620. }
  7621. else if ( order.length && ! $.isArray( order[0] ) ) {
  7622. // Arguments passed in (list of 1D arrays)
  7623. order = Array.prototype.slice.call( arguments );
  7624. }
  7625. // otherwise a 2D array was passed in
  7626. return this.iterator( 'table', function ( settings ) {
  7627. settings.aaSorting = order.slice();
  7628. } );
  7629. } );
  7630. /**
  7631. * Attach a sort listener to an element for a given column
  7632. *
  7633. * @param {node|jQuery|string} node Identifier for the element(s) to attach the
  7634. * listener to. This can take the form of a single DOM node, a jQuery
  7635. * collection of nodes or a jQuery selector which will identify the node(s).
  7636. * @param {integer} column the column that a click on this node will sort on
  7637. * @param {function} [callback] callback function when sort is run
  7638. * @returns {DataTables.Api} this
  7639. */
  7640. _api_register( 'order.listener()', function ( node, column, callback ) {
  7641. return this.iterator( 'table', function ( settings ) {
  7642. _fnSortAttachListener( settings, node, column, callback );
  7643. } );
  7644. } );
  7645. _api_register( 'order.fixed()', function ( set ) {
  7646. if ( ! set ) {
  7647. var ctx = this.context;
  7648. var fixed = ctx.length ?
  7649. ctx[0].aaSortingFixed :
  7650. undefined;
  7651. return $.isArray( fixed ) ?
  7652. { pre: fixed } :
  7653. fixed;
  7654. }
  7655. return this.iterator( 'table', function ( settings ) {
  7656. settings.aaSortingFixed = $.extend( true, {}, set );
  7657. } );
  7658. } );
  7659. // Order by the selected column(s)
  7660. _api_register( [
  7661. 'columns().order()',
  7662. 'column().order()'
  7663. ], function ( dir ) {
  7664. var that = this;
  7665. return this.iterator( 'table', function ( settings, i ) {
  7666. var sort = [];
  7667. $.each( that[i], function (j, col) {
  7668. sort.push( [ col, dir ] );
  7669. } );
  7670. settings.aaSorting = sort;
  7671. } );
  7672. } );
  7673. _api_register( 'search()', function ( input, regex, smart, caseInsen ) {
  7674. var ctx = this.context;
  7675. if ( input === undefined ) {
  7676. // get
  7677. return ctx.length !== 0 ?
  7678. ctx[0].oPreviousSearch.sSearch :
  7679. undefined;
  7680. }
  7681. // set
  7682. return this.iterator( 'table', function ( settings ) {
  7683. if ( ! settings.oFeatures.bFilter ) {
  7684. return;
  7685. }
  7686. _fnFilterComplete( settings, $.extend( {}, settings.oPreviousSearch, {
  7687. "sSearch": input+"",
  7688. "bRegex": regex === null ? false : regex,
  7689. "bSmart": smart === null ? true : smart,
  7690. "bCaseInsensitive": caseInsen === null ? true : caseInsen
  7691. } ), 1 );
  7692. } );
  7693. } );
  7694. _api_registerPlural(
  7695. 'columns().search()',
  7696. 'column().search()',
  7697. function ( input, regex, smart, caseInsen ) {
  7698. return this.iterator( 'column', function ( settings, column ) {
  7699. var preSearch = settings.aoPreSearchCols;
  7700. if ( input === undefined ) {
  7701. // get
  7702. return preSearch[ column ].sSearch;
  7703. }
  7704. // set
  7705. if ( ! settings.oFeatures.bFilter ) {
  7706. return;
  7707. }
  7708. $.extend( preSearch[ column ], {
  7709. "sSearch": input+"",
  7710. "bRegex": regex === null ? false : regex,
  7711. "bSmart": smart === null ? true : smart,
  7712. "bCaseInsensitive": caseInsen === null ? true : caseInsen
  7713. } );
  7714. _fnFilterComplete( settings, settings.oPreviousSearch, 1 );
  7715. } );
  7716. }
  7717. );
  7718. /*
  7719. * State API methods
  7720. */
  7721. _api_register( 'state()', function () {
  7722. return this.context.length ?
  7723. this.context[0].oSavedState :
  7724. null;
  7725. } );
  7726. _api_register( 'state.clear()', function () {
  7727. return this.iterator( 'table', function ( settings ) {
  7728. // Save an empty object
  7729. settings.fnStateSaveCallback.call( settings.oInstance, settings, {} );
  7730. } );
  7731. } );
  7732. _api_register( 'state.loaded()', function () {
  7733. return this.context.length ?
  7734. this.context[0].oLoadedState :
  7735. null;
  7736. } );
  7737. _api_register( 'state.save()', function () {
  7738. return this.iterator( 'table', function ( settings ) {
  7739. _fnSaveState( settings );
  7740. } );
  7741. } );
  7742. /**
  7743. * Provide a common method for plug-ins to check the version of DataTables being
  7744. * used, in order to ensure compatibility.
  7745. *
  7746. * @param {string} version Version string to check for, in the format "X.Y.Z".
  7747. * Note that the formats "X" and "X.Y" are also acceptable.
  7748. * @returns {boolean} true if this version of DataTables is greater or equal to
  7749. * the required version, or false if this version of DataTales is not
  7750. * suitable
  7751. * @static
  7752. * @dtopt API-Static
  7753. *
  7754. * @example
  7755. * alert( $.fn.dataTable.versionCheck( '1.9.0' ) );
  7756. */
  7757. DataTable.versionCheck = DataTable.fnVersionCheck = function( version )
  7758. {
  7759. var aThis = DataTable.version.split('.');
  7760. var aThat = version.split('.');
  7761. var iThis, iThat;
  7762. for ( var i=0, iLen=aThat.length ; i<iLen ; i++ ) {
  7763. iThis = parseInt( aThis[i], 10 ) || 0;
  7764. iThat = parseInt( aThat[i], 10 ) || 0;
  7765. // Parts are the same, keep comparing
  7766. if (iThis === iThat) {
  7767. continue;
  7768. }
  7769. // Parts are different, return immediately
  7770. return iThis > iThat;
  7771. }
  7772. return true;
  7773. };
  7774. /**
  7775. * Check if a `<table>` node is a DataTable table already or not.
  7776. *
  7777. * @param {node|jquery|string} table Table node, jQuery object or jQuery
  7778. * selector for the table to test. Note that if more than more than one
  7779. * table is passed on, only the first will be checked
  7780. * @returns {boolean} true the table given is a DataTable, or false otherwise
  7781. * @static
  7782. * @dtopt API-Static
  7783. *
  7784. * @example
  7785. * if ( ! $.fn.DataTable.isDataTable( '#example' ) ) {
  7786. * $('#example').dataTable();
  7787. * }
  7788. */
  7789. DataTable.isDataTable = DataTable.fnIsDataTable = function ( table )
  7790. {
  7791. var t = $(table).get(0);
  7792. var is = false;
  7793. if ( table instanceof DataTable.Api ) {
  7794. return true;
  7795. }
  7796. $.each( DataTable.settings, function (i, o) {
  7797. var head = o.nScrollHead ? $('table', o.nScrollHead)[0] : null;
  7798. var foot = o.nScrollFoot ? $('table', o.nScrollFoot)[0] : null;
  7799. if ( o.nTable === t || head === t || foot === t ) {
  7800. is = true;
  7801. }
  7802. } );
  7803. return is;
  7804. };
  7805. /**
  7806. * Get all DataTable tables that have been initialised - optionally you can
  7807. * select to get only currently visible tables.
  7808. *
  7809. * @param {boolean} [visible=false] Flag to indicate if you want all (default)
  7810. * or visible tables only.
  7811. * @returns {array} Array of `table` nodes (not DataTable instances) which are
  7812. * DataTables
  7813. * @static
  7814. * @dtopt API-Static
  7815. *
  7816. * @example
  7817. * $.each( $.fn.dataTable.tables(true), function () {
  7818. * $(table).DataTable().columns.adjust();
  7819. * } );
  7820. */
  7821. DataTable.tables = DataTable.fnTables = function ( visible )
  7822. {
  7823. var api = false;
  7824. if ( $.isPlainObject( visible ) ) {
  7825. api = visible.api;
  7826. visible = visible.visible;
  7827. }
  7828. var a = $.map( DataTable.settings, function (o) {
  7829. if ( !visible || (visible && $(o.nTable).is(':visible')) ) {
  7830. return o.nTable;
  7831. }
  7832. } );
  7833. return api ?
  7834. new _Api( a ) :
  7835. a;
  7836. };
  7837. /**
  7838. * Convert from camel case parameters to Hungarian notation. This is made public
  7839. * for the extensions to provide the same ability as DataTables core to accept
  7840. * either the 1.9 style Hungarian notation, or the 1.10+ style camelCase
  7841. * parameters.
  7842. *
  7843. * @param {object} src The model object which holds all parameters that can be
  7844. * mapped.
  7845. * @param {object} user The object to convert from camel case to Hungarian.
  7846. * @param {boolean} force When set to `true`, properties which already have a
  7847. * Hungarian value in the `user` object will be overwritten. Otherwise they
  7848. * won't be.
  7849. */
  7850. DataTable.camelToHungarian = _fnCamelToHungarian;
  7851. /**
  7852. *
  7853. */
  7854. _api_register( '$()', function ( selector, opts ) {
  7855. var
  7856. rows = this.rows( opts ).nodes(), // Get all rows
  7857. jqRows = $(rows);
  7858. return $( [].concat(
  7859. jqRows.filter( selector ).toArray(),
  7860. jqRows.find( selector ).toArray()
  7861. ) );
  7862. } );
  7863. // jQuery functions to operate on the tables
  7864. $.each( [ 'on', 'one', 'off' ], function (i, key) {
  7865. _api_register( key+'()', function ( /* event, handler */ ) {
  7866. var args = Array.prototype.slice.call(arguments);
  7867. // Add the `dt` namespace automatically if it isn't already present
  7868. args[0] = $.map( args[0].split( /\s/ ), function ( e ) {
  7869. return ! e.match(/\.dt\b/) ?
  7870. e+'.dt' :
  7871. e;
  7872. } ).join( ' ' );
  7873. var inst = $( this.tables().nodes() );
  7874. inst[key].apply( inst, args );
  7875. return this;
  7876. } );
  7877. } );
  7878. _api_register( 'clear()', function () {
  7879. return this.iterator( 'table', function ( settings ) {
  7880. _fnClearTable( settings );
  7881. } );
  7882. } );
  7883. _api_register( 'settings()', function () {
  7884. return new _Api( this.context, this.context );
  7885. } );
  7886. _api_register( 'init()', function () {
  7887. var ctx = this.context;
  7888. return ctx.length ? ctx[0].oInit : null;
  7889. } );
  7890. _api_register( 'data()', function () {
  7891. return this.iterator( 'table', function ( settings ) {
  7892. return _pluck( settings.aoData, '_aData' );
  7893. } ).flatten();
  7894. } );
  7895. _api_register( 'destroy()', function ( remove ) {
  7896. remove = remove || false;
  7897. return this.iterator( 'table', function ( settings ) {
  7898. var orig = settings.nTableWrapper.parentNode;
  7899. var classes = settings.oClasses;
  7900. var table = settings.nTable;
  7901. var tbody = settings.nTBody;
  7902. var thead = settings.nTHead;
  7903. var tfoot = settings.nTFoot;
  7904. var jqTable = $(table);
  7905. var jqTbody = $(tbody);
  7906. var jqWrapper = $(settings.nTableWrapper);
  7907. var rows = $.map( settings.aoData, function (r) { return r.nTr; } );
  7908. var i, ien;
  7909. // Flag to note that the table is currently being destroyed - no action
  7910. // should be taken
  7911. settings.bDestroying = true;
  7912. // Fire off the destroy callbacks for plug-ins etc
  7913. _fnCallbackFire( settings, "aoDestroyCallback", "destroy", [settings] );
  7914. // If not being removed from the document, make all columns visible
  7915. if ( ! remove ) {
  7916. new _Api( settings ).columns().visible( true );
  7917. }
  7918. // Blitz all `DT` namespaced events (these are internal events, the
  7919. // lowercase, `dt` events are user subscribed and they are responsible
  7920. // for removing them
  7921. jqWrapper.off('.DT').find(':not(tbody *)').off('.DT');
  7922. $(window).off('.DT-'+settings.sInstance);
  7923. // When scrolling we had to break the table up - restore it
  7924. if ( table != thead.parentNode ) {
  7925. jqTable.children('thead').detach();
  7926. jqTable.append( thead );
  7927. }
  7928. if ( tfoot && table != tfoot.parentNode ) {
  7929. jqTable.children('tfoot').detach();
  7930. jqTable.append( tfoot );
  7931. }
  7932. settings.aaSorting = [];
  7933. settings.aaSortingFixed = [];
  7934. _fnSortingClasses( settings );
  7935. $( rows ).removeClass( settings.asStripeClasses.join(' ') );
  7936. $('th, td', thead).removeClass( classes.sSortable+' '+
  7937. classes.sSortableAsc+' '+classes.sSortableDesc+' '+classes.sSortableNone
  7938. );
  7939. // Add the TR elements back into the table in their original order
  7940. jqTbody.children().detach();
  7941. jqTbody.append( rows );
  7942. // Remove the DataTables generated nodes, events and classes
  7943. var removedMethod = remove ? 'remove' : 'detach';
  7944. jqTable[ removedMethod ]();
  7945. jqWrapper[ removedMethod ]();
  7946. // If we need to reattach the table to the document
  7947. if ( ! remove && orig ) {
  7948. // insertBefore acts like appendChild if !arg[1]
  7949. orig.insertBefore( table, settings.nTableReinsertBefore );
  7950. // Restore the width of the original table - was read from the style property,
  7951. // so we can restore directly to that
  7952. jqTable
  7953. .css( 'width', settings.sDestroyWidth )
  7954. .removeClass( classes.sTable );
  7955. // If the were originally stripe classes - then we add them back here.
  7956. // Note this is not fool proof (for example if not all rows had stripe
  7957. // classes - but it's a good effort without getting carried away
  7958. ien = settings.asDestroyStripes.length;
  7959. if ( ien ) {
  7960. jqTbody.children().each( function (i) {
  7961. $(this).addClass( settings.asDestroyStripes[i % ien] );
  7962. } );
  7963. }
  7964. }
  7965. /* Remove the settings object from the settings array */
  7966. var idx = $.inArray( settings, DataTable.settings );
  7967. if ( idx !== -1 ) {
  7968. DataTable.settings.splice( idx, 1 );
  7969. }
  7970. } );
  7971. } );
  7972. // Add the `every()` method for rows, columns and cells in a compact form
  7973. $.each( [ 'column', 'row', 'cell' ], function ( i, type ) {
  7974. _api_register( type+'s().every()', function ( fn ) {
  7975. var opts = this.selector.opts;
  7976. var api = this;
  7977. return this.iterator( type, function ( settings, arg1, arg2, arg3, arg4 ) {
  7978. // Rows and columns:
  7979. // arg1 - index
  7980. // arg2 - table counter
  7981. // arg3 - loop counter
  7982. // arg4 - undefined
  7983. // Cells:
  7984. // arg1 - row index
  7985. // arg2 - column index
  7986. // arg3 - table counter
  7987. // arg4 - loop counter
  7988. fn.call(
  7989. api[ type ](
  7990. arg1,
  7991. type==='cell' ? arg2 : opts,
  7992. type==='cell' ? opts : undefined
  7993. ),
  7994. arg1, arg2, arg3, arg4
  7995. );
  7996. } );
  7997. } );
  7998. } );
  7999. // i18n method for extensions to be able to use the language object from the
  8000. // DataTable
  8001. _api_register( 'i18n()', function ( token, def, plural ) {
  8002. var ctx = this.context[0];
  8003. var resolved = _fnGetObjectDataFn( token )( ctx.oLanguage );
  8004. if ( resolved === undefined ) {
  8005. resolved = def;
  8006. }
  8007. if ( plural !== undefined && $.isPlainObject( resolved ) ) {
  8008. resolved = resolved[ plural ] !== undefined ?
  8009. resolved[ plural ] :
  8010. resolved._;
  8011. }
  8012. return resolved.replace( '%d', plural ); // nb: plural might be undefined,
  8013. } );
  8014. /**
  8015. * Version string for plug-ins to check compatibility. Allowed format is
  8016. * `a.b.c-d` where: a:int, b:int, c:int, d:string(dev|beta|alpha). `d` is used
  8017. * only for non-release builds. See http://semver.org/ for more information.
  8018. * @member
  8019. * @type string
  8020. * @default Version number
  8021. */
  8022. DataTable.version = "1.10.18";
  8023. /**
  8024. * Private data store, containing all of the settings objects that are
  8025. * created for the tables on a given page.
  8026. *
  8027. * Note that the `DataTable.settings` object is aliased to
  8028. * `jQuery.fn.dataTableExt` through which it may be accessed and
  8029. * manipulated, or `jQuery.fn.dataTable.settings`.
  8030. * @member
  8031. * @type array
  8032. * @default []
  8033. * @private
  8034. */
  8035. DataTable.settings = [];
  8036. /**
  8037. * Object models container, for the various models that DataTables has
  8038. * available to it. These models define the objects that are used to hold
  8039. * the active state and configuration of the table.
  8040. * @namespace
  8041. */
  8042. DataTable.models = {};
  8043. /**
  8044. * Template object for the way in which DataTables holds information about
  8045. * search information for the global filter and individual column filters.
  8046. * @namespace
  8047. */
  8048. DataTable.models.oSearch = {
  8049. /**
  8050. * Flag to indicate if the filtering should be case insensitive or not
  8051. * @type boolean
  8052. * @default true
  8053. */
  8054. "bCaseInsensitive": true,
  8055. /**
  8056. * Applied search term
  8057. * @type string
  8058. * @default <i>Empty string</i>
  8059. */
  8060. "sSearch": "",
  8061. /**
  8062. * Flag to indicate if the search term should be interpreted as a
  8063. * regular expression (true) or not (false) and therefore and special
  8064. * regex characters escaped.
  8065. * @type boolean
  8066. * @default false
  8067. */
  8068. "bRegex": false,
  8069. /**
  8070. * Flag to indicate if DataTables is to use its smart filtering or not.
  8071. * @type boolean
  8072. * @default true
  8073. */
  8074. "bSmart": true
  8075. };
  8076. /**
  8077. * Template object for the way in which DataTables holds information about
  8078. * each individual row. This is the object format used for the settings
  8079. * aoData array.
  8080. * @namespace
  8081. */
  8082. DataTable.models.oRow = {
  8083. /**
  8084. * TR element for the row
  8085. * @type node
  8086. * @default null
  8087. */
  8088. "nTr": null,
  8089. /**
  8090. * Array of TD elements for each row. This is null until the row has been
  8091. * created.
  8092. * @type array nodes
  8093. * @default []
  8094. */
  8095. "anCells": null,
  8096. /**
  8097. * Data object from the original data source for the row. This is either
  8098. * an array if using the traditional form of DataTables, or an object if
  8099. * using mData options. The exact type will depend on the passed in
  8100. * data from the data source, or will be an array if using DOM a data
  8101. * source.
  8102. * @type array|object
  8103. * @default []
  8104. */
  8105. "_aData": [],
  8106. /**
  8107. * Sorting data cache - this array is ostensibly the same length as the
  8108. * number of columns (although each index is generated only as it is
  8109. * needed), and holds the data that is used for sorting each column in the
  8110. * row. We do this cache generation at the start of the sort in order that
  8111. * the formatting of the sort data need be done only once for each cell
  8112. * per sort. This array should not be read from or written to by anything
  8113. * other than the master sorting methods.
  8114. * @type array
  8115. * @default null
  8116. * @private
  8117. */
  8118. "_aSortData": null,
  8119. /**
  8120. * Per cell filtering data cache. As per the sort data cache, used to
  8121. * increase the performance of the filtering in DataTables
  8122. * @type array
  8123. * @default null
  8124. * @private
  8125. */
  8126. "_aFilterData": null,
  8127. /**
  8128. * Filtering data cache. This is the same as the cell filtering cache, but
  8129. * in this case a string rather than an array. This is easily computed with
  8130. * a join on `_aFilterData`, but is provided as a cache so the join isn't
  8131. * needed on every search (memory traded for performance)
  8132. * @type array
  8133. * @default null
  8134. * @private
  8135. */
  8136. "_sFilterRow": null,
  8137. /**
  8138. * Cache of the class name that DataTables has applied to the row, so we
  8139. * can quickly look at this variable rather than needing to do a DOM check
  8140. * on className for the nTr property.
  8141. * @type string
  8142. * @default <i>Empty string</i>
  8143. * @private
  8144. */
  8145. "_sRowStripe": "",
  8146. /**
  8147. * Denote if the original data source was from the DOM, or the data source
  8148. * object. This is used for invalidating data, so DataTables can
  8149. * automatically read data from the original source, unless uninstructed
  8150. * otherwise.
  8151. * @type string
  8152. * @default null
  8153. * @private
  8154. */
  8155. "src": null,
  8156. /**
  8157. * Index in the aoData array. This saves an indexOf lookup when we have the
  8158. * object, but want to know the index
  8159. * @type integer
  8160. * @default -1
  8161. * @private
  8162. */
  8163. "idx": -1
  8164. };
  8165. /**
  8166. * Template object for the column information object in DataTables. This object
  8167. * is held in the settings aoColumns array and contains all the information that
  8168. * DataTables needs about each individual column.
  8169. *
  8170. * Note that this object is related to {@link DataTable.defaults.column}
  8171. * but this one is the internal data store for DataTables's cache of columns.
  8172. * It should NOT be manipulated outside of DataTables. Any configuration should
  8173. * be done through the initialisation options.
  8174. * @namespace
  8175. */
  8176. DataTable.models.oColumn = {
  8177. /**
  8178. * Column index. This could be worked out on-the-fly with $.inArray, but it
  8179. * is faster to just hold it as a variable
  8180. * @type integer
  8181. * @default null
  8182. */
  8183. "idx": null,
  8184. /**
  8185. * A list of the columns that sorting should occur on when this column
  8186. * is sorted. That this property is an array allows multi-column sorting
  8187. * to be defined for a column (for example first name / last name columns
  8188. * would benefit from this). The values are integers pointing to the
  8189. * columns to be sorted on (typically it will be a single integer pointing
  8190. * at itself, but that doesn't need to be the case).
  8191. * @type array
  8192. */
  8193. "aDataSort": null,
  8194. /**
  8195. * Define the sorting directions that are applied to the column, in sequence
  8196. * as the column is repeatedly sorted upon - i.e. the first value is used
  8197. * as the sorting direction when the column if first sorted (clicked on).
  8198. * Sort it again (click again) and it will move on to the next index.
  8199. * Repeat until loop.
  8200. * @type array
  8201. */
  8202. "asSorting": null,
  8203. /**
  8204. * Flag to indicate if the column is searchable, and thus should be included
  8205. * in the filtering or not.
  8206. * @type boolean
  8207. */
  8208. "bSearchable": null,
  8209. /**
  8210. * Flag to indicate if the column is sortable or not.
  8211. * @type boolean
  8212. */
  8213. "bSortable": null,
  8214. /**
  8215. * Flag to indicate if the column is currently visible in the table or not
  8216. * @type boolean
  8217. */
  8218. "bVisible": null,
  8219. /**
  8220. * Store for manual type assignment using the `column.type` option. This
  8221. * is held in store so we can manipulate the column's `sType` property.
  8222. * @type string
  8223. * @default null
  8224. * @private
  8225. */
  8226. "_sManualType": null,
  8227. /**
  8228. * Flag to indicate if HTML5 data attributes should be used as the data
  8229. * source for filtering or sorting. True is either are.
  8230. * @type boolean
  8231. * @default false
  8232. * @private
  8233. */
  8234. "_bAttrSrc": false,
  8235. /**
  8236. * Developer definable function that is called whenever a cell is created (Ajax source,
  8237. * etc) or processed for input (DOM source). This can be used as a compliment to mRender
  8238. * allowing you to modify the DOM element (add background colour for example) when the
  8239. * element is available.
  8240. * @type function
  8241. * @param {element} nTd The TD node that has been created
  8242. * @param {*} sData The Data for the cell
  8243. * @param {array|object} oData The data for the whole row
  8244. * @param {int} iRow The row index for the aoData data store
  8245. * @default null
  8246. */
  8247. "fnCreatedCell": null,
  8248. /**
  8249. * Function to get data from a cell in a column. You should <b>never</b>
  8250. * access data directly through _aData internally in DataTables - always use
  8251. * the method attached to this property. It allows mData to function as
  8252. * required. This function is automatically assigned by the column
  8253. * initialisation method
  8254. * @type function
  8255. * @param {array|object} oData The data array/object for the array
  8256. * (i.e. aoData[]._aData)
  8257. * @param {string} sSpecific The specific data type you want to get -
  8258. * 'display', 'type' 'filter' 'sort'
  8259. * @returns {*} The data for the cell from the given row's data
  8260. * @default null
  8261. */
  8262. "fnGetData": null,
  8263. /**
  8264. * Function to set data for a cell in the column. You should <b>never</b>
  8265. * set the data directly to _aData internally in DataTables - always use
  8266. * this method. It allows mData to function as required. This function
  8267. * is automatically assigned by the column initialisation method
  8268. * @type function
  8269. * @param {array|object} oData The data array/object for the array
  8270. * (i.e. aoData[]._aData)
  8271. * @param {*} sValue Value to set
  8272. * @default null
  8273. */
  8274. "fnSetData": null,
  8275. /**
  8276. * Property to read the value for the cells in the column from the data
  8277. * source array / object. If null, then the default content is used, if a
  8278. * function is given then the return from the function is used.
  8279. * @type function|int|string|null
  8280. * @default null
  8281. */
  8282. "mData": null,
  8283. /**
  8284. * Partner property to mData which is used (only when defined) to get
  8285. * the data - i.e. it is basically the same as mData, but without the
  8286. * 'set' option, and also the data fed to it is the result from mData.
  8287. * This is the rendering method to match the data method of mData.
  8288. * @type function|int|string|null
  8289. * @default null
  8290. */
  8291. "mRender": null,
  8292. /**
  8293. * Unique header TH/TD element for this column - this is what the sorting
  8294. * listener is attached to (if sorting is enabled.)
  8295. * @type node
  8296. * @default null
  8297. */
  8298. "nTh": null,
  8299. /**
  8300. * Unique footer TH/TD element for this column (if there is one). Not used
  8301. * in DataTables as such, but can be used for plug-ins to reference the
  8302. * footer for each column.
  8303. * @type node
  8304. * @default null
  8305. */
  8306. "nTf": null,
  8307. /**
  8308. * The class to apply to all TD elements in the table's TBODY for the column
  8309. * @type string
  8310. * @default null
  8311. */
  8312. "sClass": null,
  8313. /**
  8314. * When DataTables calculates the column widths to assign to each column,
  8315. * it finds the longest string in each column and then constructs a
  8316. * temporary table and reads the widths from that. The problem with this
  8317. * is that "mmm" is much wider then "iiii", but the latter is a longer
  8318. * string - thus the calculation can go wrong (doing it properly and putting
  8319. * it into an DOM object and measuring that is horribly(!) slow). Thus as
  8320. * a "work around" we provide this option. It will append its value to the
  8321. * text that is found to be the longest string for the column - i.e. padding.
  8322. * @type string
  8323. */
  8324. "sContentPadding": null,
  8325. /**
  8326. * Allows a default value to be given for a column's data, and will be used
  8327. * whenever a null data source is encountered (this can be because mData
  8328. * is set to null, or because the data source itself is null).
  8329. * @type string
  8330. * @default null
  8331. */
  8332. "sDefaultContent": null,
  8333. /**
  8334. * Name for the column, allowing reference to the column by name as well as
  8335. * by index (needs a lookup to work by name).
  8336. * @type string
  8337. */
  8338. "sName": null,
  8339. /**
  8340. * Custom sorting data type - defines which of the available plug-ins in
  8341. * afnSortData the custom sorting will use - if any is defined.
  8342. * @type string
  8343. * @default std
  8344. */
  8345. "sSortDataType": 'std',
  8346. /**
  8347. * Class to be applied to the header element when sorting on this column
  8348. * @type string
  8349. * @default null
  8350. */
  8351. "sSortingClass": null,
  8352. /**
  8353. * Class to be applied to the header element when sorting on this column -
  8354. * when jQuery UI theming is used.
  8355. * @type string
  8356. * @default null
  8357. */
  8358. "sSortingClassJUI": null,
  8359. /**
  8360. * Title of the column - what is seen in the TH element (nTh).
  8361. * @type string
  8362. */
  8363. "sTitle": null,
  8364. /**
  8365. * Column sorting and filtering type
  8366. * @type string
  8367. * @default null
  8368. */
  8369. "sType": null,
  8370. /**
  8371. * Width of the column
  8372. * @type string
  8373. * @default null
  8374. */
  8375. "sWidth": null,
  8376. /**
  8377. * Width of the column when it was first "encountered"
  8378. * @type string
  8379. * @default null
  8380. */
  8381. "sWidthOrig": null
  8382. };
  8383. /*
  8384. * Developer note: The properties of the object below are given in Hungarian
  8385. * notation, that was used as the interface for DataTables prior to v1.10, however
  8386. * from v1.10 onwards the primary interface is camel case. In order to avoid
  8387. * breaking backwards compatibility utterly with this change, the Hungarian
  8388. * version is still, internally the primary interface, but is is not documented
  8389. * - hence the @name tags in each doc comment. This allows a Javascript function
  8390. * to create a map from Hungarian notation to camel case (going the other direction
  8391. * would require each property to be listed, which would at around 3K to the size
  8392. * of DataTables, while this method is about a 0.5K hit.
  8393. *
  8394. * Ultimately this does pave the way for Hungarian notation to be dropped
  8395. * completely, but that is a massive amount of work and will break current
  8396. * installs (therefore is on-hold until v2).
  8397. */
  8398. /**
  8399. * Initialisation options that can be given to DataTables at initialisation
  8400. * time.
  8401. * @namespace
  8402. */
  8403. DataTable.defaults = {
  8404. /**
  8405. * An array of data to use for the table, passed in at initialisation which
  8406. * will be used in preference to any data which is already in the DOM. This is
  8407. * particularly useful for constructing tables purely in Javascript, for
  8408. * example with a custom Ajax call.
  8409. * @type array
  8410. * @default null
  8411. *
  8412. * @dtopt Option
  8413. * @name DataTable.defaults.data
  8414. *
  8415. * @example
  8416. * // Using a 2D array data source
  8417. * $(document).ready( function () {
  8418. * $('#example').dataTable( {
  8419. * "data": [
  8420. * ['Trident', 'Internet Explorer 4.0', 'Win 95+', 4, 'X'],
  8421. * ['Trident', 'Internet Explorer 5.0', 'Win 95+', 5, 'C'],
  8422. * ],
  8423. * "columns": [
  8424. * { "title": "Engine" },
  8425. * { "title": "Browser" },
  8426. * { "title": "Platform" },
  8427. * { "title": "Version" },
  8428. * { "title": "Grade" }
  8429. * ]
  8430. * } );
  8431. * } );
  8432. *
  8433. * @example
  8434. * // Using an array of objects as a data source (`data`)
  8435. * $(document).ready( function () {
  8436. * $('#example').dataTable( {
  8437. * "data": [
  8438. * {
  8439. * "engine": "Trident",
  8440. * "browser": "Internet Explorer 4.0",
  8441. * "platform": "Win 95+",
  8442. * "version": 4,
  8443. * "grade": "X"
  8444. * },
  8445. * {
  8446. * "engine": "Trident",
  8447. * "browser": "Internet Explorer 5.0",
  8448. * "platform": "Win 95+",
  8449. * "version": 5,
  8450. * "grade": "C"
  8451. * }
  8452. * ],
  8453. * "columns": [
  8454. * { "title": "Engine", "data": "engine" },
  8455. * { "title": "Browser", "data": "browser" },
  8456. * { "title": "Platform", "data": "platform" },
  8457. * { "title": "Version", "data": "version" },
  8458. * { "title": "Grade", "data": "grade" }
  8459. * ]
  8460. * } );
  8461. * } );
  8462. */
  8463. "aaData": null,
  8464. /**
  8465. * If ordering is enabled, then DataTables will perform a first pass sort on
  8466. * initialisation. You can define which column(s) the sort is performed
  8467. * upon, and the sorting direction, with this variable. The `sorting` array
  8468. * should contain an array for each column to be sorted initially containing
  8469. * the column's index and a direction string ('asc' or 'desc').
  8470. * @type array
  8471. * @default [[0,'asc']]
  8472. *
  8473. * @dtopt Option
  8474. * @name DataTable.defaults.order
  8475. *
  8476. * @example
  8477. * // Sort by 3rd column first, and then 4th column
  8478. * $(document).ready( function() {
  8479. * $('#example').dataTable( {
  8480. * "order": [[2,'asc'], [3,'desc']]
  8481. * } );
  8482. * } );
  8483. *
  8484. * // No initial sorting
  8485. * $(document).ready( function() {
  8486. * $('#example').dataTable( {
  8487. * "order": []
  8488. * } );
  8489. * } );
  8490. */
  8491. "aaSorting": [[0,'asc']],
  8492. /**
  8493. * This parameter is basically identical to the `sorting` parameter, but
  8494. * cannot be overridden by user interaction with the table. What this means
  8495. * is that you could have a column (visible or hidden) which the sorting
  8496. * will always be forced on first - any sorting after that (from the user)
  8497. * will then be performed as required. This can be useful for grouping rows
  8498. * together.
  8499. * @type array
  8500. * @default null
  8501. *
  8502. * @dtopt Option
  8503. * @name DataTable.defaults.orderFixed
  8504. *
  8505. * @example
  8506. * $(document).ready( function() {
  8507. * $('#example').dataTable( {
  8508. * "orderFixed": [[0,'asc']]
  8509. * } );
  8510. * } )
  8511. */
  8512. "aaSortingFixed": [],
  8513. /**
  8514. * DataTables can be instructed to load data to display in the table from a
  8515. * Ajax source. This option defines how that Ajax call is made and where to.
  8516. *
  8517. * The `ajax` property has three different modes of operation, depending on
  8518. * how it is defined. These are:
  8519. *
  8520. * * `string` - Set the URL from where the data should be loaded from.
  8521. * * `object` - Define properties for `jQuery.ajax`.
  8522. * * `function` - Custom data get function
  8523. *
  8524. * `string`
  8525. * --------
  8526. *
  8527. * As a string, the `ajax` property simply defines the URL from which
  8528. * DataTables will load data.
  8529. *
  8530. * `object`
  8531. * --------
  8532. *
  8533. * As an object, the parameters in the object are passed to
  8534. * [jQuery.ajax](http://api.jquery.com/jQuery.ajax/) allowing fine control
  8535. * of the Ajax request. DataTables has a number of default parameters which
  8536. * you can override using this option. Please refer to the jQuery
  8537. * documentation for a full description of the options available, although
  8538. * the following parameters provide additional options in DataTables or
  8539. * require special consideration:
  8540. *
  8541. * * `data` - As with jQuery, `data` can be provided as an object, but it
  8542. * can also be used as a function to manipulate the data DataTables sends
  8543. * to the server. The function takes a single parameter, an object of
  8544. * parameters with the values that DataTables has readied for sending. An
  8545. * object may be returned which will be merged into the DataTables
  8546. * defaults, or you can add the items to the object that was passed in and
  8547. * not return anything from the function. This supersedes `fnServerParams`
  8548. * from DataTables 1.9-.
  8549. *
  8550. * * `dataSrc` - By default DataTables will look for the property `data` (or
  8551. * `aaData` for compatibility with DataTables 1.9-) when obtaining data
  8552. * from an Ajax source or for server-side processing - this parameter
  8553. * allows that property to be changed. You can use Javascript dotted
  8554. * object notation to get a data source for multiple levels of nesting, or
  8555. * it my be used as a function. As a function it takes a single parameter,
  8556. * the JSON returned from the server, which can be manipulated as
  8557. * required, with the returned value being that used by DataTables as the
  8558. * data source for the table. This supersedes `sAjaxDataProp` from
  8559. * DataTables 1.9-.
  8560. *
  8561. * * `success` - Should not be overridden it is used internally in
  8562. * DataTables. To manipulate / transform the data returned by the server
  8563. * use `ajax.dataSrc`, or use `ajax` as a function (see below).
  8564. *
  8565. * `function`
  8566. * ----------
  8567. *
  8568. * As a function, making the Ajax call is left up to yourself allowing
  8569. * complete control of the Ajax request. Indeed, if desired, a method other
  8570. * than Ajax could be used to obtain the required data, such as Web storage
  8571. * or an AIR database.
  8572. *
  8573. * The function is given four parameters and no return is required. The
  8574. * parameters are:
  8575. *
  8576. * 1. _object_ - Data to send to the server
  8577. * 2. _function_ - Callback function that must be executed when the required
  8578. * data has been obtained. That data should be passed into the callback
  8579. * as the only parameter
  8580. * 3. _object_ - DataTables settings object for the table
  8581. *
  8582. * Note that this supersedes `fnServerData` from DataTables 1.9-.
  8583. *
  8584. * @type string|object|function
  8585. * @default null
  8586. *
  8587. * @dtopt Option
  8588. * @name DataTable.defaults.ajax
  8589. * @since 1.10.0
  8590. *
  8591. * @example
  8592. * // Get JSON data from a file via Ajax.
  8593. * // Note DataTables expects data in the form `{ data: [ ...data... ] }` by default).
  8594. * $('#example').dataTable( {
  8595. * "ajax": "data.json"
  8596. * } );
  8597. *
  8598. * @example
  8599. * // Get JSON data from a file via Ajax, using `dataSrc` to change
  8600. * // `data` to `tableData` (i.e. `{ tableData: [ ...data... ] }`)
  8601. * $('#example').dataTable( {
  8602. * "ajax": {
  8603. * "url": "data.json",
  8604. * "dataSrc": "tableData"
  8605. * }
  8606. * } );
  8607. *
  8608. * @example
  8609. * // Get JSON data from a file via Ajax, using `dataSrc` to read data
  8610. * // from a plain array rather than an array in an object
  8611. * $('#example').dataTable( {
  8612. * "ajax": {
  8613. * "url": "data.json",
  8614. * "dataSrc": ""
  8615. * }
  8616. * } );
  8617. *
  8618. * @example
  8619. * // Manipulate the data returned from the server - add a link to data
  8620. * // (note this can, should, be done using `render` for the column - this
  8621. * // is just a simple example of how the data can be manipulated).
  8622. * $('#example').dataTable( {
  8623. * "ajax": {
  8624. * "url": "data.json",
  8625. * "dataSrc": function ( json ) {
  8626. * for ( var i=0, ien=json.length ; i<ien ; i++ ) {
  8627. * json[i][0] = '<a href="/message/'+json[i][0]+'>View message</a>';
  8628. * }
  8629. * return json;
  8630. * }
  8631. * }
  8632. * } );
  8633. *
  8634. * @example
  8635. * // Add data to the request
  8636. * $('#example').dataTable( {
  8637. * "ajax": {
  8638. * "url": "data.json",
  8639. * "data": function ( d ) {
  8640. * return {
  8641. * "extra_search": $('#extra').val()
  8642. * };
  8643. * }
  8644. * }
  8645. * } );
  8646. *
  8647. * @example
  8648. * // Send request as POST
  8649. * $('#example').dataTable( {
  8650. * "ajax": {
  8651. * "url": "data.json",
  8652. * "type": "POST"
  8653. * }
  8654. * } );
  8655. *
  8656. * @example
  8657. * // Get the data from localStorage (could interface with a form for
  8658. * // adding, editing and removing rows).
  8659. * $('#example').dataTable( {
  8660. * "ajax": function (data, callback, settings) {
  8661. * callback(
  8662. * JSON.parse( localStorage.getItem('dataTablesData') )
  8663. * );
  8664. * }
  8665. * } );
  8666. */
  8667. "ajax": null,
  8668. /**
  8669. * This parameter allows you to readily specify the entries in the length drop
  8670. * down menu that DataTables shows when pagination is enabled. It can be
  8671. * either a 1D array of options which will be used for both the displayed
  8672. * option and the value, or a 2D array which will use the array in the first
  8673. * position as the value, and the array in the second position as the
  8674. * displayed options (useful for language strings such as 'All').
  8675. *
  8676. * Note that the `pageLength` property will be automatically set to the
  8677. * first value given in this array, unless `pageLength` is also provided.
  8678. * @type array
  8679. * @default [ 10, 25, 50, 100 ]
  8680. *
  8681. * @dtopt Option
  8682. * @name DataTable.defaults.lengthMenu
  8683. *
  8684. * @example
  8685. * $(document).ready( function() {
  8686. * $('#example').dataTable( {
  8687. * "lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]]
  8688. * } );
  8689. * } );
  8690. */
  8691. "aLengthMenu": [ 10, 25, 50, 100 ],
  8692. /**
  8693. * The `columns` option in the initialisation parameter allows you to define
  8694. * details about the way individual columns behave. For a full list of
  8695. * column options that can be set, please see
  8696. * {@link DataTable.defaults.column}. Note that if you use `columns` to
  8697. * define your columns, you must have an entry in the array for every single
  8698. * column that you have in your table (these can be null if you don't which
  8699. * to specify any options).
  8700. * @member
  8701. *
  8702. * @name DataTable.defaults.column
  8703. */
  8704. "aoColumns": null,
  8705. /**
  8706. * Very similar to `columns`, `columnDefs` allows you to target a specific
  8707. * column, multiple columns, or all columns, using the `targets` property of
  8708. * each object in the array. This allows great flexibility when creating
  8709. * tables, as the `columnDefs` arrays can be of any length, targeting the
  8710. * columns you specifically want. `columnDefs` may use any of the column
  8711. * options available: {@link DataTable.defaults.column}, but it _must_
  8712. * have `targets` defined in each object in the array. Values in the `targets`
  8713. * array may be:
  8714. * <ul>
  8715. * <li>a string - class name will be matched on the TH for the column</li>
  8716. * <li>0 or a positive integer - column index counting from the left</li>
  8717. * <li>a negative integer - column index counting from the right</li>
  8718. * <li>the string "_all" - all columns (i.e. assign a default)</li>
  8719. * </ul>
  8720. * @member
  8721. *
  8722. * @name DataTable.defaults.columnDefs
  8723. */
  8724. "aoColumnDefs": null,
  8725. /**
  8726. * Basically the same as `search`, this parameter defines the individual column
  8727. * filtering state at initialisation time. The array must be of the same size
  8728. * as the number of columns, and each element be an object with the parameters
  8729. * `search` and `escapeRegex` (the latter is optional). 'null' is also
  8730. * accepted and the default will be used.
  8731. * @type array
  8732. * @default []
  8733. *
  8734. * @dtopt Option
  8735. * @name DataTable.defaults.searchCols
  8736. *
  8737. * @example
  8738. * $(document).ready( function() {
  8739. * $('#example').dataTable( {
  8740. * "searchCols": [
  8741. * null,
  8742. * { "search": "My filter" },
  8743. * null,
  8744. * { "search": "^[0-9]", "escapeRegex": false }
  8745. * ]
  8746. * } );
  8747. * } )
  8748. */
  8749. "aoSearchCols": [],
  8750. /**
  8751. * An array of CSS classes that should be applied to displayed rows. This
  8752. * array may be of any length, and DataTables will apply each class
  8753. * sequentially, looping when required.
  8754. * @type array
  8755. * @default null <i>Will take the values determined by the `oClasses.stripe*`
  8756. * options</i>
  8757. *
  8758. * @dtopt Option
  8759. * @name DataTable.defaults.stripeClasses
  8760. *
  8761. * @example
  8762. * $(document).ready( function() {
  8763. * $('#example').dataTable( {
  8764. * "stripeClasses": [ 'strip1', 'strip2', 'strip3' ]
  8765. * } );
  8766. * } )
  8767. */
  8768. "asStripeClasses": null,
  8769. /**
  8770. * Enable or disable automatic column width calculation. This can be disabled
  8771. * as an optimisation (it takes some time to calculate the widths) if the
  8772. * tables widths are passed in using `columns`.
  8773. * @type boolean
  8774. * @default true
  8775. *
  8776. * @dtopt Features
  8777. * @name DataTable.defaults.autoWidth
  8778. *
  8779. * @example
  8780. * $(document).ready( function () {
  8781. * $('#example').dataTable( {
  8782. * "autoWidth": false
  8783. * } );
  8784. * } );
  8785. */
  8786. "bAutoWidth": true,
  8787. /**
  8788. * Deferred rendering can provide DataTables with a huge speed boost when you
  8789. * are using an Ajax or JS data source for the table. This option, when set to
  8790. * true, will cause DataTables to defer the creation of the table elements for
  8791. * each row until they are needed for a draw - saving a significant amount of
  8792. * time.
  8793. * @type boolean
  8794. * @default false
  8795. *
  8796. * @dtopt Features
  8797. * @name DataTable.defaults.deferRender
  8798. *
  8799. * @example
  8800. * $(document).ready( function() {
  8801. * $('#example').dataTable( {
  8802. * "ajax": "sources/arrays.txt",
  8803. * "deferRender": true
  8804. * } );
  8805. * } );
  8806. */
  8807. "bDeferRender": false,
  8808. /**
  8809. * Replace a DataTable which matches the given selector and replace it with
  8810. * one which has the properties of the new initialisation object passed. If no
  8811. * table matches the selector, then the new DataTable will be constructed as
  8812. * per normal.
  8813. * @type boolean
  8814. * @default false
  8815. *
  8816. * @dtopt Options
  8817. * @name DataTable.defaults.destroy
  8818. *
  8819. * @example
  8820. * $(document).ready( function() {
  8821. * $('#example').dataTable( {
  8822. * "srollY": "200px",
  8823. * "paginate": false
  8824. * } );
  8825. *
  8826. * // Some time later....
  8827. * $('#example').dataTable( {
  8828. * "filter": false,
  8829. * "destroy": true
  8830. * } );
  8831. * } );
  8832. */
  8833. "bDestroy": false,
  8834. /**
  8835. * Enable or disable filtering of data. Filtering in DataTables is "smart" in
  8836. * that it allows the end user to input multiple words (space separated) and
  8837. * will match a row containing those words, even if not in the order that was
  8838. * specified (this allow matching across multiple columns). Note that if you
  8839. * wish to use filtering in DataTables this must remain 'true' - to remove the
  8840. * default filtering input box and retain filtering abilities, please use
  8841. * {@link DataTable.defaults.dom}.
  8842. * @type boolean
  8843. * @default true
  8844. *
  8845. * @dtopt Features
  8846. * @name DataTable.defaults.searching
  8847. *
  8848. * @example
  8849. * $(document).ready( function () {
  8850. * $('#example').dataTable( {
  8851. * "searching": false
  8852. * } );
  8853. * } );
  8854. */
  8855. "bFilter": true,
  8856. /**
  8857. * Enable or disable the table information display. This shows information
  8858. * about the data that is currently visible on the page, including information
  8859. * about filtered data if that action is being performed.
  8860. * @type boolean
  8861. * @default true
  8862. *
  8863. * @dtopt Features
  8864. * @name DataTable.defaults.info
  8865. *
  8866. * @example
  8867. * $(document).ready( function () {
  8868. * $('#example').dataTable( {
  8869. * "info": false
  8870. * } );
  8871. * } );
  8872. */
  8873. "bInfo": true,
  8874. /**
  8875. * Allows the end user to select the size of a formatted page from a select
  8876. * menu (sizes are 10, 25, 50 and 100). Requires pagination (`paginate`).
  8877. * @type boolean
  8878. * @default true
  8879. *
  8880. * @dtopt Features
  8881. * @name DataTable.defaults.lengthChange
  8882. *
  8883. * @example
  8884. * $(document).ready( function () {
  8885. * $('#example').dataTable( {
  8886. * "lengthChange": false
  8887. * } );
  8888. * } );
  8889. */
  8890. "bLengthChange": true,
  8891. /**
  8892. * Enable or disable pagination.
  8893. * @type boolean
  8894. * @default true
  8895. *
  8896. * @dtopt Features
  8897. * @name DataTable.defaults.paging
  8898. *
  8899. * @example
  8900. * $(document).ready( function () {
  8901. * $('#example').dataTable( {
  8902. * "paging": false
  8903. * } );
  8904. * } );
  8905. */
  8906. "bPaginate": true,
  8907. /**
  8908. * Enable or disable the display of a 'processing' indicator when the table is
  8909. * being processed (e.g. a sort). This is particularly useful for tables with
  8910. * large amounts of data where it can take a noticeable amount of time to sort
  8911. * the entries.
  8912. * @type boolean
  8913. * @default false
  8914. *
  8915. * @dtopt Features
  8916. * @name DataTable.defaults.processing
  8917. *
  8918. * @example
  8919. * $(document).ready( function () {
  8920. * $('#example').dataTable( {
  8921. * "processing": true
  8922. * } );
  8923. * } );
  8924. */
  8925. "bProcessing": false,
  8926. /**
  8927. * Retrieve the DataTables object for the given selector. Note that if the
  8928. * table has already been initialised, this parameter will cause DataTables
  8929. * to simply return the object that has already been set up - it will not take
  8930. * account of any changes you might have made to the initialisation object
  8931. * passed to DataTables (setting this parameter to true is an acknowledgement
  8932. * that you understand this). `destroy` can be used to reinitialise a table if
  8933. * you need.
  8934. * @type boolean
  8935. * @default false
  8936. *
  8937. * @dtopt Options
  8938. * @name DataTable.defaults.retrieve
  8939. *
  8940. * @example
  8941. * $(document).ready( function() {
  8942. * initTable();
  8943. * tableActions();
  8944. * } );
  8945. *
  8946. * function initTable ()
  8947. * {
  8948. * return $('#example').dataTable( {
  8949. * "scrollY": "200px",
  8950. * "paginate": false,
  8951. * "retrieve": true
  8952. * } );
  8953. * }
  8954. *
  8955. * function tableActions ()
  8956. * {
  8957. * var table = initTable();
  8958. * // perform API operations with oTable
  8959. * }
  8960. */
  8961. "bRetrieve": false,
  8962. /**
  8963. * When vertical (y) scrolling is enabled, DataTables will force the height of
  8964. * the table's viewport to the given height at all times (useful for layout).
  8965. * However, this can look odd when filtering data down to a small data set,
  8966. * and the footer is left "floating" further down. This parameter (when
  8967. * enabled) will cause DataTables to collapse the table's viewport down when
  8968. * the result set will fit within the given Y height.
  8969. * @type boolean
  8970. * @default false
  8971. *
  8972. * @dtopt Options
  8973. * @name DataTable.defaults.scrollCollapse
  8974. *
  8975. * @example
  8976. * $(document).ready( function() {
  8977. * $('#example').dataTable( {
  8978. * "scrollY": "200",
  8979. * "scrollCollapse": true
  8980. * } );
  8981. * } );
  8982. */
  8983. "bScrollCollapse": false,
  8984. /**
  8985. * Configure DataTables to use server-side processing. Note that the
  8986. * `ajax` parameter must also be given in order to give DataTables a
  8987. * source to obtain the required data for each draw.
  8988. * @type boolean
  8989. * @default false
  8990. *
  8991. * @dtopt Features
  8992. * @dtopt Server-side
  8993. * @name DataTable.defaults.serverSide
  8994. *
  8995. * @example
  8996. * $(document).ready( function () {
  8997. * $('#example').dataTable( {
  8998. * "serverSide": true,
  8999. * "ajax": "xhr.php"
  9000. * } );
  9001. * } );
  9002. */
  9003. "bServerSide": false,
  9004. /**
  9005. * Enable or disable sorting of columns. Sorting of individual columns can be
  9006. * disabled by the `sortable` option for each column.
  9007. * @type boolean
  9008. * @default true
  9009. *
  9010. * @dtopt Features
  9011. * @name DataTable.defaults.ordering
  9012. *
  9013. * @example
  9014. * $(document).ready( function () {
  9015. * $('#example').dataTable( {
  9016. * "ordering": false
  9017. * } );
  9018. * } );
  9019. */
  9020. "bSort": true,
  9021. /**
  9022. * Enable or display DataTables' ability to sort multiple columns at the
  9023. * same time (activated by shift-click by the user).
  9024. * @type boolean
  9025. * @default true
  9026. *
  9027. * @dtopt Options
  9028. * @name DataTable.defaults.orderMulti
  9029. *
  9030. * @example
  9031. * // Disable multiple column sorting ability
  9032. * $(document).ready( function () {
  9033. * $('#example').dataTable( {
  9034. * "orderMulti": false
  9035. * } );
  9036. * } );
  9037. */
  9038. "bSortMulti": true,
  9039. /**
  9040. * Allows control over whether DataTables should use the top (true) unique
  9041. * cell that is found for a single column, or the bottom (false - default).
  9042. * This is useful when using complex headers.
  9043. * @type boolean
  9044. * @default false
  9045. *
  9046. * @dtopt Options
  9047. * @name DataTable.defaults.orderCellsTop
  9048. *
  9049. * @example
  9050. * $(document).ready( function() {
  9051. * $('#example').dataTable( {
  9052. * "orderCellsTop": true
  9053. * } );
  9054. * } );
  9055. */
  9056. "bSortCellsTop": false,
  9057. /**
  9058. * Enable or disable the addition of the classes `sorting\_1`, `sorting\_2` and
  9059. * `sorting\_3` to the columns which are currently being sorted on. This is
  9060. * presented as a feature switch as it can increase processing time (while
  9061. * classes are removed and added) so for large data sets you might want to
  9062. * turn this off.
  9063. * @type boolean
  9064. * @default true
  9065. *
  9066. * @dtopt Features
  9067. * @name DataTable.defaults.orderClasses
  9068. *
  9069. * @example
  9070. * $(document).ready( function () {
  9071. * $('#example').dataTable( {
  9072. * "orderClasses": false
  9073. * } );
  9074. * } );
  9075. */
  9076. "bSortClasses": true,
  9077. /**
  9078. * Enable or disable state saving. When enabled HTML5 `localStorage` will be
  9079. * used to save table display information such as pagination information,
  9080. * display length, filtering and sorting. As such when the end user reloads
  9081. * the page the display display will match what thy had previously set up.
  9082. *
  9083. * Due to the use of `localStorage` the default state saving is not supported
  9084. * in IE6 or 7. If state saving is required in those browsers, use
  9085. * `stateSaveCallback` to provide a storage solution such as cookies.
  9086. * @type boolean
  9087. * @default false
  9088. *
  9089. * @dtopt Features
  9090. * @name DataTable.defaults.stateSave
  9091. *
  9092. * @example
  9093. * $(document).ready( function () {
  9094. * $('#example').dataTable( {
  9095. * "stateSave": true
  9096. * } );
  9097. * } );
  9098. */
  9099. "bStateSave": false,
  9100. /**
  9101. * This function is called when a TR element is created (and all TD child
  9102. * elements have been inserted), or registered if using a DOM source, allowing
  9103. * manipulation of the TR element (adding classes etc).
  9104. * @type function
  9105. * @param {node} row "TR" element for the current row
  9106. * @param {array} data Raw data array for this row
  9107. * @param {int} dataIndex The index of this row in the internal aoData array
  9108. *
  9109. * @dtopt Callbacks
  9110. * @name DataTable.defaults.createdRow
  9111. *
  9112. * @example
  9113. * $(document).ready( function() {
  9114. * $('#example').dataTable( {
  9115. * "createdRow": function( row, data, dataIndex ) {
  9116. * // Bold the grade for all 'A' grade browsers
  9117. * if ( data[4] == "A" )
  9118. * {
  9119. * $('td:eq(4)', row).html( '<b>A</b>' );
  9120. * }
  9121. * }
  9122. * } );
  9123. * } );
  9124. */
  9125. "fnCreatedRow": null,
  9126. /**
  9127. * This function is called on every 'draw' event, and allows you to
  9128. * dynamically modify any aspect you want about the created DOM.
  9129. * @type function
  9130. * @param {object} settings DataTables settings object
  9131. *
  9132. * @dtopt Callbacks
  9133. * @name DataTable.defaults.drawCallback
  9134. *
  9135. * @example
  9136. * $(document).ready( function() {
  9137. * $('#example').dataTable( {
  9138. * "drawCallback": function( settings ) {
  9139. * alert( 'DataTables has redrawn the table' );
  9140. * }
  9141. * } );
  9142. * } );
  9143. */
  9144. "fnDrawCallback": null,
  9145. /**
  9146. * Identical to fnHeaderCallback() but for the table footer this function
  9147. * allows you to modify the table footer on every 'draw' event.
  9148. * @type function
  9149. * @param {node} foot "TR" element for the footer
  9150. * @param {array} data Full table data (as derived from the original HTML)
  9151. * @param {int} start Index for the current display starting point in the
  9152. * display array
  9153. * @param {int} end Index for the current display ending point in the
  9154. * display array
  9155. * @param {array int} display Index array to translate the visual position
  9156. * to the full data array
  9157. *
  9158. * @dtopt Callbacks
  9159. * @name DataTable.defaults.footerCallback
  9160. *
  9161. * @example
  9162. * $(document).ready( function() {
  9163. * $('#example').dataTable( {
  9164. * "footerCallback": function( tfoot, data, start, end, display ) {
  9165. * tfoot.getElementsByTagName('th')[0].innerHTML = "Starting index is "+start;
  9166. * }
  9167. * } );
  9168. * } )
  9169. */
  9170. "fnFooterCallback": null,
  9171. /**
  9172. * When rendering large numbers in the information element for the table
  9173. * (i.e. "Showing 1 to 10 of 57 entries") DataTables will render large numbers
  9174. * to have a comma separator for the 'thousands' units (e.g. 1 million is
  9175. * rendered as "1,000,000") to help readability for the end user. This
  9176. * function will override the default method DataTables uses.
  9177. * @type function
  9178. * @member
  9179. * @param {int} toFormat number to be formatted
  9180. * @returns {string} formatted string for DataTables to show the number
  9181. *
  9182. * @dtopt Callbacks
  9183. * @name DataTable.defaults.formatNumber
  9184. *
  9185. * @example
  9186. * // Format a number using a single quote for the separator (note that
  9187. * // this can also be done with the language.thousands option)
  9188. * $(document).ready( function() {
  9189. * $('#example').dataTable( {
  9190. * "formatNumber": function ( toFormat ) {
  9191. * return toFormat.toString().replace(
  9192. * /\B(?=(\d{3})+(?!\d))/g, "'"
  9193. * );
  9194. * };
  9195. * } );
  9196. * } );
  9197. */
  9198. "fnFormatNumber": function ( toFormat ) {
  9199. return toFormat.toString().replace(
  9200. /\B(?=(\d{3})+(?!\d))/g,
  9201. this.oLanguage.sThousands
  9202. );
  9203. },
  9204. /**
  9205. * This function is called on every 'draw' event, and allows you to
  9206. * dynamically modify the header row. This can be used to calculate and
  9207. * display useful information about the table.
  9208. * @type function
  9209. * @param {node} head "TR" element for the header
  9210. * @param {array} data Full table data (as derived from the original HTML)
  9211. * @param {int} start Index for the current display starting point in the
  9212. * display array
  9213. * @param {int} end Index for the current display ending point in the
  9214. * display array
  9215. * @param {array int} display Index array to translate the visual position
  9216. * to the full data array
  9217. *
  9218. * @dtopt Callbacks
  9219. * @name DataTable.defaults.headerCallback
  9220. *
  9221. * @example
  9222. * $(document).ready( function() {
  9223. * $('#example').dataTable( {
  9224. * "fheaderCallback": function( head, data, start, end, display ) {
  9225. * head.getElementsByTagName('th')[0].innerHTML = "Displaying "+(end-start)+" records";
  9226. * }
  9227. * } );
  9228. * } )
  9229. */
  9230. "fnHeaderCallback": null,
  9231. /**
  9232. * The information element can be used to convey information about the current
  9233. * state of the table. Although the internationalisation options presented by
  9234. * DataTables are quite capable of dealing with most customisations, there may
  9235. * be times where you wish to customise the string further. This callback
  9236. * allows you to do exactly that.
  9237. * @type function
  9238. * @param {object} oSettings DataTables settings object
  9239. * @param {int} start Starting position in data for the draw
  9240. * @param {int} end End position in data for the draw
  9241. * @param {int} max Total number of rows in the table (regardless of
  9242. * filtering)
  9243. * @param {int} total Total number of rows in the data set, after filtering
  9244. * @param {string} pre The string that DataTables has formatted using it's
  9245. * own rules
  9246. * @returns {string} The string to be displayed in the information element.
  9247. *
  9248. * @dtopt Callbacks
  9249. * @name DataTable.defaults.infoCallback
  9250. *
  9251. * @example
  9252. * $('#example').dataTable( {
  9253. * "infoCallback": function( settings, start, end, max, total, pre ) {
  9254. * return start +" to "+ end;
  9255. * }
  9256. * } );
  9257. */
  9258. "fnInfoCallback": null,
  9259. /**
  9260. * Called when the table has been initialised. Normally DataTables will
  9261. * initialise sequentially and there will be no need for this function,
  9262. * however, this does not hold true when using external language information
  9263. * since that is obtained using an async XHR call.
  9264. * @type function
  9265. * @param {object} settings DataTables settings object
  9266. * @param {object} json The JSON object request from the server - only
  9267. * present if client-side Ajax sourced data is used
  9268. *
  9269. * @dtopt Callbacks
  9270. * @name DataTable.defaults.initComplete
  9271. *
  9272. * @example
  9273. * $(document).ready( function() {
  9274. * $('#example').dataTable( {
  9275. * "initComplete": function(settings, json) {
  9276. * alert( 'DataTables has finished its initialisation.' );
  9277. * }
  9278. * } );
  9279. * } )
  9280. */
  9281. "fnInitComplete": null,
  9282. /**
  9283. * Called at the very start of each table draw and can be used to cancel the
  9284. * draw by returning false, any other return (including undefined) results in
  9285. * the full draw occurring).
  9286. * @type function
  9287. * @param {object} settings DataTables settings object
  9288. * @returns {boolean} False will cancel the draw, anything else (including no
  9289. * return) will allow it to complete.
  9290. *
  9291. * @dtopt Callbacks
  9292. * @name DataTable.defaults.preDrawCallback
  9293. *
  9294. * @example
  9295. * $(document).ready( function() {
  9296. * $('#example').dataTable( {
  9297. * "preDrawCallback": function( settings ) {
  9298. * if ( $('#test').val() == 1 ) {
  9299. * return false;
  9300. * }
  9301. * }
  9302. * } );
  9303. * } );
  9304. */
  9305. "fnPreDrawCallback": null,
  9306. /**
  9307. * This function allows you to 'post process' each row after it have been
  9308. * generated for each table draw, but before it is rendered on screen. This
  9309. * function might be used for setting the row class name etc.
  9310. * @type function
  9311. * @param {node} row "TR" element for the current row
  9312. * @param {array} data Raw data array for this row
  9313. * @param {int} displayIndex The display index for the current table draw
  9314. * @param {int} displayIndexFull The index of the data in the full list of
  9315. * rows (after filtering)
  9316. *
  9317. * @dtopt Callbacks
  9318. * @name DataTable.defaults.rowCallback
  9319. *
  9320. * @example
  9321. * $(document).ready( function() {
  9322. * $('#example').dataTable( {
  9323. * "rowCallback": function( row, data, displayIndex, displayIndexFull ) {
  9324. * // Bold the grade for all 'A' grade browsers
  9325. * if ( data[4] == "A" ) {
  9326. * $('td:eq(4)', row).html( '<b>A</b>' );
  9327. * }
  9328. * }
  9329. * } );
  9330. * } );
  9331. */
  9332. "fnRowCallback": null,
  9333. /**
  9334. * __Deprecated__ The functionality provided by this parameter has now been
  9335. * superseded by that provided through `ajax`, which should be used instead.
  9336. *
  9337. * This parameter allows you to override the default function which obtains
  9338. * the data from the server so something more suitable for your application.
  9339. * For example you could use POST data, or pull information from a Gears or
  9340. * AIR database.
  9341. * @type function
  9342. * @member
  9343. * @param {string} source HTTP source to obtain the data from (`ajax`)
  9344. * @param {array} data A key/value pair object containing the data to send
  9345. * to the server
  9346. * @param {function} callback to be called on completion of the data get
  9347. * process that will draw the data on the page.
  9348. * @param {object} settings DataTables settings object
  9349. *
  9350. * @dtopt Callbacks
  9351. * @dtopt Server-side
  9352. * @name DataTable.defaults.serverData
  9353. *
  9354. * @deprecated 1.10. Please use `ajax` for this functionality now.
  9355. */
  9356. "fnServerData": null,
  9357. /**
  9358. * __Deprecated__ The functionality provided by this parameter has now been
  9359. * superseded by that provided through `ajax`, which should be used instead.
  9360. *
  9361. * It is often useful to send extra data to the server when making an Ajax
  9362. * request - for example custom filtering information, and this callback
  9363. * function makes it trivial to send extra information to the server. The
  9364. * passed in parameter is the data set that has been constructed by
  9365. * DataTables, and you can add to this or modify it as you require.
  9366. * @type function
  9367. * @param {array} data Data array (array of objects which are name/value
  9368. * pairs) that has been constructed by DataTables and will be sent to the
  9369. * server. In the case of Ajax sourced data with server-side processing
  9370. * this will be an empty array, for server-side processing there will be a
  9371. * significant number of parameters!
  9372. * @returns {undefined} Ensure that you modify the data array passed in,
  9373. * as this is passed by reference.
  9374. *
  9375. * @dtopt Callbacks
  9376. * @dtopt Server-side
  9377. * @name DataTable.defaults.serverParams
  9378. *
  9379. * @deprecated 1.10. Please use `ajax` for this functionality now.
  9380. */
  9381. "fnServerParams": null,
  9382. /**
  9383. * Load the table state. With this function you can define from where, and how, the
  9384. * state of a table is loaded. By default DataTables will load from `localStorage`
  9385. * but you might wish to use a server-side database or cookies.
  9386. * @type function
  9387. * @member
  9388. * @param {object} settings DataTables settings object
  9389. * @param {object} callback Callback that can be executed when done. It
  9390. * should be passed the loaded state object.
  9391. * @return {object} The DataTables state object to be loaded
  9392. *
  9393. * @dtopt Callbacks
  9394. * @name DataTable.defaults.stateLoadCallback
  9395. *
  9396. * @example
  9397. * $(document).ready( function() {
  9398. * $('#example').dataTable( {
  9399. * "stateSave": true,
  9400. * "stateLoadCallback": function (settings, callback) {
  9401. * $.ajax( {
  9402. * "url": "/state_load",
  9403. * "dataType": "json",
  9404. * "success": function (json) {
  9405. * callback( json );
  9406. * }
  9407. * } );
  9408. * }
  9409. * } );
  9410. * } );
  9411. */
  9412. "fnStateLoadCallback": function ( settings ) {
  9413. try {
  9414. return JSON.parse(
  9415. (settings.iStateDuration === -1 ? sessionStorage : localStorage).getItem(
  9416. 'DataTables_'+settings.sInstance+'_'+location.pathname
  9417. )
  9418. );
  9419. } catch (e) {}
  9420. },
  9421. /**
  9422. * Callback which allows modification of the saved state prior to loading that state.
  9423. * This callback is called when the table is loading state from the stored data, but
  9424. * prior to the settings object being modified by the saved state. Note that for
  9425. * plug-in authors, you should use the `stateLoadParams` event to load parameters for
  9426. * a plug-in.
  9427. * @type function
  9428. * @param {object} settings DataTables settings object
  9429. * @param {object} data The state object that is to be loaded
  9430. *
  9431. * @dtopt Callbacks
  9432. * @name DataTable.defaults.stateLoadParams
  9433. *
  9434. * @example
  9435. * // Remove a saved filter, so filtering is never loaded
  9436. * $(document).ready( function() {
  9437. * $('#example').dataTable( {
  9438. * "stateSave": true,
  9439. * "stateLoadParams": function (settings, data) {
  9440. * data.oSearch.sSearch = "";
  9441. * }
  9442. * } );
  9443. * } );
  9444. *
  9445. * @example
  9446. * // Disallow state loading by returning false
  9447. * $(document).ready( function() {
  9448. * $('#example').dataTable( {
  9449. * "stateSave": true,
  9450. * "stateLoadParams": function (settings, data) {
  9451. * return false;
  9452. * }
  9453. * } );
  9454. * } );
  9455. */
  9456. "fnStateLoadParams": null,
  9457. /**
  9458. * Callback that is called when the state has been loaded from the state saving method
  9459. * and the DataTables settings object has been modified as a result of the loaded state.
  9460. * @type function
  9461. * @param {object} settings DataTables settings object
  9462. * @param {object} data The state object that was loaded
  9463. *
  9464. * @dtopt Callbacks
  9465. * @name DataTable.defaults.stateLoaded
  9466. *
  9467. * @example
  9468. * // Show an alert with the filtering value that was saved
  9469. * $(document).ready( function() {
  9470. * $('#example').dataTable( {
  9471. * "stateSave": true,
  9472. * "stateLoaded": function (settings, data) {
  9473. * alert( 'Saved filter was: '+data.oSearch.sSearch );
  9474. * }
  9475. * } );
  9476. * } );
  9477. */
  9478. "fnStateLoaded": null,
  9479. /**
  9480. * Save the table state. This function allows you to define where and how the state
  9481. * information for the table is stored By default DataTables will use `localStorage`
  9482. * but you might wish to use a server-side database or cookies.
  9483. * @type function
  9484. * @member
  9485. * @param {object} settings DataTables settings object
  9486. * @param {object} data The state object to be saved
  9487. *
  9488. * @dtopt Callbacks
  9489. * @name DataTable.defaults.stateSaveCallback
  9490. *
  9491. * @example
  9492. * $(document).ready( function() {
  9493. * $('#example').dataTable( {
  9494. * "stateSave": true,
  9495. * "stateSaveCallback": function (settings, data) {
  9496. * // Send an Ajax request to the server with the state object
  9497. * $.ajax( {
  9498. * "url": "/state_save",
  9499. * "data": data,
  9500. * "dataType": "json",
  9501. * "method": "POST"
  9502. * "success": function () {}
  9503. * } );
  9504. * }
  9505. * } );
  9506. * } );
  9507. */
  9508. "fnStateSaveCallback": function ( settings, data ) {
  9509. try {
  9510. (settings.iStateDuration === -1 ? sessionStorage : localStorage).setItem(
  9511. 'DataTables_'+settings.sInstance+'_'+location.pathname,
  9512. JSON.stringify( data )
  9513. );
  9514. } catch (e) {}
  9515. },
  9516. /**
  9517. * Callback which allows modification of the state to be saved. Called when the table
  9518. * has changed state a new state save is required. This method allows modification of
  9519. * the state saving object prior to actually doing the save, including addition or
  9520. * other state properties or modification. Note that for plug-in authors, you should
  9521. * use the `stateSaveParams` event to save parameters for a plug-in.
  9522. * @type function
  9523. * @param {object} settings DataTables settings object
  9524. * @param {object} data The state object to be saved
  9525. *
  9526. * @dtopt Callbacks
  9527. * @name DataTable.defaults.stateSaveParams
  9528. *
  9529. * @example
  9530. * // Remove a saved filter, so filtering is never saved
  9531. * $(document).ready( function() {
  9532. * $('#example').dataTable( {
  9533. * "stateSave": true,
  9534. * "stateSaveParams": function (settings, data) {
  9535. * data.oSearch.sSearch = "";
  9536. * }
  9537. * } );
  9538. * } );
  9539. */
  9540. "fnStateSaveParams": null,
  9541. /**
  9542. * Duration for which the saved state information is considered valid. After this period
  9543. * has elapsed the state will be returned to the default.
  9544. * Value is given in seconds.
  9545. * @type int
  9546. * @default 7200 <i>(2 hours)</i>
  9547. *
  9548. * @dtopt Options
  9549. * @name DataTable.defaults.stateDuration
  9550. *
  9551. * @example
  9552. * $(document).ready( function() {
  9553. * $('#example').dataTable( {
  9554. * "stateDuration": 60*60*24; // 1 day
  9555. * } );
  9556. * } )
  9557. */
  9558. "iStateDuration": 7200,
  9559. /**
  9560. * When enabled DataTables will not make a request to the server for the first
  9561. * page draw - rather it will use the data already on the page (no sorting etc
  9562. * will be applied to it), thus saving on an XHR at load time. `deferLoading`
  9563. * is used to indicate that deferred loading is required, but it is also used
  9564. * to tell DataTables how many records there are in the full table (allowing
  9565. * the information element and pagination to be displayed correctly). In the case
  9566. * where a filtering is applied to the table on initial load, this can be
  9567. * indicated by giving the parameter as an array, where the first element is
  9568. * the number of records available after filtering and the second element is the
  9569. * number of records without filtering (allowing the table information element
  9570. * to be shown correctly).
  9571. * @type int | array
  9572. * @default null
  9573. *
  9574. * @dtopt Options
  9575. * @name DataTable.defaults.deferLoading
  9576. *
  9577. * @example
  9578. * // 57 records available in the table, no filtering applied
  9579. * $(document).ready( function() {
  9580. * $('#example').dataTable( {
  9581. * "serverSide": true,
  9582. * "ajax": "scripts/server_processing.php",
  9583. * "deferLoading": 57
  9584. * } );
  9585. * } );
  9586. *
  9587. * @example
  9588. * // 57 records after filtering, 100 without filtering (an initial filter applied)
  9589. * $(document).ready( function() {
  9590. * $('#example').dataTable( {
  9591. * "serverSide": true,
  9592. * "ajax": "scripts/server_processing.php",
  9593. * "deferLoading": [ 57, 100 ],
  9594. * "search": {
  9595. * "search": "my_filter"
  9596. * }
  9597. * } );
  9598. * } );
  9599. */
  9600. "iDeferLoading": null,
  9601. /**
  9602. * Number of rows to display on a single page when using pagination. If
  9603. * feature enabled (`lengthChange`) then the end user will be able to override
  9604. * this to a custom setting using a pop-up menu.
  9605. * @type int
  9606. * @default 10
  9607. *
  9608. * @dtopt Options
  9609. * @name DataTable.defaults.pageLength
  9610. *
  9611. * @example
  9612. * $(document).ready( function() {
  9613. * $('#example').dataTable( {
  9614. * "pageLength": 50
  9615. * } );
  9616. * } )
  9617. */
  9618. "iDisplayLength": 10,
  9619. /**
  9620. * Define the starting point for data display when using DataTables with
  9621. * pagination. Note that this parameter is the number of records, rather than
  9622. * the page number, so if you have 10 records per page and want to start on
  9623. * the third page, it should be "20".
  9624. * @type int
  9625. * @default 0
  9626. *
  9627. * @dtopt Options
  9628. * @name DataTable.defaults.displayStart
  9629. *
  9630. * @example
  9631. * $(document).ready( function() {
  9632. * $('#example').dataTable( {
  9633. * "displayStart": 20
  9634. * } );
  9635. * } )
  9636. */
  9637. "iDisplayStart": 0,
  9638. /**
  9639. * By default DataTables allows keyboard navigation of the table (sorting, paging,
  9640. * and filtering) by adding a `tabindex` attribute to the required elements. This
  9641. * allows you to tab through the controls and press the enter key to activate them.
  9642. * The tabindex is default 0, meaning that the tab follows the flow of the document.
  9643. * You can overrule this using this parameter if you wish. Use a value of -1 to
  9644. * disable built-in keyboard navigation.
  9645. * @type int
  9646. * @default 0
  9647. *
  9648. * @dtopt Options
  9649. * @name DataTable.defaults.tabIndex
  9650. *
  9651. * @example
  9652. * $(document).ready( function() {
  9653. * $('#example').dataTable( {
  9654. * "tabIndex": 1
  9655. * } );
  9656. * } );
  9657. */
  9658. "iTabIndex": 0,
  9659. /**
  9660. * Classes that DataTables assigns to the various components and features
  9661. * that it adds to the HTML table. This allows classes to be configured
  9662. * during initialisation in addition to through the static
  9663. * {@link DataTable.ext.oStdClasses} object).
  9664. * @namespace
  9665. * @name DataTable.defaults.classes
  9666. */
  9667. "oClasses": {},
  9668. /**
  9669. * All strings that DataTables uses in the user interface that it creates
  9670. * are defined in this object, allowing you to modified them individually or
  9671. * completely replace them all as required.
  9672. * @namespace
  9673. * @name DataTable.defaults.language
  9674. */
  9675. "oLanguage": {
  9676. /**
  9677. * Strings that are used for WAI-ARIA labels and controls only (these are not
  9678. * actually visible on the page, but will be read by screenreaders, and thus
  9679. * must be internationalised as well).
  9680. * @namespace
  9681. * @name DataTable.defaults.language.aria
  9682. */
  9683. "oAria": {
  9684. /**
  9685. * ARIA label that is added to the table headers when the column may be
  9686. * sorted ascending by activing the column (click or return when focused).
  9687. * Note that the column header is prefixed to this string.
  9688. * @type string
  9689. * @default : activate to sort column ascending
  9690. *
  9691. * @dtopt Language
  9692. * @name DataTable.defaults.language.aria.sortAscending
  9693. *
  9694. * @example
  9695. * $(document).ready( function() {
  9696. * $('#example').dataTable( {
  9697. * "language": {
  9698. * "aria": {
  9699. * "sortAscending": " - click/return to sort ascending"
  9700. * }
  9701. * }
  9702. * } );
  9703. * } );
  9704. */
  9705. "sSortAscending": ": activate to sort column ascending",
  9706. /**
  9707. * ARIA label that is added to the table headers when the column may be
  9708. * sorted descending by activing the column (click or return when focused).
  9709. * Note that the column header is prefixed to this string.
  9710. * @type string
  9711. * @default : activate to sort column ascending
  9712. *
  9713. * @dtopt Language
  9714. * @name DataTable.defaults.language.aria.sortDescending
  9715. *
  9716. * @example
  9717. * $(document).ready( function() {
  9718. * $('#example').dataTable( {
  9719. * "language": {
  9720. * "aria": {
  9721. * "sortDescending": " - click/return to sort descending"
  9722. * }
  9723. * }
  9724. * } );
  9725. * } );
  9726. */
  9727. "sSortDescending": ": activate to sort column descending"
  9728. },
  9729. /**
  9730. * Pagination string used by DataTables for the built-in pagination
  9731. * control types.
  9732. * @namespace
  9733. * @name DataTable.defaults.language.paginate
  9734. */
  9735. "oPaginate": {
  9736. /**
  9737. * Text to use when using the 'full_numbers' type of pagination for the
  9738. * button to take the user to the first page.
  9739. * @type string
  9740. * @default First
  9741. *
  9742. * @dtopt Language
  9743. * @name DataTable.defaults.language.paginate.first
  9744. *
  9745. * @example
  9746. * $(document).ready( function() {
  9747. * $('#example').dataTable( {
  9748. * "language": {
  9749. * "paginate": {
  9750. * "first": "First page"
  9751. * }
  9752. * }
  9753. * } );
  9754. * } );
  9755. */
  9756. "sFirst": "First",
  9757. /**
  9758. * Text to use when using the 'full_numbers' type of pagination for the
  9759. * button to take the user to the last page.
  9760. * @type string
  9761. * @default Last
  9762. *
  9763. * @dtopt Language
  9764. * @name DataTable.defaults.language.paginate.last
  9765. *
  9766. * @example
  9767. * $(document).ready( function() {
  9768. * $('#example').dataTable( {
  9769. * "language": {
  9770. * "paginate": {
  9771. * "last": "Last page"
  9772. * }
  9773. * }
  9774. * } );
  9775. * } );
  9776. */
  9777. "sLast": "Last",
  9778. /**
  9779. * Text to use for the 'next' pagination button (to take the user to the
  9780. * next page).
  9781. * @type string
  9782. * @default Next
  9783. *
  9784. * @dtopt Language
  9785. * @name DataTable.defaults.language.paginate.next
  9786. *
  9787. * @example
  9788. * $(document).ready( function() {
  9789. * $('#example').dataTable( {
  9790. * "language": {
  9791. * "paginate": {
  9792. * "next": "Next page"
  9793. * }
  9794. * }
  9795. * } );
  9796. * } );
  9797. */
  9798. "sNext": "Next",
  9799. /**
  9800. * Text to use for the 'previous' pagination button (to take the user to
  9801. * the previous page).
  9802. * @type string
  9803. * @default Previous
  9804. *
  9805. * @dtopt Language
  9806. * @name DataTable.defaults.language.paginate.previous
  9807. *
  9808. * @example
  9809. * $(document).ready( function() {
  9810. * $('#example').dataTable( {
  9811. * "language": {
  9812. * "paginate": {
  9813. * "previous": "Previous page"
  9814. * }
  9815. * }
  9816. * } );
  9817. * } );
  9818. */
  9819. "sPrevious": "Previous"
  9820. },
  9821. /**
  9822. * This string is shown in preference to `zeroRecords` when the table is
  9823. * empty of data (regardless of filtering). Note that this is an optional
  9824. * parameter - if it is not given, the value of `zeroRecords` will be used
  9825. * instead (either the default or given value).
  9826. * @type string
  9827. * @default No data available in table
  9828. *
  9829. * @dtopt Language
  9830. * @name DataTable.defaults.language.emptyTable
  9831. *
  9832. * @example
  9833. * $(document).ready( function() {
  9834. * $('#example').dataTable( {
  9835. * "language": {
  9836. * "emptyTable": "No data available in table"
  9837. * }
  9838. * } );
  9839. * } );
  9840. */
  9841. "sEmptyTable": "No data available in table",
  9842. /**
  9843. * This string gives information to the end user about the information
  9844. * that is current on display on the page. The following tokens can be
  9845. * used in the string and will be dynamically replaced as the table
  9846. * display updates. This tokens can be placed anywhere in the string, or
  9847. * removed as needed by the language requires:
  9848. *
  9849. * * `\_START\_` - Display index of the first record on the current page
  9850. * * `\_END\_` - Display index of the last record on the current page
  9851. * * `\_TOTAL\_` - Number of records in the table after filtering
  9852. * * `\_MAX\_` - Number of records in the table without filtering
  9853. * * `\_PAGE\_` - Current page number
  9854. * * `\_PAGES\_` - Total number of pages of data in the table
  9855. *
  9856. * @type string
  9857. * @default Showing _START_ to _END_ of _TOTAL_ entries
  9858. *
  9859. * @dtopt Language
  9860. * @name DataTable.defaults.language.info
  9861. *
  9862. * @example
  9863. * $(document).ready( function() {
  9864. * $('#example').dataTable( {
  9865. * "language": {
  9866. * "info": "Showing page _PAGE_ of _PAGES_"
  9867. * }
  9868. * } );
  9869. * } );
  9870. */
  9871. "sInfo": "Showing _START_ to _END_ of _TOTAL_ entries",
  9872. /**
  9873. * Display information string for when the table is empty. Typically the
  9874. * format of this string should match `info`.
  9875. * @type string
  9876. * @default Showing 0 to 0 of 0 entries
  9877. *
  9878. * @dtopt Language
  9879. * @name DataTable.defaults.language.infoEmpty
  9880. *
  9881. * @example
  9882. * $(document).ready( function() {
  9883. * $('#example').dataTable( {
  9884. * "language": {
  9885. * "infoEmpty": "No entries to show"
  9886. * }
  9887. * } );
  9888. * } );
  9889. */
  9890. "sInfoEmpty": "Showing 0 to 0 of 0 entries",
  9891. /**
  9892. * When a user filters the information in a table, this string is appended
  9893. * to the information (`info`) to give an idea of how strong the filtering
  9894. * is. The variable _MAX_ is dynamically updated.
  9895. * @type string
  9896. * @default (filtered from _MAX_ total entries)
  9897. *
  9898. * @dtopt Language
  9899. * @name DataTable.defaults.language.infoFiltered
  9900. *
  9901. * @example
  9902. * $(document).ready( function() {
  9903. * $('#example').dataTable( {
  9904. * "language": {
  9905. * "infoFiltered": " - filtering from _MAX_ records"
  9906. * }
  9907. * } );
  9908. * } );
  9909. */
  9910. "sInfoFiltered": "(filtered from _MAX_ total entries)",
  9911. /**
  9912. * If can be useful to append extra information to the info string at times,
  9913. * and this variable does exactly that. This information will be appended to
  9914. * the `info` (`infoEmpty` and `infoFiltered` in whatever combination they are
  9915. * being used) at all times.
  9916. * @type string
  9917. * @default <i>Empty string</i>
  9918. *
  9919. * @dtopt Language
  9920. * @name DataTable.defaults.language.infoPostFix
  9921. *
  9922. * @example
  9923. * $(document).ready( function() {
  9924. * $('#example').dataTable( {
  9925. * "language": {
  9926. * "infoPostFix": "All records shown are derived from real information."
  9927. * }
  9928. * } );
  9929. * } );
  9930. */
  9931. "sInfoPostFix": "",
  9932. /**
  9933. * This decimal place operator is a little different from the other
  9934. * language options since DataTables doesn't output floating point
  9935. * numbers, so it won't ever use this for display of a number. Rather,
  9936. * what this parameter does is modify the sort methods of the table so
  9937. * that numbers which are in a format which has a character other than
  9938. * a period (`.`) as a decimal place will be sorted numerically.
  9939. *
  9940. * Note that numbers with different decimal places cannot be shown in
  9941. * the same table and still be sortable, the table must be consistent.
  9942. * However, multiple different tables on the page can use different
  9943. * decimal place characters.
  9944. * @type string
  9945. * @default
  9946. *
  9947. * @dtopt Language
  9948. * @name DataTable.defaults.language.decimal
  9949. *
  9950. * @example
  9951. * $(document).ready( function() {
  9952. * $('#example').dataTable( {
  9953. * "language": {
  9954. * "decimal": ","
  9955. * "thousands": "."
  9956. * }
  9957. * } );
  9958. * } );
  9959. */
  9960. "sDecimal": "",
  9961. /**
  9962. * DataTables has a build in number formatter (`formatNumber`) which is
  9963. * used to format large numbers that are used in the table information.
  9964. * By default a comma is used, but this can be trivially changed to any
  9965. * character you wish with this parameter.
  9966. * @type string
  9967. * @default ,
  9968. *
  9969. * @dtopt Language
  9970. * @name DataTable.defaults.language.thousands
  9971. *
  9972. * @example
  9973. * $(document).ready( function() {
  9974. * $('#example').dataTable( {
  9975. * "language": {
  9976. * "thousands": "'"
  9977. * }
  9978. * } );
  9979. * } );
  9980. */
  9981. "sThousands": ",",
  9982. /**
  9983. * Detail the action that will be taken when the drop down menu for the
  9984. * pagination length option is changed. The '_MENU_' variable is replaced
  9985. * with a default select list of 10, 25, 50 and 100, and can be replaced
  9986. * with a custom select box if required.
  9987. * @type string
  9988. * @default Show _MENU_ entries
  9989. *
  9990. * @dtopt Language
  9991. * @name DataTable.defaults.language.lengthMenu
  9992. *
  9993. * @example
  9994. * // Language change only
  9995. * $(document).ready( function() {
  9996. * $('#example').dataTable( {
  9997. * "language": {
  9998. * "lengthMenu": "Display _MENU_ records"
  9999. * }
  10000. * } );
  10001. * } );
  10002. *
  10003. * @example
  10004. * // Language and options change
  10005. * $(document).ready( function() {
  10006. * $('#example').dataTable( {
  10007. * "language": {
  10008. * "lengthMenu": 'Display <select>'+
  10009. * '<option value="10">10</option>'+
  10010. * '<option value="20">20</option>'+
  10011. * '<option value="30">30</option>'+
  10012. * '<option value="40">40</option>'+
  10013. * '<option value="50">50</option>'+
  10014. * '<option value="-1">All</option>'+
  10015. * '</select> records'
  10016. * }
  10017. * } );
  10018. * } );
  10019. */
  10020. "sLengthMenu": "Show _MENU_ entries",
  10021. /**
  10022. * When using Ajax sourced data and during the first draw when DataTables is
  10023. * gathering the data, this message is shown in an empty row in the table to
  10024. * indicate to the end user the the data is being loaded. Note that this
  10025. * parameter is not used when loading data by server-side processing, just
  10026. * Ajax sourced data with client-side processing.
  10027. * @type string
  10028. * @default Loading...
  10029. *
  10030. * @dtopt Language
  10031. * @name DataTable.defaults.language.loadingRecords
  10032. *
  10033. * @example
  10034. * $(document).ready( function() {
  10035. * $('#example').dataTable( {
  10036. * "language": {
  10037. * "loadingRecords": "Please wait - loading..."
  10038. * }
  10039. * } );
  10040. * } );
  10041. */
  10042. "sLoadingRecords": "Loading...",
  10043. /**
  10044. * Text which is displayed when the table is processing a user action
  10045. * (usually a sort command or similar).
  10046. * @type string
  10047. * @default Processing...
  10048. *
  10049. * @dtopt Language
  10050. * @name DataTable.defaults.language.processing
  10051. *
  10052. * @example
  10053. * $(document).ready( function() {
  10054. * $('#example').dataTable( {
  10055. * "language": {
  10056. * "processing": "DataTables is currently busy"
  10057. * }
  10058. * } );
  10059. * } );
  10060. */
  10061. "sProcessing": "Processing...",
  10062. /**
  10063. * Details the actions that will be taken when the user types into the
  10064. * filtering input text box. The variable "_INPUT_", if used in the string,
  10065. * is replaced with the HTML text box for the filtering input allowing
  10066. * control over where it appears in the string. If "_INPUT_" is not given
  10067. * then the input box is appended to the string automatically.
  10068. * @type string
  10069. * @default Search:
  10070. *
  10071. * @dtopt Language
  10072. * @name DataTable.defaults.language.search
  10073. *
  10074. * @example
  10075. * // Input text box will be appended at the end automatically
  10076. * $(document).ready( function() {
  10077. * $('#example').dataTable( {
  10078. * "language": {
  10079. * "search": "Filter records:"
  10080. * }
  10081. * } );
  10082. * } );
  10083. *
  10084. * @example
  10085. * // Specify where the filter should appear
  10086. * $(document).ready( function() {
  10087. * $('#example').dataTable( {
  10088. * "language": {
  10089. * "search": "Apply filter _INPUT_ to table"
  10090. * }
  10091. * } );
  10092. * } );
  10093. */
  10094. "sSearch": "Search:",
  10095. /**
  10096. * Assign a `placeholder` attribute to the search `input` element
  10097. * @type string
  10098. * @default
  10099. *
  10100. * @dtopt Language
  10101. * @name DataTable.defaults.language.searchPlaceholder
  10102. */
  10103. "sSearchPlaceholder": "",
  10104. /**
  10105. * All of the language information can be stored in a file on the
  10106. * server-side, which DataTables will look up if this parameter is passed.
  10107. * It must store the URL of the language file, which is in a JSON format,
  10108. * and the object has the same properties as the oLanguage object in the
  10109. * initialiser object (i.e. the above parameters). Please refer to one of
  10110. * the example language files to see how this works in action.
  10111. * @type string
  10112. * @default <i>Empty string - i.e. disabled</i>
  10113. *
  10114. * @dtopt Language
  10115. * @name DataTable.defaults.language.url
  10116. *
  10117. * @example
  10118. * $(document).ready( function() {
  10119. * $('#example').dataTable( {
  10120. * "language": {
  10121. * "url": "http://www.sprymedia.co.uk/dataTables/lang.txt"
  10122. * }
  10123. * } );
  10124. * } );
  10125. */
  10126. "sUrl": "",
  10127. /**
  10128. * Text shown inside the table records when the is no information to be
  10129. * displayed after filtering. `emptyTable` is shown when there is simply no
  10130. * information in the table at all (regardless of filtering).
  10131. * @type string
  10132. * @default No matching records found
  10133. *
  10134. * @dtopt Language
  10135. * @name DataTable.defaults.language.zeroRecords
  10136. *
  10137. * @example
  10138. * $(document).ready( function() {
  10139. * $('#example').dataTable( {
  10140. * "language": {
  10141. * "zeroRecords": "No records to display"
  10142. * }
  10143. * } );
  10144. * } );
  10145. */
  10146. "sZeroRecords": "No matching records found"
  10147. },
  10148. /**
  10149. * This parameter allows you to have define the global filtering state at
  10150. * initialisation time. As an object the `search` parameter must be
  10151. * defined, but all other parameters are optional. When `regex` is true,
  10152. * the search string will be treated as a regular expression, when false
  10153. * (default) it will be treated as a straight string. When `smart`
  10154. * DataTables will use it's smart filtering methods (to word match at
  10155. * any point in the data), when false this will not be done.
  10156. * @namespace
  10157. * @extends DataTable.models.oSearch
  10158. *
  10159. * @dtopt Options
  10160. * @name DataTable.defaults.search
  10161. *
  10162. * @example
  10163. * $(document).ready( function() {
  10164. * $('#example').dataTable( {
  10165. * "search": {"search": "Initial search"}
  10166. * } );
  10167. * } )
  10168. */
  10169. "oSearch": $.extend( {}, DataTable.models.oSearch ),
  10170. /**
  10171. * __Deprecated__ The functionality provided by this parameter has now been
  10172. * superseded by that provided through `ajax`, which should be used instead.
  10173. *
  10174. * By default DataTables will look for the property `data` (or `aaData` for
  10175. * compatibility with DataTables 1.9-) when obtaining data from an Ajax
  10176. * source or for server-side processing - this parameter allows that
  10177. * property to be changed. You can use Javascript dotted object notation to
  10178. * get a data source for multiple levels of nesting.
  10179. * @type string
  10180. * @default data
  10181. *
  10182. * @dtopt Options
  10183. * @dtopt Server-side
  10184. * @name DataTable.defaults.ajaxDataProp
  10185. *
  10186. * @deprecated 1.10. Please use `ajax` for this functionality now.
  10187. */
  10188. "sAjaxDataProp": "data",
  10189. /**
  10190. * __Deprecated__ The functionality provided by this parameter has now been
  10191. * superseded by that provided through `ajax`, which should be used instead.
  10192. *
  10193. * You can instruct DataTables to load data from an external
  10194. * source using this parameter (use aData if you want to pass data in you
  10195. * already have). Simply provide a url a JSON object can be obtained from.
  10196. * @type string
  10197. * @default null
  10198. *
  10199. * @dtopt Options
  10200. * @dtopt Server-side
  10201. * @name DataTable.defaults.ajaxSource
  10202. *
  10203. * @deprecated 1.10. Please use `ajax` for this functionality now.
  10204. */
  10205. "sAjaxSource": null,
  10206. /**
  10207. * This initialisation variable allows you to specify exactly where in the
  10208. * DOM you want DataTables to inject the various controls it adds to the page
  10209. * (for example you might want the pagination controls at the top of the
  10210. * table). DIV elements (with or without a custom class) can also be added to
  10211. * aid styling. The follow syntax is used:
  10212. * <ul>
  10213. * <li>The following options are allowed:
  10214. * <ul>
  10215. * <li>'l' - Length changing</li>
  10216. * <li>'f' - Filtering input</li>
  10217. * <li>'t' - The table!</li>
  10218. * <li>'i' - Information</li>
  10219. * <li>'p' - Pagination</li>
  10220. * <li>'r' - pRocessing</li>
  10221. * </ul>
  10222. * </li>
  10223. * <li>The following constants are allowed:
  10224. * <ul>
  10225. * <li>'H' - jQueryUI theme "header" classes ('fg-toolbar ui-widget-header ui-corner-tl ui-corner-tr ui-helper-clearfix')</li>
  10226. * <li>'F' - jQueryUI theme "footer" classes ('fg-toolbar ui-widget-header ui-corner-bl ui-corner-br ui-helper-clearfix')</li>
  10227. * </ul>
  10228. * </li>
  10229. * <li>The following syntax is expected:
  10230. * <ul>
  10231. * <li>'&lt;' and '&gt;' - div elements</li>
  10232. * <li>'&lt;"class" and '&gt;' - div with a class</li>
  10233. * <li>'&lt;"#id" and '&gt;' - div with an ID</li>
  10234. * </ul>
  10235. * </li>
  10236. * <li>Examples:
  10237. * <ul>
  10238. * <li>'&lt;"wrapper"flipt&gt;'</li>
  10239. * <li>'&lt;lf&lt;t&gt;ip&gt;'</li>
  10240. * </ul>
  10241. * </li>
  10242. * </ul>
  10243. * @type string
  10244. * @default lfrtip <i>(when `jQueryUI` is false)</i> <b>or</b>
  10245. * <"H"lfr>t<"F"ip> <i>(when `jQueryUI` is true)</i>
  10246. *
  10247. * @dtopt Options
  10248. * @name DataTable.defaults.dom
  10249. *
  10250. * @example
  10251. * $(document).ready( function() {
  10252. * $('#example').dataTable( {
  10253. * "dom": '&lt;"top"i&gt;rt&lt;"bottom"flp&gt;&lt;"clear"&gt;'
  10254. * } );
  10255. * } );
  10256. */
  10257. "sDom": "lfrtip",
  10258. /**
  10259. * Search delay option. This will throttle full table searches that use the
  10260. * DataTables provided search input element (it does not effect calls to
  10261. * `dt-api search()`, providing a delay before the search is made.
  10262. * @type integer
  10263. * @default 0
  10264. *
  10265. * @dtopt Options
  10266. * @name DataTable.defaults.searchDelay
  10267. *
  10268. * @example
  10269. * $(document).ready( function() {
  10270. * $('#example').dataTable( {
  10271. * "searchDelay": 200
  10272. * } );
  10273. * } )
  10274. */
  10275. "searchDelay": null,
  10276. /**
  10277. * DataTables features six different built-in options for the buttons to
  10278. * display for pagination control:
  10279. *
  10280. * * `numbers` - Page number buttons only
  10281. * * `simple` - 'Previous' and 'Next' buttons only
  10282. * * 'simple_numbers` - 'Previous' and 'Next' buttons, plus page numbers
  10283. * * `full` - 'First', 'Previous', 'Next' and 'Last' buttons
  10284. * * `full_numbers` - 'First', 'Previous', 'Next' and 'Last' buttons, plus page numbers
  10285. * * `first_last_numbers` - 'First' and 'Last' buttons, plus page numbers
  10286. *
  10287. * Further methods can be added using {@link DataTable.ext.oPagination}.
  10288. * @type string
  10289. * @default simple_numbers
  10290. *
  10291. * @dtopt Options
  10292. * @name DataTable.defaults.pagingType
  10293. *
  10294. * @example
  10295. * $(document).ready( function() {
  10296. * $('#example').dataTable( {
  10297. * "pagingType": "full_numbers"
  10298. * } );
  10299. * } )
  10300. */
  10301. "sPaginationType": "simple_numbers",
  10302. /**
  10303. * Enable horizontal scrolling. When a table is too wide to fit into a
  10304. * certain layout, or you have a large number of columns in the table, you
  10305. * can enable x-scrolling to show the table in a viewport, which can be
  10306. * scrolled. This property can be `true` which will allow the table to
  10307. * scroll horizontally when needed, or any CSS unit, or a number (in which
  10308. * case it will be treated as a pixel measurement). Setting as simply `true`
  10309. * is recommended.
  10310. * @type boolean|string
  10311. * @default <i>blank string - i.e. disabled</i>
  10312. *
  10313. * @dtopt Features
  10314. * @name DataTable.defaults.scrollX
  10315. *
  10316. * @example
  10317. * $(document).ready( function() {
  10318. * $('#example').dataTable( {
  10319. * "scrollX": true,
  10320. * "scrollCollapse": true
  10321. * } );
  10322. * } );
  10323. */
  10324. "sScrollX": "",
  10325. /**
  10326. * This property can be used to force a DataTable to use more width than it
  10327. * might otherwise do when x-scrolling is enabled. For example if you have a
  10328. * table which requires to be well spaced, this parameter is useful for
  10329. * "over-sizing" the table, and thus forcing scrolling. This property can by
  10330. * any CSS unit, or a number (in which case it will be treated as a pixel
  10331. * measurement).
  10332. * @type string
  10333. * @default <i>blank string - i.e. disabled</i>
  10334. *
  10335. * @dtopt Options
  10336. * @name DataTable.defaults.scrollXInner
  10337. *
  10338. * @example
  10339. * $(document).ready( function() {
  10340. * $('#example').dataTable( {
  10341. * "scrollX": "100%",
  10342. * "scrollXInner": "110%"
  10343. * } );
  10344. * } );
  10345. */
  10346. "sScrollXInner": "",
  10347. /**
  10348. * Enable vertical scrolling. Vertical scrolling will constrain the DataTable
  10349. * to the given height, and enable scrolling for any data which overflows the
  10350. * current viewport. This can be used as an alternative to paging to display
  10351. * a lot of data in a small area (although paging and scrolling can both be
  10352. * enabled at the same time). This property can be any CSS unit, or a number
  10353. * (in which case it will be treated as a pixel measurement).
  10354. * @type string
  10355. * @default <i>blank string - i.e. disabled</i>
  10356. *
  10357. * @dtopt Features
  10358. * @name DataTable.defaults.scrollY
  10359. *
  10360. * @example
  10361. * $(document).ready( function() {
  10362. * $('#example').dataTable( {
  10363. * "scrollY": "200px",
  10364. * "paginate": false
  10365. * } );
  10366. * } );
  10367. */
  10368. "sScrollY": "",
  10369. /**
  10370. * __Deprecated__ The functionality provided by this parameter has now been
  10371. * superseded by that provided through `ajax`, which should be used instead.
  10372. *
  10373. * Set the HTTP method that is used to make the Ajax call for server-side
  10374. * processing or Ajax sourced data.
  10375. * @type string
  10376. * @default GET
  10377. *
  10378. * @dtopt Options
  10379. * @dtopt Server-side
  10380. * @name DataTable.defaults.serverMethod
  10381. *
  10382. * @deprecated 1.10. Please use `ajax` for this functionality now.
  10383. */
  10384. "sServerMethod": "GET",
  10385. /**
  10386. * DataTables makes use of renderers when displaying HTML elements for
  10387. * a table. These renderers can be added or modified by plug-ins to
  10388. * generate suitable mark-up for a site. For example the Bootstrap
  10389. * integration plug-in for DataTables uses a paging button renderer to
  10390. * display pagination buttons in the mark-up required by Bootstrap.
  10391. *
  10392. * For further information about the renderers available see
  10393. * DataTable.ext.renderer
  10394. * @type string|object
  10395. * @default null
  10396. *
  10397. * @name DataTable.defaults.renderer
  10398. *
  10399. */
  10400. "renderer": null,
  10401. /**
  10402. * Set the data property name that DataTables should use to get a row's id
  10403. * to set as the `id` property in the node.
  10404. * @type string
  10405. * @default DT_RowId
  10406. *
  10407. * @name DataTable.defaults.rowId
  10408. */
  10409. "rowId": "DT_RowId"
  10410. };
  10411. _fnHungarianMap( DataTable.defaults );
  10412. /*
  10413. * Developer note - See note in model.defaults.js about the use of Hungarian
  10414. * notation and camel case.
  10415. */
  10416. /**
  10417. * Column options that can be given to DataTables at initialisation time.
  10418. * @namespace
  10419. */
  10420. DataTable.defaults.column = {
  10421. /**
  10422. * Define which column(s) an order will occur on for this column. This
  10423. * allows a column's ordering to take multiple columns into account when
  10424. * doing a sort or use the data from a different column. For example first
  10425. * name / last name columns make sense to do a multi-column sort over the
  10426. * two columns.
  10427. * @type array|int
  10428. * @default null <i>Takes the value of the column index automatically</i>
  10429. *
  10430. * @name DataTable.defaults.column.orderData
  10431. * @dtopt Columns
  10432. *
  10433. * @example
  10434. * // Using `columnDefs`
  10435. * $(document).ready( function() {
  10436. * $('#example').dataTable( {
  10437. * "columnDefs": [
  10438. * { "orderData": [ 0, 1 ], "targets": [ 0 ] },
  10439. * { "orderData": [ 1, 0 ], "targets": [ 1 ] },
  10440. * { "orderData": 2, "targets": [ 2 ] }
  10441. * ]
  10442. * } );
  10443. * } );
  10444. *
  10445. * @example
  10446. * // Using `columns`
  10447. * $(document).ready( function() {
  10448. * $('#example').dataTable( {
  10449. * "columns": [
  10450. * { "orderData": [ 0, 1 ] },
  10451. * { "orderData": [ 1, 0 ] },
  10452. * { "orderData": 2 },
  10453. * null,
  10454. * null
  10455. * ]
  10456. * } );
  10457. * } );
  10458. */
  10459. "aDataSort": null,
  10460. "iDataSort": -1,
  10461. /**
  10462. * You can control the default ordering direction, and even alter the
  10463. * behaviour of the sort handler (i.e. only allow ascending ordering etc)
  10464. * using this parameter.
  10465. * @type array
  10466. * @default [ 'asc', 'desc' ]
  10467. *
  10468. * @name DataTable.defaults.column.orderSequence
  10469. * @dtopt Columns
  10470. *
  10471. * @example
  10472. * // Using `columnDefs`
  10473. * $(document).ready( function() {
  10474. * $('#example').dataTable( {
  10475. * "columnDefs": [
  10476. * { "orderSequence": [ "asc" ], "targets": [ 1 ] },
  10477. * { "orderSequence": [ "desc", "asc", "asc" ], "targets": [ 2 ] },
  10478. * { "orderSequence": [ "desc" ], "targets": [ 3 ] }
  10479. * ]
  10480. * } );
  10481. * } );
  10482. *
  10483. * @example
  10484. * // Using `columns`
  10485. * $(document).ready( function() {
  10486. * $('#example').dataTable( {
  10487. * "columns": [
  10488. * null,
  10489. * { "orderSequence": [ "asc" ] },
  10490. * { "orderSequence": [ "desc", "asc", "asc" ] },
  10491. * { "orderSequence": [ "desc" ] },
  10492. * null
  10493. * ]
  10494. * } );
  10495. * } );
  10496. */
  10497. "asSorting": [ 'asc', 'desc' ],
  10498. /**
  10499. * Enable or disable filtering on the data in this column.
  10500. * @type boolean
  10501. * @default true
  10502. *
  10503. * @name DataTable.defaults.column.searchable
  10504. * @dtopt Columns
  10505. *
  10506. * @example
  10507. * // Using `columnDefs`
  10508. * $(document).ready( function() {
  10509. * $('#example').dataTable( {
  10510. * "columnDefs": [
  10511. * { "searchable": false, "targets": [ 0 ] }
  10512. * ] } );
  10513. * } );
  10514. *
  10515. * @example
  10516. * // Using `columns`
  10517. * $(document).ready( function() {
  10518. * $('#example').dataTable( {
  10519. * "columns": [
  10520. * { "searchable": false },
  10521. * null,
  10522. * null,
  10523. * null,
  10524. * null
  10525. * ] } );
  10526. * } );
  10527. */
  10528. "bSearchable": true,
  10529. /**
  10530. * Enable or disable ordering on this column.
  10531. * @type boolean
  10532. * @default true
  10533. *
  10534. * @name DataTable.defaults.column.orderable
  10535. * @dtopt Columns
  10536. *
  10537. * @example
  10538. * // Using `columnDefs`
  10539. * $(document).ready( function() {
  10540. * $('#example').dataTable( {
  10541. * "columnDefs": [
  10542. * { "orderable": false, "targets": [ 0 ] }
  10543. * ] } );
  10544. * } );
  10545. *
  10546. * @example
  10547. * // Using `columns`
  10548. * $(document).ready( function() {
  10549. * $('#example').dataTable( {
  10550. * "columns": [
  10551. * { "orderable": false },
  10552. * null,
  10553. * null,
  10554. * null,
  10555. * null
  10556. * ] } );
  10557. * } );
  10558. */
  10559. "bSortable": true,
  10560. /**
  10561. * Enable or disable the display of this column.
  10562. * @type boolean
  10563. * @default true
  10564. *
  10565. * @name DataTable.defaults.column.visible
  10566. * @dtopt Columns
  10567. *
  10568. * @example
  10569. * // Using `columnDefs`
  10570. * $(document).ready( function() {
  10571. * $('#example').dataTable( {
  10572. * "columnDefs": [
  10573. * { "visible": false, "targets": [ 0 ] }
  10574. * ] } );
  10575. * } );
  10576. *
  10577. * @example
  10578. * // Using `columns`
  10579. * $(document).ready( function() {
  10580. * $('#example').dataTable( {
  10581. * "columns": [
  10582. * { "visible": false },
  10583. * null,
  10584. * null,
  10585. * null,
  10586. * null
  10587. * ] } );
  10588. * } );
  10589. */
  10590. "bVisible": true,
  10591. /**
  10592. * Developer definable function that is called whenever a cell is created (Ajax source,
  10593. * etc) or processed for input (DOM source). This can be used as a compliment to mRender
  10594. * allowing you to modify the DOM element (add background colour for example) when the
  10595. * element is available.
  10596. * @type function
  10597. * @param {element} td The TD node that has been created
  10598. * @param {*} cellData The Data for the cell
  10599. * @param {array|object} rowData The data for the whole row
  10600. * @param {int} row The row index for the aoData data store
  10601. * @param {int} col The column index for aoColumns
  10602. *
  10603. * @name DataTable.defaults.column.createdCell
  10604. * @dtopt Columns
  10605. *
  10606. * @example
  10607. * $(document).ready( function() {
  10608. * $('#example').dataTable( {
  10609. * "columnDefs": [ {
  10610. * "targets": [3],
  10611. * "createdCell": function (td, cellData, rowData, row, col) {
  10612. * if ( cellData == "1.7" ) {
  10613. * $(td).css('color', 'blue')
  10614. * }
  10615. * }
  10616. * } ]
  10617. * });
  10618. * } );
  10619. */
  10620. "fnCreatedCell": null,
  10621. /**
  10622. * This parameter has been replaced by `data` in DataTables to ensure naming
  10623. * consistency. `dataProp` can still be used, as there is backwards
  10624. * compatibility in DataTables for this option, but it is strongly
  10625. * recommended that you use `data` in preference to `dataProp`.
  10626. * @name DataTable.defaults.column.dataProp
  10627. */
  10628. /**
  10629. * This property can be used to read data from any data source property,
  10630. * including deeply nested objects / properties. `data` can be given in a
  10631. * number of different ways which effect its behaviour:
  10632. *
  10633. * * `integer` - treated as an array index for the data source. This is the
  10634. * default that DataTables uses (incrementally increased for each column).
  10635. * * `string` - read an object property from the data source. There are
  10636. * three 'special' options that can be used in the string to alter how
  10637. * DataTables reads the data from the source object:
  10638. * * `.` - Dotted Javascript notation. Just as you use a `.` in
  10639. * Javascript to read from nested objects, so to can the options
  10640. * specified in `data`. For example: `browser.version` or
  10641. * `browser.name`. If your object parameter name contains a period, use
  10642. * `\\` to escape it - i.e. `first\\.name`.
  10643. * * `[]` - Array notation. DataTables can automatically combine data
  10644. * from and array source, joining the data with the characters provided
  10645. * between the two brackets. For example: `name[, ]` would provide a
  10646. * comma-space separated list from the source array. If no characters
  10647. * are provided between the brackets, the original array source is
  10648. * returned.
  10649. * * `()` - Function notation. Adding `()` to the end of a parameter will
  10650. * execute a function of the name given. For example: `browser()` for a
  10651. * simple function on the data source, `browser.version()` for a
  10652. * function in a nested property or even `browser().version` to get an
  10653. * object property if the function called returns an object. Note that
  10654. * function notation is recommended for use in `render` rather than
  10655. * `data` as it is much simpler to use as a renderer.
  10656. * * `null` - use the original data source for the row rather than plucking
  10657. * data directly from it. This action has effects on two other
  10658. * initialisation options:
  10659. * * `defaultContent` - When null is given as the `data` option and
  10660. * `defaultContent` is specified for the column, the value defined by
  10661. * `defaultContent` will be used for the cell.
  10662. * * `render` - When null is used for the `data` option and the `render`
  10663. * option is specified for the column, the whole data source for the
  10664. * row is used for the renderer.
  10665. * * `function` - the function given will be executed whenever DataTables
  10666. * needs to set or get the data for a cell in the column. The function
  10667. * takes three parameters:
  10668. * * Parameters:
  10669. * * `{array|object}` The data source for the row
  10670. * * `{string}` The type call data requested - this will be 'set' when
  10671. * setting data or 'filter', 'display', 'type', 'sort' or undefined
  10672. * when gathering data. Note that when `undefined` is given for the
  10673. * type DataTables expects to get the raw data for the object back<
  10674. * * `{*}` Data to set when the second parameter is 'set'.
  10675. * * Return:
  10676. * * The return value from the function is not required when 'set' is
  10677. * the type of call, but otherwise the return is what will be used
  10678. * for the data requested.
  10679. *
  10680. * Note that `data` is a getter and setter option. If you just require
  10681. * formatting of data for output, you will likely want to use `render` which
  10682. * is simply a getter and thus simpler to use.
  10683. *
  10684. * Note that prior to DataTables 1.9.2 `data` was called `mDataProp`. The
  10685. * name change reflects the flexibility of this property and is consistent
  10686. * with the naming of mRender. If 'mDataProp' is given, then it will still
  10687. * be used by DataTables, as it automatically maps the old name to the new
  10688. * if required.
  10689. *
  10690. * @type string|int|function|null
  10691. * @default null <i>Use automatically calculated column index</i>
  10692. *
  10693. * @name DataTable.defaults.column.data
  10694. * @dtopt Columns
  10695. *
  10696. * @example
  10697. * // Read table data from objects
  10698. * // JSON structure for each row:
  10699. * // {
  10700. * // "engine": {value},
  10701. * // "browser": {value},
  10702. * // "platform": {value},
  10703. * // "version": {value},
  10704. * // "grade": {value}
  10705. * // }
  10706. * $(document).ready( function() {
  10707. * $('#example').dataTable( {
  10708. * "ajaxSource": "sources/objects.txt",
  10709. * "columns": [
  10710. * { "data": "engine" },
  10711. * { "data": "browser" },
  10712. * { "data": "platform" },
  10713. * { "data": "version" },
  10714. * { "data": "grade" }
  10715. * ]
  10716. * } );
  10717. * } );
  10718. *
  10719. * @example
  10720. * // Read information from deeply nested objects
  10721. * // JSON structure for each row:
  10722. * // {
  10723. * // "engine": {value},
  10724. * // "browser": {value},
  10725. * // "platform": {
  10726. * // "inner": {value}
  10727. * // },
  10728. * // "details": [
  10729. * // {value}, {value}
  10730. * // ]
  10731. * // }
  10732. * $(document).ready( function() {
  10733. * $('#example').dataTable( {
  10734. * "ajaxSource": "sources/deep.txt",
  10735. * "columns": [
  10736. * { "data": "engine" },
  10737. * { "data": "browser" },
  10738. * { "data": "platform.inner" },
  10739. * { "data": "details.0" },
  10740. * { "data": "details.1" }
  10741. * ]
  10742. * } );
  10743. * } );
  10744. *
  10745. * @example
  10746. * // Using `data` as a function to provide different information for
  10747. * // sorting, filtering and display. In this case, currency (price)
  10748. * $(document).ready( function() {
  10749. * $('#example').dataTable( {
  10750. * "columnDefs": [ {
  10751. * "targets": [ 0 ],
  10752. * "data": function ( source, type, val ) {
  10753. * if (type === 'set') {
  10754. * source.price = val;
  10755. * // Store the computed dislay and filter values for efficiency
  10756. * source.price_display = val=="" ? "" : "$"+numberFormat(val);
  10757. * source.price_filter = val=="" ? "" : "$"+numberFormat(val)+" "+val;
  10758. * return;
  10759. * }
  10760. * else if (type === 'display') {
  10761. * return source.price_display;
  10762. * }
  10763. * else if (type === 'filter') {
  10764. * return source.price_filter;
  10765. * }
  10766. * // 'sort', 'type' and undefined all just use the integer
  10767. * return source.price;
  10768. * }
  10769. * } ]
  10770. * } );
  10771. * } );
  10772. *
  10773. * @example
  10774. * // Using default content
  10775. * $(document).ready( function() {
  10776. * $('#example').dataTable( {
  10777. * "columnDefs": [ {
  10778. * "targets": [ 0 ],
  10779. * "data": null,
  10780. * "defaultContent": "Click to edit"
  10781. * } ]
  10782. * } );
  10783. * } );
  10784. *
  10785. * @example
  10786. * // Using array notation - outputting a list from an array
  10787. * $(document).ready( function() {
  10788. * $('#example').dataTable( {
  10789. * "columnDefs": [ {
  10790. * "targets": [ 0 ],
  10791. * "data": "name[, ]"
  10792. * } ]
  10793. * } );
  10794. * } );
  10795. *
  10796. */
  10797. "mData": null,
  10798. /**
  10799. * This property is the rendering partner to `data` and it is suggested that
  10800. * when you want to manipulate data for display (including filtering,
  10801. * sorting etc) without altering the underlying data for the table, use this
  10802. * property. `render` can be considered to be the the read only companion to
  10803. * `data` which is read / write (then as such more complex). Like `data`
  10804. * this option can be given in a number of different ways to effect its
  10805. * behaviour:
  10806. *
  10807. * * `integer` - treated as an array index for the data source. This is the
  10808. * default that DataTables uses (incrementally increased for each column).
  10809. * * `string` - read an object property from the data source. There are
  10810. * three 'special' options that can be used in the string to alter how
  10811. * DataTables reads the data from the source object:
  10812. * * `.` - Dotted Javascript notation. Just as you use a `.` in
  10813. * Javascript to read from nested objects, so to can the options
  10814. * specified in `data`. For example: `browser.version` or
  10815. * `browser.name`. If your object parameter name contains a period, use
  10816. * `\\` to escape it - i.e. `first\\.name`.
  10817. * * `[]` - Array notation. DataTables can automatically combine data
  10818. * from and array source, joining the data with the characters provided
  10819. * between the two brackets. For example: `name[, ]` would provide a
  10820. * comma-space separated list from the source array. If no characters
  10821. * are provided between the brackets, the original array source is
  10822. * returned.
  10823. * * `()` - Function notation. Adding `()` to the end of a parameter will
  10824. * execute a function of the name given. For example: `browser()` for a
  10825. * simple function on the data source, `browser.version()` for a
  10826. * function in a nested property or even `browser().version` to get an
  10827. * object property if the function called returns an object.
  10828. * * `object` - use different data for the different data types requested by
  10829. * DataTables ('filter', 'display', 'type' or 'sort'). The property names
  10830. * of the object is the data type the property refers to and the value can
  10831. * defined using an integer, string or function using the same rules as
  10832. * `render` normally does. Note that an `_` option _must_ be specified.
  10833. * This is the default value to use if you haven't specified a value for
  10834. * the data type requested by DataTables.
  10835. * * `function` - the function given will be executed whenever DataTables
  10836. * needs to set or get the data for a cell in the column. The function
  10837. * takes three parameters:
  10838. * * Parameters:
  10839. * * {array|object} The data source for the row (based on `data`)
  10840. * * {string} The type call data requested - this will be 'filter',
  10841. * 'display', 'type' or 'sort'.
  10842. * * {array|object} The full data source for the row (not based on
  10843. * `data`)
  10844. * * Return:
  10845. * * The return value from the function is what will be used for the
  10846. * data requested.
  10847. *
  10848. * @type string|int|function|object|null
  10849. * @default null Use the data source value.
  10850. *
  10851. * @name DataTable.defaults.column.render
  10852. * @dtopt Columns
  10853. *
  10854. * @example
  10855. * // Create a comma separated list from an array of objects
  10856. * $(document).ready( function() {
  10857. * $('#example').dataTable( {
  10858. * "ajaxSource": "sources/deep.txt",
  10859. * "columns": [
  10860. * { "data": "engine" },
  10861. * { "data": "browser" },
  10862. * {
  10863. * "data": "platform",
  10864. * "render": "[, ].name"
  10865. * }
  10866. * ]
  10867. * } );
  10868. * } );
  10869. *
  10870. * @example
  10871. * // Execute a function to obtain data
  10872. * $(document).ready( function() {
  10873. * $('#example').dataTable( {
  10874. * "columnDefs": [ {
  10875. * "targets": [ 0 ],
  10876. * "data": null, // Use the full data source object for the renderer's source
  10877. * "render": "browserName()"
  10878. * } ]
  10879. * } );
  10880. * } );
  10881. *
  10882. * @example
  10883. * // As an object, extracting different data for the different types
  10884. * // This would be used with a data source such as:
  10885. * // { "phone": 5552368, "phone_filter": "5552368 555-2368", "phone_display": "555-2368" }
  10886. * // Here the `phone` integer is used for sorting and type detection, while `phone_filter`
  10887. * // (which has both forms) is used for filtering for if a user inputs either format, while
  10888. * // the formatted phone number is the one that is shown in the table.
  10889. * $(document).ready( function() {
  10890. * $('#example').dataTable( {
  10891. * "columnDefs": [ {
  10892. * "targets": [ 0 ],
  10893. * "data": null, // Use the full data source object for the renderer's source
  10894. * "render": {
  10895. * "_": "phone",
  10896. * "filter": "phone_filter",
  10897. * "display": "phone_display"
  10898. * }
  10899. * } ]
  10900. * } );
  10901. * } );
  10902. *
  10903. * @example
  10904. * // Use as a function to create a link from the data source
  10905. * $(document).ready( function() {
  10906. * $('#example').dataTable( {
  10907. * "columnDefs": [ {
  10908. * "targets": [ 0 ],
  10909. * "data": "download_link",
  10910. * "render": function ( data, type, full ) {
  10911. * return '<a href="'+data+'">Download</a>';
  10912. * }
  10913. * } ]
  10914. * } );
  10915. * } );
  10916. */
  10917. "mRender": null,
  10918. /**
  10919. * Change the cell type created for the column - either TD cells or TH cells. This
  10920. * can be useful as TH cells have semantic meaning in the table body, allowing them
  10921. * to act as a header for a row (you may wish to add scope='row' to the TH elements).
  10922. * @type string
  10923. * @default td
  10924. *
  10925. * @name DataTable.defaults.column.cellType
  10926. * @dtopt Columns
  10927. *
  10928. * @example
  10929. * // Make the first column use TH cells
  10930. * $(document).ready( function() {
  10931. * $('#example').dataTable( {
  10932. * "columnDefs": [ {
  10933. * "targets": [ 0 ],
  10934. * "cellType": "th"
  10935. * } ]
  10936. * } );
  10937. * } );
  10938. */
  10939. "sCellType": "td",
  10940. /**
  10941. * Class to give to each cell in this column.
  10942. * @type string
  10943. * @default <i>Empty string</i>
  10944. *
  10945. * @name DataTable.defaults.column.class
  10946. * @dtopt Columns
  10947. *
  10948. * @example
  10949. * // Using `columnDefs`
  10950. * $(document).ready( function() {
  10951. * $('#example').dataTable( {
  10952. * "columnDefs": [
  10953. * { "class": "my_class", "targets": [ 0 ] }
  10954. * ]
  10955. * } );
  10956. * } );
  10957. *
  10958. * @example
  10959. * // Using `columns`
  10960. * $(document).ready( function() {
  10961. * $('#example').dataTable( {
  10962. * "columns": [
  10963. * { "class": "my_class" },
  10964. * null,
  10965. * null,
  10966. * null,
  10967. * null
  10968. * ]
  10969. * } );
  10970. * } );
  10971. */
  10972. "sClass": "",
  10973. /**
  10974. * When DataTables calculates the column widths to assign to each column,
  10975. * it finds the longest string in each column and then constructs a
  10976. * temporary table and reads the widths from that. The problem with this
  10977. * is that "mmm" is much wider then "iiii", but the latter is a longer
  10978. * string - thus the calculation can go wrong (doing it properly and putting
  10979. * it into an DOM object and measuring that is horribly(!) slow). Thus as
  10980. * a "work around" we provide this option. It will append its value to the
  10981. * text that is found to be the longest string for the column - i.e. padding.
  10982. * Generally you shouldn't need this!
  10983. * @type string
  10984. * @default <i>Empty string<i>
  10985. *
  10986. * @name DataTable.defaults.column.contentPadding
  10987. * @dtopt Columns
  10988. *
  10989. * @example
  10990. * // Using `columns`
  10991. * $(document).ready( function() {
  10992. * $('#example').dataTable( {
  10993. * "columns": [
  10994. * null,
  10995. * null,
  10996. * null,
  10997. * {
  10998. * "contentPadding": "mmm"
  10999. * }
  11000. * ]
  11001. * } );
  11002. * } );
  11003. */
  11004. "sContentPadding": "",
  11005. /**
  11006. * Allows a default value to be given for a column's data, and will be used
  11007. * whenever a null data source is encountered (this can be because `data`
  11008. * is set to null, or because the data source itself is null).
  11009. * @type string
  11010. * @default null
  11011. *
  11012. * @name DataTable.defaults.column.defaultContent
  11013. * @dtopt Columns
  11014. *
  11015. * @example
  11016. * // Using `columnDefs`
  11017. * $(document).ready( function() {
  11018. * $('#example').dataTable( {
  11019. * "columnDefs": [
  11020. * {
  11021. * "data": null,
  11022. * "defaultContent": "Edit",
  11023. * "targets": [ -1 ]
  11024. * }
  11025. * ]
  11026. * } );
  11027. * } );
  11028. *
  11029. * @example
  11030. * // Using `columns`
  11031. * $(document).ready( function() {
  11032. * $('#example').dataTable( {
  11033. * "columns": [
  11034. * null,
  11035. * null,
  11036. * null,
  11037. * {
  11038. * "data": null,
  11039. * "defaultContent": "Edit"
  11040. * }
  11041. * ]
  11042. * } );
  11043. * } );
  11044. */
  11045. "sDefaultContent": null,
  11046. /**
  11047. * This parameter is only used in DataTables' server-side processing. It can
  11048. * be exceptionally useful to know what columns are being displayed on the
  11049. * client side, and to map these to database fields. When defined, the names
  11050. * also allow DataTables to reorder information from the server if it comes
  11051. * back in an unexpected order (i.e. if you switch your columns around on the
  11052. * client-side, your server-side code does not also need updating).
  11053. * @type string
  11054. * @default <i>Empty string</i>
  11055. *
  11056. * @name DataTable.defaults.column.name
  11057. * @dtopt Columns
  11058. *
  11059. * @example
  11060. * // Using `columnDefs`
  11061. * $(document).ready( function() {
  11062. * $('#example').dataTable( {
  11063. * "columnDefs": [
  11064. * { "name": "engine", "targets": [ 0 ] },
  11065. * { "name": "browser", "targets": [ 1 ] },
  11066. * { "name": "platform", "targets": [ 2 ] },
  11067. * { "name": "version", "targets": [ 3 ] },
  11068. * { "name": "grade", "targets": [ 4 ] }
  11069. * ]
  11070. * } );
  11071. * } );
  11072. *
  11073. * @example
  11074. * // Using `columns`
  11075. * $(document).ready( function() {
  11076. * $('#example').dataTable( {
  11077. * "columns": [
  11078. * { "name": "engine" },
  11079. * { "name": "browser" },
  11080. * { "name": "platform" },
  11081. * { "name": "version" },
  11082. * { "name": "grade" }
  11083. * ]
  11084. * } );
  11085. * } );
  11086. */
  11087. "sName": "",
  11088. /**
  11089. * Defines a data source type for the ordering which can be used to read
  11090. * real-time information from the table (updating the internally cached
  11091. * version) prior to ordering. This allows ordering to occur on user
  11092. * editable elements such as form inputs.
  11093. * @type string
  11094. * @default std
  11095. *
  11096. * @name DataTable.defaults.column.orderDataType
  11097. * @dtopt Columns
  11098. *
  11099. * @example
  11100. * // Using `columnDefs`
  11101. * $(document).ready( function() {
  11102. * $('#example').dataTable( {
  11103. * "columnDefs": [
  11104. * { "orderDataType": "dom-text", "targets": [ 2, 3 ] },
  11105. * { "type": "numeric", "targets": [ 3 ] },
  11106. * { "orderDataType": "dom-select", "targets": [ 4 ] },
  11107. * { "orderDataType": "dom-checkbox", "targets": [ 5 ] }
  11108. * ]
  11109. * } );
  11110. * } );
  11111. *
  11112. * @example
  11113. * // Using `columns`
  11114. * $(document).ready( function() {
  11115. * $('#example').dataTable( {
  11116. * "columns": [
  11117. * null,
  11118. * null,
  11119. * { "orderDataType": "dom-text" },
  11120. * { "orderDataType": "dom-text", "type": "numeric" },
  11121. * { "orderDataType": "dom-select" },
  11122. * { "orderDataType": "dom-checkbox" }
  11123. * ]
  11124. * } );
  11125. * } );
  11126. */
  11127. "sSortDataType": "std",
  11128. /**
  11129. * The title of this column.
  11130. * @type string
  11131. * @default null <i>Derived from the 'TH' value for this column in the
  11132. * original HTML table.</i>
  11133. *
  11134. * @name DataTable.defaults.column.title
  11135. * @dtopt Columns
  11136. *
  11137. * @example
  11138. * // Using `columnDefs`
  11139. * $(document).ready( function() {
  11140. * $('#example').dataTable( {
  11141. * "columnDefs": [
  11142. * { "title": "My column title", "targets": [ 0 ] }
  11143. * ]
  11144. * } );
  11145. * } );
  11146. *
  11147. * @example
  11148. * // Using `columns`
  11149. * $(document).ready( function() {
  11150. * $('#example').dataTable( {
  11151. * "columns": [
  11152. * { "title": "My column title" },
  11153. * null,
  11154. * null,
  11155. * null,
  11156. * null
  11157. * ]
  11158. * } );
  11159. * } );
  11160. */
  11161. "sTitle": null,
  11162. /**
  11163. * The type allows you to specify how the data for this column will be
  11164. * ordered. Four types (string, numeric, date and html (which will strip
  11165. * HTML tags before ordering)) are currently available. Note that only date
  11166. * formats understood by Javascript's Date() object will be accepted as type
  11167. * date. For example: "Mar 26, 2008 5:03 PM". May take the values: 'string',
  11168. * 'numeric', 'date' or 'html' (by default). Further types can be adding
  11169. * through plug-ins.
  11170. * @type string
  11171. * @default null <i>Auto-detected from raw data</i>
  11172. *
  11173. * @name DataTable.defaults.column.type
  11174. * @dtopt Columns
  11175. *
  11176. * @example
  11177. * // Using `columnDefs`
  11178. * $(document).ready( function() {
  11179. * $('#example').dataTable( {
  11180. * "columnDefs": [
  11181. * { "type": "html", "targets": [ 0 ] }
  11182. * ]
  11183. * } );
  11184. * } );
  11185. *
  11186. * @example
  11187. * // Using `columns`
  11188. * $(document).ready( function() {
  11189. * $('#example').dataTable( {
  11190. * "columns": [
  11191. * { "type": "html" },
  11192. * null,
  11193. * null,
  11194. * null,
  11195. * null
  11196. * ]
  11197. * } );
  11198. * } );
  11199. */
  11200. "sType": null,
  11201. /**
  11202. * Defining the width of the column, this parameter may take any CSS value
  11203. * (3em, 20px etc). DataTables applies 'smart' widths to columns which have not
  11204. * been given a specific width through this interface ensuring that the table
  11205. * remains readable.
  11206. * @type string
  11207. * @default null <i>Automatic</i>
  11208. *
  11209. * @name DataTable.defaults.column.width
  11210. * @dtopt Columns
  11211. *
  11212. * @example
  11213. * // Using `columnDefs`
  11214. * $(document).ready( function() {
  11215. * $('#example').dataTable( {
  11216. * "columnDefs": [
  11217. * { "width": "20%", "targets": [ 0 ] }
  11218. * ]
  11219. * } );
  11220. * } );
  11221. *
  11222. * @example
  11223. * // Using `columns`
  11224. * $(document).ready( function() {
  11225. * $('#example').dataTable( {
  11226. * "columns": [
  11227. * { "width": "20%" },
  11228. * null,
  11229. * null,
  11230. * null,
  11231. * null
  11232. * ]
  11233. * } );
  11234. * } );
  11235. */
  11236. "sWidth": null
  11237. };
  11238. _fnHungarianMap( DataTable.defaults.column );
  11239. /**
  11240. * DataTables settings object - this holds all the information needed for a
  11241. * given table, including configuration, data and current application of the
  11242. * table options. DataTables does not have a single instance for each DataTable
  11243. * with the settings attached to that instance, but rather instances of the
  11244. * DataTable "class" are created on-the-fly as needed (typically by a
  11245. * $().dataTable() call) and the settings object is then applied to that
  11246. * instance.
  11247. *
  11248. * Note that this object is related to {@link DataTable.defaults} but this
  11249. * one is the internal data store for DataTables's cache of columns. It should
  11250. * NOT be manipulated outside of DataTables. Any configuration should be done
  11251. * through the initialisation options.
  11252. * @namespace
  11253. * @todo Really should attach the settings object to individual instances so we
  11254. * don't need to create new instances on each $().dataTable() call (if the
  11255. * table already exists). It would also save passing oSettings around and
  11256. * into every single function. However, this is a very significant
  11257. * architecture change for DataTables and will almost certainly break
  11258. * backwards compatibility with older installations. This is something that
  11259. * will be done in 2.0.
  11260. */
  11261. DataTable.models.oSettings = {
  11262. /**
  11263. * Primary features of DataTables and their enablement state.
  11264. * @namespace
  11265. */
  11266. "oFeatures": {
  11267. /**
  11268. * Flag to say if DataTables should automatically try to calculate the
  11269. * optimum table and columns widths (true) or not (false).
  11270. * Note that this parameter will be set by the initialisation routine. To
  11271. * set a default use {@link DataTable.defaults}.
  11272. * @type boolean
  11273. */
  11274. "bAutoWidth": null,
  11275. /**
  11276. * Delay the creation of TR and TD elements until they are actually
  11277. * needed by a driven page draw. This can give a significant speed
  11278. * increase for Ajax source and Javascript source data, but makes no
  11279. * difference at all fro DOM and server-side processing tables.
  11280. * Note that this parameter will be set by the initialisation routine. To
  11281. * set a default use {@link DataTable.defaults}.
  11282. * @type boolean
  11283. */
  11284. "bDeferRender": null,
  11285. /**
  11286. * Enable filtering on the table or not. Note that if this is disabled
  11287. * then there is no filtering at all on the table, including fnFilter.
  11288. * To just remove the filtering input use sDom and remove the 'f' option.
  11289. * Note that this parameter will be set by the initialisation routine. To
  11290. * set a default use {@link DataTable.defaults}.
  11291. * @type boolean
  11292. */
  11293. "bFilter": null,
  11294. /**
  11295. * Table information element (the 'Showing x of y records' div) enable
  11296. * flag.
  11297. * Note that this parameter will be set by the initialisation routine. To
  11298. * set a default use {@link DataTable.defaults}.
  11299. * @type boolean
  11300. */
  11301. "bInfo": null,
  11302. /**
  11303. * Present a user control allowing the end user to change the page size
  11304. * when pagination is enabled.
  11305. * Note that this parameter will be set by the initialisation routine. To
  11306. * set a default use {@link DataTable.defaults}.
  11307. * @type boolean
  11308. */
  11309. "bLengthChange": null,
  11310. /**
  11311. * Pagination enabled or not. Note that if this is disabled then length
  11312. * changing must also be disabled.
  11313. * Note that this parameter will be set by the initialisation routine. To
  11314. * set a default use {@link DataTable.defaults}.
  11315. * @type boolean
  11316. */
  11317. "bPaginate": null,
  11318. /**
  11319. * Processing indicator enable flag whenever DataTables is enacting a
  11320. * user request - typically an Ajax request for server-side processing.
  11321. * Note that this parameter will be set by the initialisation routine. To
  11322. * set a default use {@link DataTable.defaults}.
  11323. * @type boolean
  11324. */
  11325. "bProcessing": null,
  11326. /**
  11327. * Server-side processing enabled flag - when enabled DataTables will
  11328. * get all data from the server for every draw - there is no filtering,
  11329. * sorting or paging done on the client-side.
  11330. * Note that this parameter will be set by the initialisation routine. To
  11331. * set a default use {@link DataTable.defaults}.
  11332. * @type boolean
  11333. */
  11334. "bServerSide": null,
  11335. /**
  11336. * Sorting enablement flag.
  11337. * Note that this parameter will be set by the initialisation routine. To
  11338. * set a default use {@link DataTable.defaults}.
  11339. * @type boolean
  11340. */
  11341. "bSort": null,
  11342. /**
  11343. * Multi-column sorting
  11344. * Note that this parameter will be set by the initialisation routine. To
  11345. * set a default use {@link DataTable.defaults}.
  11346. * @type boolean
  11347. */
  11348. "bSortMulti": null,
  11349. /**
  11350. * Apply a class to the columns which are being sorted to provide a
  11351. * visual highlight or not. This can slow things down when enabled since
  11352. * there is a lot of DOM interaction.
  11353. * Note that this parameter will be set by the initialisation routine. To
  11354. * set a default use {@link DataTable.defaults}.
  11355. * @type boolean
  11356. */
  11357. "bSortClasses": null,
  11358. /**
  11359. * State saving enablement flag.
  11360. * Note that this parameter will be set by the initialisation routine. To
  11361. * set a default use {@link DataTable.defaults}.
  11362. * @type boolean
  11363. */
  11364. "bStateSave": null
  11365. },
  11366. /**
  11367. * Scrolling settings for a table.
  11368. * @namespace
  11369. */
  11370. "oScroll": {
  11371. /**
  11372. * When the table is shorter in height than sScrollY, collapse the
  11373. * table container down to the height of the table (when true).
  11374. * Note that this parameter will be set by the initialisation routine. To
  11375. * set a default use {@link DataTable.defaults}.
  11376. * @type boolean
  11377. */
  11378. "bCollapse": null,
  11379. /**
  11380. * Width of the scrollbar for the web-browser's platform. Calculated
  11381. * during table initialisation.
  11382. * @type int
  11383. * @default 0
  11384. */
  11385. "iBarWidth": 0,
  11386. /**
  11387. * Viewport width for horizontal scrolling. Horizontal scrolling is
  11388. * disabled if an empty string.
  11389. * Note that this parameter will be set by the initialisation routine. To
  11390. * set a default use {@link DataTable.defaults}.
  11391. * @type string
  11392. */
  11393. "sX": null,
  11394. /**
  11395. * Width to expand the table to when using x-scrolling. Typically you
  11396. * should not need to use this.
  11397. * Note that this parameter will be set by the initialisation routine. To
  11398. * set a default use {@link DataTable.defaults}.
  11399. * @type string
  11400. * @deprecated
  11401. */
  11402. "sXInner": null,
  11403. /**
  11404. * Viewport height for vertical scrolling. Vertical scrolling is disabled
  11405. * if an empty string.
  11406. * Note that this parameter will be set by the initialisation routine. To
  11407. * set a default use {@link DataTable.defaults}.
  11408. * @type string
  11409. */
  11410. "sY": null
  11411. },
  11412. /**
  11413. * Language information for the table.
  11414. * @namespace
  11415. * @extends DataTable.defaults.oLanguage
  11416. */
  11417. "oLanguage": {
  11418. /**
  11419. * Information callback function. See
  11420. * {@link DataTable.defaults.fnInfoCallback}
  11421. * @type function
  11422. * @default null
  11423. */
  11424. "fnInfoCallback": null
  11425. },
  11426. /**
  11427. * Browser support parameters
  11428. * @namespace
  11429. */
  11430. "oBrowser": {
  11431. /**
  11432. * Indicate if the browser incorrectly calculates width:100% inside a
  11433. * scrolling element (IE6/7)
  11434. * @type boolean
  11435. * @default false
  11436. */
  11437. "bScrollOversize": false,
  11438. /**
  11439. * Determine if the vertical scrollbar is on the right or left of the
  11440. * scrolling container - needed for rtl language layout, although not
  11441. * all browsers move the scrollbar (Safari).
  11442. * @type boolean
  11443. * @default false
  11444. */
  11445. "bScrollbarLeft": false,
  11446. /**
  11447. * Flag for if `getBoundingClientRect` is fully supported or not
  11448. * @type boolean
  11449. * @default false
  11450. */
  11451. "bBounding": false,
  11452. /**
  11453. * Browser scrollbar width
  11454. * @type integer
  11455. * @default 0
  11456. */
  11457. "barWidth": 0
  11458. },
  11459. "ajax": null,
  11460. /**
  11461. * Array referencing the nodes which are used for the features. The
  11462. * parameters of this object match what is allowed by sDom - i.e.
  11463. * <ul>
  11464. * <li>'l' - Length changing</li>
  11465. * <li>'f' - Filtering input</li>
  11466. * <li>'t' - The table!</li>
  11467. * <li>'i' - Information</li>
  11468. * <li>'p' - Pagination</li>
  11469. * <li>'r' - pRocessing</li>
  11470. * </ul>
  11471. * @type array
  11472. * @default []
  11473. */
  11474. "aanFeatures": [],
  11475. /**
  11476. * Store data information - see {@link DataTable.models.oRow} for detailed
  11477. * information.
  11478. * @type array
  11479. * @default []
  11480. */
  11481. "aoData": [],
  11482. /**
  11483. * Array of indexes which are in the current display (after filtering etc)
  11484. * @type array
  11485. * @default []
  11486. */
  11487. "aiDisplay": [],
  11488. /**
  11489. * Array of indexes for display - no filtering
  11490. * @type array
  11491. * @default []
  11492. */
  11493. "aiDisplayMaster": [],
  11494. /**
  11495. * Map of row ids to data indexes
  11496. * @type object
  11497. * @default {}
  11498. */
  11499. "aIds": {},
  11500. /**
  11501. * Store information about each column that is in use
  11502. * @type array
  11503. * @default []
  11504. */
  11505. "aoColumns": [],
  11506. /**
  11507. * Store information about the table's header
  11508. * @type array
  11509. * @default []
  11510. */
  11511. "aoHeader": [],
  11512. /**
  11513. * Store information about the table's footer
  11514. * @type array
  11515. * @default []
  11516. */
  11517. "aoFooter": [],
  11518. /**
  11519. * Store the applied global search information in case we want to force a
  11520. * research or compare the old search to a new one.
  11521. * Note that this parameter will be set by the initialisation routine. To
  11522. * set a default use {@link DataTable.defaults}.
  11523. * @namespace
  11524. * @extends DataTable.models.oSearch
  11525. */
  11526. "oPreviousSearch": {},
  11527. /**
  11528. * Store the applied search for each column - see
  11529. * {@link DataTable.models.oSearch} for the format that is used for the
  11530. * filtering information for each column.
  11531. * @type array
  11532. * @default []
  11533. */
  11534. "aoPreSearchCols": [],
  11535. /**
  11536. * Sorting that is applied to the table. Note that the inner arrays are
  11537. * used in the following manner:
  11538. * <ul>
  11539. * <li>Index 0 - column number</li>
  11540. * <li>Index 1 - current sorting direction</li>
  11541. * </ul>
  11542. * Note that this parameter will be set by the initialisation routine. To
  11543. * set a default use {@link DataTable.defaults}.
  11544. * @type array
  11545. * @todo These inner arrays should really be objects
  11546. */
  11547. "aaSorting": null,
  11548. /**
  11549. * Sorting that is always applied to the table (i.e. prefixed in front of
  11550. * aaSorting).
  11551. * Note that this parameter will be set by the initialisation routine. To
  11552. * set a default use {@link DataTable.defaults}.
  11553. * @type array
  11554. * @default []
  11555. */
  11556. "aaSortingFixed": [],
  11557. /**
  11558. * Classes to use for the striping of a table.
  11559. * Note that this parameter will be set by the initialisation routine. To
  11560. * set a default use {@link DataTable.defaults}.
  11561. * @type array
  11562. * @default []
  11563. */
  11564. "asStripeClasses": null,
  11565. /**
  11566. * If restoring a table - we should restore its striping classes as well
  11567. * @type array
  11568. * @default []
  11569. */
  11570. "asDestroyStripes": [],
  11571. /**
  11572. * If restoring a table - we should restore its width
  11573. * @type int
  11574. * @default 0
  11575. */
  11576. "sDestroyWidth": 0,
  11577. /**
  11578. * Callback functions array for every time a row is inserted (i.e. on a draw).
  11579. * @type array
  11580. * @default []
  11581. */
  11582. "aoRowCallback": [],
  11583. /**
  11584. * Callback functions for the header on each draw.
  11585. * @type array
  11586. * @default []
  11587. */
  11588. "aoHeaderCallback": [],
  11589. /**
  11590. * Callback function for the footer on each draw.
  11591. * @type array
  11592. * @default []
  11593. */
  11594. "aoFooterCallback": [],
  11595. /**
  11596. * Array of callback functions for draw callback functions
  11597. * @type array
  11598. * @default []
  11599. */
  11600. "aoDrawCallback": [],
  11601. /**
  11602. * Array of callback functions for row created function
  11603. * @type array
  11604. * @default []
  11605. */
  11606. "aoRowCreatedCallback": [],
  11607. /**
  11608. * Callback functions for just before the table is redrawn. A return of
  11609. * false will be used to cancel the draw.
  11610. * @type array
  11611. * @default []
  11612. */
  11613. "aoPreDrawCallback": [],
  11614. /**
  11615. * Callback functions for when the table has been initialised.
  11616. * @type array
  11617. * @default []
  11618. */
  11619. "aoInitComplete": [],
  11620. /**
  11621. * Callbacks for modifying the settings to be stored for state saving, prior to
  11622. * saving state.
  11623. * @type array
  11624. * @default []
  11625. */
  11626. "aoStateSaveParams": [],
  11627. /**
  11628. * Callbacks for modifying the settings that have been stored for state saving
  11629. * prior to using the stored values to restore the state.
  11630. * @type array
  11631. * @default []
  11632. */
  11633. "aoStateLoadParams": [],
  11634. /**
  11635. * Callbacks for operating on the settings object once the saved state has been
  11636. * loaded
  11637. * @type array
  11638. * @default []
  11639. */
  11640. "aoStateLoaded": [],
  11641. /**
  11642. * Cache the table ID for quick access
  11643. * @type string
  11644. * @default <i>Empty string</i>
  11645. */
  11646. "sTableId": "",
  11647. /**
  11648. * The TABLE node for the main table
  11649. * @type node
  11650. * @default null
  11651. */
  11652. "nTable": null,
  11653. /**
  11654. * Permanent ref to the thead element
  11655. * @type node
  11656. * @default null
  11657. */
  11658. "nTHead": null,
  11659. /**
  11660. * Permanent ref to the tfoot element - if it exists
  11661. * @type node
  11662. * @default null
  11663. */
  11664. "nTFoot": null,
  11665. /**
  11666. * Permanent ref to the tbody element
  11667. * @type node
  11668. * @default null
  11669. */
  11670. "nTBody": null,
  11671. /**
  11672. * Cache the wrapper node (contains all DataTables controlled elements)
  11673. * @type node
  11674. * @default null
  11675. */
  11676. "nTableWrapper": null,
  11677. /**
  11678. * Indicate if when using server-side processing the loading of data
  11679. * should be deferred until the second draw.
  11680. * Note that this parameter will be set by the initialisation routine. To
  11681. * set a default use {@link DataTable.defaults}.
  11682. * @type boolean
  11683. * @default false
  11684. */
  11685. "bDeferLoading": false,
  11686. /**
  11687. * Indicate if all required information has been read in
  11688. * @type boolean
  11689. * @default false
  11690. */
  11691. "bInitialised": false,
  11692. /**
  11693. * Information about open rows. Each object in the array has the parameters
  11694. * 'nTr' and 'nParent'
  11695. * @type array
  11696. * @default []
  11697. */
  11698. "aoOpenRows": [],
  11699. /**
  11700. * Dictate the positioning of DataTables' control elements - see
  11701. * {@link DataTable.model.oInit.sDom}.
  11702. * Note that this parameter will be set by the initialisation routine. To
  11703. * set a default use {@link DataTable.defaults}.
  11704. * @type string
  11705. * @default null
  11706. */
  11707. "sDom": null,
  11708. /**
  11709. * Search delay (in mS)
  11710. * @type integer
  11711. * @default null
  11712. */
  11713. "searchDelay": null,
  11714. /**
  11715. * Which type of pagination should be used.
  11716. * Note that this parameter will be set by the initialisation routine. To
  11717. * set a default use {@link DataTable.defaults}.
  11718. * @type string
  11719. * @default two_button
  11720. */
  11721. "sPaginationType": "two_button",
  11722. /**
  11723. * The state duration (for `stateSave`) in seconds.
  11724. * Note that this parameter will be set by the initialisation routine. To
  11725. * set a default use {@link DataTable.defaults}.
  11726. * @type int
  11727. * @default 0
  11728. */
  11729. "iStateDuration": 0,
  11730. /**
  11731. * Array of callback functions for state saving. Each array element is an
  11732. * object with the following parameters:
  11733. * <ul>
  11734. * <li>function:fn - function to call. Takes two parameters, oSettings
  11735. * and the JSON string to save that has been thus far created. Returns
  11736. * a JSON string to be inserted into a json object
  11737. * (i.e. '"param": [ 0, 1, 2]')</li>
  11738. * <li>string:sName - name of callback</li>
  11739. * </ul>
  11740. * @type array
  11741. * @default []
  11742. */
  11743. "aoStateSave": [],
  11744. /**
  11745. * Array of callback functions for state loading. Each array element is an
  11746. * object with the following parameters:
  11747. * <ul>
  11748. * <li>function:fn - function to call. Takes two parameters, oSettings
  11749. * and the object stored. May return false to cancel state loading</li>
  11750. * <li>string:sName - name of callback</li>
  11751. * </ul>
  11752. * @type array
  11753. * @default []
  11754. */
  11755. "aoStateLoad": [],
  11756. /**
  11757. * State that was saved. Useful for back reference
  11758. * @type object
  11759. * @default null
  11760. */
  11761. "oSavedState": null,
  11762. /**
  11763. * State that was loaded. Useful for back reference
  11764. * @type object
  11765. * @default null
  11766. */
  11767. "oLoadedState": null,
  11768. /**
  11769. * Source url for AJAX data for the table.
  11770. * Note that this parameter will be set by the initialisation routine. To
  11771. * set a default use {@link DataTable.defaults}.
  11772. * @type string
  11773. * @default null
  11774. */
  11775. "sAjaxSource": null,
  11776. /**
  11777. * Property from a given object from which to read the table data from. This
  11778. * can be an empty string (when not server-side processing), in which case
  11779. * it is assumed an an array is given directly.
  11780. * Note that this parameter will be set by the initialisation routine. To
  11781. * set a default use {@link DataTable.defaults}.
  11782. * @type string
  11783. */
  11784. "sAjaxDataProp": null,
  11785. /**
  11786. * Note if draw should be blocked while getting data
  11787. * @type boolean
  11788. * @default true
  11789. */
  11790. "bAjaxDataGet": true,
  11791. /**
  11792. * The last jQuery XHR object that was used for server-side data gathering.
  11793. * This can be used for working with the XHR information in one of the
  11794. * callbacks
  11795. * @type object
  11796. * @default null
  11797. */
  11798. "jqXHR": null,
  11799. /**
  11800. * JSON returned from the server in the last Ajax request
  11801. * @type object
  11802. * @default undefined
  11803. */
  11804. "json": undefined,
  11805. /**
  11806. * Data submitted as part of the last Ajax request
  11807. * @type object
  11808. * @default undefined
  11809. */
  11810. "oAjaxData": undefined,
  11811. /**
  11812. * Function to get the server-side data.
  11813. * Note that this parameter will be set by the initialisation routine. To
  11814. * set a default use {@link DataTable.defaults}.
  11815. * @type function
  11816. */
  11817. "fnServerData": null,
  11818. /**
  11819. * Functions which are called prior to sending an Ajax request so extra
  11820. * parameters can easily be sent to the server
  11821. * @type array
  11822. * @default []
  11823. */
  11824. "aoServerParams": [],
  11825. /**
  11826. * Send the XHR HTTP method - GET or POST (could be PUT or DELETE if
  11827. * required).
  11828. * Note that this parameter will be set by the initialisation routine. To
  11829. * set a default use {@link DataTable.defaults}.
  11830. * @type string
  11831. */
  11832. "sServerMethod": null,
  11833. /**
  11834. * Format numbers for display.
  11835. * Note that this parameter will be set by the initialisation routine. To
  11836. * set a default use {@link DataTable.defaults}.
  11837. * @type function
  11838. */
  11839. "fnFormatNumber": null,
  11840. /**
  11841. * List of options that can be used for the user selectable length menu.
  11842. * Note that this parameter will be set by the initialisation routine. To
  11843. * set a default use {@link DataTable.defaults}.
  11844. * @type array
  11845. * @default []
  11846. */
  11847. "aLengthMenu": null,
  11848. /**
  11849. * Counter for the draws that the table does. Also used as a tracker for
  11850. * server-side processing
  11851. * @type int
  11852. * @default 0
  11853. */
  11854. "iDraw": 0,
  11855. /**
  11856. * Indicate if a redraw is being done - useful for Ajax
  11857. * @type boolean
  11858. * @default false
  11859. */
  11860. "bDrawing": false,
  11861. /**
  11862. * Draw index (iDraw) of the last error when parsing the returned data
  11863. * @type int
  11864. * @default -1
  11865. */
  11866. "iDrawError": -1,
  11867. /**
  11868. * Paging display length
  11869. * @type int
  11870. * @default 10
  11871. */
  11872. "_iDisplayLength": 10,
  11873. /**
  11874. * Paging start point - aiDisplay index
  11875. * @type int
  11876. * @default 0
  11877. */
  11878. "_iDisplayStart": 0,
  11879. /**
  11880. * Server-side processing - number of records in the result set
  11881. * (i.e. before filtering), Use fnRecordsTotal rather than
  11882. * this property to get the value of the number of records, regardless of
  11883. * the server-side processing setting.
  11884. * @type int
  11885. * @default 0
  11886. * @private
  11887. */
  11888. "_iRecordsTotal": 0,
  11889. /**
  11890. * Server-side processing - number of records in the current display set
  11891. * (i.e. after filtering). Use fnRecordsDisplay rather than
  11892. * this property to get the value of the number of records, regardless of
  11893. * the server-side processing setting.
  11894. * @type boolean
  11895. * @default 0
  11896. * @private
  11897. */
  11898. "_iRecordsDisplay": 0,
  11899. /**
  11900. * The classes to use for the table
  11901. * @type object
  11902. * @default {}
  11903. */
  11904. "oClasses": {},
  11905. /**
  11906. * Flag attached to the settings object so you can check in the draw
  11907. * callback if filtering has been done in the draw. Deprecated in favour of
  11908. * events.
  11909. * @type boolean
  11910. * @default false
  11911. * @deprecated
  11912. */
  11913. "bFiltered": false,
  11914. /**
  11915. * Flag attached to the settings object so you can check in the draw
  11916. * callback if sorting has been done in the draw. Deprecated in favour of
  11917. * events.
  11918. * @type boolean
  11919. * @default false
  11920. * @deprecated
  11921. */
  11922. "bSorted": false,
  11923. /**
  11924. * Indicate that if multiple rows are in the header and there is more than
  11925. * one unique cell per column, if the top one (true) or bottom one (false)
  11926. * should be used for sorting / title by DataTables.
  11927. * Note that this parameter will be set by the initialisation routine. To
  11928. * set a default use {@link DataTable.defaults}.
  11929. * @type boolean
  11930. */
  11931. "bSortCellsTop": null,
  11932. /**
  11933. * Initialisation object that is used for the table
  11934. * @type object
  11935. * @default null
  11936. */
  11937. "oInit": null,
  11938. /**
  11939. * Destroy callback functions - for plug-ins to attach themselves to the
  11940. * destroy so they can clean up markup and events.
  11941. * @type array
  11942. * @default []
  11943. */
  11944. "aoDestroyCallback": [],
  11945. /**
  11946. * Get the number of records in the current record set, before filtering
  11947. * @type function
  11948. */
  11949. "fnRecordsTotal": function ()
  11950. {
  11951. return _fnDataSource( this ) == 'ssp' ?
  11952. this._iRecordsTotal * 1 :
  11953. this.aiDisplayMaster.length;
  11954. },
  11955. /**
  11956. * Get the number of records in the current record set, after filtering
  11957. * @type function
  11958. */
  11959. "fnRecordsDisplay": function ()
  11960. {
  11961. return _fnDataSource( this ) == 'ssp' ?
  11962. this._iRecordsDisplay * 1 :
  11963. this.aiDisplay.length;
  11964. },
  11965. /**
  11966. * Get the display end point - aiDisplay index
  11967. * @type function
  11968. */
  11969. "fnDisplayEnd": function ()
  11970. {
  11971. var
  11972. len = this._iDisplayLength,
  11973. start = this._iDisplayStart,
  11974. calc = start + len,
  11975. records = this.aiDisplay.length,
  11976. features = this.oFeatures,
  11977. paginate = features.bPaginate;
  11978. if ( features.bServerSide ) {
  11979. return paginate === false || len === -1 ?
  11980. start + records :
  11981. Math.min( start+len, this._iRecordsDisplay );
  11982. }
  11983. else {
  11984. return ! paginate || calc>records || len===-1 ?
  11985. records :
  11986. calc;
  11987. }
  11988. },
  11989. /**
  11990. * The DataTables object for this table
  11991. * @type object
  11992. * @default null
  11993. */
  11994. "oInstance": null,
  11995. /**
  11996. * Unique identifier for each instance of the DataTables object. If there
  11997. * is an ID on the table node, then it takes that value, otherwise an
  11998. * incrementing internal counter is used.
  11999. * @type string
  12000. * @default null
  12001. */
  12002. "sInstance": null,
  12003. /**
  12004. * tabindex attribute value that is added to DataTables control elements, allowing
  12005. * keyboard navigation of the table and its controls.
  12006. */
  12007. "iTabIndex": 0,
  12008. /**
  12009. * DIV container for the footer scrolling table if scrolling
  12010. */
  12011. "nScrollHead": null,
  12012. /**
  12013. * DIV container for the footer scrolling table if scrolling
  12014. */
  12015. "nScrollFoot": null,
  12016. /**
  12017. * Last applied sort
  12018. * @type array
  12019. * @default []
  12020. */
  12021. "aLastSort": [],
  12022. /**
  12023. * Stored plug-in instances
  12024. * @type object
  12025. * @default {}
  12026. */
  12027. "oPlugins": {},
  12028. /**
  12029. * Function used to get a row's id from the row's data
  12030. * @type function
  12031. * @default null
  12032. */
  12033. "rowIdFn": null,
  12034. /**
  12035. * Data location where to store a row's id
  12036. * @type string
  12037. * @default null
  12038. */
  12039. "rowId": null
  12040. };
  12041. /**
  12042. * Extension object for DataTables that is used to provide all extension
  12043. * options.
  12044. *
  12045. * Note that the `DataTable.ext` object is available through
  12046. * `jQuery.fn.dataTable.ext` where it may be accessed and manipulated. It is
  12047. * also aliased to `jQuery.fn.dataTableExt` for historic reasons.
  12048. * @namespace
  12049. * @extends DataTable.models.ext
  12050. */
  12051. /**
  12052. * DataTables extensions
  12053. *
  12054. * This namespace acts as a collection area for plug-ins that can be used to
  12055. * extend DataTables capabilities. Indeed many of the build in methods
  12056. * use this method to provide their own capabilities (sorting methods for
  12057. * example).
  12058. *
  12059. * Note that this namespace is aliased to `jQuery.fn.dataTableExt` for legacy
  12060. * reasons
  12061. *
  12062. * @namespace
  12063. */
  12064. DataTable.ext = _ext = {
  12065. /**
  12066. * Buttons. For use with the Buttons extension for DataTables. This is
  12067. * defined here so other extensions can define buttons regardless of load
  12068. * order. It is _not_ used by DataTables core.
  12069. *
  12070. * @type object
  12071. * @default {}
  12072. */
  12073. buttons: {},
  12074. /**
  12075. * Element class names
  12076. *
  12077. * @type object
  12078. * @default {}
  12079. */
  12080. classes: {},
  12081. /**
  12082. * DataTables build type (expanded by the download builder)
  12083. *
  12084. * @type string
  12085. */
  12086. build:"bs4/dt-1.10.18",
  12087. /**
  12088. * Error reporting.
  12089. *
  12090. * How should DataTables report an error. Can take the value 'alert',
  12091. * 'throw', 'none' or a function.
  12092. *
  12093. * @type string|function
  12094. * @default alert
  12095. */
  12096. errMode: "alert",
  12097. /**
  12098. * Feature plug-ins.
  12099. *
  12100. * This is an array of objects which describe the feature plug-ins that are
  12101. * available to DataTables. These feature plug-ins are then available for
  12102. * use through the `dom` initialisation option.
  12103. *
  12104. * Each feature plug-in is described by an object which must have the
  12105. * following properties:
  12106. *
  12107. * * `fnInit` - function that is used to initialise the plug-in,
  12108. * * `cFeature` - a character so the feature can be enabled by the `dom`
  12109. * instillation option. This is case sensitive.
  12110. *
  12111. * The `fnInit` function has the following input parameters:
  12112. *
  12113. * 1. `{object}` DataTables settings object: see
  12114. * {@link DataTable.models.oSettings}
  12115. *
  12116. * And the following return is expected:
  12117. *
  12118. * * {node|null} The element which contains your feature. Note that the
  12119. * return may also be void if your plug-in does not require to inject any
  12120. * DOM elements into DataTables control (`dom`) - for example this might
  12121. * be useful when developing a plug-in which allows table control via
  12122. * keyboard entry
  12123. *
  12124. * @type array
  12125. *
  12126. * @example
  12127. * $.fn.dataTable.ext.features.push( {
  12128. * "fnInit": function( oSettings ) {
  12129. * return new TableTools( { "oDTSettings": oSettings } );
  12130. * },
  12131. * "cFeature": "T"
  12132. * } );
  12133. */
  12134. feature: [],
  12135. /**
  12136. * Row searching.
  12137. *
  12138. * This method of searching is complimentary to the default type based
  12139. * searching, and a lot more comprehensive as it allows you complete control
  12140. * over the searching logic. Each element in this array is a function
  12141. * (parameters described below) that is called for every row in the table,
  12142. * and your logic decides if it should be included in the searching data set
  12143. * or not.
  12144. *
  12145. * Searching functions have the following input parameters:
  12146. *
  12147. * 1. `{object}` DataTables settings object: see
  12148. * {@link DataTable.models.oSettings}
  12149. * 2. `{array|object}` Data for the row to be processed (same as the
  12150. * original format that was passed in as the data source, or an array
  12151. * from a DOM data source
  12152. * 3. `{int}` Row index ({@link DataTable.models.oSettings.aoData}), which
  12153. * can be useful to retrieve the `TR` element if you need DOM interaction.
  12154. *
  12155. * And the following return is expected:
  12156. *
  12157. * * {boolean} Include the row in the searched result set (true) or not
  12158. * (false)
  12159. *
  12160. * Note that as with the main search ability in DataTables, technically this
  12161. * is "filtering", since it is subtractive. However, for consistency in
  12162. * naming we call it searching here.
  12163. *
  12164. * @type array
  12165. * @default []
  12166. *
  12167. * @example
  12168. * // The following example shows custom search being applied to the
  12169. * // fourth column (i.e. the data[3] index) based on two input values
  12170. * // from the end-user, matching the data in a certain range.
  12171. * $.fn.dataTable.ext.search.push(
  12172. * function( settings, data, dataIndex ) {
  12173. * var min = document.getElementById('min').value * 1;
  12174. * var max = document.getElementById('max').value * 1;
  12175. * var version = data[3] == "-" ? 0 : data[3]*1;
  12176. *
  12177. * if ( min == "" && max == "" ) {
  12178. * return true;
  12179. * }
  12180. * else if ( min == "" && version < max ) {
  12181. * return true;
  12182. * }
  12183. * else if ( min < version && "" == max ) {
  12184. * return true;
  12185. * }
  12186. * else if ( min < version && version < max ) {
  12187. * return true;
  12188. * }
  12189. * return false;
  12190. * }
  12191. * );
  12192. */
  12193. search: [],
  12194. /**
  12195. * Selector extensions
  12196. *
  12197. * The `selector` option can be used to extend the options available for the
  12198. * selector modifier options (`selector-modifier` object data type) that
  12199. * each of the three built in selector types offer (row, column and cell +
  12200. * their plural counterparts). For example the Select extension uses this
  12201. * mechanism to provide an option to select only rows, columns and cells
  12202. * that have been marked as selected by the end user (`{selected: true}`),
  12203. * which can be used in conjunction with the existing built in selector
  12204. * options.
  12205. *
  12206. * Each property is an array to which functions can be pushed. The functions
  12207. * take three attributes:
  12208. *
  12209. * * Settings object for the host table
  12210. * * Options object (`selector-modifier` object type)
  12211. * * Array of selected item indexes
  12212. *
  12213. * The return is an array of the resulting item indexes after the custom
  12214. * selector has been applied.
  12215. *
  12216. * @type object
  12217. */
  12218. selector: {
  12219. cell: [],
  12220. column: [],
  12221. row: []
  12222. },
  12223. /**
  12224. * Internal functions, exposed for used in plug-ins.
  12225. *
  12226. * Please note that you should not need to use the internal methods for
  12227. * anything other than a plug-in (and even then, try to avoid if possible).
  12228. * The internal function may change between releases.
  12229. *
  12230. * @type object
  12231. * @default {}
  12232. */
  12233. internal: {},
  12234. /**
  12235. * Legacy configuration options. Enable and disable legacy options that
  12236. * are available in DataTables.
  12237. *
  12238. * @type object
  12239. */
  12240. legacy: {
  12241. /**
  12242. * Enable / disable DataTables 1.9 compatible server-side processing
  12243. * requests
  12244. *
  12245. * @type boolean
  12246. * @default null
  12247. */
  12248. ajax: null
  12249. },
  12250. /**
  12251. * Pagination plug-in methods.
  12252. *
  12253. * Each entry in this object is a function and defines which buttons should
  12254. * be shown by the pagination rendering method that is used for the table:
  12255. * {@link DataTable.ext.renderer.pageButton}. The renderer addresses how the
  12256. * buttons are displayed in the document, while the functions here tell it
  12257. * what buttons to display. This is done by returning an array of button
  12258. * descriptions (what each button will do).
  12259. *
  12260. * Pagination types (the four built in options and any additional plug-in
  12261. * options defined here) can be used through the `paginationType`
  12262. * initialisation parameter.
  12263. *
  12264. * The functions defined take two parameters:
  12265. *
  12266. * 1. `{int} page` The current page index
  12267. * 2. `{int} pages` The number of pages in the table
  12268. *
  12269. * Each function is expected to return an array where each element of the
  12270. * array can be one of:
  12271. *
  12272. * * `first` - Jump to first page when activated
  12273. * * `last` - Jump to last page when activated
  12274. * * `previous` - Show previous page when activated
  12275. * * `next` - Show next page when activated
  12276. * * `{int}` - Show page of the index given
  12277. * * `{array}` - A nested array containing the above elements to add a
  12278. * containing 'DIV' element (might be useful for styling).
  12279. *
  12280. * Note that DataTables v1.9- used this object slightly differently whereby
  12281. * an object with two functions would be defined for each plug-in. That
  12282. * ability is still supported by DataTables 1.10+ to provide backwards
  12283. * compatibility, but this option of use is now decremented and no longer
  12284. * documented in DataTables 1.10+.
  12285. *
  12286. * @type object
  12287. * @default {}
  12288. *
  12289. * @example
  12290. * // Show previous, next and current page buttons only
  12291. * $.fn.dataTableExt.oPagination.current = function ( page, pages ) {
  12292. * return [ 'previous', page, 'next' ];
  12293. * };
  12294. */
  12295. pager: {},
  12296. renderer: {
  12297. pageButton: {},
  12298. header: {}
  12299. },
  12300. /**
  12301. * Ordering plug-ins - custom data source
  12302. *
  12303. * The extension options for ordering of data available here is complimentary
  12304. * to the default type based ordering that DataTables typically uses. It
  12305. * allows much greater control over the the data that is being used to
  12306. * order a column, but is necessarily therefore more complex.
  12307. *
  12308. * This type of ordering is useful if you want to do ordering based on data
  12309. * live from the DOM (for example the contents of an 'input' element) rather
  12310. * than just the static string that DataTables knows of.
  12311. *
  12312. * The way these plug-ins work is that you create an array of the values you
  12313. * wish to be ordering for the column in question and then return that
  12314. * array. The data in the array much be in the index order of the rows in
  12315. * the table (not the currently ordering order!). Which order data gathering
  12316. * function is run here depends on the `dt-init columns.orderDataType`
  12317. * parameter that is used for the column (if any).
  12318. *
  12319. * The functions defined take two parameters:
  12320. *
  12321. * 1. `{object}` DataTables settings object: see
  12322. * {@link DataTable.models.oSettings}
  12323. * 2. `{int}` Target column index
  12324. *
  12325. * Each function is expected to return an array:
  12326. *
  12327. * * `{array}` Data for the column to be ordering upon
  12328. *
  12329. * @type array
  12330. *
  12331. * @example
  12332. * // Ordering using `input` node values
  12333. * $.fn.dataTable.ext.order['dom-text'] = function ( settings, col )
  12334. * {
  12335. * return this.api().column( col, {order:'index'} ).nodes().map( function ( td, i ) {
  12336. * return $('input', td).val();
  12337. * } );
  12338. * }
  12339. */
  12340. order: {},
  12341. /**
  12342. * Type based plug-ins.
  12343. *
  12344. * Each column in DataTables has a type assigned to it, either by automatic
  12345. * detection or by direct assignment using the `type` option for the column.
  12346. * The type of a column will effect how it is ordering and search (plug-ins
  12347. * can also make use of the column type if required).
  12348. *
  12349. * @namespace
  12350. */
  12351. type: {
  12352. /**
  12353. * Type detection functions.
  12354. *
  12355. * The functions defined in this object are used to automatically detect
  12356. * a column's type, making initialisation of DataTables super easy, even
  12357. * when complex data is in the table.
  12358. *
  12359. * The functions defined take two parameters:
  12360. *
  12361. * 1. `{*}` Data from the column cell to be analysed
  12362. * 2. `{settings}` DataTables settings object. This can be used to
  12363. * perform context specific type detection - for example detection
  12364. * based on language settings such as using a comma for a decimal
  12365. * place. Generally speaking the options from the settings will not
  12366. * be required
  12367. *
  12368. * Each function is expected to return:
  12369. *
  12370. * * `{string|null}` Data type detected, or null if unknown (and thus
  12371. * pass it on to the other type detection functions.
  12372. *
  12373. * @type array
  12374. *
  12375. * @example
  12376. * // Currency type detection plug-in:
  12377. * $.fn.dataTable.ext.type.detect.push(
  12378. * function ( data, settings ) {
  12379. * // Check the numeric part
  12380. * if ( ! data.substring(1).match(/[0-9]/) ) {
  12381. * return null;
  12382. * }
  12383. *
  12384. * // Check prefixed by currency
  12385. * if ( data.charAt(0) == '$' || data.charAt(0) == '&pound;' ) {
  12386. * return 'currency';
  12387. * }
  12388. * return null;
  12389. * }
  12390. * );
  12391. */
  12392. detect: [],
  12393. /**
  12394. * Type based search formatting.
  12395. *
  12396. * The type based searching functions can be used to pre-format the
  12397. * data to be search on. For example, it can be used to strip HTML
  12398. * tags or to de-format telephone numbers for numeric only searching.
  12399. *
  12400. * Note that is a search is not defined for a column of a given type,
  12401. * no search formatting will be performed.
  12402. *
  12403. * Pre-processing of searching data plug-ins - When you assign the sType
  12404. * for a column (or have it automatically detected for you by DataTables
  12405. * or a type detection plug-in), you will typically be using this for
  12406. * custom sorting, but it can also be used to provide custom searching
  12407. * by allowing you to pre-processing the data and returning the data in
  12408. * the format that should be searched upon. This is done by adding
  12409. * functions this object with a parameter name which matches the sType
  12410. * for that target column. This is the corollary of <i>afnSortData</i>
  12411. * for searching data.
  12412. *
  12413. * The functions defined take a single parameter:
  12414. *
  12415. * 1. `{*}` Data from the column cell to be prepared for searching
  12416. *
  12417. * Each function is expected to return:
  12418. *
  12419. * * `{string|null}` Formatted string that will be used for the searching.
  12420. *
  12421. * @type object
  12422. * @default {}
  12423. *
  12424. * @example
  12425. * $.fn.dataTable.ext.type.search['title-numeric'] = function ( d ) {
  12426. * return d.replace(/\n/g," ").replace( /<.*?>/g, "" );
  12427. * }
  12428. */
  12429. search: {},
  12430. /**
  12431. * Type based ordering.
  12432. *
  12433. * The column type tells DataTables what ordering to apply to the table
  12434. * when a column is sorted upon. The order for each type that is defined,
  12435. * is defined by the functions available in this object.
  12436. *
  12437. * Each ordering option can be described by three properties added to
  12438. * this object:
  12439. *
  12440. * * `{type}-pre` - Pre-formatting function
  12441. * * `{type}-asc` - Ascending order function
  12442. * * `{type}-desc` - Descending order function
  12443. *
  12444. * All three can be used together, only `{type}-pre` or only
  12445. * `{type}-asc` and `{type}-desc` together. It is generally recommended
  12446. * that only `{type}-pre` is used, as this provides the optimal
  12447. * implementation in terms of speed, although the others are provided
  12448. * for compatibility with existing Javascript sort functions.
  12449. *
  12450. * `{type}-pre`: Functions defined take a single parameter:
  12451. *
  12452. * 1. `{*}` Data from the column cell to be prepared for ordering
  12453. *
  12454. * And return:
  12455. *
  12456. * * `{*}` Data to be sorted upon
  12457. *
  12458. * `{type}-asc` and `{type}-desc`: Functions are typical Javascript sort
  12459. * functions, taking two parameters:
  12460. *
  12461. * 1. `{*}` Data to compare to the second parameter
  12462. * 2. `{*}` Data to compare to the first parameter
  12463. *
  12464. * And returning:
  12465. *
  12466. * * `{*}` Ordering match: <0 if first parameter should be sorted lower
  12467. * than the second parameter, ===0 if the two parameters are equal and
  12468. * >0 if the first parameter should be sorted height than the second
  12469. * parameter.
  12470. *
  12471. * @type object
  12472. * @default {}
  12473. *
  12474. * @example
  12475. * // Numeric ordering of formatted numbers with a pre-formatter
  12476. * $.extend( $.fn.dataTable.ext.type.order, {
  12477. * "string-pre": function(x) {
  12478. * a = (a === "-" || a === "") ? 0 : a.replace( /[^\d\-\.]/g, "" );
  12479. * return parseFloat( a );
  12480. * }
  12481. * } );
  12482. *
  12483. * @example
  12484. * // Case-sensitive string ordering, with no pre-formatting method
  12485. * $.extend( $.fn.dataTable.ext.order, {
  12486. * "string-case-asc": function(x,y) {
  12487. * return ((x < y) ? -1 : ((x > y) ? 1 : 0));
  12488. * },
  12489. * "string-case-desc": function(x,y) {
  12490. * return ((x < y) ? 1 : ((x > y) ? -1 : 0));
  12491. * }
  12492. * } );
  12493. */
  12494. order: {}
  12495. },
  12496. /**
  12497. * Unique DataTables instance counter
  12498. *
  12499. * @type int
  12500. * @private
  12501. */
  12502. _unique: 0,
  12503. //
  12504. // Depreciated
  12505. // The following properties are retained for backwards compatiblity only.
  12506. // The should not be used in new projects and will be removed in a future
  12507. // version
  12508. //
  12509. /**
  12510. * Version check function.
  12511. * @type function
  12512. * @depreciated Since 1.10
  12513. */
  12514. fnVersionCheck: DataTable.fnVersionCheck,
  12515. /**
  12516. * Index for what 'this' index API functions should use
  12517. * @type int
  12518. * @deprecated Since v1.10
  12519. */
  12520. iApiIndex: 0,
  12521. /**
  12522. * jQuery UI class container
  12523. * @type object
  12524. * @deprecated Since v1.10
  12525. */
  12526. oJUIClasses: {},
  12527. /**
  12528. * Software version
  12529. * @type string
  12530. * @deprecated Since v1.10
  12531. */
  12532. sVersion: DataTable.version
  12533. };
  12534. //
  12535. // Backwards compatibility. Alias to pre 1.10 Hungarian notation counter parts
  12536. //
  12537. $.extend( _ext, {
  12538. afnFiltering: _ext.search,
  12539. aTypes: _ext.type.detect,
  12540. ofnSearch: _ext.type.search,
  12541. oSort: _ext.type.order,
  12542. afnSortData: _ext.order,
  12543. aoFeatures: _ext.feature,
  12544. oApi: _ext.internal,
  12545. oStdClasses: _ext.classes,
  12546. oPagination: _ext.pager
  12547. } );
  12548. $.extend( DataTable.ext.classes, {
  12549. "sTable": "dataTable",
  12550. "sNoFooter": "no-footer",
  12551. /* Paging buttons */
  12552. "sPageButton": "paginate_button",
  12553. "sPageButtonActive": "current",
  12554. "sPageButtonDisabled": "disabled",
  12555. /* Striping classes */
  12556. "sStripeOdd": "odd",
  12557. "sStripeEven": "even",
  12558. /* Empty row */
  12559. "sRowEmpty": "dataTables_empty",
  12560. /* Features */
  12561. "sWrapper": "dataTables_wrapper",
  12562. "sFilter": "dataTables_filter",
  12563. "sInfo": "dataTables_info",
  12564. "sPaging": "dataTables_paginate paging_", /* Note that the type is postfixed */
  12565. "sLength": "dataTables_length",
  12566. "sProcessing": "dataTables_processing",
  12567. /* Sorting */
  12568. "sSortAsc": "sorting_asc",
  12569. "sSortDesc": "sorting_desc",
  12570. "sSortable": "sorting", /* Sortable in both directions */
  12571. "sSortableAsc": "sorting_asc_disabled",
  12572. "sSortableDesc": "sorting_desc_disabled",
  12573. "sSortableNone": "sorting_disabled",
  12574. "sSortColumn": "sorting_", /* Note that an int is postfixed for the sorting order */
  12575. /* Filtering */
  12576. "sFilterInput": "",
  12577. /* Page length */
  12578. "sLengthSelect": "",
  12579. /* Scrolling */
  12580. "sScrollWrapper": "dataTables_scroll",
  12581. "sScrollHead": "dataTables_scrollHead",
  12582. "sScrollHeadInner": "dataTables_scrollHeadInner",
  12583. "sScrollBody": "dataTables_scrollBody",
  12584. "sScrollFoot": "dataTables_scrollFoot",
  12585. "sScrollFootInner": "dataTables_scrollFootInner",
  12586. /* Misc */
  12587. "sHeaderTH": "",
  12588. "sFooterTH": "",
  12589. // Deprecated
  12590. "sSortJUIAsc": "",
  12591. "sSortJUIDesc": "",
  12592. "sSortJUI": "",
  12593. "sSortJUIAscAllowed": "",
  12594. "sSortJUIDescAllowed": "",
  12595. "sSortJUIWrapper": "",
  12596. "sSortIcon": "",
  12597. "sJUIHeader": "",
  12598. "sJUIFooter": ""
  12599. } );
  12600. var extPagination = DataTable.ext.pager;
  12601. function _numbers ( page, pages ) {
  12602. var
  12603. numbers = [],
  12604. buttons = extPagination.numbers_length,
  12605. half = Math.floor( buttons / 2 ),
  12606. i = 1;
  12607. if ( pages <= buttons ) {
  12608. numbers = _range( 0, pages );
  12609. }
  12610. else if ( page <= half ) {
  12611. numbers = _range( 0, buttons-2 );
  12612. numbers.push( 'ellipsis' );
  12613. numbers.push( pages-1 );
  12614. }
  12615. else if ( page >= pages - 1 - half ) {
  12616. numbers = _range( pages-(buttons-2), pages );
  12617. numbers.splice( 0, 0, 'ellipsis' ); // no unshift in ie6
  12618. numbers.splice( 0, 0, 0 );
  12619. }
  12620. else {
  12621. numbers = _range( page-half+2, page+half-1 );
  12622. numbers.push( 'ellipsis' );
  12623. numbers.push( pages-1 );
  12624. numbers.splice( 0, 0, 'ellipsis' );
  12625. numbers.splice( 0, 0, 0 );
  12626. }
  12627. numbers.DT_el = 'span';
  12628. return numbers;
  12629. }
  12630. $.extend( extPagination, {
  12631. simple: function ( page, pages ) {
  12632. return [ 'previous', 'next' ];
  12633. },
  12634. full: function ( page, pages ) {
  12635. return [ 'first', 'previous', 'next', 'last' ];
  12636. },
  12637. numbers: function ( page, pages ) {
  12638. return [ _numbers(page, pages) ];
  12639. },
  12640. simple_numbers: function ( page, pages ) {
  12641. return [ 'previous', _numbers(page, pages), 'next' ];
  12642. },
  12643. full_numbers: function ( page, pages ) {
  12644. return [ 'first', 'previous', _numbers(page, pages), 'next', 'last' ];
  12645. },
  12646. first_last_numbers: function (page, pages) {
  12647. return ['first', _numbers(page, pages), 'last'];
  12648. },
  12649. // For testing and plug-ins to use
  12650. _numbers: _numbers,
  12651. // Number of number buttons (including ellipsis) to show. _Must be odd!_
  12652. numbers_length: 7
  12653. } );
  12654. $.extend( true, DataTable.ext.renderer, {
  12655. pageButton: {
  12656. _: function ( settings, host, idx, buttons, page, pages ) {
  12657. var classes = settings.oClasses;
  12658. var lang = settings.oLanguage.oPaginate;
  12659. var aria = settings.oLanguage.oAria.paginate || {};
  12660. var btnDisplay, btnClass, counter=0;
  12661. var attach = function( container, buttons ) {
  12662. var i, ien, node, button;
  12663. var clickHandler = function ( e ) {
  12664. _fnPageChange( settings, e.data.action, true );
  12665. };
  12666. for ( i=0, ien=buttons.length ; i<ien ; i++ ) {
  12667. button = buttons[i];
  12668. if ( $.isArray( button ) ) {
  12669. var inner = $( '<'+(button.DT_el || 'div')+'/>' )
  12670. .appendTo( container );
  12671. attach( inner, button );
  12672. }
  12673. else {
  12674. btnDisplay = null;
  12675. btnClass = '';
  12676. switch ( button ) {
  12677. case 'ellipsis':
  12678. container.append('<span class="ellipsis">&#x2026;</span>');
  12679. break;
  12680. case 'first':
  12681. btnDisplay = lang.sFirst;
  12682. btnClass = button + (page > 0 ?
  12683. '' : ' '+classes.sPageButtonDisabled);
  12684. break;
  12685. case 'previous':
  12686. btnDisplay = lang.sPrevious;
  12687. btnClass = button + (page > 0 ?
  12688. '' : ' '+classes.sPageButtonDisabled);
  12689. break;
  12690. case 'next':
  12691. btnDisplay = lang.sNext;
  12692. btnClass = button + (page < pages-1 ?
  12693. '' : ' '+classes.sPageButtonDisabled);
  12694. break;
  12695. case 'last':
  12696. btnDisplay = lang.sLast;
  12697. btnClass = button + (page < pages-1 ?
  12698. '' : ' '+classes.sPageButtonDisabled);
  12699. break;
  12700. default:
  12701. btnDisplay = button + 1;
  12702. btnClass = page === button ?
  12703. classes.sPageButtonActive : '';
  12704. break;
  12705. }
  12706. if ( btnDisplay !== null ) {
  12707. node = $('<a>', {
  12708. 'class': classes.sPageButton+' '+btnClass,
  12709. 'aria-controls': settings.sTableId,
  12710. 'aria-label': aria[ button ],
  12711. 'data-dt-idx': counter,
  12712. 'tabindex': settings.iTabIndex,
  12713. 'id': idx === 0 && typeof button === 'string' ?
  12714. settings.sTableId +'_'+ button :
  12715. null
  12716. } )
  12717. .html( btnDisplay )
  12718. .appendTo( container );
  12719. _fnBindAction(
  12720. node, {action: button}, clickHandler
  12721. );
  12722. counter++;
  12723. }
  12724. }
  12725. }
  12726. };
  12727. // IE9 throws an 'unknown error' if document.activeElement is used
  12728. // inside an iframe or frame. Try / catch the error. Not good for
  12729. // accessibility, but neither are frames.
  12730. var activeEl;
  12731. try {
  12732. // Because this approach is destroying and recreating the paging
  12733. // elements, focus is lost on the select button which is bad for
  12734. // accessibility. So we want to restore focus once the draw has
  12735. // completed
  12736. activeEl = $(host).find(document.activeElement).data('dt-idx');
  12737. }
  12738. catch (e) {}
  12739. attach( $(host).empty(), buttons );
  12740. if ( activeEl !== undefined ) {
  12741. $(host).find( '[data-dt-idx='+activeEl+']' ).focus();
  12742. }
  12743. }
  12744. }
  12745. } );
  12746. // Built in type detection. See model.ext.aTypes for information about
  12747. // what is required from this methods.
  12748. $.extend( DataTable.ext.type.detect, [
  12749. // Plain numbers - first since V8 detects some plain numbers as dates
  12750. // e.g. Date.parse('55') (but not all, e.g. Date.parse('22')...).
  12751. function ( d, settings )
  12752. {
  12753. var decimal = settings.oLanguage.sDecimal;
  12754. return _isNumber( d, decimal ) ? 'num'+decimal : null;
  12755. },
  12756. // Dates (only those recognised by the browser's Date.parse)
  12757. function ( d, settings )
  12758. {
  12759. // V8 tries _very_ hard to make a string passed into `Date.parse()`
  12760. // valid, so we need to use a regex to restrict date formats. Use a
  12761. // plug-in for anything other than ISO8601 style strings
  12762. if ( d && !(d instanceof Date) && ! _re_date.test(d) ) {
  12763. return null;
  12764. }
  12765. var parsed = Date.parse(d);
  12766. return (parsed !== null && !isNaN(parsed)) || _empty(d) ? 'date' : null;
  12767. },
  12768. // Formatted numbers
  12769. function ( d, settings )
  12770. {
  12771. var decimal = settings.oLanguage.sDecimal;
  12772. return _isNumber( d, decimal, true ) ? 'num-fmt'+decimal : null;
  12773. },
  12774. // HTML numeric
  12775. function ( d, settings )
  12776. {
  12777. var decimal = settings.oLanguage.sDecimal;
  12778. return _htmlNumeric( d, decimal ) ? 'html-num'+decimal : null;
  12779. },
  12780. // HTML numeric, formatted
  12781. function ( d, settings )
  12782. {
  12783. var decimal = settings.oLanguage.sDecimal;
  12784. return _htmlNumeric( d, decimal, true ) ? 'html-num-fmt'+decimal : null;
  12785. },
  12786. // HTML (this is strict checking - there must be html)
  12787. function ( d, settings )
  12788. {
  12789. return _empty( d ) || (typeof d === 'string' && d.indexOf('<') !== -1) ?
  12790. 'html' : null;
  12791. }
  12792. ] );
  12793. // Filter formatting functions. See model.ext.ofnSearch for information about
  12794. // what is required from these methods.
  12795. //
  12796. // Note that additional search methods are added for the html numbers and
  12797. // html formatted numbers by `_addNumericSort()` when we know what the decimal
  12798. // place is
  12799. $.extend( DataTable.ext.type.search, {
  12800. html: function ( data ) {
  12801. return _empty(data) ?
  12802. data :
  12803. typeof data === 'string' ?
  12804. data
  12805. .replace( _re_new_lines, " " )
  12806. .replace( _re_html, "" ) :
  12807. '';
  12808. },
  12809. string: function ( data ) {
  12810. return _empty(data) ?
  12811. data :
  12812. typeof data === 'string' ?
  12813. data.replace( _re_new_lines, " " ) :
  12814. data;
  12815. }
  12816. } );
  12817. var __numericReplace = function ( d, decimalPlace, re1, re2 ) {
  12818. if ( d !== 0 && (!d || d === '-') ) {
  12819. return -Infinity;
  12820. }
  12821. // If a decimal place other than `.` is used, it needs to be given to the
  12822. // function so we can detect it and replace with a `.` which is the only
  12823. // decimal place Javascript recognises - it is not locale aware.
  12824. if ( decimalPlace ) {
  12825. d = _numToDecimal( d, decimalPlace );
  12826. }
  12827. if ( d.replace ) {
  12828. if ( re1 ) {
  12829. d = d.replace( re1, '' );
  12830. }
  12831. if ( re2 ) {
  12832. d = d.replace( re2, '' );
  12833. }
  12834. }
  12835. return d * 1;
  12836. };
  12837. // Add the numeric 'deformatting' functions for sorting and search. This is done
  12838. // in a function to provide an easy ability for the language options to add
  12839. // additional methods if a non-period decimal place is used.
  12840. function _addNumericSort ( decimalPlace ) {
  12841. $.each(
  12842. {
  12843. // Plain numbers
  12844. "num": function ( d ) {
  12845. return __numericReplace( d, decimalPlace );
  12846. },
  12847. // Formatted numbers
  12848. "num-fmt": function ( d ) {
  12849. return __numericReplace( d, decimalPlace, _re_formatted_numeric );
  12850. },
  12851. // HTML numeric
  12852. "html-num": function ( d ) {
  12853. return __numericReplace( d, decimalPlace, _re_html );
  12854. },
  12855. // HTML numeric, formatted
  12856. "html-num-fmt": function ( d ) {
  12857. return __numericReplace( d, decimalPlace, _re_html, _re_formatted_numeric );
  12858. }
  12859. },
  12860. function ( key, fn ) {
  12861. // Add the ordering method
  12862. _ext.type.order[ key+decimalPlace+'-pre' ] = fn;
  12863. // For HTML types add a search formatter that will strip the HTML
  12864. if ( key.match(/^html\-/) ) {
  12865. _ext.type.search[ key+decimalPlace ] = _ext.type.search.html;
  12866. }
  12867. }
  12868. );
  12869. }
  12870. // Default sort methods
  12871. $.extend( _ext.type.order, {
  12872. // Dates
  12873. "date-pre": function ( d ) {
  12874. var ts = Date.parse( d );
  12875. return isNaN(ts) ? -Infinity : ts;
  12876. },
  12877. // html
  12878. "html-pre": function ( a ) {
  12879. return _empty(a) ?
  12880. '' :
  12881. a.replace ?
  12882. a.replace( /<.*?>/g, "" ).toLowerCase() :
  12883. a+'';
  12884. },
  12885. // string
  12886. "string-pre": function ( a ) {
  12887. // This is a little complex, but faster than always calling toString,
  12888. // http://jsperf.com/tostring-v-check
  12889. return _empty(a) ?
  12890. '' :
  12891. typeof a === 'string' ?
  12892. a.toLowerCase() :
  12893. ! a.toString ?
  12894. '' :
  12895. a.toString();
  12896. },
  12897. // string-asc and -desc are retained only for compatibility with the old
  12898. // sort methods
  12899. "string-asc": function ( x, y ) {
  12900. return ((x < y) ? -1 : ((x > y) ? 1 : 0));
  12901. },
  12902. "string-desc": function ( x, y ) {
  12903. return ((x < y) ? 1 : ((x > y) ? -1 : 0));
  12904. }
  12905. } );
  12906. // Numeric sorting types - order doesn't matter here
  12907. _addNumericSort( '' );
  12908. $.extend( true, DataTable.ext.renderer, {
  12909. header: {
  12910. _: function ( settings, cell, column, classes ) {
  12911. // No additional mark-up required
  12912. // Attach a sort listener to update on sort - note that using the
  12913. // `DT` namespace will allow the event to be removed automatically
  12914. // on destroy, while the `dt` namespaced event is the one we are
  12915. // listening for
  12916. $(settings.nTable).on( 'order.dt.DT', function ( e, ctx, sorting, columns ) {
  12917. if ( settings !== ctx ) { // need to check this this is the host
  12918. return; // table, not a nested one
  12919. }
  12920. var colIdx = column.idx;
  12921. cell
  12922. .removeClass(
  12923. column.sSortingClass +' '+
  12924. classes.sSortAsc +' '+
  12925. classes.sSortDesc
  12926. )
  12927. .addClass( columns[ colIdx ] == 'asc' ?
  12928. classes.sSortAsc : columns[ colIdx ] == 'desc' ?
  12929. classes.sSortDesc :
  12930. column.sSortingClass
  12931. );
  12932. } );
  12933. },
  12934. jqueryui: function ( settings, cell, column, classes ) {
  12935. $('<div/>')
  12936. .addClass( classes.sSortJUIWrapper )
  12937. .append( cell.contents() )
  12938. .append( $('<span/>')
  12939. .addClass( classes.sSortIcon+' '+column.sSortingClassJUI )
  12940. )
  12941. .appendTo( cell );
  12942. // Attach a sort listener to update on sort
  12943. $(settings.nTable).on( 'order.dt.DT', function ( e, ctx, sorting, columns ) {
  12944. if ( settings !== ctx ) {
  12945. return;
  12946. }
  12947. var colIdx = column.idx;
  12948. cell
  12949. .removeClass( classes.sSortAsc +" "+classes.sSortDesc )
  12950. .addClass( columns[ colIdx ] == 'asc' ?
  12951. classes.sSortAsc : columns[ colIdx ] == 'desc' ?
  12952. classes.sSortDesc :
  12953. column.sSortingClass
  12954. );
  12955. cell
  12956. .find( 'span.'+classes.sSortIcon )
  12957. .removeClass(
  12958. classes.sSortJUIAsc +" "+
  12959. classes.sSortJUIDesc +" "+
  12960. classes.sSortJUI +" "+
  12961. classes.sSortJUIAscAllowed +" "+
  12962. classes.sSortJUIDescAllowed
  12963. )
  12964. .addClass( columns[ colIdx ] == 'asc' ?
  12965. classes.sSortJUIAsc : columns[ colIdx ] == 'desc' ?
  12966. classes.sSortJUIDesc :
  12967. column.sSortingClassJUI
  12968. );
  12969. } );
  12970. }
  12971. }
  12972. } );
  12973. /*
  12974. * Public helper functions. These aren't used internally by DataTables, or
  12975. * called by any of the options passed into DataTables, but they can be used
  12976. * externally by developers working with DataTables. They are helper functions
  12977. * to make working with DataTables a little bit easier.
  12978. */
  12979. var __htmlEscapeEntities = function ( d ) {
  12980. return typeof d === 'string' ?
  12981. d.replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;') :
  12982. d;
  12983. };
  12984. /**
  12985. * Helpers for `columns.render`.
  12986. *
  12987. * The options defined here can be used with the `columns.render` initialisation
  12988. * option to provide a display renderer. The following functions are defined:
  12989. *
  12990. * * `number` - Will format numeric data (defined by `columns.data`) for
  12991. * display, retaining the original unformatted data for sorting and filtering.
  12992. * It takes 5 parameters:
  12993. * * `string` - Thousands grouping separator
  12994. * * `string` - Decimal point indicator
  12995. * * `integer` - Number of decimal points to show
  12996. * * `string` (optional) - Prefix.
  12997. * * `string` (optional) - Postfix (/suffix).
  12998. * * `text` - Escape HTML to help prevent XSS attacks. It has no optional
  12999. * parameters.
  13000. *
  13001. * @example
  13002. * // Column definition using the number renderer
  13003. * {
  13004. * data: "salary",
  13005. * render: $.fn.dataTable.render.number( '\'', '.', 0, '$' )
  13006. * }
  13007. *
  13008. * @namespace
  13009. */
  13010. DataTable.render = {
  13011. number: function ( thousands, decimal, precision, prefix, postfix ) {
  13012. return {
  13013. display: function ( d ) {
  13014. if ( typeof d !== 'number' && typeof d !== 'string' ) {
  13015. return d;
  13016. }
  13017. var negative = d < 0 ? '-' : '';
  13018. var flo = parseFloat( d );
  13019. // If NaN then there isn't much formatting that we can do - just
  13020. // return immediately, escaping any HTML (this was supposed to
  13021. // be a number after all)
  13022. if ( isNaN( flo ) ) {
  13023. return __htmlEscapeEntities( d );
  13024. }
  13025. flo = flo.toFixed( precision );
  13026. d = Math.abs( flo );
  13027. var intPart = parseInt( d, 10 );
  13028. var floatPart = precision ?
  13029. decimal+(d - intPart).toFixed( precision ).substring( 2 ):
  13030. '';
  13031. return negative + (prefix||'') +
  13032. intPart.toString().replace(
  13033. /\B(?=(\d{3})+(?!\d))/g, thousands
  13034. ) +
  13035. floatPart +
  13036. (postfix||'');
  13037. }
  13038. };
  13039. },
  13040. text: function () {
  13041. return {
  13042. display: __htmlEscapeEntities
  13043. };
  13044. }
  13045. };
  13046. /*
  13047. * This is really a good bit rubbish this method of exposing the internal methods
  13048. * publicly... - To be fixed in 2.0 using methods on the prototype
  13049. */
  13050. /**
  13051. * Create a wrapper function for exporting an internal functions to an external API.
  13052. * @param {string} fn API function name
  13053. * @returns {function} wrapped function
  13054. * @memberof DataTable#internal
  13055. */
  13056. function _fnExternApiFunc (fn)
  13057. {
  13058. return function() {
  13059. var args = [_fnSettingsFromNode( this[DataTable.ext.iApiIndex] )].concat(
  13060. Array.prototype.slice.call(arguments)
  13061. );
  13062. return DataTable.ext.internal[fn].apply( this, args );
  13063. };
  13064. }
  13065. /**
  13066. * Reference to internal functions for use by plug-in developers. Note that
  13067. * these methods are references to internal functions and are considered to be
  13068. * private. If you use these methods, be aware that they are liable to change
  13069. * between versions.
  13070. * @namespace
  13071. */
  13072. $.extend( DataTable.ext.internal, {
  13073. _fnExternApiFunc: _fnExternApiFunc,
  13074. _fnBuildAjax: _fnBuildAjax,
  13075. _fnAjaxUpdate: _fnAjaxUpdate,
  13076. _fnAjaxParameters: _fnAjaxParameters,
  13077. _fnAjaxUpdateDraw: _fnAjaxUpdateDraw,
  13078. _fnAjaxDataSrc: _fnAjaxDataSrc,
  13079. _fnAddColumn: _fnAddColumn,
  13080. _fnColumnOptions: _fnColumnOptions,
  13081. _fnAdjustColumnSizing: _fnAdjustColumnSizing,
  13082. _fnVisibleToColumnIndex: _fnVisibleToColumnIndex,
  13083. _fnColumnIndexToVisible: _fnColumnIndexToVisible,
  13084. _fnVisbleColumns: _fnVisbleColumns,
  13085. _fnGetColumns: _fnGetColumns,
  13086. _fnColumnTypes: _fnColumnTypes,
  13087. _fnApplyColumnDefs: _fnApplyColumnDefs,
  13088. _fnHungarianMap: _fnHungarianMap,
  13089. _fnCamelToHungarian: _fnCamelToHungarian,
  13090. _fnLanguageCompat: _fnLanguageCompat,
  13091. _fnBrowserDetect: _fnBrowserDetect,
  13092. _fnAddData: _fnAddData,
  13093. _fnAddTr: _fnAddTr,
  13094. _fnNodeToDataIndex: _fnNodeToDataIndex,
  13095. _fnNodeToColumnIndex: _fnNodeToColumnIndex,
  13096. _fnGetCellData: _fnGetCellData,
  13097. _fnSetCellData: _fnSetCellData,
  13098. _fnSplitObjNotation: _fnSplitObjNotation,
  13099. _fnGetObjectDataFn: _fnGetObjectDataFn,
  13100. _fnSetObjectDataFn: _fnSetObjectDataFn,
  13101. _fnGetDataMaster: _fnGetDataMaster,
  13102. _fnClearTable: _fnClearTable,
  13103. _fnDeleteIndex: _fnDeleteIndex,
  13104. _fnInvalidate: _fnInvalidate,
  13105. _fnGetRowElements: _fnGetRowElements,
  13106. _fnCreateTr: _fnCreateTr,
  13107. _fnBuildHead: _fnBuildHead,
  13108. _fnDrawHead: _fnDrawHead,
  13109. _fnDraw: _fnDraw,
  13110. _fnReDraw: _fnReDraw,
  13111. _fnAddOptionsHtml: _fnAddOptionsHtml,
  13112. _fnDetectHeader: _fnDetectHeader,
  13113. _fnGetUniqueThs: _fnGetUniqueThs,
  13114. _fnFeatureHtmlFilter: _fnFeatureHtmlFilter,
  13115. _fnFilterComplete: _fnFilterComplete,
  13116. _fnFilterCustom: _fnFilterCustom,
  13117. _fnFilterColumn: _fnFilterColumn,
  13118. _fnFilter: _fnFilter,
  13119. _fnFilterCreateSearch: _fnFilterCreateSearch,
  13120. _fnEscapeRegex: _fnEscapeRegex,
  13121. _fnFilterData: _fnFilterData,
  13122. _fnFeatureHtmlInfo: _fnFeatureHtmlInfo,
  13123. _fnUpdateInfo: _fnUpdateInfo,
  13124. _fnInfoMacros: _fnInfoMacros,
  13125. _fnInitialise: _fnInitialise,
  13126. _fnInitComplete: _fnInitComplete,
  13127. _fnLengthChange: _fnLengthChange,
  13128. _fnFeatureHtmlLength: _fnFeatureHtmlLength,
  13129. _fnFeatureHtmlPaginate: _fnFeatureHtmlPaginate,
  13130. _fnPageChange: _fnPageChange,
  13131. _fnFeatureHtmlProcessing: _fnFeatureHtmlProcessing,
  13132. _fnProcessingDisplay: _fnProcessingDisplay,
  13133. _fnFeatureHtmlTable: _fnFeatureHtmlTable,
  13134. _fnScrollDraw: _fnScrollDraw,
  13135. _fnApplyToChildren: _fnApplyToChildren,
  13136. _fnCalculateColumnWidths: _fnCalculateColumnWidths,
  13137. _fnThrottle: _fnThrottle,
  13138. _fnConvertToWidth: _fnConvertToWidth,
  13139. _fnGetWidestNode: _fnGetWidestNode,
  13140. _fnGetMaxLenString: _fnGetMaxLenString,
  13141. _fnStringToCss: _fnStringToCss,
  13142. _fnSortFlatten: _fnSortFlatten,
  13143. _fnSort: _fnSort,
  13144. _fnSortAria: _fnSortAria,
  13145. _fnSortListener: _fnSortListener,
  13146. _fnSortAttachListener: _fnSortAttachListener,
  13147. _fnSortingClasses: _fnSortingClasses,
  13148. _fnSortData: _fnSortData,
  13149. _fnSaveState: _fnSaveState,
  13150. _fnLoadState: _fnLoadState,
  13151. _fnSettingsFromNode: _fnSettingsFromNode,
  13152. _fnLog: _fnLog,
  13153. _fnMap: _fnMap,
  13154. _fnBindAction: _fnBindAction,
  13155. _fnCallbackReg: _fnCallbackReg,
  13156. _fnCallbackFire: _fnCallbackFire,
  13157. _fnLengthOverflow: _fnLengthOverflow,
  13158. _fnRenderer: _fnRenderer,
  13159. _fnDataSource: _fnDataSource,
  13160. _fnRowAttributes: _fnRowAttributes,
  13161. _fnExtend: _fnExtend,
  13162. _fnCalculateEnd: function () {} // Used by a lot of plug-ins, but redundant
  13163. // in 1.10, so this dead-end function is
  13164. // added to prevent errors
  13165. } );
  13166. // jQuery access
  13167. $.fn.dataTable = DataTable;
  13168. // Provide access to the host jQuery object (circular reference)
  13169. DataTable.$ = $;
  13170. // Legacy aliases
  13171. $.fn.dataTableSettings = DataTable.settings;
  13172. $.fn.dataTableExt = DataTable.ext;
  13173. // With a capital `D` we return a DataTables API instance rather than a
  13174. // jQuery object
  13175. $.fn.DataTable = function ( opts ) {
  13176. return $(this).dataTable( opts ).api();
  13177. };
  13178. // All properties that are available to $.fn.dataTable should also be
  13179. // available on $.fn.DataTable
  13180. $.each( DataTable, function ( prop, val ) {
  13181. $.fn.DataTable[ prop ] = val;
  13182. } );
  13183. // Information about events fired by DataTables - for documentation.
  13184. /**
  13185. * Draw event, fired whenever the table is redrawn on the page, at the same
  13186. * point as fnDrawCallback. This may be useful for binding events or
  13187. * performing calculations when the table is altered at all.
  13188. * @name DataTable#draw.dt
  13189. * @event
  13190. * @param {event} e jQuery event object
  13191. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13192. */
  13193. /**
  13194. * Search event, fired when the searching applied to the table (using the
  13195. * built-in global search, or column filters) is altered.
  13196. * @name DataTable#search.dt
  13197. * @event
  13198. * @param {event} e jQuery event object
  13199. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13200. */
  13201. /**
  13202. * Page change event, fired when the paging of the table is altered.
  13203. * @name DataTable#page.dt
  13204. * @event
  13205. * @param {event} e jQuery event object
  13206. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13207. */
  13208. /**
  13209. * Order event, fired when the ordering applied to the table is altered.
  13210. * @name DataTable#order.dt
  13211. * @event
  13212. * @param {event} e jQuery event object
  13213. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13214. */
  13215. /**
  13216. * DataTables initialisation complete event, fired when the table is fully
  13217. * drawn, including Ajax data loaded, if Ajax data is required.
  13218. * @name DataTable#init.dt
  13219. * @event
  13220. * @param {event} e jQuery event object
  13221. * @param {object} oSettings DataTables settings object
  13222. * @param {object} json The JSON object request from the server - only
  13223. * present if client-side Ajax sourced data is used</li></ol>
  13224. */
  13225. /**
  13226. * State save event, fired when the table has changed state a new state save
  13227. * is required. This event allows modification of the state saving object
  13228. * prior to actually doing the save, including addition or other state
  13229. * properties (for plug-ins) or modification of a DataTables core property.
  13230. * @name DataTable#stateSaveParams.dt
  13231. * @event
  13232. * @param {event} e jQuery event object
  13233. * @param {object} oSettings DataTables settings object
  13234. * @param {object} json The state information to be saved
  13235. */
  13236. /**
  13237. * State load event, fired when the table is loading state from the stored
  13238. * data, but prior to the settings object being modified by the saved state
  13239. * - allowing modification of the saved state is required or loading of
  13240. * state for a plug-in.
  13241. * @name DataTable#stateLoadParams.dt
  13242. * @event
  13243. * @param {event} e jQuery event object
  13244. * @param {object} oSettings DataTables settings object
  13245. * @param {object} json The saved state information
  13246. */
  13247. /**
  13248. * State loaded event, fired when state has been loaded from stored data and
  13249. * the settings object has been modified by the loaded data.
  13250. * @name DataTable#stateLoaded.dt
  13251. * @event
  13252. * @param {event} e jQuery event object
  13253. * @param {object} oSettings DataTables settings object
  13254. * @param {object} json The saved state information
  13255. */
  13256. /**
  13257. * Processing event, fired when DataTables is doing some kind of processing
  13258. * (be it, order, searcg or anything else). It can be used to indicate to
  13259. * the end user that there is something happening, or that something has
  13260. * finished.
  13261. * @name DataTable#processing.dt
  13262. * @event
  13263. * @param {event} e jQuery event object
  13264. * @param {object} oSettings DataTables settings object
  13265. * @param {boolean} bShow Flag for if DataTables is doing processing or not
  13266. */
  13267. /**
  13268. * Ajax (XHR) event, fired whenever an Ajax request is completed from a
  13269. * request to made to the server for new data. This event is called before
  13270. * DataTables processed the returned data, so it can also be used to pre-
  13271. * process the data returned from the server, if needed.
  13272. *
  13273. * Note that this trigger is called in `fnServerData`, if you override
  13274. * `fnServerData` and which to use this event, you need to trigger it in you
  13275. * success function.
  13276. * @name DataTable#xhr.dt
  13277. * @event
  13278. * @param {event} e jQuery event object
  13279. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13280. * @param {object} json JSON returned from the server
  13281. *
  13282. * @example
  13283. * // Use a custom property returned from the server in another DOM element
  13284. * $('#table').dataTable().on('xhr.dt', function (e, settings, json) {
  13285. * $('#status').html( json.status );
  13286. * } );
  13287. *
  13288. * @example
  13289. * // Pre-process the data returned from the server
  13290. * $('#table').dataTable().on('xhr.dt', function (e, settings, json) {
  13291. * for ( var i=0, ien=json.aaData.length ; i<ien ; i++ ) {
  13292. * json.aaData[i].sum = json.aaData[i].one + json.aaData[i].two;
  13293. * }
  13294. * // Note no return - manipulate the data directly in the JSON object.
  13295. * } );
  13296. */
  13297. /**
  13298. * Destroy event, fired when the DataTable is destroyed by calling fnDestroy
  13299. * or passing the bDestroy:true parameter in the initialisation object. This
  13300. * can be used to remove bound events, added DOM nodes, etc.
  13301. * @name DataTable#destroy.dt
  13302. * @event
  13303. * @param {event} e jQuery event object
  13304. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13305. */
  13306. /**
  13307. * Page length change event, fired when number of records to show on each
  13308. * page (the length) is changed.
  13309. * @name DataTable#length.dt
  13310. * @event
  13311. * @param {event} e jQuery event object
  13312. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13313. * @param {integer} len New length
  13314. */
  13315. /**
  13316. * Column sizing has changed.
  13317. * @name DataTable#column-sizing.dt
  13318. * @event
  13319. * @param {event} e jQuery event object
  13320. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13321. */
  13322. /**
  13323. * Column visibility has changed.
  13324. * @name DataTable#column-visibility.dt
  13325. * @event
  13326. * @param {event} e jQuery event object
  13327. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13328. * @param {int} column Column index
  13329. * @param {bool} vis `false` if column now hidden, or `true` if visible
  13330. */
  13331. return $.fn.dataTable;
  13332. }));
  13333. /*! DataTables Bootstrap 4 integration
  13334. * ©2011-2017 SpryMedia Ltd - datatables.net/license
  13335. */
  13336. /**
  13337. * DataTables integration for Bootstrap 4. This requires Bootstrap 4 and
  13338. * DataTables 1.10 or newer.
  13339. *
  13340. * This file sets the defaults and adds options to DataTables to style its
  13341. * controls using Bootstrap. See http://datatables.net/manual/styling/bootstrap
  13342. * for further information.
  13343. */
  13344. (function( factory ){
  13345. if ( typeof define === 'function' && define.amd ) {
  13346. // AMD
  13347. define( ['jquery', 'datatables.net'], function ( $ ) {
  13348. return factory( $, window, document );
  13349. } );
  13350. }
  13351. else if ( typeof exports === 'object' ) {
  13352. // CommonJS
  13353. module.exports = function (root, $) {
  13354. if ( ! root ) {
  13355. root = window;
  13356. }
  13357. if ( ! $ || ! $.fn.dataTable ) {
  13358. // Require DataTables, which attaches to jQuery, including
  13359. // jQuery if needed and have a $ property so we can access the
  13360. // jQuery object that is used
  13361. $ = require('datatables.net')(root, $).$;
  13362. }
  13363. return factory( $, root, root.document );
  13364. };
  13365. }
  13366. else {
  13367. // Browser
  13368. factory( jQuery, window, document );
  13369. }
  13370. }(function( $, window, document, undefined ) {
  13371. 'use strict';
  13372. var DataTable = $.fn.dataTable;
  13373. /* Set the defaults for DataTables initialisation */
  13374. $.extend( true, DataTable.defaults, {
  13375. dom:
  13376. "<'row'<'col-sm-12 col-md-6'l><'col-sm-12 col-md-6'f>>" +
  13377. "<'row'<'col-sm-12'tr>>" +
  13378. "<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>",
  13379. renderer: 'bootstrap'
  13380. } );
  13381. /* Default class modification */
  13382. $.extend( DataTable.ext.classes, {
  13383. sWrapper: "dataTables_wrapper dt-bootstrap4",
  13384. sFilterInput: "form-control form-control-sm",
  13385. sLengthSelect: "custom-select custom-select-sm form-control form-control-sm",
  13386. sProcessing: "dataTables_processing card",
  13387. sPageButton: "paginate_button page-item"
  13388. } );
  13389. /* Bootstrap paging button renderer */
  13390. DataTable.ext.renderer.pageButton.bootstrap = function ( settings, host, idx, buttons, page, pages ) {
  13391. var api = new DataTable.Api( settings );
  13392. var classes = settings.oClasses;
  13393. var lang = settings.oLanguage.oPaginate;
  13394. var aria = settings.oLanguage.oAria.paginate || {};
  13395. var btnDisplay, btnClass, counter=0;
  13396. var attach = function( container, buttons ) {
  13397. var i, ien, node, button;
  13398. var clickHandler = function ( e ) {
  13399. e.preventDefault();
  13400. if ( !$(e.currentTarget).hasClass('disabled') && api.page() != e.data.action ) {
  13401. api.page( e.data.action ).draw( 'page' );
  13402. }
  13403. };
  13404. for ( i=0, ien=buttons.length ; i<ien ; i++ ) {
  13405. button = buttons[i];
  13406. if ( $.isArray( button ) ) {
  13407. attach( container, button );
  13408. }
  13409. else {
  13410. btnDisplay = '';
  13411. btnClass = '';
  13412. switch ( button ) {
  13413. case 'ellipsis':
  13414. btnDisplay = '&#x2026;';
  13415. btnClass = 'disabled';
  13416. break;
  13417. case 'first':
  13418. btnDisplay = lang.sFirst;
  13419. btnClass = button + (page > 0 ?
  13420. '' : ' disabled');
  13421. break;
  13422. case 'previous':
  13423. btnDisplay = lang.sPrevious;
  13424. btnClass = button + (page > 0 ?
  13425. '' : ' disabled');
  13426. break;
  13427. case 'next':
  13428. btnDisplay = lang.sNext;
  13429. btnClass = button + (page < pages-1 ?
  13430. '' : ' disabled');
  13431. break;
  13432. case 'last':
  13433. btnDisplay = lang.sLast;
  13434. btnClass = button + (page < pages-1 ?
  13435. '' : ' disabled');
  13436. break;
  13437. default:
  13438. btnDisplay = button + 1;
  13439. btnClass = page === button ?
  13440. 'active' : '';
  13441. break;
  13442. }
  13443. if ( btnDisplay ) {
  13444. node = $('<li>', {
  13445. 'class': classes.sPageButton+' '+btnClass,
  13446. 'id': idx === 0 && typeof button === 'string' ?
  13447. settings.sTableId +'_'+ button :
  13448. null
  13449. } )
  13450. .append( $('<a>', {
  13451. 'href': '#',
  13452. 'aria-controls': settings.sTableId,
  13453. 'aria-label': aria[ button ],
  13454. 'data-dt-idx': counter,
  13455. 'tabindex': settings.iTabIndex,
  13456. 'class': 'page-link'
  13457. } )
  13458. .html( btnDisplay )
  13459. )
  13460. .appendTo( container );
  13461. settings.oApi._fnBindAction(
  13462. node, {action: button}, clickHandler
  13463. );
  13464. counter++;
  13465. }
  13466. }
  13467. }
  13468. };
  13469. // IE9 throws an 'unknown error' if document.activeElement is used
  13470. // inside an iframe or frame.
  13471. var activeEl;
  13472. try {
  13473. // Because this approach is destroying and recreating the paging
  13474. // elements, focus is lost on the select button which is bad for
  13475. // accessibility. So we want to restore focus once the draw has
  13476. // completed
  13477. activeEl = $(host).find(document.activeElement).data('dt-idx');
  13478. }
  13479. catch (e) {}
  13480. attach(
  13481. $(host).empty().html('<ul class="pagination"/>').children('ul'),
  13482. buttons
  13483. );
  13484. if ( activeEl !== undefined ) {
  13485. $(host).find( '[data-dt-idx='+activeEl+']' ).focus();
  13486. }
  13487. };
  13488. return DataTable;
  13489. }));